fix(v12): clarify remaining financial diagnostics and preserve editable recovery
This commit is contained in:
@@ -183,22 +183,35 @@ export function buildIntegralFinancialTables(
|
||||
return total + cents(row.amount);
|
||||
}, 0n);
|
||||
const count = result.rows.length;
|
||||
const schedule = (values: string[]) => {
|
||||
const schedule = (values: string[], field: string) => {
|
||||
if (!Array.isArray(values) || values.length !== count)
|
||||
throw new Error(
|
||||
'Preencha imposto estimado e pagamento fiscal para cada mês, incluindo zero quando aplicável.',
|
||||
);
|
||||
return values.map((value) => {
|
||||
const amount = cents(value);
|
||||
return values.map((value, month) => {
|
||||
let amount: bigint;
|
||||
try {
|
||||
amount = cents(value);
|
||||
} catch {
|
||||
throw new Error(
|
||||
`Impostos por mês — ${field}, mês ${month + 1}: preencha este campo com um montante até duas casas decimais; indique zero apenas quando aplicável.`,
|
||||
);
|
||||
}
|
||||
if (amount < 0n)
|
||||
throw new Error(
|
||||
'Os impostos estimados não podem ser negativos.',
|
||||
`Impostos por mês — ${field}, mês ${month + 1}: o montante não pode ser negativo. Corrija este campo.`,
|
||||
);
|
||||
return amount;
|
||||
});
|
||||
};
|
||||
const taxExpenses = schedule(a.taxExpenseByMonth),
|
||||
taxPayments = schedule(a.taxPaymentByMonth);
|
||||
const taxExpenses = schedule(
|
||||
a.taxExpenseByMonth,
|
||||
'Imposto reconhecido',
|
||||
),
|
||||
taxPayments = schedule(
|
||||
a.taxPaymentByMonth,
|
||||
'Pagamento fiscal previsto',
|
||||
);
|
||||
if (!a.taxSource.trim())
|
||||
throw new Error(
|
||||
'Indique a fonte ou o pressuposto fiscal, incluindo quando não prevê imposto.',
|
||||
|
||||
Reference in New Issue
Block a user