feat(qa): consolidate eleven financial report tables pending private visual acceptance

This commit is contained in:
2026-11-20 13:31:47 +02:00
parent 2e5b7f973c
commit 93fc837a47
12 changed files with 674 additions and 68 deletions
@@ -1,4 +1,5 @@
import { useMemo, useRef, useState } from 'react';
import { DossierReportPreview } from './dossier-report-preview';
import {
DossierExportGate,
dossierExportFailure,
@@ -7,6 +8,7 @@ import {
import {
createProjectDossierPrintHtml,
createProjectDossierReport,
createIntegralFinancialReport,
dossierReportSections,
generateProjectDossierDocx,
generateProjectDossierPackage,
@@ -58,6 +60,7 @@ export function ProjectDossierExport({
currentCalculation = null,
}: Props) {
const [selectedSections, setSelectedSections] = useState(defaultSections);
const [reportMode, setReportMode] = useState('dossier');
const [attachments, setAttachments] = useState<DossierAttachment[]>([]);
const [error, setError] = useState('');
const [busy, setBusy] = useState('');
@@ -127,13 +130,31 @@ export function ProjectDossierExport({
);
}
function model() {
return createProjectDossierReport(draft, {
selectedSections: selectedSectionSet,
const report = useMemo(
() =>
reportMode === 'financial'
? createIntegralFinancialReport(draft, {
version,
references,
currentCalculation,
})
: createProjectDossierReport(draft, {
selectedSections: selectedSectionSet,
version,
references,
currentCalculation,
}),
[
draft,
reportMode,
version,
references,
currentCalculation,
});
selectedSectionSet,
],
);
function model() {
return report;
}
async function exportWord(): Promise<void> {
@@ -272,7 +293,10 @@ export function ProjectDossierExport({
</p>
</div>
<fieldset className="space-y-2">
<fieldset
className="space-y-2"
disabled={reportMode === 'financial'}
>
<legend className="font-medium">
Escolha as secções a incluir
</legend>
@@ -400,6 +424,26 @@ export function ProjectDossierExport({
em zero. O relatório identifica pressupostos, estimativas e
referências sem as apresentar como resultados confirmados.
</p>
<label className="grid min-w-0 gap-1">
Conteúdo do relatório
<select
className="w-full min-w-0 rounded border p-2"
value={reportMode}
onChange={(e) => setReportMode(e.target.value)}
disabled={Boolean(busy)}
>
<option value="dossier">
Dossier e contexto — secções seleccionadas
</option>
<option value="financial">
Relatório financeiro integral — onze tabelas
</option>
</select>
</label>
<details className="rounded border p-3">
<summary>Conferir o relatório antes de exportar</summary>
<DossierReportPreview report={report} />
</details>
{notice && (
<p role="status" className="text-sm">
{notice}
@@ -414,7 +458,11 @@ export function ProjectDossierExport({
<button
type="button"
className="rounded bg-emerald-800 px-4 py-2 font-semibold text-white disabled:opacity-50"
disabled={Boolean(busy) || selectedSections.size === 0}
disabled={
Boolean(busy) ||
(reportMode === 'dossier' &&
selectedSections.size === 0)
}
onClick={() => void exportWord()}
>
{busy === 'word'
@@ -424,7 +472,11 @@ export function ProjectDossierExport({
<button
type="button"
className="rounded border px-4 py-2 disabled:opacity-50"
disabled={Boolean(busy) || selectedSections.size === 0}
disabled={
Boolean(busy) ||
(reportMode === 'dossier' &&
selectedSections.size === 0)
}
onClick={() => void exportPdf()}
>
{busy === 'pdf'