fix: preserve scoped V12 diagnostics pending interrupted QA proof

This commit is contained in:
2026-11-20 22:36:41 +02:00
parent a5f3714cac
commit 74ba0bd0d2
10 changed files with 349 additions and 14 deletions
+29 -1
View File
@@ -1837,10 +1837,38 @@ export function forecastBusinessPlan(input: BusinessFinancialPlanInput) {
entry.paymentLagMonths! < 0 ||
entry.paymentLagMonths! > 12)),
)
)
) {
// Diagnose only an already-rejected schedule; preserve every validation
// condition above and all payment calculations below.
if (useSupplierPaymentTerms && Array.isArray(schedule)) {
const overflowMonth = schedule.findIndex((entry) => {
if (!entry || !Array.isArray(entry.paymentInstallments))
return false;
try {
return (
entry.paymentInstallments.reduce(
(sum, part) =>
sum +
percentMicro(
part.percent,
'Percentagem da parcela',
),
0n,
) > 100_000_000n
);
} catch {
return false;
}
});
if (overflowMonth >= 0)
throw new Error(
`${product.label} — encomenda do mês ${overflowMonth + 1}: a soma das percentagens em «Parcelas ao fornecedor» excede 100%. Corrija os campos «Percentagem» desta encomenda; o plano não pode ser calculado com esta distribuição.`,
);
}
throw new Error(
`${product.label}: declare encomendas e prazos de entrega para todos os ${periods} meses.`,
);
}
return {
opening,
orders: schedule.slice(0, periods).map((entry, month) => ({