Integrate supplied institutions by location category and type through investor dossiers

This commit is contained in:
2026-11-10 20:59:24 +02:00
parent 5ff9402fd0
commit 5a5cc9e815
26 changed files with 33731 additions and 80 deletions
@@ -0,0 +1,195 @@
import { card, input } from '@/pages/investment/shared';
export const financialCategories: Record<string, string> = {
banking: 'Banca',
credit: 'Crédito e microfinanças',
investment: 'Gestão de investimento',
pensions: 'Fundos de pensões',
insurance: 'Seguros e resseguros',
intermediation: 'Mediação de seguros',
exchange: 'Câmbio',
payments: 'Pagamentos e serviços interbancários',
supervision: 'Supervisão',
other: 'Outras instituições',
};
export const financialTypes: Record<string, string> = {
commercial_bank: 'Banco comercial',
investment_bank: 'Banco de investimento',
bank: 'Banco (tipo não especificado)',
microbank: 'Microbanco',
cooperative: 'Cooperativa de crédito',
savings: 'Organização de poupança e empréstimo',
investment_manager: 'Gestora de fundos de investimento',
investment_company: 'Sociedade de investimento',
pension_manager: 'Gestora de fundos de pensões',
insurer: 'Seguradora',
reinsurer: 'Resseguradora',
microinsurer: 'Micro-seguradora',
broker: 'Corretora de seguros',
agent: 'Agente de seguros',
reinsurance_broker: 'Corretor de resseguro',
exchange_house: 'Casa de câmbio',
electronic_money: 'Instituição de moeda electrónica',
interbank: 'Serviços interbancários',
supervisor: 'Supervisor',
other: 'Outro tipo documentado',
};
export type Classification = {
institution_categories?: string[];
institution_types?: string[];
institution_services?: string[];
institution_status?: string;
successor_key?: string | null;
register_reference?: string | null;
source_document_name?: string | null;
source_document_sha256?: string | null;
aliases?: string[];
source_rows?: { id: string; section: string; text: string }[];
};
export const evidenceLabels: Record<string, string> = {
reported: 'Reportado no documento',
to_confirm: 'A confirmar',
historical: 'Referência histórica',
conflict: 'Informação divergente/identidade por confirmar',
unlocated: 'Localização por confirmar',
};
export function ClassificationSummary({ value }: { value: Classification }) {
return (
<section className={card}>
<h2>Categoria e tipo da instituição</h2>
<p>
Categorias:{' '}
{(value.institution_categories ?? [])
.map((k) => financialCategories[k] ?? k)
.join(' · ') || 'Por classificar'}
</p>
<p>
Tipos:{' '}
{(value.institution_types ?? [])
.map((k) => financialTypes[k] ?? k)
.join(' · ') || 'Por classificar'}
</p>
<p>
Situação segundo a fonte:{' '}
{value.institution_status === 'merged'
? 'Fundida/extinta segundo o documento; não apresentar como instituição activa'
: value.institution_status === 'historical'
? 'Registo histórico'
: value.institution_status === 'unknown'
? 'Situação actual por confirmar'
: 'Reportada no documento; não é confirmação independente de licença actual'}
{value.successor_key
? ` · Sucessora indicada: ${value.successor_key}`
: ''}
</p>
{value.register_reference && (
<p>
Referência de registo no documento:{' '}
{value.register_reference}
</p>
)}
<details>
<summary>
Rastrear o conteúdo até ao documento e à linha de origem
</summary>
<p>
{value.source_document_name} · SHA-256{' '}
{value.source_document_sha256}
</p>
{(value.source_rows ?? []).map((row) => (
<article key={row.id}>
<h3>{row.section}</h3>
<p>{row.id}</p>
<p>{row.text}</p>
</article>
))}
</details>
<p>
Categoria e presença física não confirmam cobertura de crédito,
oferta de seguro específica, garantia ou aceitação do processo.
</p>
</section>
);
}
export function ClassificationFields({
value,
change,
needs,
}: {
value: Classification;
change: (patch: Partial<Classification>) => void;
needs: Record<string, string>;
}) {
const multiple = (
key:
| 'institution_categories'
| 'institution_types'
| 'institution_services',
label: string,
options: Record<string, string>,
) => (
<label className="my-3 block">
{label}
<select
multiple
className={input}
value={value[key] ?? []}
onChange={(e) =>
change({
[key]: Array.from(
e.target.selectedOptions,
(o) => o.value,
),
})
}
>
{Object.entries(options).map(([id, title]) => (
<option key={id} value={id}>
{title}
</option>
))}
</select>
</label>
);
return (
<details className={card}>
<summary>Categoria, tipo e serviço — Alterar</summary>
{multiple(
'institution_categories',
'Categorias documentadas',
financialCategories,
)}
{multiple(
'institution_types',
'Tipos documentados',
financialTypes,
)}
{multiple(
'institution_services',
'Serviços identificados (não é oferta garantida)',
needs,
)}
<label>
Situação
<select
className={input}
value={value.institution_status ?? 'unknown'}
onChange={(e) =>
change({ institution_status: e.target.value })
}
>
<option value="unknown">Por confirmar</option>
<option value="reported">Reportada no documento</option>
<option value="historical">Histórica</option>
<option value="merged">
Fundida/extinta segundo a fonte
</option>
</select>
</label>
<p>
As linhas originais e as classificações anteriores conservam-se
nas versões. Não complete lacunas por inferência.
</p>
</details>
);
}
@@ -27,6 +27,7 @@ export function FundingDossierChoice({
}) {
const [need, setNeed] = useState(selection.need ?? '');
const [product, setProduct] = useState('');
const [location, setLocation] = useState('');
const [consent, setConsent] = useState(false);
const [busy, setBusy] = useState(false);
const [error, setError] = useState('');
@@ -42,6 +43,8 @@ export function FundingDossierChoice({
version: dossier.version,
version_id: record.version_id,
product: product || null,
location_id: location || null,
location_mode: selection.location_mode ?? 'coverage',
need,
territory: selection.territory,
consent,
@@ -164,12 +167,46 @@ export function FundingDossierChoice({
</select>
</label>
)}
{record.payload.kind === 'institution' && (
<label>
Sede/balcão a conservar na preparação
<select
className={input}
value={location}
onChange={(e) =>
setLocation(e.target.value)
}
>
<option value="">
Sem local específico seleccionado / por
confirmar
</option>
{(record.payload.locations ?? [])
.filter((l) => l.id)
.map((l) => (
<option key={l.id} value={l.id}>
{l.label} ·{' '}
{l.location_text ||
l.territory_path
?.map((n) => n.name)
.join(' / ') ||
'Local por confirmar'}{' '}
·{' '}
{l.evidence_status ===
'to_confirm'
? 'A confirmar'
: ''}
</option>
))}
</select>
</label>
)}
<p>
Local seleccionado:{' '}
{selection.territory
? selection.territory_label ||
'Conservado da pesquisa; consulte a cobertura do produto.'
: 'Volte à pesquisa e escolha a localização antes de guardar.'}
: 'Local de interesse por identificar; a referência fica guardada com essa lacuna explícita.'}
</p>
<label>
<input
@@ -187,8 +224,7 @@ export function FundingDossierChoice({
disabled={
busy ||
dossier.closed ||
(!pending.current &&
(!consent || !need || !selection.territory))
(!pending.current && (!consent || !need))
}
onClick={() => void save()}
>
+114 -31
View File
@@ -1,12 +1,26 @@
import {
ClassificationFields,
ClassificationSummary,
evidenceLabels,
type Classification,
} from '@/components/funding-classification';
import { card, input, button } from '@/pages/investment/shared';
export type FundingSource = {
source_url: string;
source_url: string | null;
source_document_name?: string | null;
source_document_sha256?: string | null;
evidence_status?: string | null;
origin?: string;
source_refs?: string[];
source_reference: string;
checked_on: string;
};
export type FundingContact = FundingSource & { kind: string; value: string };
export type FundingLocation = FundingSource & {
id?: string;
location_text?: string;
hours?: string;
role: string;
label: string;
address: string;
@@ -27,7 +41,7 @@ export type FundingProduct = FundingSource & {
availability: string;
contact_url: string;
};
export type InstitutionDetails = {
export type InstitutionDetails = Classification & {
institution_key: string;
institution_nature: string;
contacts: FundingContact[];
@@ -83,9 +97,45 @@ function Sources({
<Text
label="Endereço da fonte"
type="url"
value={value.source_url}
value={value.source_url ?? ''}
change={(source_url) => change({ source_url })}
/>
{!value.source_url && (
<>
<Text
label="Documento de origem"
value={value.source_document_name ?? ''}
change={(source_document_name) =>
change({ source_document_name })
}
/>
<Text
label="SHA-256 do original"
value={value.source_document_sha256 ?? ''}
change={(source_document_sha256) =>
change({ source_document_sha256 })
}
/>
</>
)}
{value.source_document_sha256 && (
<label>
Situação desta informação
<select
className={input}
value={value.evidence_status ?? 'to_confirm'}
onChange={(e) =>
change({ evidence_status: e.target.value })
}
>
{Object.entries(evidenceLabels).map(([key, label]) => (
<option key={key} value={key}>
{label}
</option>
))}
</select>
</label>
)}
<Text
label="Referência/edição"
value={value.source_reference}
@@ -130,6 +180,7 @@ export function InstitutionFields({
A sede ou balcão não determina a cobertura do financiamento. Não
preencha condições desconhecidas por inferência.
</p>
<ClassificationFields value={value} change={change} needs={needs} />
<Text
label="Identidade estável da instituição (referência do cadastro/fonte)"
value={value.institution_key}
@@ -502,40 +553,63 @@ export function InstitutionFields({
}
function Source({ value }: { value: FundingSource }) {
return (
<p>
<a
className="underline"
href={value.source_url}
target="_blank"
rel="noopener noreferrer"
>
{value.source_reference}
</a>{' '}
· consulta {value.checked_on}
</p>
<div>
<p>
{value.source_url ? (
<a
className="underline"
href={value.source_url}
target="_blank"
rel="noopener noreferrer"
>
{value.source_reference}
</a>
) : (
value.source_reference
)}{' '}
· consulta {value.checked_on}
</p>
{value.source_document_name && (
<p>
Documento: {value.source_document_name} · SHA-256{' '}
{value.source_document_sha256}
</p>
)}
{value.evidence_status && (
<p>
{evidenceLabels[value.evidence_status] ??
value.evidence_status}{' '}
· {value.origin}
</p>
)}
</div>
);
}
export function InstitutionView({ value }: { value: InstitutionDetails }) {
return (
<section className={card}>
<h2>Instituição financeira</h2>
<p>
Natureza:{' '}
{
(
{
bank: 'Banco',
credit: 'Instituição de crédito',
microfinance: 'Microfinanças',
investment_fund: 'Fundo de investimento',
development:
'Agência de desenvolvimento/financiamento',
other: 'Outra natureza documentada',
unknown: 'Por confirmar',
} as Record<string, string>
)[value.institution_nature]
}
</p>
<ClassificationSummary value={value} />
{!value.institution_types?.length && (
<p>
Natureza:{' '}
{
(
{
bank: 'Banco',
credit: 'Instituição de crédito',
microfinance: 'Microfinanças',
investment_fund: 'Fundo de investimento',
development:
'Agência de desenvolvimento/financiamento',
other: 'Outra natureza documentada',
unknown: 'Por confirmar',
} as Record<string, string>
)[value.institution_nature]
}
</p>
)}
<h3>Contactos</h3>
{value.contacts.length === 0 && <p>Contactos por confirmar.</p>}
{value.contacts.map((c, i) => (
@@ -575,6 +649,15 @@ export function InstitutionView({ value }: { value: InstitutionDetails }) {
{l.territory_path?.map((n) => n.name).join(' / ') ||
'Correspondência ao cadastro territorial por confirmar'}
</p>
{l.location_text && (
<p>Local indicado: {l.location_text}</p>
)}
{l.hours && (
<p>
Horário indicado na fonte (pode ter mudado):{' '}
{l.hours}
</p>
)}
<Source value={l} />
</article>
))}
+1 -1
View File
@@ -511,7 +511,7 @@ export function portalNavigation(access: PortalNavAccess): PortalNavItem[] {
? [
link(
'funding',
'Fundos e programas de apoio',
'Instituições financeiras e seguros',
'/fundos',
),
...(access.authenticated
+15 -1
View File
@@ -279,7 +279,9 @@ function Editor({
}
function text(
key: {
[K in keyof Draft]: Draft[K] extends string ? K : never;
[K in keyof Draft]-?: Draft[K] extends string | null | undefined
? K
: never;
}[keyof Draft],
label: string,
type = 'text',
@@ -427,6 +429,18 @@ function Editor({
{!draft.manager_organization_id &&
text('manager_name', 'Gestor indicado pela fonte')}
{text('source_url', 'Endereço da fonte', 'url')}
{!draft.source_url && (
<>
{text(
'source_document_name',
'Documento de origem',
)}
{text(
'source_document_sha256',
'SHA-256 do documento',
)}
</>
)}
{text('source_reference', 'Documento, edição e referência')}
{text(
'source_checked_on',
+89 -1
View File
@@ -1,3 +1,7 @@
import {
financialCategories,
financialTypes,
} from '@/components/funding-classification';
import { Link, useForm } from '@inertiajs/react';
import { Frame, card, button } from '@/pages/investment/shared';
import { type Programme, windowLabels } from './shared';
@@ -24,6 +28,10 @@ export default function Index({
need?: string;
context?: string;
opportunity?: string;
category?: string;
institution_type?: string;
location_mode?: string;
include_historical?: string;
};
options: {
sectors: { id: number; name: string }[];
@@ -34,6 +42,10 @@ export default function Index({
management: boolean;
}) {
const form = useForm({
category: filters.category ?? '',
institution_type: filters.institution_type ?? '',
location_mode: filters.location_mode ?? 'coverage',
include_historical: filters.include_historical ?? '0',
context: filters.context ?? '',
opportunity: filters.opportunity ?? '',
need: filters.need ?? '',
@@ -66,7 +78,74 @@ export default function Index({
}}
>
<label>
Necessidade de financiamento
Categoria
<select
className="block rounded border p-2"
value={form.data.category}
onChange={(e) =>
form.setData('category', e.target.value)
}
>
<option value="">Todas</option>
{Object.entries(financialCategories).map(
([id, label]) => (
<option key={id} value={id}>
{label}
</option>
),
)}
</select>
</label>
<label>
Tipo
<select
className="block rounded border p-2"
value={form.data.institution_type}
onChange={(e) =>
form.setData('institution_type', e.target.value)
}
>
<option value="">Todos</option>
{Object.entries(financialTypes).map(([id, label]) => (
<option key={id} value={id}>
{label}
</option>
))}
</select>
</label>
<label>
Localização a pesquisar
<select
className="block rounded border p-2"
value={form.data.location_mode}
onChange={(e) =>
form.setData('location_mode', e.target.value)
}
>
<option value="physical">
Sede, balcão ou presença física
</option>
<option value="coverage">
Cobertura do financiamento/produto
</option>
</select>
</label>
<label>
<input
type="checkbox"
checked={form.data.include_historical === '1'}
onChange={(e) =>
form.setData(
'include_historical',
e.target.checked ? '1' : '0',
)
}
/>
Incluir instituições históricas/fundidas, identificadas como
tal
</label>
<label>
Necessidade do processo
<select
className="block rounded border p-2"
value={form.data.need}
@@ -195,6 +274,15 @@ export default function Index({
</Link>
</h2>
<p>{item.payload.summary}</p>
<p>
{(item.payload.institution_categories ?? [])
.map((k) => financialCategories[k] ?? k)
.join(' · ')}{' '}
·{' '}
{(item.payload.institution_types ?? [])
.map((k) => financialTypes[k] ?? k)
.join(' · ')}
</p>
<p>Gestor: {item.payload.manager_name}</p>
{Object.entries(item.filter_explanation ?? {}).map(
([key, message]) => (
+8 -2
View File
@@ -85,13 +85,19 @@ export default function Show({
<p>
<a
className="underline"
href={payload.source_url}
href={payload.source_url || undefined}
target="_blank"
rel="noopener noreferrer"
>
Consultar fonte: {payload.source_reference}
</a>
. Consultada em {payload.source_checked_on}.
. Consultada em {payload.source_checked_on}.{' '}
{payload.source_document_name && (
<span>
Documento: {payload.source_document_name} · SHA-256{' '}
{payload.source_document_sha256}
</span>
)}
</p>
<section className={card}>
<h2 className="text-xl font-semibold">
+54 -2
View File
@@ -1,3 +1,8 @@
import {
financialCategories,
financialTypes,
evidenceLabels,
} from '@/components/funding-classification';
import {
ProactiveSummary,
proactiveView,
@@ -45,6 +50,18 @@ type Path = {
programme_id: string;
version: number;
need: string;
institution_key?: string;
categories?: string[];
institution_types?: string[];
location?: {
id: string;
label: string;
address?: string;
source_reference: string;
source_document_sha256?: string;
evidence_status?: string;
location_text?: string;
} | null;
opportunity: string | null;
notice: string;
product?: {
@@ -1077,14 +1094,14 @@ export default function InvestmentPath(path: Path) {
id="financiamento"
className="rounded-xl border bg-white p-4"
>
<h2>Referências de financiamento do dossier</h2>
<h2>Instituições e serviços ligados ao processo</h2>
<p>
Escolhas privadas para preparação; não são candidaturas
enviadas nem concessões de financiamento.
</p>
{path.tools.funding && (
<Link className="underline" href={path.tools.funding}>
Pesquisar instituições e apoios para este investimento
Pesquisar bancos, seguradoras e outras instituições
</Link>
)}
{(path.funding_selections ?? []).map((row) => (
@@ -1101,6 +1118,41 @@ export default function InvestmentPath(path: Path) {
'Condições por confirmar'}
</p>
<p>{row.notice}</p>
<p>
Identidade:{' '}
{row.institution_key ?? 'Referência anterior'} ·
Categoria:{' '}
{(row.categories ?? [])
.map((k) => financialCategories[k] ?? k)
.join(' · ') || 'Por classificar'}{' '}
· Tipo:{' '}
{(row.institution_types ?? [])
.map((k) => financialTypes[k] ?? k)
.join(' · ') || 'Por classificar'}
</p>
{row.location && (
<section>
<h4>
Sede/balcão escolhido: {row.location.label}
</h4>
<p>
{row.location.location_text} ·{' '}
{row.location.address}
</p>
<p>
{row.location.evidence_status
? evidenceLabels[
row.location.evidence_status
]
: ''}{' '}
· {row.location.source_reference}
</p>
<p>
SHA-256 da origem:{' '}
{row.location.source_document_sha256}
</p>
</section>
)}
<Link
className="underline"
href={`/fundos/${row.programme_id}?context=${path.case.id}${row.opportunity ? '&opportunity=' + encodeURIComponent(row.opportunity) : ''}`}