fix(demography): verify D01-D06 in isolated QA with INE traceability
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { populationValueLabel } from '@/lib/demographic-reading';
|
||||
import EvidenceDetails from './evidence-details';
|
||||
import DemographicReadingSummary from './demographic-reading-summary';
|
||||
|
||||
@@ -191,30 +192,13 @@ export default function DemographicEvidence({
|
||||
antes de comparar ou utilizar os valores.
|
||||
</p>
|
||||
)}
|
||||
<EvidenceDetails title="Valores por dimensão, fonte e advertências">
|
||||
<p>
|
||||
{s.version} · {s.file_name}
|
||||
</p>
|
||||
<p className="text-xs break-all">
|
||||
SHA256: {s.sha256}
|
||||
</p>
|
||||
{Object.keys(s.issue_counts).length > 0 && (
|
||||
<details>
|
||||
<summary>Advertências da série</summary>
|
||||
<pre className="overflow-auto text-xs">
|
||||
{JSON.stringify(
|
||||
s.issue_counts,
|
||||
null,
|
||||
2,
|
||||
)}
|
||||
</pre>
|
||||
</details>
|
||||
)}
|
||||
<EvidenceDetails title="Valores por ano e dimensão">
|
||||
<div className="max-h-96 overflow-auto">
|
||||
<table className="w-full min-w-[44rem] text-left text-sm whitespace-nowrap">
|
||||
<caption className="text-left">
|
||||
Valores originais por ano e dimensão
|
||||
— versões apresentadas separadamente
|
||||
Valores de apresentação por ano e
|
||||
dimensão — versões apresentadas
|
||||
separadamente
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -226,7 +210,6 @@ export default function DemographicEvidence({
|
||||
'Valor',
|
||||
'Unidade',
|
||||
'Tipo',
|
||||
'Referência',
|
||||
].map((h) => (
|
||||
<th className="p-2" key={h}>
|
||||
{h}
|
||||
@@ -262,7 +245,14 @@ export default function DemographicEvidence({
|
||||
}[v.residence]
|
||||
}
|
||||
</td>
|
||||
<td>{v.original_value}</td>
|
||||
<td>
|
||||
{v.indicator ===
|
||||
'population'
|
||||
? populationValueLabel(
|
||||
v.value,
|
||||
)
|
||||
: v.original_value}
|
||||
</td>
|
||||
<td>
|
||||
{v.unit ===
|
||||
'unspecified'
|
||||
@@ -275,9 +265,6 @@ export default function DemographicEvidence({
|
||||
? 'Projecção'
|
||||
: 'Não especificado'}
|
||||
</td>
|
||||
<td>
|
||||
{v.sheet}!{v.cell}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
@@ -293,38 +280,55 @@ export default function DemographicEvidence({
|
||||
<h2 className="text-xl font-semibold">
|
||||
Diferenças entre localizações
|
||||
</h2>
|
||||
{evidence.comparisons.map((c) => (
|
||||
<p
|
||||
key={`${c.year}:${c.left_import}:${c.right_import}:${c.left}:${c.right}`}
|
||||
>
|
||||
{c.year}: {c.left} ({c.left_value}) / {c.right} (
|
||||
{c.right_value}). Diferença:{' '}
|
||||
{c.difference ?? 'não comparável'}. {c.explanation}
|
||||
</p>
|
||||
))}
|
||||
{Array.from(
|
||||
new Set(evidence.comparisons.map((c) => c.year)),
|
||||
)
|
||||
.sort((a, b) => a - b)
|
||||
.map((year) => (
|
||||
<section key={year} className="space-y-2">
|
||||
<h3 className="font-semibold">{year}</h3>
|
||||
{evidence.comparisons
|
||||
.filter((c) => c.year === year)
|
||||
.map((c) => (
|
||||
<p
|
||||
key={[
|
||||
c.year,
|
||||
c.left_import,
|
||||
c.right_import,
|
||||
c.left,
|
||||
c.right,
|
||||
].join(':')}
|
||||
>
|
||||
{c.left} (
|
||||
{populationValueLabel(c.left_value)}
|
||||
) / {c.right} (
|
||||
{populationValueLabel(
|
||||
c.right_value,
|
||||
)}
|
||||
). Diferença:{' '}
|
||||
{c.difference === null
|
||||
? 'não comparável: âmbitos ou metadados distintos'
|
||||
: populationValueLabel(
|
||||
c.difference,
|
||||
)}
|
||||
{c.difference !== null &&
|
||||
' pessoas'}
|
||||
.
|
||||
</p>
|
||||
))}
|
||||
</section>
|
||||
))}
|
||||
</section>
|
||||
)}
|
||||
{evidence.differences.length > 0 && (
|
||||
<details>
|
||||
<summary>
|
||||
Reconciliação entre exemplares:{' '}
|
||||
{evidence.differences.length} dimensões comuns
|
||||
</summary>
|
||||
<ul>
|
||||
{evidence.differences.map((d) => (
|
||||
<li key={`${d.territory_id}:${d.dimension}`}>
|
||||
{d.dimension}:{' '}
|
||||
{d.state === 'matching_values'
|
||||
? 'valores coincidentes; conservar ambas as fontes'
|
||||
: 'valores divergentes'}{' '}
|
||||
—{' '}
|
||||
{d.values
|
||||
.map((v) => `${v.value} (${v.data_kind})`)
|
||||
.join(' / ')}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</details>
|
||||
{evidence.differences.some(
|
||||
(d) => d.state === 'divergent_values',
|
||||
) && (
|
||||
<p role="status">
|
||||
Há valores divergentes entre séries para a mesma localização
|
||||
e período. As séries são apresentadas separadamente; não
|
||||
foram somadas nem escolhidas como substitutas umas das
|
||||
outras.
|
||||
</p>
|
||||
)}
|
||||
<ul className="list-disc pl-5 text-sm">
|
||||
{evidence.limitations.map((l) => (
|
||||
|
||||
@@ -31,8 +31,8 @@ export default function DemographicReadingSummary({
|
||||
{current.kind === 'projected'
|
||||
? 'Projecção'
|
||||
: 'Tipo de dado não especificado'}
|
||||
. Valores de apresentação arredondados; os originais permanecem
|
||||
disponíveis abaixo.
|
||||
. Valores de apresentação arredondados; os originais são
|
||||
preservados na administração.
|
||||
</p>
|
||||
<dl className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
||||
{[
|
||||
|
||||
@@ -39,9 +39,15 @@ function one(rows: Row[], age: string, residence = 'all'): Row | undefined {
|
||||
export const populationLabel = (n: number | null) =>
|
||||
n === null
|
||||
? 'Sem dados'
|
||||
: new Intl.NumberFormat('pt-MZ', { maximumFractionDigits: 0 }).format(
|
||||
n,
|
||||
);
|
||||
: new Intl.NumberFormat('pt-MZ', {
|
||||
maximumFractionDigits: 0,
|
||||
useGrouping: 'always',
|
||||
}).format(n);
|
||||
// Formatting only: never write rounded values back to evidence or calculations.
|
||||
export const populationValueLabel = (value: string) =>
|
||||
/^-?\d+(\.\d+)?$/.test(value) && Number.isFinite(Number(value))
|
||||
? populationLabel(Number(value))
|
||||
: 'Sem dados';
|
||||
export const percentageLabel = (n: number | null) =>
|
||||
n === null
|
||||
? 'Sem dados'
|
||||
|
||||
@@ -24,6 +24,7 @@ function DemographySelection({
|
||||
territories,
|
||||
sectors,
|
||||
sectorReadings = [],
|
||||
entrySector,
|
||||
}: {
|
||||
evidence: DemographicAnalysis;
|
||||
filters: {
|
||||
@@ -44,6 +45,7 @@ function DemographySelection({
|
||||
href: string;
|
||||
analysis: SectorAnalysis;
|
||||
}[];
|
||||
entrySector?: string | null;
|
||||
}) {
|
||||
const [selected, setSelected] = useState(filters.territories ?? []);
|
||||
const [province, setProvince] = useState('');
|
||||
@@ -211,6 +213,13 @@ function DemographySelection({
|
||||
</div>
|
||||
</form>
|
||||
<DemographicEvidence evidence={evidence} />
|
||||
{filters.sector === 'tourism' && (
|
||||
<p>
|
||||
Os dados de população constituem contexto territorial. Não
|
||||
há nesta consulta estatísticas sectoriais de Turismo que
|
||||
permitam avaliar a procura turística por distrito.
|
||||
</p>
|
||||
)}
|
||||
{evidence.territories.length > 0 && (
|
||||
<section className="space-y-3 rounded border p-4">
|
||||
<h2 className="text-xl font-semibold">
|
||||
@@ -227,7 +236,11 @@ function DemographySelection({
|
||||
className="block py-2 underline"
|
||||
href={
|
||||
'/investimentos/iniciar?source=' +
|
||||
encodeURIComponent('territory:' + t.id)
|
||||
encodeURIComponent('territory:' + t.id) +
|
||||
(entrySector
|
||||
? '§or=' +
|
||||
encodeURIComponent(entrySector)
|
||||
: '')
|
||||
}
|
||||
>
|
||||
Preparar ideia em {t.name}
|
||||
@@ -235,6 +248,15 @@ function DemographySelection({
|
||||
))}
|
||||
</section>
|
||||
)}
|
||||
{filters.sector &&
|
||||
filters.sector !== 'general' &&
|
||||
sectorReadings.length === 0 && (
|
||||
<p>
|
||||
Não há ideias documentadas compatíveis com o sector
|
||||
seleccionado nesta consulta. Pode preparar a sua própria
|
||||
ideia, sem substituir o sector escolhido.
|
||||
</p>
|
||||
)}
|
||||
{sectorReadings.map((reading) => (
|
||||
<section key={reading.href} className="space-y-3">
|
||||
<h2 className="text-xl font-semibold">{reading.title}</h2>
|
||||
|
||||
Reference in New Issue
Block a user