frontend fix
This commit is contained in:
parent
e2d34a8c3f
commit
82489eab2b
|
|
@ -178,17 +178,32 @@ const RuleDetailsModal: React.FC<RuleDetailsModalProps> = ({
|
||||||
|
|
||||||
const colLower = sk.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
const colLower = sk.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
||||||
const isDateColumn = colLower.includes('fecha') || colLower.includes('vencimiento') ||
|
const isDateColumn = colLower.includes('fecha') || colLower.includes('vencimiento') ||
|
||||||
colLower.includes('publicacion') || colLower.includes('desde') || colLower.includes('hasta');
|
colLower.includes('publicacion') || colLower.includes('desde') || colLower.includes('hasta') ||
|
||||||
|
colLower.includes('periodo');
|
||||||
|
|
||||||
if (isDateColumn) {
|
if (isDateColumn) {
|
||||||
const parseDate = (val: any): Date | null => {
|
const parseDate = (val: any): Date | null => {
|
||||||
if (val == null) return null;
|
if (val == null) return null;
|
||||||
const valStr = String(val).trim();
|
const valStr = String(val).trim();
|
||||||
|
// DD-MM-YYYY o DD/MM/YYYY
|
||||||
const match1 = valStr.match(/^(\d{1,2})[-/](\d{1,2})[-/](\d{4})/);
|
const match1 = valStr.match(/^(\d{1,2})[-/](\d{1,2})[-/](\d{4})/);
|
||||||
if (match1) {
|
if (match1) {
|
||||||
const [, day, month, year] = match1;
|
const [, day, month, year] = match1;
|
||||||
return new Date(Number(year), Number(month) - 1, Number(day));
|
return new Date(Number(year), Number(month) - 1, Number(day));
|
||||||
}
|
}
|
||||||
|
// YYYYMMDD
|
||||||
|
if (/^\d{8}$/.test(valStr)) {
|
||||||
|
const year = Number(valStr.slice(0, 4));
|
||||||
|
const month = Number(valStr.slice(4, 6)) - 1;
|
||||||
|
const day = Number(valStr.slice(6, 8));
|
||||||
|
return new Date(year, month, day);
|
||||||
|
}
|
||||||
|
// YYYY-MM-DD
|
||||||
|
const match2 = valStr.match(/^(\d{4})-(\d{2})-(\d{2})/);
|
||||||
|
if (match2) {
|
||||||
|
const [, year, month, day] = match2;
|
||||||
|
return new Date(Number(year), Number(month) - 1, Number(day));
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
const dateA = parseDate(av);
|
const dateA = parseDate(av);
|
||||||
|
|
@ -366,7 +381,7 @@ ${xmlRows.join('\n')}
|
||||||
const clean = String(monto).replace(/\$/g, '').replace(/\./g, '').replace(/,/g, '').trim();
|
const clean = String(monto).replace(/\$/g, '').replace(/\./g, '').replace(/,/g, '').trim();
|
||||||
const num = typeof monto === 'number' ? monto : Number.parseFloat(clean) || 0;
|
const num = typeof monto === 'number' ? monto : Number.parseFloat(clean) || 0;
|
||||||
return sum + num;
|
return sum + num;
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-wrap gap-2">
|
<div className="flex flex-wrap gap-2">
|
||||||
|
|
|
||||||
|
|
@ -527,7 +527,15 @@ const FastCheck: React.FC = () => {
|
||||||
const getTooltip = (category: string, label: string): string | undefined => {
|
const getTooltip = (category: string, label: string): string | undefined => {
|
||||||
return tooltipMessages[category]?.[label];
|
return tooltipMessages[category]?.[label];
|
||||||
};
|
};
|
||||||
|
const normalizeDetails = (details: any) => {
|
||||||
|
if (!details) return [];
|
||||||
|
if (Array.isArray(details)) return details;
|
||||||
|
if (typeof details === 'object') {
|
||||||
|
if (Array.isArray(details.casos)) return details.casos;
|
||||||
|
return Object.values(details);
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
};
|
||||||
const normalizeDetailsForExport = (): { columns: string[]; rows: Record<string, unknown>[] } => {
|
const normalizeDetailsForExport = (): { columns: string[]; rows: Record<string, unknown>[] } => {
|
||||||
let d: unknown = ruleDetailsContent;
|
let d: unknown = ruleDetailsContent;
|
||||||
if (typeof d === 'string') {
|
if (typeof d === 'string') {
|
||||||
|
|
@ -4103,38 +4111,39 @@ const FastCheck: React.FC = () => {
|
||||||
titleTooltip="Evalúa el cumplimiento laboral y previsional del tercero crítico y su impacto en la operación."
|
titleTooltip="Evalúa el cumplimiento laboral y previsional del tercero crítico y su impacto en la operación."
|
||||||
title="Laboral y Capital Humano"
|
title="Laboral y Capital Humano"
|
||||||
dataTitle={["Parámetro", "Impacto", "Detectado", "Riesgo", "Detalles"]}
|
dataTitle={["Parámetro", "Impacto", "Detectado", "Riesgo", "Detalles"]}
|
||||||
data={(riskSummary.allRules?.capitalHumanoRules || []).map(rule => {
|
data={(riskSummary.allRules?.capitalHumanoRules || []).map((rule) => {
|
||||||
let dataRisk = rule.risk;
|
let dataRisk = rule.risk;
|
||||||
let detectedValue = rule.detected;
|
let detectedValue = rule.detected;
|
||||||
let detailsContent = rule.details;
|
let detailsContent: any = rule.details;
|
||||||
|
|
||||||
// Fix para Deuda Previsional Presunta
|
// Fix para Deuda Previsional Presunta
|
||||||
if (rule.label === "Deuda Previsional Presunta") {
|
if (rule.label === "Deuda Previsional Presunta") {
|
||||||
const hasCases = (rule.details as any)?.casos?.length > 0;
|
const normalized = normalizeDetails(rule.details);
|
||||||
if (hasCases) {
|
const hasCases = normalized.length > 0;
|
||||||
dataRisk = "alto";
|
dataRisk = hasCases ? "alto" : "bajo";
|
||||||
detectedValue = true;
|
detectedValue = hasCases;
|
||||||
} else {
|
detailsContent = normalized;
|
||||||
dataRisk = "bajo";
|
|
||||||
detectedValue = false;
|
|
||||||
}
|
|
||||||
detailsContent = (rule.details as any)?.casos ?? rule.details;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix para Término de Giro
|
// Fix para dataToCheck
|
||||||
let dataToCheck = rule.details;
|
let dataToCheck = rule.label === "Deuda Previsional Presunta" ? detailsContent : rule.details;
|
||||||
if (rule.label === "Deuda Previsional Presunta" && (rule.details as any)?.casos) {
|
|
||||||
dataToCheck = (rule.details as any)?.casos;
|
|
||||||
}
|
|
||||||
if (rule.label === "Término de Giro") {
|
if (rule.label === "Término de Giro") {
|
||||||
dataToCheck = null;
|
dataToCheck = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasDetails = ['Quiebra Judicial', 'Término de Giro', 'Contribuyente de difícil fiscalización'].includes(rule.label) ||
|
const hasDetails =
|
||||||
Boolean(dataToCheck && (
|
[
|
||||||
(Array.isArray(dataToCheck) && dataToCheck.length > 0) ||
|
"Quiebra Judicial",
|
||||||
(typeof dataToCheck === 'object' && dataToCheck !== null && Object.keys(dataToCheck as any).length > 0)
|
"Término de Giro",
|
||||||
));
|
"Contribuyente de difícil fiscalización",
|
||||||
|
].includes(rule.label) ||
|
||||||
|
Boolean(
|
||||||
|
dataToCheck &&
|
||||||
|
((Array.isArray(dataToCheck) && dataToCheck.length > 0) ||
|
||||||
|
(typeof dataToCheck === "object" &&
|
||||||
|
dataToCheck !== null &&
|
||||||
|
Object.keys(dataToCheck as any).length > 0))
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
label: rule.label,
|
label: rule.label,
|
||||||
|
|
@ -4142,24 +4151,30 @@ const FastCheck: React.FC = () => {
|
||||||
detected: detectedValue,
|
detected: detectedValue,
|
||||||
risk: dataRisk,
|
risk: dataRisk,
|
||||||
details: detailsContent,
|
details: detailsContent,
|
||||||
showDetails: hasDetails
|
showDetails: hasDetails,
|
||||||
};
|
};
|
||||||
})}
|
})}
|
||||||
getImpactColor={getImpactColor}
|
getImpactColor={getImpactColor}
|
||||||
getTooltip={(label) => getTooltip("Laboral y Capital Humano", label) || `Información sobre ${label}`}
|
getTooltip={(label) =>
|
||||||
|
getTooltip("Laboral y Capital Humano", label) ||
|
||||||
|
`Información sobre ${label}`
|
||||||
|
}
|
||||||
onShowDetails={(title, details) => {
|
onShowDetails={(title, details) => {
|
||||||
let processedDetails = details;
|
let processedDetails = details;
|
||||||
|
|
||||||
if (title === 'Deuda Previsional Presunta') {
|
if (title === "Deuda Previsional Presunta") {
|
||||||
// Manejar tanto array directo como objeto con propiedad casos
|
const casos = Array.isArray(details)
|
||||||
const casos = Array.isArray(details) ? details : ((details as any)?.casos ?? []);
|
? details
|
||||||
|
: (details as any)?.casos ?? [];
|
||||||
processedDetails = casos.map((row: any) => ({
|
processedDetails = casos.map((row: any) => ({
|
||||||
'RUT': row.rutAfiliado ?? '—',
|
RUT: row["Rut Afiliado"] ?? row.rutAfiliado ?? "—",
|
||||||
'Nombre': row.nombreAfiliado ?? '—',
|
Nombre: row["Nombre Afiliado"] ?? row.nombreAfiliado ?? "—",
|
||||||
'Tipo Entidad': row.afp ?? '—',
|
"Tipo Producto": row["Tipo Producto"] ?? row.tipoProducto ?? "—",
|
||||||
'Período': row.periodo ?? '—',
|
"Tipo Entidad": row["Tipo entidad"] ?? row.afp ?? "—",
|
||||||
'Fecha Carta': row.fecha ?? '—',
|
Período: row["Periodo"] ?? row.periodo ?? "—",
|
||||||
'Estado': row.fechaDemanda ?? '—',
|
"Fecha Carta": row["Fecha carta"] ?? row.fecha ?? "—",
|
||||||
|
Estado: row["Estado"] ?? row.estado ?? "—",
|
||||||
|
ID: row["ID"] ?? row.id ?? "—",
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4216,17 +4231,30 @@ const FastCheck: React.FC = () => {
|
||||||
onShowDetails={(title, details) => {
|
onShowDetails={(title, details) => {
|
||||||
let filteredDetails = details;
|
let filteredDetails = details;
|
||||||
if (title === 'Protestos y Morosidades' && Array.isArray(details)) {
|
if (title === 'Protestos y Morosidades' && Array.isArray(details)) {
|
||||||
const allowedCols = columnasPermitidas['Protestos y Morosidades'] ?? [];
|
const keyMap: Record<string, string> = {
|
||||||
|
vencimiento: 'vencimiento',
|
||||||
|
expirationDate: 'vencimiento',
|
||||||
|
monto: 'monto',
|
||||||
|
unpaidAmount: 'monto',
|
||||||
|
tipoDeuda: 'tipoDeuda',
|
||||||
|
documentType: 'tipoDeuda',
|
||||||
|
publicacion: 'publicacion',
|
||||||
|
};
|
||||||
|
const colOrder = ['vencimiento', 'monto', 'tipoDeuda', 'publicacion'];
|
||||||
filteredDetails = details.map((row: any) => {
|
filteredDetails = details.map((row: any) => {
|
||||||
const filtered: Record<string, any> = {};
|
const filtered: Record<string, any> = {};
|
||||||
allowedCols.forEach(col => {
|
Object.keys(keyMap).forEach(srcKey => {
|
||||||
if (row[col] !== undefined) filtered[col] = row[col];
|
if (row[srcKey] !== undefined) {
|
||||||
|
filtered[keyMap[srcKey]] = row[srcKey];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
// formateos...
|
|
||||||
return filtered;
|
return filtered;
|
||||||
});
|
});
|
||||||
// ← AGREGA ESTO
|
setRuleDetailsTitle(title);
|
||||||
console.log('Keys después del filtro:', Object.keys(filteredDetails[0] ?? {}));
|
setRuleDetailsContent(filteredDetails);
|
||||||
|
setRuleDetailsColumnOrder(colOrder.filter(c => Object.keys(filteredDetails[0] ?? {}).includes(c)));
|
||||||
|
setShowRuleDetailsModal(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
setRuleDetailsTitle(title);
|
setRuleDetailsTitle(title);
|
||||||
setRuleDetailsContent(filteredDetails);
|
setRuleDetailsContent(filteredDetails);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user