feat(qa): integrate official Mozambique CAE into saved financial plans
This commit is contained in:
@@ -82,6 +82,11 @@ function validCurrency(value: string): boolean {
|
||||
}
|
||||
|
||||
export type BusinessFinancialPlanInput = {
|
||||
economicClassification?: {
|
||||
code: string;
|
||||
revision: string;
|
||||
sourceSha256: string;
|
||||
};
|
||||
ratioCurrentBalances?: {
|
||||
assetsByMonth: string[];
|
||||
liabilitiesByMonth: string[];
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,60 @@
|
||||
import { mozambiqueCaeSubclasses } from './cae-mozambique-data.ts';
|
||||
|
||||
export const mozambiqueCaeSource = {
|
||||
revision: 'CAE-Rev.2',
|
||||
title: 'Classificação das Actividades Económicas de Moçambique — INE, 2008',
|
||||
url: 'https://www.ine.gov.mz/documents/20119/280028/Classificacao%20Das%20Actividades%20Economicas%20de%20Mocambique%20-CAE-REV.2.pdf/2d0e4657-e55c-3254-e815-5d0a8cb513bd?download=true&t=1725451130089&version=1.0',
|
||||
sha256: 'cb3dee56db5b2c3f12e3071615725051828a9e1eba17662aa5e78d5f3356b0fc',
|
||||
} as const;
|
||||
|
||||
export type PlanCaeSelection = {
|
||||
code: string;
|
||||
revision: string;
|
||||
sourceSha256: string;
|
||||
};
|
||||
|
||||
export const planCaeChoices = mozambiqueCaeSubclasses.map((node) => ({
|
||||
value: node.code,
|
||||
label: `${node.code} — ${node.label}`,
|
||||
keywords: /hotéis/i.test(node.label) ? ['hotel'] : [],
|
||||
}));
|
||||
|
||||
/** An explicit choice only; a sector, product name or forecast never assigns a CAE. */
|
||||
export function selectPlanCae(code: string): PlanCaeSelection | undefined {
|
||||
if (!code) return undefined;
|
||||
if (!mozambiqueCaeSubclasses.some((node) => node.code === code))
|
||||
throw Error('Seleccione uma subclasse da referência CAE apresentada.');
|
||||
return {
|
||||
code,
|
||||
revision: mozambiqueCaeSource.revision,
|
||||
sourceSha256: mozambiqueCaeSource.sha256,
|
||||
};
|
||||
}
|
||||
|
||||
export function describePlanCae(selection: unknown) {
|
||||
if (selection === undefined || selection === null)
|
||||
return {
|
||||
value: 'Não documentado',
|
||||
source: mozambiqueCaeSource.title,
|
||||
confirmed: false,
|
||||
};
|
||||
const item = selection as Partial<PlanCaeSelection>;
|
||||
const node = mozambiqueCaeSubclasses.find(
|
||||
(node) => node.code === item.code,
|
||||
);
|
||||
if (
|
||||
!node ||
|
||||
item.revision !== mozambiqueCaeSource.revision ||
|
||||
item.sourceSha256 !== mozambiqueCaeSource.sha256
|
||||
)
|
||||
return {
|
||||
value: 'Classificação guardada por conferir — escolha novamente na referência oficial',
|
||||
source: mozambiqueCaeSource.title,
|
||||
confirmed: false,
|
||||
};
|
||||
return {
|
||||
value: `${node.code} — ${node.label}`,
|
||||
source: `${mozambiqueCaeSource.title}, página PDF ${node.page}. ${mozambiqueCaeSource.url}#page=${node.page}`,
|
||||
confirmed: true,
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { displayValue } from './display-value.ts';
|
||||
import { describePlanCae } from './cae-mozambique.ts';
|
||||
import { buildComplementaryTables } from './complementary-report.ts';
|
||||
import { buildFinancialRatiosTable } from './financial-ratios-report.ts';
|
||||
import {
|
||||
@@ -526,6 +527,17 @@ function makeSections(
|
||||
const financialPlan = restoreBusinessPlanSnapshot(
|
||||
text(draft, 'business_plan_snapshot'),
|
||||
);
|
||||
if (finance) {
|
||||
const cae = describePlanCae(financialPlan?.economicClassification);
|
||||
finance.rows.push({
|
||||
field: 'Classificação CAE do plano',
|
||||
value: cae.value,
|
||||
classification: cae.confirmed
|
||||
? 'Escolha declarada pelo investidor; a confirmar documentalmente'
|
||||
: 'Não documentado ou por conferir',
|
||||
origin: cae.source,
|
||||
});
|
||||
}
|
||||
const complementaryTables = buildComplementaryTables(draft, financialPlan);
|
||||
for (const [i, id] of ['market', 'execution', 'team'].entries()) {
|
||||
const section = sections.get(id as DossierReportSectionId);
|
||||
@@ -894,6 +906,7 @@ export function createIntegralFinancialReport(
|
||||
)?.currency;
|
||||
const declaredCurrency = text(draft, 'currency');
|
||||
const summary = new Set([
|
||||
'Classificação CAE do plano',
|
||||
'Moeda do plano',
|
||||
'Horizonte',
|
||||
'Facturação no horizonte',
|
||||
|
||||
Reference in New Issue
Block a user