Allow private stage report preview and explicit Word/HTML download
This commit is contained in:
@@ -552,3 +552,63 @@ export function createInvestorDossierReport(
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
/** A preparation summary, never a substitute for an external act or its original. */
|
||||
export function createInvestorStageReport(
|
||||
input: InvestorDossierReportInput,
|
||||
stageCode: string,
|
||||
generatedAt = new Date().toISOString(),
|
||||
): DossierReportModel {
|
||||
const step = input.steps.find((item) => item.code === stageCode);
|
||||
if (!step) throw new Error('Etapa não encontrada neste dossier.');
|
||||
const report = createInvestorDossierReport(input, generatedAt);
|
||||
const entries = investorDossierReportIndex(input).filter((entry) =>
|
||||
entry.stage.split(', ').includes(stageCode),
|
||||
);
|
||||
const origins = new Set(entries.map((entry) => entry.href));
|
||||
const specificSections = new Set([
|
||||
...(stageCode === 'S02' ? ['market'] : []),
|
||||
...(stageCode === 'S03' ? ['finance'] : []),
|
||||
...(['S06', 'S07'].includes(stageCode) ? ['sources'] : []),
|
||||
]);
|
||||
return {
|
||||
...report,
|
||||
title: `${input.case.title} — ${stageCode}: ${step.title}`,
|
||||
version: `${report.version} · etapa v${step.version ?? 'não registada'}`,
|
||||
limitations: [
|
||||
...report.limitations,
|
||||
'Resumo dos registos disponíveis nesta etapa; não cria documentos, decisões ou resultados em falta.',
|
||||
],
|
||||
sections: report.sections
|
||||
.filter(
|
||||
(section) =>
|
||||
['project', 'summary', 'execution', 'resources'].includes(
|
||||
section.id,
|
||||
) || specificSections.has(section.id),
|
||||
)
|
||||
.map((section) => {
|
||||
if (section.id === 'summary')
|
||||
return {
|
||||
...section,
|
||||
rows: section.rows.filter((item) =>
|
||||
origins.has(item.origin),
|
||||
),
|
||||
};
|
||||
if (section.id === 'execution')
|
||||
return {
|
||||
...section,
|
||||
rows: section.rows.filter((item) =>
|
||||
item.field.startsWith(`${stageCode} —`),
|
||||
),
|
||||
};
|
||||
if (section.id === 'resources')
|
||||
return {
|
||||
...section,
|
||||
rows: section.rows.filter((item) =>
|
||||
origins.has(item.origin),
|
||||
),
|
||||
};
|
||||
return section;
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -396,6 +396,11 @@ export async function generateProjectDossierDocx(
|
||||
],
|
||||
}),
|
||||
];
|
||||
for (const limitation of model.limitations) {
|
||||
children.push(
|
||||
new Paragraph({ children: [new TextRun({ text: limitation })] }),
|
||||
);
|
||||
}
|
||||
for (const section of model.sections) {
|
||||
if (section.id === 'annexes') {
|
||||
if (!attachments.some((item) => item.include)) {
|
||||
@@ -591,6 +596,8 @@ export async function createProjectDossierPrintHtml(
|
||||
annexesIncluded: boolean,
|
||||
): Promise<string> {
|
||||
const content: string[] = [];
|
||||
for (const limitation of model.limitations)
|
||||
content.push(`<p>${escapeHtml(limitation)}</p>`);
|
||||
for (const section of model.sections) {
|
||||
if (
|
||||
section.id === 'annexes' &&
|
||||
|
||||
Reference in New Issue
Block a user