fix: preserve scoped V12 diagnostics pending interrupted QA proof
This commit is contained in:
@@ -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) => ({
|
||||
|
||||
@@ -5,6 +5,20 @@ import {
|
||||
type InvestmentReportTable,
|
||||
} from './integral-financial-report.ts';
|
||||
import type { BusinessFinancialPlanInput } from './business-financial-plan.ts';
|
||||
import { calculateStartupAssetRequirements } from './startup-asset-requirements.ts';
|
||||
|
||||
/** The local startup editor owns this error when report tables are unavailable. */
|
||||
export function startupErrorMessage(plan: BusinessFinancialPlanInput): string {
|
||||
if (plan.startupAssetRequirements)
|
||||
try {
|
||||
calculateStartupAssetRequirements(plan);
|
||||
} catch (cause) {
|
||||
return cause instanceof Error
|
||||
? cause.message
|
||||
: 'Confira os dados de arranque.';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/** Do not hide a forecast error when the report editor itself cannot show the tables. */
|
||||
export function forecastErrorShownInReport(
|
||||
|
||||
@@ -537,9 +537,13 @@ export function buildIntegralFinancialTables(
|
||||
table('balance').issues.push(
|
||||
`Mês ${i + 1}: existências insuficientes para as vendas declaradas.`,
|
||||
);
|
||||
if (depreciation > fixed || principal > loans)
|
||||
if (depreciation > fixed)
|
||||
table('balance').issues.push(
|
||||
`Mês ${i + 1}: depreciação superior aos activos ou reembolso superior à dívida; confira os dados.`,
|
||||
`Balanço Projectado — mês ${i + 1}: a depreciação acumulada excede os activos fixos disponíveis. Confira «Base depreciável contabilística» e «Vida útil (meses)» face a «Aquisição de activos» e «Activos fixos anteriores (valor líquido)»; corrija os pressupostos inconsistentes.`,
|
||||
);
|
||||
if (principal > loans)
|
||||
table('balance').issues.push(
|
||||
`Balanço Projectado — mês ${i + 1}: o capital reembolsado acumulado excede a dívida declarada. Confira «Reembolso de capital» face a «Empréstimo recebido» e «Suprimentos»; corrija os pressupostos inconsistentes.`,
|
||||
);
|
||||
const assets =
|
||||
cash +
|
||||
|
||||
Reference in New Issue
Block a user