Repõe a regra aprovada dos rácios e agrupa as faltas por causa
O Pacote 3, aprovado a 20/11, não classifica automaticamente empréstimos nem presume vencimentos: a liquidez volta a exigir a classificação declarada. Na lista «Falta preencher» do plano de negócio, a mesma instrução para vários meses passa a ser uma linha com os meses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MzJmxFy3izprXr5dSq91jM
This commit is contained in:
@@ -119,23 +119,12 @@ export function buildFinancialRatiosTable(
|
||||
rows['Retorno do capital'].push(
|
||||
consistent && profitValid ? quotient(net, capital, true) : unknown,
|
||||
);
|
||||
// Ask only what cannot be calculated: without a declared
|
||||
// classification, the balance gives the current amounts and loans
|
||||
// are read as long-term (stated in the table notes).
|
||||
const fixed = cell(balance, 'Activos fixos líquidos', i),
|
||||
loans = cell(balance, 'Empréstimos e suprimentos por reembolsar', i);
|
||||
const currentAssets = settingsValid
|
||||
? declaration(settings.assetsByMonth[end])
|
||||
: settings === undefined && assets !== null && fixed !== null
|
||||
? assets - fixed
|
||||
: null,
|
||||
: null,
|
||||
currentLiabilities = settingsValid
|
||||
? declaration(settings.liabilitiesByMonth[end])
|
||||
: settings === undefined &&
|
||||
liabilities !== null &&
|
||||
loans !== null
|
||||
? liabilities - loans
|
||||
: null;
|
||||
: null;
|
||||
const validCurrent =
|
||||
currentAssets !== null &&
|
||||
currentLiabilities !== null &&
|
||||
@@ -169,10 +158,6 @@ export function buildFinancialRatiosTable(
|
||||
`${headers[i + 1]}: capital negativo; o retorno conserva o sinal matemático e exige interpretação desta situação.`,
|
||||
);
|
||||
}
|
||||
if (settings === undefined)
|
||||
result.notes.push(
|
||||
'Activo e passivo correntes calculados a partir do balanço: activo corrente = total do activo − activos fixos líquidos; passivo corrente = total do passivo − empréstimos e suprimentos, considerados de longo prazo. Se parte dos empréstimos vencer em menos de um ano, declare a classificação.',
|
||||
);
|
||||
result.rows = Object.values(rows);
|
||||
if (blockedPeriods.length)
|
||||
result.issues.push(
|
||||
|
||||
@@ -1049,10 +1049,31 @@ export function createInvestorDecisionReport(
|
||||
missing.push({
|
||||
message: `Tabelas ainda sem dados suficientes: ${expected.length} de ${integralFinancialTableIds.length}.`,
|
||||
});
|
||||
for (const issue of financialIssuesForDisplay(tables))
|
||||
// One line per cause: the same instruction for many months is grouped.
|
||||
const grouped = new Map<string, { months: number[]; tables: string }>();
|
||||
for (const issue of financialIssuesForDisplay(tables)) {
|
||||
const month = /— mês (\d+):/.exec(issue.message);
|
||||
const key = month
|
||||
? issue.message.replace(/— mês \d+:/, '— meses {meses}:')
|
||||
: issue.message;
|
||||
const entry = grouped.get(key) ?? {
|
||||
months: [],
|
||||
tables: issue.tables.join('; '),
|
||||
};
|
||||
if (month) entry.months.push(Number(month[1]));
|
||||
grouped.set(key, entry);
|
||||
}
|
||||
for (const [key, entry] of grouped) {
|
||||
const months = entry.months.sort((a, b) => a - b);
|
||||
const range =
|
||||
months.length > 1 &&
|
||||
months[months.length - 1] - months[0] === months.length - 1
|
||||
? `${months[0]} a ${months[months.length - 1]}`
|
||||
: months.join(', ');
|
||||
missing.push({
|
||||
message: `${issue.message} (${issue.tables.join('; ')})`,
|
||||
message: `${key.replace('{meses}', range).replace('— meses ' + months[0] + ':', '— mês ' + months[0] + ':')} (${entry.tables})`,
|
||||
});
|
||||
}
|
||||
const chapter = (
|
||||
title: string,
|
||||
paragraphs: string[],
|
||||
|
||||
@@ -95,29 +95,11 @@ void test('approved formulas are presented from the same monthly and annual stat
|
||||
assert.equal(get(t, 'Crescimento das vendas')[2], '0,00%');
|
||||
assert.equal(get(t, 'Crescimento das vendas').at(-1), 'Por determinar');
|
||||
});
|
||||
void test('inconsistent balance blocks only dependent indicators; without classification liquidity comes from the balance', () => {
|
||||
void test('inconsistent balance blocks only dependent indicators; missing liquidity does not invent maturity', () => {
|
||||
const { plan, source } = fixture();
|
||||
delete plan.ratioCurrentBalances;
|
||||
let t = buildFinancialRatiosTable(plan, source);
|
||||
// Mapa de erros, plano de negócio: ratios are calculated from the balance;
|
||||
// loans are read as long-term and the rule is stated in the notes.
|
||||
const balance = source.find((b) => b.id === 'balance');
|
||||
const value = (label) =>
|
||||
Number(balance.rows.find((r) => r[0] === label)[1]);
|
||||
const expected =
|
||||
(value('Total do activo') - value('Activos fixos líquidos')) /
|
||||
(value('Total do passivo') -
|
||||
value('Empréstimos e suprimentos por reembolsar'));
|
||||
assert.equal(
|
||||
get(t, 'Liquidez corrente')[1],
|
||||
expected.toFixed(2).replace('.', ',') + '×',
|
||||
);
|
||||
assert.ok(
|
||||
t.notes.some((n) =>
|
||||
n.startsWith('Activo e passivo correntes calculados a partir do balanço'),
|
||||
),
|
||||
);
|
||||
assert.ok(!t.issues.some((i) => i.includes('Activo corrente — mês')));
|
||||
assert.equal(get(t, 'Liquidez corrente')[1], 'Por determinar');
|
||||
assert.equal(get(t, 'Margem líquida')[1], '26,00%');
|
||||
assert.equal(get(t, 'Retorno do capital')[1], '14,77%');
|
||||
source
|
||||
|
||||
@@ -133,3 +133,15 @@ void test("missing executive summary fields are listed with the field to open (C
|
||||
/Preencha este campo para continuar/,
|
||||
);
|
||||
});
|
||||
|
||||
void test("the same missing classification for many months is one line with the months (Criar Hotel)", () => {
|
||||
const plan = financialReportFixture(36);
|
||||
delete plan.ratioCurrentBalances;
|
||||
const report = createInvestorDecisionReport({
|
||||
project_title: "Hotel",
|
||||
business_plan_snapshot: serializeBusinessPlanSnapshot(plan),
|
||||
});
|
||||
const lines = report.missing.filter((g) => g.message.startsWith("Rácios financeiros / Activo corrente"));
|
||||
assert.equal(lines.length, 1);
|
||||
assert.match(lines[0].message, /— meses 1 a 36:/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user