fix(qa): evaluate credit warnings from declared contractual days

This commit is contained in:
2026-11-20 15:03:55 +02:00
parent 9c34af0406
commit 19f06ddfe1
4 changed files with 74 additions and 1 deletions
+11 -1
View File
@@ -38,6 +38,7 @@ export function financialPlanWarningMetrics(
: undefined;
const metrics: PlanWarningMetrics = {
currency: plan.currency,
creditDays: inputCreditDays(plan.creditTermDays),
fundingGap:
year === 0
? read('funding', 'Diferença por financiar', 1)
@@ -97,7 +98,10 @@ export function financialPlanWarnings(
id: `${year}-${w.id}`,
message: `${year}: ${w.message}`,
}));
if ((plan.salesCollectionLagMonths ?? 0) > 3)
if (
inputCreditDays(plan.creditTermDays) === undefined &&
(plan.salesCollectionLagMonths ?? 0) > 3
)
warnings.push({
id: `${year}-credit`,
message: `${year}: O prazo de recebimento é superior a três meses no modelo mensal e pressiona a caixa. Confirme o prazo indicado.`,
@@ -106,3 +110,9 @@ export function financialPlanWarnings(
},
);
}
function inputCreditDays(value: string | undefined) {
return value && /^\d+$/.test(value) && Number(value) <= 365
? Number(value)
: undefined;
}