Reconciliar fontes instaladas 423bd512d8c5 com main
This commit is contained in:
@@ -111,6 +111,30 @@ function classification(origin: string): string {
|
||||
return 'Referência/estado indicado';
|
||||
}
|
||||
|
||||
export function formatDossierReportValue(field: string, value: string, currency = ''): string {
|
||||
if (field === 'Estado do plano detalhado') {
|
||||
return value.replace('Snapshot versionado disponível; usar também a exportação do plano financeiro', 'Plano guardado disponível; consulte também a exportação financeira');
|
||||
}
|
||||
if (field === 'Reconciliação do financiamento') {
|
||||
const states: Record<string, string> = { shortfall: 'Financiamento insuficiente', surplus: 'Fontes superiores aos usos previstos', balanced: 'Fontes e usos equilibrados', unknown: 'Informação insuficiente', incomplete: 'Informação insuficiente' };
|
||||
return states[value] ?? value;
|
||||
}
|
||||
if (/^Necessidade \d+$/.test(field)) {
|
||||
value = value.replace('; gap;', '; Competência em falta;').replace('; unknown;', '; Por confirmar;').replace('; available;', '; Disponível (declarado);');
|
||||
}
|
||||
if (/^Marco \d+$/.test(field)) {
|
||||
value = value.replace('; planned;', '; Planeado;').replace('; in_progress;', '; Em curso;').replace('; completed;', '; Concluído (declarado);');
|
||||
}
|
||||
if (/^(Necessidade|Marco) \d+$/.test(field)) {
|
||||
value = value.replace(/(custo|planeado|realizado): ([^;]*)(?=;|$)/g, (_, label: string, amount: string) => {
|
||||
const raw = amount.trim();
|
||||
return `${label}: ${raw ? (/^\d+(?:\.\d{1,2})?$/.test(raw) ? `${raw} ${currency || '(moeda não informada)'}` : raw) : 'Não informado'}`;
|
||||
}).replace(/prazo: (?=;|$)/g, 'prazo: Não informado');
|
||||
}
|
||||
// Presentation only: group the decimal string without converting the amount
|
||||
// to a JavaScript float or changing the saved financial snapshot.
|
||||
return value.replace(/^(-?)(\d+)\.(\d{2}) ([A-Z]{3})$/, (_, sign: string, whole: string, cents: string, currency: string) => `${sign}${whole.replace(/\B(?=(\d{3})+(?!\d))/g, ' ')},${cents} ${currency}`);
|
||||
}
|
||||
const rowSection: Record<string, DossierReportSectionId> = {
|
||||
Projecto: 'project',
|
||||
Mercado: 'market',
|
||||
@@ -180,28 +204,31 @@ function makeSections(
|
||||
{
|
||||
field: 'Data de geração',
|
||||
value: new Date(generatedAt).toLocaleString('pt-MZ'),
|
||||
origin: 'Relógio do dispositivo no momento da exportação',
|
||||
classification: 'Metadado do relatório',
|
||||
origin: 'Emissão no momento da exportação',
|
||||
classification: 'Data de emissão',
|
||||
},
|
||||
{
|
||||
field: 'Versão/revisão do dossier',
|
||||
value: version,
|
||||
origin: 'Revisão de rascunho guardada ou impressão digital local',
|
||||
classification: 'Metadado técnico',
|
||||
origin: 'Revisão do dossier exportado',
|
||||
classification: 'Referência da revisão',
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
for (const [sectionName, field, value, origin] of rows.slice(1)) {
|
||||
// Questionnaire schema identifiers remain stored; they do not help the
|
||||
// reader assess the project and are not a business report field.
|
||||
if (field === 'Versão do questionário') continue;
|
||||
const id = rowSection[sectionName];
|
||||
if (!id) continue;
|
||||
const section = sections.get(id);
|
||||
if (!section) continue;
|
||||
section.rows.push({
|
||||
field,
|
||||
value: absent(value),
|
||||
value: absent(formatDossierReportValue(field, value, text(draft, 'currency'))),
|
||||
origin,
|
||||
classification: classification(origin),
|
||||
classification: value.trim() === '' ? 'Informação em falta' : classification(origin),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -321,7 +348,7 @@ function makeSections(
|
||||
field: 'Versão do motor/cenário',
|
||||
value: `${typeof context?.engine_version === 'string' ? context.engine_version : 'não identificada'} / ${typeof context?.scenario_version === 'number' ? context.scenario_version : currentCalculation.version}`,
|
||||
origin: 'Contexto guardado na execução',
|
||||
classification: 'Metadado técnico',
|
||||
classification: 'Referência da revisão',
|
||||
},
|
||||
{
|
||||
field: 'Fórmula e valores usados',
|
||||
|
||||
Reference in New Issue
Block a user