fix(qa): review package one deficits and print layout pending acceptance
This commit is contained in:
@@ -12,6 +12,29 @@ export type InvestmentReportTable = {
|
||||
notes: string[];
|
||||
issues: string[];
|
||||
};
|
||||
|
||||
/** Shared print/Word layout: repeat the rubric beside at most four periods. */
|
||||
export function investmentReportTableSlices(table: InvestmentReportTable) {
|
||||
return Array.from(
|
||||
{ length: Math.ceil((table.headers.length - 1) / 4) },
|
||||
(_, chunk) => {
|
||||
const start = 1 + chunk * 4;
|
||||
const indices = [
|
||||
0,
|
||||
...Array.from(
|
||||
{ length: Math.min(4, table.headers.length - start) },
|
||||
(_, i) => start + i,
|
||||
),
|
||||
];
|
||||
return {
|
||||
headers: indices.map((i) => table.headers[i]),
|
||||
rows: table.rows.map((row) =>
|
||||
indices.map((i) => displayReportMoney(row[i] ?? '')),
|
||||
),
|
||||
};
|
||||
},
|
||||
);
|
||||
}
|
||||
const cents = (value: string): bigint => {
|
||||
if (!/^-?\d+(?:\.\d{1,2})?$/.test(value))
|
||||
throw new Error(
|
||||
@@ -383,7 +406,7 @@ export function buildIntegralFinancialTables(
|
||||
`Mês ${i + 1}: depreciação superior aos activos ou reembolso superior à dívida; confira os dados.`,
|
||||
);
|
||||
const assets =
|
||||
positive(cash) +
|
||||
cash +
|
||||
positive(receivables) +
|
||||
(inventory ?? 0n) +
|
||||
fixed -
|
||||
@@ -392,7 +415,6 @@ export function buildIntegralFinancialTables(
|
||||
positive(-obligations) +
|
||||
positive(-taxDue);
|
||||
const liabilities =
|
||||
positive(-cash) +
|
||||
positive(-receivables) +
|
||||
positive(obligations) +
|
||||
positive(taxDue) +
|
||||
@@ -535,7 +557,7 @@ export function buildIntegralFinancialTables(
|
||||
'Existem períodos não reconciliados; reveja as rubricas indicadas.',
|
||||
);
|
||||
table('balance').notes.push(
|
||||
'Caixa negativa é necessidade de tesouraria no passivo; recebíveis negativos são adiantamentos de clientes; obrigações negativas são adiantamentos a fornecedores. Não são fontes mobilizadas.',
|
||||
'Caixa negativa conserva-se como défice projectado de tesouraria; não cria dívida, crédito aprovado ou financiamento mobilizado. Recebíveis negativos são adiantamentos de clientes; obrigações negativas são adiantamentos a fornecedores.',
|
||||
'Capital inicial e activos anteriores são declarados. Depreciação e reembolsos provêm do motor existente. Subvenções: ' +
|
||||
(a.grantsTreatment || 'sem montante declarado') +
|
||||
'.',
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
WidthType,
|
||||
} from 'docx';
|
||||
import JSZip from 'jszip';
|
||||
import { displayReportMoney } from './integral-financial-report.ts';
|
||||
import { investmentReportTableSlices } from './integral-financial-report.ts';
|
||||
import {
|
||||
classifyDossierAttachment,
|
||||
MAX_EMBEDDED_TEXT_BYTES,
|
||||
@@ -460,26 +460,8 @@ export async function generateProjectDossierDocx(
|
||||
);
|
||||
for (const note of [...entry.issues, ...entry.notes])
|
||||
children.push(new Paragraph(note));
|
||||
// Repeat the rubric with at most four periods per page-width table.
|
||||
for (let start = 1; start < entry.headers.length; start += 4) {
|
||||
const indices = [
|
||||
0,
|
||||
...Array.from(
|
||||
{ length: Math.min(4, entry.headers.length - start) },
|
||||
(_, i) => start + i,
|
||||
),
|
||||
];
|
||||
children.push(
|
||||
tableForDocx(
|
||||
indices.map((i) => entry.headers[i]),
|
||||
entry.rows.map((row) =>
|
||||
indices.map((i) =>
|
||||
displayReportMoney(row[i] ?? ''),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
for (const slice of investmentReportTableSlices(entry))
|
||||
children.push(tableForDocx(slice.headers, slice.rows));
|
||||
}
|
||||
if (!section.rows.length && !section.paragraphs.length)
|
||||
children.push(
|
||||
@@ -644,12 +626,8 @@ export async function createProjectDossierPrintHtml(
|
||||
content.push(`<h3>${escapeHtml(entry.title)}</h3>`);
|
||||
for (const note of [...entry.issues, ...entry.notes])
|
||||
content.push(`<p>${escapeHtml(note)}</p>`);
|
||||
content.push(
|
||||
`<div style="overflow-x:auto">${htmlTable(
|
||||
entry.headers,
|
||||
entry.rows.map((row) => row.map(displayReportMoney)),
|
||||
)}</div>`,
|
||||
);
|
||||
for (const slice of investmentReportTableSlices(entry))
|
||||
content.push(htmlTable(slice.headers, slice.rows));
|
||||
}
|
||||
if (section.rows.length)
|
||||
content.push(
|
||||
|
||||
Reference in New Issue
Block a user