Adapt preparation presentation to declared applicability
This commit is contained in:
@@ -12,6 +12,29 @@ import {
|
||||
validateDossierAttachments,
|
||||
} from '../../resources/js/lib/project-dossier-report.ts';
|
||||
|
||||
test('report separates inapplicable documents from missing and unknown requirements without changing the saved snapshot', async () => {
|
||||
const requirements = [
|
||||
{ label: 'Título DUAT', state: 'not_applicable', reason: 'Arrendamento declarado' },
|
||||
{ label: 'Identificação', state: 'missing', reason: 'Pedido em preparação' },
|
||||
{ label: 'Capital externo', state: 'indeterminate', reason: 'Origem por determinar' },
|
||||
];
|
||||
const snapshot = JSON.stringify({ version: 1, context_revision: 2, preparation: {
|
||||
enabled: true, mode: 'registration', version: 'QA', next: 'Completar identificação',
|
||||
calculation_notice: 'Cálculo separado', notice: 'Preparação', requirements,
|
||||
} });
|
||||
const draft = { context_applicability_snapshot: snapshot };
|
||||
const report = createProjectDossierReport(draft, { selectedSections: new Set(['sources']) });
|
||||
const section = report.sections.find((section) => section.id === 'sources');
|
||||
assert.ok(section);
|
||||
assert.equal(section.rows.some((row) => row.field === 'Título DUAT'), false);
|
||||
assert.match(section.paragraphs.join(' '), /Não exigido neste contexto: Título DUAT \(Arrendamento declarado\)/);
|
||||
assert.equal(section.rows.find((row) => row.field === 'Identificação').value, 'Documento por associar');
|
||||
assert.equal(section.rows.find((row) => row.field === 'Capital externo').value, 'Informação em falta para decidir');
|
||||
const print = await createProjectDossierPrintHtml(report, [], false);
|
||||
assert.match(print, /Arrendamento declarado/);
|
||||
assert.equal(draft.context_applicability_snapshot, snapshot);
|
||||
});
|
||||
|
||||
test('executive summary exposes the same financial result and period without replacing missing data by zero', () => {
|
||||
const draft = { currency:'MZN', financial_tools_snapshot:serializeFinancialToolsSnapshot({budgetPeriod:'Mensal',loan:{principal:'1200',rate:'0',months:'12',rateType:'nominal',periodMonths:'1',gracePeriods:'0',upfrontFee:'0',recurringFee:'0'},breakEven:{fixed:'100.01',price:'30',variable:'20'},funding:{total:'1000',secured:'800'},incomes:[{label:'Receita QA',amount:'1000'}],expenses:[{label:'Despesa QA',amount:'1100'}]}) };
|
||||
const report = createProjectDossierReport(draft,{selectedSections:new Set(['summary','finance'])});
|
||||
|
||||
Reference in New Issue
Block a user