Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
996b5b08cd | ||
|
|
838ad941a2 | ||
|
|
814fe0a9b7 |
@@ -1491,3 +1491,73 @@ QA dirigida:3testes/319asserções, transacções com rollback em loopback55441;
|
||||
Capacidade antes:88,3GiB e23,76milhões de inodes livres;novamente conferida após backup. Backup fresco `/var/backups/investmoz-sector-navigation-20261027/backup`,dumpSHA256`9b2437017495fe449cfe0c869da62870bd0fc4bddde596660a37392b8dbdaaba`;restauro das174tabelas com contagens/checksums idênticos,em contentor sem rede,porta55441.369ficheiros persistentes/configuração verificados;172tabelas de negócio intactas depois da instalação;cache/sessões operacionais reconciliados por identidade/expiração/pedidos públicos. Schema,papéis,grants epermissões iguais. Sem migrations,importações ou publicação de pilotos;storageQA fica separado da release servida. Songo/Gurué privados;L8 e percurso proactivo anteriores preservados. PEC`7fdb6b42` continua emQA separado e não foi instalado nesta passagem. Avaliação real da equipa continua dependente do retorno dos participantes.
|
||||
|
||||
Recibo consolidado: `docs/investmoz/unification/sector-navigation-delivery-20261027.json`. Cópia remota: `/var/backups/investmoz-sector-navigation-20261027/installed-receipt.json`,SHA256`cd95142b7f85e40a0f86e0f7d3dca513e7bc208c89aa91b8e3ad213191d8465f`. Provas locais: `outputs/sector-navigation-delivery-20261027/`. Os registos anteriores de QA/transferência são históricos;esta correcção já não está pendente de instalação. Não se declara concluído o âmbito global dos requisitos sectoriais ou do simulador.
|
||||
|
||||
|
||||
## 27/10/2026 — PEC entregue e retoma dos créditos próprios de L8
|
||||
|
||||
**Instalado e conferido em `e182d1d79dc945f35d2079c6b8ca2ac93048cec3`**, incluindo o PEC aceite emQA`7fdb6b42` e preservando integralmente a correcção dos sectores`669cb897`. A reconciliação alterou apenas conflitos documentais, conservando os históricos das duas linhas e o recibo sectorial`4ee427ba`. Os4ficheiros de aplicação PEC ficaram idênticos à QA;os ficheiros sectoriais e seus testes idênticos ao instalado. Fonte/configuração/routes/schema fora do delta preservados. A matriz mantém as4actualizações documentais aceites da avaliação pela equipa,além da linhaPEC;sem nova revisão funcional do percurso proactivo.
|
||||
|
||||
**Âmbito entregue:** residente geral,ano civil2026,MZN;PEC efectivamente pago do próprio exercício,titular/data/prova/parcelas e uso anterior documentados. Dedução até à colecta disponível antes de retenções/PPC;créditos precedentes ausentes ou conhecidos zero. ExcedentePEC não gera reembolso nem saldo oficial transportado. Cálculo da obrigação,prestações,transporte/caducidade anteriores,créditos próprios positivos e imposto autónomo continuam separados. Informação em falta não vira zero;históricos não são recalculados. Reutilizadas as5recuperações e relatórios QA aceites:1 408−200−500=708 a pagar;PEC2 000 deduz1 408 e deixa592 não deduzidos;os500 a recuperar no caso comPPC provêm doPPC,sem reembolsar oPEC.
|
||||
|
||||
**Entrega:** capacidade87,16GiB e inodes suficientes antes,e novamente conferida após backup. Dump frescoSHA256`eff57769cda1e9d0f3d507348b57fc455c0bbc6e38beeb3688135109a6e219fd`,em`/var/backups/investmoz-irpc-l8-pec-20261027/backup`;restauro174tabelas com contagens/checksums iguais,contentor sem rede,porta55441.369ficheiros persistentes/configuração e172tabelas de negócio intactos;schema,papéis,grants e permissões iguais. Cache/sessões operacionais reconciliados:inclui1sessão anónima preexistente,sem mudança de identidade,com token efémero/URL anterior e IP/actividade actualizados,correlacionados individualmente comGET200de documento público pelo mesmoUA/IP/instante;nenhuma sessão sobrescrita pelo comparador. Sem migrations,importações,fixtures activas ou publicação de pilotos. Guardas do instalador mantidas;release anterior em serviço até troca atómica.1000fontes antes/1002depois conferidas comGit;delta de aplicação4ficheiros. Manifest e5marcadoresPEC servidos conferidos;10cartões dos sectores,3páginas/guias/oportunidades e filtroAgronegócio idênticos antes/depois.
|
||||
|
||||
**Provas reutilizadas:**12testesPEC+19do anual,API102asserções/5casos e relatórios aceites,sem outra ronda manual. Controlos obrigatórios do instalador aprovados:PostgreSQL1/3106,Unit59/317,frontend1092pass/0fail,TypeScript ebuild30,51s. Recibo consolidado:`docs/investmoz/simulations/irpc-l8-pec-delivery-20261027.json`;cópia remota:`/var/backups/investmoz-irpc-l8-pec-20261027/installed-receipt.json`,SHA256`a970266625807803ce73f1e63d0da1a540cff264ab88a19d3a8a387a85b26c34`. Provas locais:`outputs/irpc-l8-pec-delivery-20261027/`. Os recibosQA anteriores permanecem históricos;este PEC deixa de ser pendência de instalação.
|
||||
|
||||
### Retoma concreta — créditos próprios e saldo restante
|
||||
|
||||
O primeiro recorte para implementaçãoQA será o crédito por dupla tributação internacional do próprio exercício. Retoma desta passagem:fonte e contrato de dados/cálculo delimitados,**ainda sem novo código ou cálculo de crédito activado**. Reutilizado oCIRPC65,Lei34/2007PDF18/p768-(72),já no acervo aceite;ordem face aoPEC em66/RIRPC21. Não se exige revalidação genérica da fonte. Rendimento estrangeiro incluído na matéria colectável,imposto sobre o rendimento efectivamente pago,titular/país/exercício/prova e montante disponível devem corresponder. O crédito é limitado pela fracção nacional correspondente e,pela convenção quando aplicável;esse limite não pode ser presumido a partir do montante recebido. Exemplo sintético para provar o novo delta,**não implementado**:imposto estrangeiro10,limite nacional documentado8,ausência documentada deCDTaplicável→crédito8;colecta1 408→1 400;PEC200→1 200;PPC500→saldo700,sem retenções. Os2acima do limite não se tornam automaticamente crédito a transportar.
|
||||
|
||||
| Código ainda por implementar | Condição concreta de retoma |
|
||||
| --- | --- |
|
||||
| Qualificação,limites e dedução do crédito internacional corrente | Implementar o contrato acima,com estado conhecido/ausente/em falta,identidade da prova,ordem antes doPEC,limites e prevenção de uso duplicado comPEC/PPC/RF;demonstrar só novos efeitos,gravação/recuperação/relatório e preservação dos históricos. |
|
||||
| Crédito por dupla tributação económica e crédito de investimento/benefício | Grupos distintos;art64 e fundamentoCBFpróprio,qualificaçãoL7,titular/período,lucro/imposto/activos elegíveis,limite,cumulação e utilização documentados. Localização não concede benefício automaticamente. |
|
||||
| Transporte/utilização/caducidade dePEC e créditos anteriores | Proveniência por exercício e utilizações reais;PEC66 distinto do crédito65 e seu prazo próprio. Não confundir excesso sobre limite de elegibilidade com falta de colecta,nem criar saldos oficiais a partir de simulações. |
|
||||
| ObrigaçãoPPC/PEC,calendário,juros/multas/guias | Volume/PPC anteriores e demais factos pertinentes,edição normativa/vencimentos próprios;separado da dedução dePECjá pago agora entregue. |
|
||||
| Imposto autónomo,períodos especiais,outras moedas eM20/M22/submissão | Mantêm as dependências próprias já delimitadas;reutilizar periodização/câmbio quando a regra do caso estiver correspondida,sem compensação ou códigos oficiais presumidos. |
|
||||
|
||||
| Evidência/documento do caso em falta | Exemplo e condição concreta de retoma |
|
||||
| --- | --- |
|
||||
| Prova e inclusão do rendimento estrangeiro | Imposto10MZN sem rendimento identificado ou fracção nacional demonstrada:reutilizar dados/documentos existentes e identificar a correspondência;subtotal não resolve o saldo dependente. Não é falta de autenticação da fonte normativa. |
|
||||
| Convenção aplicável e limite | País/CDT conhecidos mas artigo,período ou imposto pago nos termos da convenção em falta:corresponder esses elementos;bloqueia apenas o caso dependente. |
|
||||
| Regulamentação2026para obrigação/calendário | Anúncio sem articulado publicado:retomar com diploma,artigos e vigência dos parâmetros afectados;sem bloquear oPECcorrente ou crédito independente cujo fundamento já está disponível. |
|
||||
|
||||
L8 permanece parcial. A avaliação real do percurso proactivo continua a aguardar retorno da equipa;dificuldades observadas serão correcções concretas. Songo eGurué permanecem privados;L3/ISPC/câmbio/L6/L7 eSGFTEMPO preservados. Sem nova estimativa global ou declaração de IRPC completo.
|
||||
|
||||
|
||||
## 27/10/2026 — Crédito internacional corrente: percurso implementado em QA
|
||||
|
||||
**Estado actual: implementado e demonstrado em QA, sem instalação.** Base `814fe0a9`, descendente do PEC instalado `e182d1d7` e da correcção dos sectores `669cb897`. Os registos anteriores de delimitação são históricos: o crédito corrente abaixo já tem código executável; os restantes grupos continuam separados. Ramo `codex/irpc-l8-international-credit-qa-20261027`. Recibo: `docs/investmoz/simulations/irpc-l8-international-credit-qa-20261027.json`.
|
||||
|
||||
**Âmbito e origem das restrições:** pedido expresso da Tempo para implementar o crédito internacional em QA, preservando o PEC e os históricos. Reutilizado CIRPC65(1–2), Lei34/2007, PDF18/p768-(72), e ordem antes do PEC em66/RIRPC21, do acervo aceite. Escolha incremental de implementação: residente geral, ano civil2026 e valores comprovados emMZN; inclusão do rendimento e fracção nacional documentadas, sem determinação automática dessa fracção, de vigência/aplicabilidade deCDT ou de conversão cambial. A selecção do país não concede crédito. A mudança de país/colecta exige reconfirmar a correspondência dos limites, conservando os valores.
|
||||
|
||||
**Percurso:** a interface permite preparar explicitamente o detalhe, reutilizando entidade/exercício/colecta e o resumo anterior quando este declara ausência ou zero; mantém esse resumo e os resultados anteriores. Uma posição por país/exercício agrega rendimentos e provas sob um só limite nacional. Regista natureza do imposto, pagamento efectivo, titular, suporte e utilização anterior real; data fora do exercício exige correspondência documental expressa, sem inferir transporte. O crédito elegível é o menor entre imposto seleccionado comprovado, fracção nacional e limiteCDT quando aplicável; desconta utilização anterior e limita a dedução à colecta. Seguem PEC, retenções ePPC existentes. Não transforma simulações históricas em utilização fiscal. Limites admitem fracção exacta; apresentação decimal não é regra de arredondamento fiscal.
|
||||
|
||||
| Caso sintético recuperado da API | Novo efeito demonstrado em MZN |
|
||||
| --- | --- |
|
||||
| Imposto estrangeiro10, limite nacional8, não aplicaçãoCDT documentada | Crédito8; 1 408−8=1 400; PEC200→1 200; PPC500→**700 a pagar, simulado**. Os2 acima do limite não são transporte. |
|
||||
| LimiteCDT documentado6 | Crédito6; saldo simulado702. Os dados de país/CDT são artificiais, sem afirmar uma convenção real. |
|
||||
| Utilização anterior comprovada3 | Elegível8, disponível5; saldo simulado703. Não somar utilizações de simulações. |
|
||||
| Crédito disponível2 000 e colecta1 408 | Deduz1 408; insuficiência592 identificada, sem transporte; PEC200 não deduzido. Os500 a recuperar provêm doPPC, sem reembolso do crédito/PEC. |
|
||||
| Ausência internacional expressa e documentada | Crédito0, saldo708; não confundir ausência com informação em falta. |
|
||||
| AplicabilidadeCDT em falta ou mesma prova usada comoPPC e imposto estrangeiro | Saldo e dedução dependentes indeterminados, com motivo; não preencher por presunção. |
|
||||
|
||||
**Provas do delta:**18testes novos e31anuais/PEC afectados,49aprovados; API privada1teste/171asserções com transacção revertida na baseQA guardada, porta55441. Sete casos porPOST/PUT/GET, recalculados após recuperação e exportados pelos relatóriosHTML e dossier existentes; histórico anterior congelado. Wayfinder `routes/actions`, TypeScript e compilação isolada aprovados. Esta passagem não inclui uma nova prova manual de utilização no browser nem uma avaliação pela equipa. Não se repetiram as suites independentes aceites. As7tabelas de registos anteriores ficaram intactas;30PDFs originais e11consumidores protegidos iguais ao instalado. Sem migrations, novas permissões ou configuração activa; nada enviado para a base do portal. Os testes usam fixtures sintéticas portáteis, sem dados comerciais ou pilotos reais.
|
||||
|
||||
**Prevenção de dupla dedução:** identidade física da prova por emitente/documento, independentemente da data; confronto entre imposto estrangeiro,RF,PPC ePEC e entre mapas do mesmo snapshot; país/entidade/exercício e montantes disponíveis coerentes. Posições repetidas do mesmo país/ano exigem consolidação, evitando repetir a quota nacional. Não existe consumo de saldos oficiais nem reconciliação global entre dossiers independentes. Valores conhecidos, ausência declarada e informação em falta permanecem distintos. Créditos económicos e benefícios positivos ou desconhecidos deixam apenas o saldo dependente indeterminado, preservando a qualificação internacional conhecida.
|
||||
|
||||
### Saldo concreto de L8 após este incremento
|
||||
|
||||
| Código por implementar | Condição de retoma |
|
||||
| --- | --- |
|
||||
| Determinação automática da fracção nacional e limites específicosCDT | Corresponder componentes da base/imposto e rendimento estrangeiro e regras específicas do caso; substituir entradas documentadas apenas quando essa correspondência estiver demonstrada. A regra corrente do menor/ordem já está implementada. |
|
||||
| Crédito económico e créditos de investimento/benefício | Aplicar art64/CBF próprio, qualificaçãoL7, base elegível, limite, cumulação e uso real; não os converter em crédito internacional. |
|
||||
| Transporte/caducidade e utilização interanual | Proveniência por exercício, utilização real e prazo próprio de65(3), distinto doPEC66; sem transformar imposto acima do limite em crédito transportável. PEC excedente/transporte continuam fora do âmbito entregue. |
|
||||
| Obrigação/calendárioPPC/PEC, autónomos, períodos especiais, outras moedas eM20/M22 | Retomar cada grupo com factos e regra de período/compensação/câmbio/campo correspondidos; reutilizar motores existentes sem alterar o cálculo independente aceite. |
|
||||
|
||||
| Informação documental externa em falta | Exemplo e condição de retoma |
|
||||
| --- | --- |
|
||||
| Inclusão e fracção nacional do caso | Imposto10 sem prova da inclusão/base: identificar o rendimento incluído e o suporte da quota; apenas o saldo desse caso fica indeterminado. Não exige nova autenticação da fonte oficial. |
|
||||
| Convenção, período e imposto elegível | País conhecido sem artigo/limite aplicável: corresponder artigo, vigência e imposto pago nos termos daCDT. O limite6 da QA não é uma correspondência oficial. |
|
||||
| Pagamento/titular/uso anterior e correspondência temporal | Pagamento em2027 afecto a2026 sem suporte: anexar/identificar correspondência expressa; sem presumir transporte ou utilização zero. |
|
||||
|
||||
**L8 permanece parcial.** Crédito internacional apenas emQA; PEC instalado em`e182d1d7` mantém o âmbito demonstrado. Songo eGurué privados; L3,ISPC,câmbio,L5–L7 eSGFTEMPO preservados. Avaliação de utilização do percurso proactivo continua a aguardar retorno da equipa. Sem instalação, publicação ou nova estimativa global nesta passagem.
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
{
|
||||
"date": "2026-10-27",
|
||||
"status": "QA demonstrated; not installed",
|
||||
"branch": "codex/irpc-l8-international-credit-qa-20261027",
|
||||
"base": "814fe0a9",
|
||||
"installed_reference": "e182d1d79dc945f35d2079c6b8ca2ac93048cec3",
|
||||
"sector_fix_preserved": "669cb8979b0c372659fc2ad3876aebc919d5df19",
|
||||
"scope": {
|
||||
"year": "2026",
|
||||
"resident": "general",
|
||||
"period": "calendar year",
|
||||
"currency": "documented MZN",
|
||||
"foreign_tax": "actual income tax paid; inclusion in taxable base documented",
|
||||
"national_fraction": "documented exact input, not automatically derived",
|
||||
"treaty": "case-specific applicability and ceiling documented, not inferred from country",
|
||||
"order": [
|
||||
"international credit limited to eligible available amount and collection",
|
||||
"PEC limited to remaining collection",
|
||||
"withholdings and PPC"
|
||||
],
|
||||
"known_absent_missing_distinct": true,
|
||||
"proof_deduplication": "issuer/document across tax natures, dates and snapshot contexts; consolidate country-year quota",
|
||||
"officialBalancesConsumed": false,
|
||||
"carryCreated": false
|
||||
},
|
||||
"sources": {
|
||||
"reuse": "accepted CIRPC65(1–2), Lei34/2007 BR52 PDF18/printed768-(72); CIRPC66/RIRPC21 order",
|
||||
"originals_preserved": 30,
|
||||
"source_preservation_artifact": "outputs/irpc-l8-international-20261027/source-preservation.json",
|
||||
"automatic_treaty_entitlement": false
|
||||
},
|
||||
"verification": {
|
||||
"frontend_new": 18,
|
||||
"frontend_annual_pec_affected": 31,
|
||||
"frontend_pass": 49,
|
||||
"frontend_fail": 0,
|
||||
"api_tests": 1,
|
||||
"api_assertions": 171,
|
||||
"api_cases": 7,
|
||||
"api_path": "POST/PUT/GET private simulation drafts; DatabaseTransactions rollback in isolated guarded PostgreSQL55441",
|
||||
"recovered_reports": "fresh recalculation of all7 API recoveries; existing HTML and dossier finance report; frozen previous result",
|
||||
"wayfinder_routes_actions": "passed --with-form",
|
||||
"typescript": "passed",
|
||||
"isolated_build": "passed",
|
||||
"new_browser_manual_proof": false,
|
||||
"team_usability_evaluation": "awaiting team return; separate"
|
||||
},
|
||||
"cases": [
|
||||
{
|
||||
"name": "payable",
|
||||
"status": "payable",
|
||||
"balance": {
|
||||
"numerator": "700",
|
||||
"denominator": "1"
|
||||
},
|
||||
"current": true,
|
||||
"history_records": 0,
|
||||
"apiRoundTrip": true,
|
||||
"dossier": true
|
||||
},
|
||||
{
|
||||
"name": "treaty",
|
||||
"status": "payable",
|
||||
"balance": {
|
||||
"numerator": "702",
|
||||
"denominator": "1"
|
||||
},
|
||||
"current": true,
|
||||
"history_records": 1,
|
||||
"apiRoundTrip": true,
|
||||
"dossier": true
|
||||
},
|
||||
{
|
||||
"name": "missing",
|
||||
"status": "indeterminate",
|
||||
"balance": null,
|
||||
"current": true,
|
||||
"history_records": 1,
|
||||
"apiRoundTrip": true,
|
||||
"dossier": true
|
||||
},
|
||||
{
|
||||
"name": "limited-collecta",
|
||||
"status": "recoverable",
|
||||
"balance": {
|
||||
"numerator": "-500",
|
||||
"denominator": "1"
|
||||
},
|
||||
"current": true,
|
||||
"history_records": 1,
|
||||
"apiRoundTrip": true,
|
||||
"dossier": true
|
||||
},
|
||||
{
|
||||
"name": "duplicate",
|
||||
"status": "indeterminate",
|
||||
"balance": null,
|
||||
"current": true,
|
||||
"history_records": 1,
|
||||
"apiRoundTrip": true,
|
||||
"dossier": true
|
||||
},
|
||||
{
|
||||
"name": "absent",
|
||||
"status": "payable",
|
||||
"balance": {
|
||||
"numerator": "708",
|
||||
"denominator": "1"
|
||||
},
|
||||
"current": true,
|
||||
"history_records": 1,
|
||||
"apiRoundTrip": true,
|
||||
"dossier": true
|
||||
},
|
||||
{
|
||||
"name": "prior-use",
|
||||
"status": "payable",
|
||||
"balance": {
|
||||
"numerator": "703",
|
||||
"denominator": "1"
|
||||
},
|
||||
"current": true,
|
||||
"history_records": 1,
|
||||
"apiRoundTrip": true,
|
||||
"dossier": true
|
||||
}
|
||||
],
|
||||
"example": {
|
||||
"foreign_tax_paid": "10 MZN",
|
||||
"documented_national_limit": "8 MZN",
|
||||
"documented_treaty_nonapplication": "synthetic only, not actual country entitlement",
|
||||
"credit": "8 MZN",
|
||||
"calculation": "1408 - 8 = 1400; - PEC200 = 1200; - PPC500 = 700 MZN simulated payable",
|
||||
"above_eligibility_limit": "2 MZN, not a carry",
|
||||
"insufficient_collection_example": "available2000, deducted1408, insufficient592; PEC200 not deducted; recoverable500 derives from PPC only"
|
||||
},
|
||||
"preservation": {
|
||||
"existing_records": {
|
||||
"database": "proactive_investment_20261027_test",
|
||||
"tables": {
|
||||
"opportunities": {
|
||||
"existing_rows": 55,
|
||||
"unchanged": true
|
||||
},
|
||||
"documents": {
|
||||
"existing_rows": 64,
|
||||
"unchanged": true
|
||||
},
|
||||
"opportunity_documents": {
|
||||
"existing_rows": 1,
|
||||
"unchanged": true
|
||||
},
|
||||
"simulation_form_drafts": {
|
||||
"existing_rows": 19,
|
||||
"unchanged": true
|
||||
},
|
||||
"users": {
|
||||
"existing_rows": 40,
|
||||
"unchanged": true
|
||||
},
|
||||
"organizations": {
|
||||
"existing_rows": 3,
|
||||
"unchanged": true
|
||||
},
|
||||
"audit_events": {
|
||||
"existing_rows": 409,
|
||||
"unchanged": true
|
||||
}
|
||||
},
|
||||
"transaction_rollback": true
|
||||
},
|
||||
"originals": 30,
|
||||
"protected_consumers_count": 11,
|
||||
"no_migrations_or_permissions_changes": true,
|
||||
"legacy_summary_and_frozen_history_preserved": true,
|
||||
"private_pilots": "Songo/Gurue unchanged and private",
|
||||
"production_written": false,
|
||||
"SGF_TEMPO": "unchanged"
|
||||
},
|
||||
"remaining_code": [
|
||||
"automatic national fraction and case-specific treaty matching",
|
||||
"economic double-tax and CBF benefit credits with own rules",
|
||||
"international carry/expiry65(3), separate from PEC66 carry/expiry",
|
||||
"PPC/PEC obligation/calendar; autonomous tax, special periods, other currencies and M20/M22 transport/submission"
|
||||
],
|
||||
"document_dependencies": [
|
||||
{
|
||||
"missing": "income inclusion and national fraction",
|
||||
"example": "tax10 but no included income/base correspondence",
|
||||
"resume_when": "income/base and documented fraction matched"
|
||||
},
|
||||
{
|
||||
"missing": "treaty article/period/ceiling",
|
||||
"example": "country selected but no applicable article or eligible tax",
|
||||
"resume_when": "case-specific article, effective period and eligible ceiling identified"
|
||||
},
|
||||
{
|
||||
"missing": "proof/titular/previous actual use/temporal link",
|
||||
"example": "payment2027 selected for2026 without correspondence",
|
||||
"resume_when": "actual payment and explicit2026 link supported, prior use reconciled"
|
||||
}
|
||||
],
|
||||
"limits": [
|
||||
"L8 partial",
|
||||
"no new PEC excess/carry scope",
|
||||
"no automatic foreign exchange or official rounding rule",
|
||||
"no official tax balance consumption, submission or refund execution",
|
||||
"same-snapshot deduplication is not a global inter-dossier official ledger",
|
||||
"synthetic QA examples do not assert any actual foreign treaty",
|
||||
"no production deployment or publication of pilots"
|
||||
],
|
||||
"local_evidence": {
|
||||
"outputs\\irpc-l8-international-20261027\\frontend-tests.log": "7f981dc819ffe0947565994c9a29a72c408eb94a9cd687dba1d1b93903949b87",
|
||||
"outputs\\irpc-l8-international-20261027\\types.log": "82962651e47f564de653ad2883f8fd34e7dae4b4468e4ac459cb3331962a3879",
|
||||
"outputs\\irpc-l8-international-20261027\\build.log": "d9a173ef26392275e42f6ef8927c2c9a79039a16c98a371e8bbcccbeea17776b",
|
||||
"outputs\\irpc-l8-international-20261027\\existing-records-preservation.json": "b45b3306d3c9dee63fbbaf9a04bba31008019e65892bd16322460b5ef53eda7d",
|
||||
"outputs\\irpc-l8-international-20261027\\source-preservation.json": "d82c68f709793103373f2110b3b55ef226fd5e6a51a6835c62425c7407bcf0bd",
|
||||
"outputs\\irpc-l8-international-20261027\\recovered-report-receipt.json": "080d61ad1e3e4a849ea8b71642fb256881aa05a9fef81144cb7cf56848383cb2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,901 @@
|
||||
{
|
||||
"date": "2026-10-27",
|
||||
"status": "installed_and_verified",
|
||||
"served_commit": "e182d1d79dc945f35d2079c6b8ca2ac93048cec3",
|
||||
"includes_accepted_qa": "7fdb6b424b70ef6462a4f88338e52e2750b9e222",
|
||||
"previous_commit": "669cb8979b0c372659fc2ad3876aebc919d5df19",
|
||||
"sector_regression_preserved": "669cb897",
|
||||
"remote_backup": "/var/backups/investmoz-irpc-l8-pec-20261027/backup",
|
||||
"remote_receipt": "/var/backups/investmoz-irpc-l8-pec-20261027/installed-receipt.json",
|
||||
"scope": {
|
||||
"subject": "resident general",
|
||||
"year": "2026",
|
||||
"period": "calendar",
|
||||
"currency": "MZN",
|
||||
"treatment": "actual documented PEC of own exercise,selected available amount after prior use,capped to valid collecta before RF/PPC",
|
||||
"preceding_credits": "absent or documented known zero;positive/missing remains indeterminate",
|
||||
"no_automatic": [
|
||||
"PEC obligation",
|
||||
"prior-year carry",
|
||||
"expiry",
|
||||
"excess PEC refund",
|
||||
"official balance consumption",
|
||||
"special positive credits",
|
||||
"declaration submission"
|
||||
]
|
||||
},
|
||||
"accepted_qa_reused": {
|
||||
"new_PEC_tests": 12,
|
||||
"affected_annual_tests": 19,
|
||||
"api_assertions": 102,
|
||||
"cases_recovered_to_HTML_and_dossier": 5,
|
||||
"runtime_files_byte_identical_to_QA": 4
|
||||
},
|
||||
"compatibility": {
|
||||
"runtime_delta": [
|
||||
"resources/js/components/simulation-irpc-annual.tsx",
|
||||
"resources/js/components/simulation-irpc-pec.tsx",
|
||||
"resources/js/lib/irpc-annual-settlement.ts",
|
||||
"resources/js/lib/irpc-pec.ts"
|
||||
],
|
||||
"runtime_PEC_identity_to_accepted_QA": true,
|
||||
"sector_code_and_tests_identity_to669cb897": true,
|
||||
"changed_matrix_ids": [
|
||||
"RF-CLU-003",
|
||||
"MASTER-9dee08d0-0067",
|
||||
"MASTER-471012ab-0010",
|
||||
"MASTER-471012ab-0067",
|
||||
"AUD-SIM-INT02"
|
||||
],
|
||||
"matrix_note": "Four accepted team-use documentation updates from PEC ancestry preserved;plus PEC AUD-SIM-INT02. Sector rows unchanged.",
|
||||
"other_records_unchanged": true,
|
||||
"schema_config_routes_unchanged": true
|
||||
},
|
||||
"runtime_delta": [
|
||||
{
|
||||
"file": "resources/js/components/simulation-irpc-annual.tsx",
|
||||
"before_sha256": "91ac4ed53ab3f05129f2173cbcf196cef2db1da080a5de5f37e0cd3c5ef74554",
|
||||
"after_sha256": "7f18abcaa1100251c5c2780fdfac32e21979d8e6ffed52f732e4a0d345ab4f40"
|
||||
},
|
||||
{
|
||||
"file": "resources/js/components/simulation-irpc-pec.tsx",
|
||||
"before_sha256": null,
|
||||
"after_sha256": "c3f0ea9ff9389cf856ecda3894c7a1486f44193eb893c341ef10c67f888a2fc6"
|
||||
},
|
||||
{
|
||||
"file": "resources/js/lib/irpc-annual-settlement.ts",
|
||||
"before_sha256": "8cca5316259e3ebabfa75be9f64143a8664a447ac30b23b882318edfd70a68f1",
|
||||
"after_sha256": "6d80889677c1904b3236b5e43fa5a3dc28327745679392529dfb5fbf5a273f7d"
|
||||
},
|
||||
{
|
||||
"file": "resources/js/lib/irpc-pec.ts",
|
||||
"before_sha256": null,
|
||||
"after_sha256": "eb40b0601b6a1a69a6e81ad210589cc8744d74c6ef65e12132de13a5fcd6a90e"
|
||||
}
|
||||
],
|
||||
"source_files_verified": {
|
||||
"before": 1000,
|
||||
"after": 1002
|
||||
},
|
||||
"installer": {
|
||||
"service": "ExecMainStatus=0\nActiveState=inactive\nSubState=dead\n",
|
||||
"installed": {
|
||||
"status": "installed",
|
||||
"commit": "e182d1d79dc945f35d2079c6b8ca2ac93048cec3",
|
||||
"release": "/var/www/investmoz-homologacao/releases/e182d1d79dc945f35d2079c6b8ca2ac93048cec3-e2a185b3",
|
||||
"previous_release": "/var/www/investmoz-homologacao/releases/669cb8979b0c372659fc2ad3876aebc919d5df19-6a2f00c6",
|
||||
"database_migrations": 0,
|
||||
"content_imports": 0
|
||||
},
|
||||
"latest_report": {
|
||||
"status": "installed",
|
||||
"commit": "e182d1d79dc945f35d2079c6b8ca2ac93048cec3",
|
||||
"release": "/var/www/investmoz-homologacao/releases/e182d1d79dc945f35d2079c6b8ca2ac93048cec3-e2a185b3",
|
||||
"previous_release": "/var/www/investmoz-homologacao/releases/669cb8979b0c372659fc2ad3876aebc919d5df19-6a2f00c6",
|
||||
"database_migrations": 0,
|
||||
"content_imports": 0,
|
||||
"requested_commits": [
|
||||
"e182d1d79dc945f35d2079c6b8ca2ac93048cec3"
|
||||
],
|
||||
"finished_at": "2026-10-27T12:10:22.122557+00:00"
|
||||
},
|
||||
"log_file": "1793102808310738327.log",
|
||||
"summaries": [
|
||||
"OK (1 test, 3106 assertions)",
|
||||
"built in 30.51s",
|
||||
"OK (59 tests, 317 assertions)",
|
||||
"# tests 1092",
|
||||
"# pass 1092",
|
||||
"# fail 0"
|
||||
],
|
||||
"log_bytes": 308894
|
||||
},
|
||||
"backup": {
|
||||
"stage": "/var/backups/investmoz-irpc-l8-pec-20261027/backup",
|
||||
"created_at": "2026-10-27T12:05:00Z",
|
||||
"target": {
|
||||
"database": "teste_investidor",
|
||||
"port": 5432
|
||||
},
|
||||
"tables": 174,
|
||||
"files_verified": 369,
|
||||
"dump_sha256": "eff57769cda1e9d0f3d507348b57fc455c0bbc6e38beeb3688135109a6e219fd",
|
||||
"files_sha256": "7830fd2f7671405777d7e5001edade7d5b08b1ebc1f86defb4bf3ec62a10446e",
|
||||
"restore_verified": false
|
||||
},
|
||||
"restore": {
|
||||
"restore_verified": true,
|
||||
"tables_verified": 174,
|
||||
"container_network": "none",
|
||||
"database": "irpc_pec_restore_20261027",
|
||||
"port": 55441,
|
||||
"source_dump_sha256": "eff57769cda1e9d0f3d507348b57fc455c0bbc6e38beeb3688135109a6e219fd",
|
||||
"active_database_writes": 0
|
||||
},
|
||||
"capacity_after_backup": {
|
||||
"at": "2026-10-27T12:06:10.511691+00:00",
|
||||
"baseline": "669cb8979b0c372659fc2ad3876aebc919d5df19",
|
||||
"capacity_after_backup_satisfied": true,
|
||||
"volumes": [
|
||||
{
|
||||
"path": "/var/www/investmoz-homologacao/releases",
|
||||
"free_bytes": 93404454912,
|
||||
"free_inodes": 23730955
|
||||
},
|
||||
{
|
||||
"path": "/var/lib/investmoz-deploy",
|
||||
"free_bytes": 93404454912,
|
||||
"free_inodes": 23730955
|
||||
},
|
||||
{
|
||||
"path": "/var/backups",
|
||||
"free_bytes": 93404454912,
|
||||
"free_inodes": 23730955
|
||||
},
|
||||
{
|
||||
"path": "/tmp",
|
||||
"free_bytes": 93404454912,
|
||||
"free_inodes": 23730955
|
||||
},
|
||||
{
|
||||
"path": "/var/lib/docker",
|
||||
"free_bytes": 93404454912,
|
||||
"free_inodes": 23730955
|
||||
}
|
||||
],
|
||||
"backup_age_seconds": 70.511645,
|
||||
"backup_dump_sha256": "eff57769cda1e9d0f3d507348b57fc455c0bbc6e38beeb3688135109a6e219fd",
|
||||
"restore_verified": true,
|
||||
"tables_verified": 174,
|
||||
"files_verified": 369,
|
||||
"backup_paths": {
|
||||
"dump": "/var/backups/investmoz-irpc-l8-pec-20261027/backup/database.dump",
|
||||
"files": "/var/backups/investmoz-irpc-l8-pec-20261027/backup/files-before.tar.gz"
|
||||
},
|
||||
"active_writes": 0
|
||||
},
|
||||
"schema_permissions": {
|
||||
"schema_sha256": "5045b3e51d2185377aa3d9ac7fa07a44fad3ec620cdfa83ffe31c8884ee1601d",
|
||||
"roles_grants_sha256": "1530c33cb016e67bfdc64891ddfce7f185b13b56b2cd87c012871a685e118109",
|
||||
"filesystem_permissions": {
|
||||
".env": {
|
||||
"mode": 416,
|
||||
"uid": 1001,
|
||||
"gid": 33
|
||||
},
|
||||
"storage": {
|
||||
"mode": 1533,
|
||||
"uid": 1001,
|
||||
"gid": 33
|
||||
},
|
||||
"storage/app": {
|
||||
"mode": 1533,
|
||||
"uid": 1001,
|
||||
"gid": 33
|
||||
},
|
||||
"bootstrap/cache": {
|
||||
"mode": 1528,
|
||||
"uid": 1001,
|
||||
"gid": 33
|
||||
}
|
||||
},
|
||||
"comparison_identity": "postgres;catalogue read only;no passwords collected",
|
||||
"unchanged": true
|
||||
},
|
||||
"preservation": {
|
||||
"checked_at": "2026-10-27T12:11:58.610510+00:00",
|
||||
"installed": "e182d1d79dc945f35d2079c6b8ca2ac93048cec3",
|
||||
"business_tables_unchanged": 172,
|
||||
"total_tables": 174,
|
||||
"operational_tables_to_reconcile": {
|
||||
"cache": {
|
||||
"before": {
|
||||
"rows": 108,
|
||||
"checksum": "8ad8adb3b4cee975cebcb15806c60af5"
|
||||
},
|
||||
"after": {
|
||||
"rows": 108,
|
||||
"checksum": "5079060f1cdc89bf00b1bb3abdc2ff40"
|
||||
}
|
||||
},
|
||||
"sessions": {
|
||||
"before": {
|
||||
"rows": 41,
|
||||
"checksum": "738960921c69e7c0272c0fdac68ce33b"
|
||||
},
|
||||
"after": {
|
||||
"rows": 53,
|
||||
"checksum": "7a5824a4f4e5bbe8b9d745a975aad665"
|
||||
}
|
||||
}
|
||||
},
|
||||
"persistent_files_unchanged": 369,
|
||||
"original_configuration_preserved": true,
|
||||
"synthetic_QA_storage_not_served": true,
|
||||
"QA_storage_saved_outside_active": "/var/lib/investmoz-deploy/qa-runtime/e182d1d79dc945f35d2079c6b8ca2ac93048cec3-e2a185b3",
|
||||
"fixture_or_content_imports": 0,
|
||||
"migrations": 0,
|
||||
"comparison_identity": "postgres;UTC;consistent before snapshot and after read-only transaction",
|
||||
"active_database_writes": 0
|
||||
},
|
||||
"operational_delta": {
|
||||
"status": "operational_delta_reconciled",
|
||||
"comparison_identity": "postgres before/after;isolated restored baseline;no RLS visibility inference",
|
||||
"cache": "queue:restart;requestthrottle;identical home-sector cached value with refreshed expiry(HomeController remember10min);no deletedcache",
|
||||
"sessions": "Anonymous delivery sessions or individually correlated public requests;one existing anonymous session had only token/previous-URL changes in payload and IP/activity metadata,with exact UA/IP/time/HTTP200 document request proof;no identity or other payload change. Deleted sessions,if any,individually expired. No session overwritten.",
|
||||
"delta": {
|
||||
"cache": {
|
||||
"before_rows": 108,
|
||||
"after_rows": 108,
|
||||
"changes": [
|
||||
{
|
||||
"key_sha256": "7f7dd83f47f5bf404d55e6e9f1367948721579970b195680645e356031a070ff",
|
||||
"kind": "updated",
|
||||
"fields": [
|
||||
"value",
|
||||
"expiration"
|
||||
],
|
||||
"key_pattern": "investemoz-cache-illuminate:queue:restart",
|
||||
"is_queue_restart_key": true,
|
||||
"expiration_unchanged": false,
|
||||
"throttle_timer_pair": false,
|
||||
"same_value_home_cache_expiry_refresh": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"sessions": {
|
||||
"before_rows": 41,
|
||||
"after_rows": 59,
|
||||
"changes": [
|
||||
{
|
||||
"key_sha256": "4e78c6a57b8f1771f6b334d7dd2697275c222d72620007b8e86e3f049427a8b3",
|
||||
"kind": "added",
|
||||
"fields": [
|
||||
"id",
|
||||
"ip_address",
|
||||
"user_agent",
|
||||
"payload",
|
||||
"last_activity"
|
||||
],
|
||||
"anonymous_user": true,
|
||||
"delivery_user_agent": true,
|
||||
"expired_before_comparison": false,
|
||||
"session_lifetime_minutes": 120,
|
||||
"anonymous_public_request_logged": true
|
||||
},
|
||||
{
|
||||
"key_sha256": "f4fa6adfd3d6918ec9e7de8022a61c9cffe66f75800cf521c12aeb98bc3f062f",
|
||||
"kind": "added",
|
||||
"fields": [
|
||||
"id",
|
||||
"ip_address",
|
||||
"user_agent",
|
||||
"payload",
|
||||
"last_activity"
|
||||
],
|
||||
"anonymous_user": true,
|
||||
"delivery_user_agent": true,
|
||||
"expired_before_comparison": false,
|
||||
"session_lifetime_minutes": 120,
|
||||
"anonymous_public_request_logged": true
|
||||
},
|
||||
{
|
||||
"key_sha256": "af76f65ffd28dfed5e35dd2111184a06a4e974608cbd2cc07314dae0dfc09a7f",
|
||||
"kind": "added",
|
||||
"fields": [
|
||||
"id",
|
||||
"ip_address",
|
||||
"user_agent",
|
||||
"payload",
|
||||
"last_activity"
|
||||
],
|
||||
"anonymous_user": true,
|
||||
"delivery_user_agent": true,
|
||||
"expired_before_comparison": false,
|
||||
"session_lifetime_minutes": 120,
|
||||
"anonymous_public_request_logged": true
|
||||
},
|
||||
{
|
||||
"key_sha256": "a23c33b4c0cc464b1d78f36f59fb3e63b12a476983d19692f3cc003a629f7f52",
|
||||
"kind": "added",
|
||||
"fields": [
|
||||
"id",
|
||||
"ip_address",
|
||||
"user_agent",
|
||||
"payload",
|
||||
"last_activity"
|
||||
],
|
||||
"anonymous_user": true,
|
||||
"delivery_user_agent": true,
|
||||
"expired_before_comparison": false,
|
||||
"session_lifetime_minutes": 120,
|
||||
"anonymous_public_request_logged": true
|
||||
},
|
||||
{
|
||||
"key_sha256": "1b9d5c268f04935e5c4daebefd1edfc1ef88c6581d7c5ebb7034b9790a37ec87",
|
||||
"kind": "added",
|
||||
"fields": [
|
||||
"id",
|
||||
"ip_address",
|
||||
"user_agent",
|
||||
"payload",
|
||||
"last_activity"
|
||||
],
|
||||
"anonymous_user": true,
|
||||
"delivery_user_agent": true,
|
||||
"expired_before_comparison": false,
|
||||
"session_lifetime_minutes": 120,
|
||||
"anonymous_public_request_logged": true
|
||||
},
|
||||
{
|
||||
"key_sha256": "805dd129ffaa6ef2e03fff399836bc1945ddee46e714fb0ab8b6ffbf62305a3b",
|
||||
"kind": "added",
|
||||
"fields": [
|
||||
"id",
|
||||
"ip_address",
|
||||
"user_agent",
|
||||
"payload",
|
||||
"last_activity"
|
||||
],
|
||||
"anonymous_user": true,
|
||||
"delivery_user_agent": true,
|
||||
"expired_before_comparison": false,
|
||||
"session_lifetime_minutes": 120,
|
||||
"anonymous_public_request_logged": true
|
||||
},
|
||||
{
|
||||
"key_sha256": "d5c7afdfe907c762e30c9036fa3821a2b6ba10eab06a87db9adfbb6e3c51c0dc",
|
||||
"kind": "added",
|
||||
"fields": [
|
||||
"id",
|
||||
"ip_address",
|
||||
"user_agent",
|
||||
"payload",
|
||||
"last_activity"
|
||||
],
|
||||
"anonymous_user": true,
|
||||
"delivery_user_agent": true,
|
||||
"expired_before_comparison": false,
|
||||
"session_lifetime_minutes": 120,
|
||||
"anonymous_public_request_logged": true
|
||||
},
|
||||
{
|
||||
"key_sha256": "4ed17597603a4ea407a9a48740ea36ae8831e484a18a6cac9fb8fd29e17d2bcd",
|
||||
"kind": "added",
|
||||
"fields": [
|
||||
"id",
|
||||
"ip_address",
|
||||
"user_agent",
|
||||
"payload",
|
||||
"last_activity"
|
||||
],
|
||||
"anonymous_user": true,
|
||||
"delivery_user_agent": true,
|
||||
"expired_before_comparison": false,
|
||||
"session_lifetime_minutes": 120,
|
||||
"anonymous_public_request_logged": true
|
||||
},
|
||||
{
|
||||
"key_sha256": "9d33a9812dcec08990f3f5e525f1d2045a0178e55c52b01e6b766c18db970909",
|
||||
"kind": "added",
|
||||
"fields": [
|
||||
"id",
|
||||
"ip_address",
|
||||
"user_agent",
|
||||
"payload",
|
||||
"last_activity"
|
||||
],
|
||||
"anonymous_user": true,
|
||||
"delivery_user_agent": true,
|
||||
"expired_before_comparison": false,
|
||||
"session_lifetime_minutes": 120,
|
||||
"anonymous_public_request_logged": true
|
||||
},
|
||||
{
|
||||
"key_sha256": "38f6c88aecd61073863027dedbdfea596cddfd088ce26bc181461381d790263d",
|
||||
"kind": "added",
|
||||
"fields": [
|
||||
"id",
|
||||
"ip_address",
|
||||
"user_agent",
|
||||
"payload",
|
||||
"last_activity"
|
||||
],
|
||||
"anonymous_user": true,
|
||||
"delivery_user_agent": true,
|
||||
"expired_before_comparison": false,
|
||||
"session_lifetime_minutes": 120,
|
||||
"anonymous_public_request_logged": true
|
||||
},
|
||||
{
|
||||
"key_sha256": "6590dfcbfa25d90e3cf00b5f3ed65ebe0385c1fdb8bbd4cfefee45775f3fb394",
|
||||
"kind": "added",
|
||||
"fields": [
|
||||
"id",
|
||||
"ip_address",
|
||||
"user_agent",
|
||||
"payload",
|
||||
"last_activity"
|
||||
],
|
||||
"anonymous_user": true,
|
||||
"delivery_user_agent": true,
|
||||
"expired_before_comparison": false,
|
||||
"session_lifetime_minutes": 120,
|
||||
"anonymous_public_request_logged": true
|
||||
},
|
||||
{
|
||||
"key_sha256": "82c72ffd5859310ca5d1ab4781d1c297e69f32808382491eb5dbae4739560a08",
|
||||
"kind": "added",
|
||||
"fields": [
|
||||
"id",
|
||||
"ip_address",
|
||||
"user_agent",
|
||||
"payload",
|
||||
"last_activity"
|
||||
],
|
||||
"anonymous_user": true,
|
||||
"delivery_user_agent": true,
|
||||
"expired_before_comparison": false,
|
||||
"session_lifetime_minutes": 120,
|
||||
"anonymous_public_request_logged": true
|
||||
},
|
||||
{
|
||||
"key_sha256": "301015a1771a6e3142105fe8267d63716d480bf2012c62f5ee1b21e5d9018cba",
|
||||
"kind": "added",
|
||||
"fields": [
|
||||
"id",
|
||||
"ip_address",
|
||||
"user_agent",
|
||||
"payload",
|
||||
"last_activity"
|
||||
],
|
||||
"anonymous_user": true,
|
||||
"delivery_user_agent": true,
|
||||
"expired_before_comparison": false,
|
||||
"session_lifetime_minutes": 120,
|
||||
"anonymous_public_request_logged": true
|
||||
},
|
||||
{
|
||||
"key_sha256": "4c3537f85bb2c588fb86f5f832f08bfafcae211c951b2b65709cb63813cc2dae",
|
||||
"kind": "updated",
|
||||
"fields": [
|
||||
"ip_address",
|
||||
"payload",
|
||||
"last_activity"
|
||||
],
|
||||
"anonymous_user": true,
|
||||
"delivery_user_agent": false,
|
||||
"expired_before_comparison": false,
|
||||
"session_lifetime_minutes": 120,
|
||||
"anonymous_public_request_logged": true,
|
||||
"payload_diagnostic": {
|
||||
"changed_keys": [
|
||||
"_token",
|
||||
"_previous"
|
||||
],
|
||||
"token_shapes_valid": true,
|
||||
"token_unchanged": false,
|
||||
"before_previous_path": "/sectores/bens-de-consumo-e-franquias",
|
||||
"after_previous_path": "/documentos/27/view"
|
||||
},
|
||||
"public_navigation_log_matches": true,
|
||||
"current_ip_matches_public_request": true,
|
||||
"both_anonymous": true
|
||||
},
|
||||
{
|
||||
"key_sha256": "58f135bb096ab4309792562b7cef59cd64eef92cb22baf5a1fbbf3a1410106b9",
|
||||
"kind": "added",
|
||||
"fields": [
|
||||
"id",
|
||||
"ip_address",
|
||||
"user_agent",
|
||||
"payload",
|
||||
"last_activity"
|
||||
],
|
||||
"anonymous_user": true,
|
||||
"delivery_user_agent": true,
|
||||
"expired_before_comparison": false,
|
||||
"session_lifetime_minutes": 120,
|
||||
"anonymous_public_request_logged": true
|
||||
},
|
||||
{
|
||||
"key_sha256": "312f863d14b15caadb4c8d69bfe56af46cc3046f6443a540de9f4fae4bddb9c7",
|
||||
"kind": "added",
|
||||
"fields": [
|
||||
"id",
|
||||
"ip_address",
|
||||
"user_agent",
|
||||
"payload",
|
||||
"last_activity"
|
||||
],
|
||||
"anonymous_user": true,
|
||||
"delivery_user_agent": true,
|
||||
"expired_before_comparison": false,
|
||||
"session_lifetime_minutes": 120,
|
||||
"anonymous_public_request_logged": true
|
||||
},
|
||||
{
|
||||
"key_sha256": "f7c9c5ef85f5adbe12adba07b05275d5405cdab6b01cee0a97344939f12d6ee0",
|
||||
"kind": "added",
|
||||
"fields": [
|
||||
"id",
|
||||
"ip_address",
|
||||
"user_agent",
|
||||
"payload",
|
||||
"last_activity"
|
||||
],
|
||||
"anonymous_user": true,
|
||||
"delivery_user_agent": true,
|
||||
"expired_before_comparison": false,
|
||||
"session_lifetime_minutes": 120,
|
||||
"anonymous_public_request_logged": true
|
||||
},
|
||||
{
|
||||
"key_sha256": "e34c74bd2b7e86dfb654e2b65ff97a60b146925ca76169866b31fa4954398bbf",
|
||||
"kind": "added",
|
||||
"fields": [
|
||||
"id",
|
||||
"ip_address",
|
||||
"user_agent",
|
||||
"payload",
|
||||
"last_activity"
|
||||
],
|
||||
"anonymous_user": true,
|
||||
"delivery_user_agent": true,
|
||||
"expired_before_comparison": false,
|
||||
"session_lifetime_minutes": 120,
|
||||
"anonymous_public_request_logged": true
|
||||
},
|
||||
{
|
||||
"key_sha256": "63d475bd758e4fd66f1e23c5bf5424e572c1e5ce2cb4ea533261ce0858040e6a",
|
||||
"kind": "added",
|
||||
"fields": [
|
||||
"id",
|
||||
"ip_address",
|
||||
"user_agent",
|
||||
"payload",
|
||||
"last_activity"
|
||||
],
|
||||
"anonymous_user": true,
|
||||
"delivery_user_agent": true,
|
||||
"expired_before_comparison": false,
|
||||
"session_lifetime_minutes": 120,
|
||||
"anonymous_public_request_logged": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"business_tables_to_confirm_separately": 172,
|
||||
"active_data_writes_by_comparison": 0,
|
||||
"restore_network": "none"
|
||||
},
|
||||
"public_delta": {
|
||||
"revision": {
|
||||
"commit": "e182d1d79dc945f35d2079c6b8ca2ac93048cec3",
|
||||
"branch": "main",
|
||||
"built_at": "2026-10-27T12:10:18.923517+00:00",
|
||||
"manifest_sha256": "47bbdd09864d0587133deec179781018e439f9c83b7b328c9dcd52482eaf6d31"
|
||||
},
|
||||
"manifest_verified": true,
|
||||
"pec_compiled_markers": {
|
||||
"IRPC-PEC/1": [
|
||||
"assets/project-dossier-D001tZjC.js"
|
||||
],
|
||||
"Preparar detalhe PEC": [
|
||||
"assets/services-I_s1lj16.js"
|
||||
],
|
||||
"Registar comprovativo PEC": [
|
||||
"assets/services-I_s1lj16.js"
|
||||
],
|
||||
"Não calcula a obrigação PEC": [
|
||||
"assets/project-dossier-D001tZjC.js"
|
||||
],
|
||||
"Excedente sem reembolso PEC": [
|
||||
"assets/project-dossier-D001tZjC.js"
|
||||
]
|
||||
},
|
||||
"sector_cards_unchanged": 10,
|
||||
"three_selected_sector_pages_and_guides_unchanged": true,
|
||||
"sector_index_still_without_aggregated_details": true,
|
||||
"filter_preserved": "agronegocio",
|
||||
"active_QA_records_created": false
|
||||
},
|
||||
"l8_remainder_and_credit_resumption": {
|
||||
"scope": "L8 partial after bounded current-year PEC delivery",
|
||||
"next_increment": {
|
||||
"name": "Own-exercise international double-tax credit",
|
||||
"status": "delimited for QA implementation; not yet implemented",
|
||||
"source": "Accepted CIRPC art65,Lei34/2007,PDF18/printed768-(72);order relative to PEC in art66 and RIRPC21",
|
||||
"reuse": [
|
||||
"entity and exercise",
|
||||
"valid L6/L7 collecta",
|
||||
"annual withholding/PPC/PEC book and frozen histories",
|
||||
"existing documents and source references",
|
||||
"existing currency records when an applicable conversion is documented"
|
||||
],
|
||||
"required_case_facts": [
|
||||
"foreign-source income included in the taxable base",
|
||||
"actual foreign income tax, not projected withholding/remittance",
|
||||
"subject, country, exercise, document and available unused amount",
|
||||
"documented domestic IRPC fraction for that foreign income",
|
||||
"known convention applicability and its limit if applicable",
|
||||
"known state of preceding credit groups; no missing-as-zero"
|
||||
],
|
||||
"calculation_contract": "Eligible current credit limited by proven foreign tax and corresponding domestic IRPC fraction, and treaty limit when applicable;then residual collecta for PEC before RF/PPC. No automatic carry/refund/official balance consumption.",
|
||||
"illustrative_case": {
|
||||
"synthetic": true,
|
||||
"foreign_tax": 10,
|
||||
"domestic_limit_documented": 8,
|
||||
"convention_not_applicable_documented": true,
|
||||
"eligible_credit": 8,
|
||||
"collecta": 1408,
|
||||
"after_credit": 1400,
|
||||
"pec": 200,
|
||||
"after_pec": 1200,
|
||||
"withholdings": 0,
|
||||
"ppc": 500,
|
||||
"simulated_payable": 700,
|
||||
"implemented": false,
|
||||
"unutilized_above_limit": "2 is not automatically a carry credit"
|
||||
},
|
||||
"delta_acceptance": [
|
||||
"known/absent/missing and qualification",
|
||||
"country/subject/year and physical proof identity",
|
||||
"no double use across credit/PEC/PPC/RF in the same snapshot",
|
||||
"credit before PEC;separate amounts and limits",
|
||||
"frozen history;save/recover/report",
|
||||
"indeterminate dependent annual balance when facts or preceding credits are missing"
|
||||
]
|
||||
},
|
||||
"remaining_code": [
|
||||
{
|
||||
"item": "international credit eligibility,limits and own-year deduction",
|
||||
"condition": "Implement the documented input contract and demonstrate only new totals and persistence."
|
||||
},
|
||||
{
|
||||
"item": "economic double-tax credit",
|
||||
"condition": "Art64 own conditions,profit inclusion and corresponding tax evidence;separate from international credit."
|
||||
},
|
||||
{
|
||||
"item": "investment/benefit credit",
|
||||
"condition": "Reuse L7 qualification and specific CBF period,amount,limit and accumulation;location alone never grants credit."
|
||||
},
|
||||
{
|
||||
"item": "prior-year PEC/credit transport,usage and expiry",
|
||||
"condition": "Implement provenance by year and actual prior use;distinguish PEC art66 from credit art65;do not equate excess above eligibility limit with lack of collecta."
|
||||
},
|
||||
{
|
||||
"item": "PPC/PEC obligation,instalments,interest and guides",
|
||||
"condition": "Specific facts and applicable rule/edition;actual paid PEC deduction already delivered is separate."
|
||||
},
|
||||
{
|
||||
"item": "autonomous tax,special periods,non-MZN,M20/M22 transport and submission",
|
||||
"condition": "Keep existing separate dependencies;no silent offset or provisional official fields."
|
||||
}
|
||||
],
|
||||
"documentary_dependencies": [
|
||||
{
|
||||
"item": "actual case evidence",
|
||||
"example": "10 MZN foreign tax with no proof of income inclusion or domestic limit",
|
||||
"resume_when": "Identify the existing evidence and amount;no generic revalidation of accepted sources."
|
||||
},
|
||||
{
|
||||
"item": "international convention",
|
||||
"example": "Treaty applies but the article/ceiling and foreign tax paid under it are unknown",
|
||||
"resume_when": "Exact country,convention,article,period and limit;block only dependent case."
|
||||
},
|
||||
{
|
||||
"item": "2026 regulatory amendment for obligation/calendars",
|
||||
"example": "Announcement without published operative articles",
|
||||
"resume_when": "Published diploma,changed articles and effective date for affected obligation/calendar only."
|
||||
}
|
||||
],
|
||||
"private_pilots": "Songo/Gurue remain private",
|
||||
"team_evaluation": "Await actual feedback;do not repeat accepted technical tests."
|
||||
},
|
||||
"private_pilots": "Songo/Gurue private;no publication,fixtures or content import",
|
||||
"team_use_evaluation": "Await actual feedback;accepted technical proofs retained",
|
||||
"artifacts": [
|
||||
{
|
||||
"file": "after.json",
|
||||
"sha256": "0a156acdc9665995f99553a8ffba04e0515ee7250e5266b1115c10d641d0bef7",
|
||||
"bytes": 235814
|
||||
},
|
||||
{
|
||||
"file": "backup.py",
|
||||
"sha256": "6342cf198110b4e5adbc8f3de524667cf30cb0779b3a5208fd2d4d85cb7ae6cc",
|
||||
"bytes": 5440
|
||||
},
|
||||
{
|
||||
"file": "backup.txt",
|
||||
"sha256": "c57f4716111352a2560ebbfd03e2fc9c24745d88067ed78dd15e83b6a108c7a7",
|
||||
"bytes": 810
|
||||
},
|
||||
{
|
||||
"file": "before.json",
|
||||
"sha256": "d50f7e56cdc84aa9ebcf690a6f2614cc81b6a2268fe61da01ba3e6c8ed7a887f",
|
||||
"bytes": 235815
|
||||
},
|
||||
{
|
||||
"file": "capacity-after.py",
|
||||
"sha256": "5fc773a1f74a3f6028c2d190c452c8d58f8b4a2f56afc508c61002d4eb892371",
|
||||
"bytes": 1610
|
||||
},
|
||||
{
|
||||
"file": "capacity-after.txt",
|
||||
"sha256": "9ee2aef5d44b3fb142e0af17e6992de052bfa9e987ffbfd39ea174aca5300af8",
|
||||
"bytes": 983
|
||||
},
|
||||
{
|
||||
"file": "compatibility.json",
|
||||
"sha256": "a9579d644b1dbd4cce1acca10374addeca11971604c5f1a4b87bcde4aac98310",
|
||||
"bytes": 715
|
||||
},
|
||||
{
|
||||
"file": "diagnose-session-delta.py",
|
||||
"sha256": "b6c0ca60258b920333e124d89252fd740587eb6081d2f965c97c13c44297941d",
|
||||
"bytes": 7385
|
||||
},
|
||||
{
|
||||
"file": "inspect.py",
|
||||
"sha256": "7c95ba88a9d5a62a15ec2bf581fa62f5151e548014d106f081487889e56b2703",
|
||||
"bytes": 1947
|
||||
},
|
||||
{
|
||||
"file": "inspect.txt",
|
||||
"sha256": "e3aa850ab8f75765fba2f18777223ea217139768a5fe3b151542462fb576e3fc",
|
||||
"bytes": 4930
|
||||
},
|
||||
{
|
||||
"file": "integrated.json",
|
||||
"sha256": "e81548bd610d293a4919c3727128681edec70badb26209d372c6cc1079cd8c76",
|
||||
"bytes": 281
|
||||
},
|
||||
{
|
||||
"file": "l8-remaining-and-credit-resumption.json",
|
||||
"sha256": "9f04414ad329af20a3f6026152477457481a8ea248367a7c2c21e6a7451df667",
|
||||
"bytes": 4496
|
||||
},
|
||||
{
|
||||
"file": "operational-delta.txt",
|
||||
"sha256": "fe6e21047fe47803c9f5040e296bc78137b9ef3c564bd3edc4005e4894c3d4b8",
|
||||
"bytes": 15960
|
||||
},
|
||||
{
|
||||
"file": "preflight.py",
|
||||
"sha256": "16c4a12ffa9766cf1350351c91c0c935776ed36fc9e214cd864d22d0941bcb42",
|
||||
"bytes": 2334
|
||||
},
|
||||
{
|
||||
"file": "preflight.txt",
|
||||
"sha256": "8d2b03d441da3f46ec268fb9b9274e41cf5ac88ae81af3284f64f1d143db316d",
|
||||
"bytes": 4446
|
||||
},
|
||||
{
|
||||
"file": "preparation.json",
|
||||
"sha256": "933e276820b297a268264a47c909fd7f8b82b2ae95d0b0b657be19fb1458b13f",
|
||||
"bytes": 245902
|
||||
},
|
||||
{
|
||||
"file": "preservation.txt",
|
||||
"sha256": "80d56892cc29aee66b012fbce808e685b409fb04ea8587c2b535a18b7e49457a",
|
||||
"bytes": 945
|
||||
},
|
||||
{
|
||||
"file": "preserve-data.py",
|
||||
"sha256": "9f0c3097467fe171508e741fa1e360df7747aab15f2feb1465adaf38520e69c3",
|
||||
"bytes": 2288
|
||||
},
|
||||
{
|
||||
"file": "public-after.json",
|
||||
"sha256": "5e9f81a2b5430e944ccb9c6cbc6a8df5e1f448d6d8e296b7bb282524972bbb49",
|
||||
"bytes": 43379
|
||||
},
|
||||
{
|
||||
"file": "public-before.json",
|
||||
"sha256": "07717e8041b44bc3b39f6e2f3f3eb78a9cf8349d88bb097faa9b41e088038f80",
|
||||
"bytes": 42785
|
||||
},
|
||||
{
|
||||
"file": "reconcile-operational-delta.py",
|
||||
"sha256": "7f85064f6d733024f4233c2fd2de05504297f033db37d70c1d7fd9a068f2fd89",
|
||||
"bytes": 8276
|
||||
},
|
||||
{
|
||||
"file": "restore.py",
|
||||
"sha256": "8a2e85c85dcf37bc1169f42d4f4164421e914ba06b8630875a68a2b122b16714",
|
||||
"bytes": 2768
|
||||
},
|
||||
{
|
||||
"file": "restore.txt",
|
||||
"sha256": "21a4b64404a16d341014e310beba4a8f802ed0dea140d6c85e474d7fbe4b6277",
|
||||
"bytes": 536
|
||||
},
|
||||
{
|
||||
"file": "schema-after.txt",
|
||||
"sha256": "d5855a7a0a16c1762cce140750c3b8c984e9ea61817bdf02e684cc9ae1c01592",
|
||||
"bytes": 526
|
||||
},
|
||||
{
|
||||
"file": "schema-before.txt",
|
||||
"sha256": "64e445bb8d8546aa399a151adbfe53a64383ea23380f77991d3ddf11721c7127",
|
||||
"bytes": 507
|
||||
},
|
||||
{
|
||||
"file": "schema-permissions-after.py",
|
||||
"sha256": "03b3eafc23c7598fa90bfbcb3e8fb6ee76e5404f3594a69206661538ab9d2a1d",
|
||||
"bytes": 1858
|
||||
},
|
||||
{
|
||||
"file": "schema-permissions-before.py",
|
||||
"sha256": "bc720ff8d3c0814f8a55a5808efd1481da111b75d538e79a3fa15d4ffc2ca74e",
|
||||
"bytes": 1701
|
||||
},
|
||||
{
|
||||
"file": "session-diagnostic.txt",
|
||||
"sha256": "b6d3e7871b1c20153dce3e3182b5a618c1172725bf3be4d4c45b978c10e472ee",
|
||||
"bytes": 1384
|
||||
},
|
||||
{
|
||||
"file": "source-after.txt",
|
||||
"sha256": "756651eb3db81a1e50ee369a62d05d6cfc86e36878194cc509324dcffdda9ad8",
|
||||
"bytes": 160
|
||||
},
|
||||
{
|
||||
"file": "source-before.txt",
|
||||
"sha256": "1a349bee2c2aff9ad38ede72205dc6a1ececea89148e0d67eab126fde5945dd2",
|
||||
"bytes": 161
|
||||
},
|
||||
{
|
||||
"file": "source-check.py",
|
||||
"sha256": "2ea95b35eb8c2eb950216ab77e2a3127b2400372e5034179953edae058b0eb84",
|
||||
"bytes": 669
|
||||
},
|
||||
{
|
||||
"file": "status-a1.txt",
|
||||
"sha256": "f6f22631054fa0920a3c897db7bc6e3a00bce5420e4893f08125bd103dc5fb8f",
|
||||
"bytes": 2244
|
||||
},
|
||||
{
|
||||
"file": "status-a2.txt",
|
||||
"sha256": "6711c9d6d9f93625851c4e161d4bd56997a77626d1df045020fce30e34fd31cf",
|
||||
"bytes": 2162
|
||||
},
|
||||
{
|
||||
"file": "status-a3.txt",
|
||||
"sha256": "6711c9d6d9f93625851c4e161d4bd56997a77626d1df045020fce30e34fd31cf",
|
||||
"bytes": 2162
|
||||
},
|
||||
{
|
||||
"file": "status-a4.txt",
|
||||
"sha256": "d45f8c746654e183e058066ae494ddbe65dd60c157f0e8ba349e256df8758a0a",
|
||||
"bytes": 2244
|
||||
},
|
||||
{
|
||||
"file": "verify-public.py",
|
||||
"sha256": "c5a7535398e0c8ad79458178bd835fa68812b540363495af6abbb38ad2cdd87d",
|
||||
"bytes": 3349
|
||||
}
|
||||
],
|
||||
"remote_receipt_sha256": "a970266625807803ce73f1e63d0da1a540cff264ab88a19d3a8a387a85b26c34"
|
||||
}
|
||||
@@ -199,3 +199,8 @@ Sem novos originais:31exemplares preservados por hash. Conferidos visualmenteCIR
|
||||
Sem novo original legal importado. Conferidos visualmente Lei34/2007PDF18/p768-(72),art66(1–2),eDecreto9/2008PDF6/p121,21(2/5),PDF7/p122,27/29;Lei34PDF19/art71 lido para delimitar obrigação separada. Lei4/2012,Lei19/2013 e acervo de alteraçõesLei12/2025 reutilizados;nenhuma alteração doart66 identificada nesses exemplares. Dedução corrente limitada à colecta,sem reembolso PEC;transporte/caducidade e obrigação separados.30PDFs presentes no arquivo source-archive iguais byte a byte a dc14f01e;recibo source-preservation.json.
|
||||
|
||||
Consulta primária dirigida identificou anúncio do Governo de alterações regulamentares2026: https://portaldogoverno.gov.mz/governo-introduz-alteracoes-nos-regulamentos-fiscais-para-reforcar-eficiencia-tributaria/ . O anúncio não fornece o articulado promulgado e contém referência editorial divergente à lei; não é tratado como nova regra. Retoma específica para obrigação/calendário: diploma publicado,artigos e vigência. Sem nova pesquisa genérica ou substituição das fontes aceites;art66 e cálculo simulado corrente permanecem no recorte explícito. Model39 oficialAT identificaPEC,mas não foi inferido transporte automáticoM20/M22: https://edeclaracao.at.gov.mz/formularios/irpc/view/formulario_irpc_m39.aspx .
|
||||
|
||||
|
||||
### 27/10/2026 — Reutilização executável: crédito internacional corrente em QA
|
||||
|
||||
CIRPC65(1–2), Lei34/2007, exemplarBR52, PDF18/p768-(72), e ordem face aoPEC em66/RIRPC21 já aceites: usados no menor entre imposto estrangeiro efectivamente pago, fracção nacional documentada e limiteCDT aplicável, antes doPEC e até à colecta. Conferência da página existente para aplicação da fonte, sem nova exigência de autenticação. Original preservado, sem activação por importação/publicação. Afracção nacional eCDT do caso continuam documentadas pelo utilizador; aQA não estabelece correspondências oficiais de convenções.65(3), transportes, créditos económicos/CBF e obrigaçãoPEC continuam separados. Ver recibo `irpc-l8-international-credit-qa-20261027.json`; não instalado.
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
{
|
||||
"date": "2026-10-29",
|
||||
"scope": "Reorganização visual local do catálogo autorizada pela Tempo; sem instalação no portal.",
|
||||
"base": "838ad941a24ae76ec4bf91ccc3f92012668fe8cf",
|
||||
"design": {
|
||||
"desktop": "Painel lateral de filtros e resultados em duas colunas; lista com acções na coluna lateral do cartão.",
|
||||
"mobile": "Filtros expansíveis; cartões numa coluna; áreas de toque e foco visível.",
|
||||
"content": "Todos os campos, descrições, avisos e acções conservados; 29 fichas agrupadas por tipo. Aviso provincial e título dos resultados recuperados do pedido fornecido."
|
||||
},
|
||||
"checks": {
|
||||
"types": {
|
||||
"command": "npm run types:check",
|
||||
"exit": 0
|
||||
},
|
||||
"build": {
|
||||
"command": "INVESTMOZ_QA_BUILD=1 npm run build",
|
||||
"exit": 0,
|
||||
"target": "public/build-qa-opportunities",
|
||||
"limitations": "Avisos existentes de fontaine opcional e chunks grandes. Compilação anterior à formatação final, apenas cosmética."
|
||||
},
|
||||
"browser": {
|
||||
"result": "passed",
|
||||
"scope": "Local compiled React application with public document-based preview fixtures and mocked HTTP, no database or external requests. Does not prove backend or live availability.",
|
||||
"layouts": [
|
||||
{
|
||||
"width": 1440,
|
||||
"scrollWidth": 1440,
|
||||
"count": 12,
|
||||
"headingY": 296.65625,
|
||||
"sidebarVisible": true,
|
||||
"groups": [
|
||||
"Corredores6",
|
||||
"Clusters8",
|
||||
"Projectos âncora15"
|
||||
]
|
||||
},
|
||||
{
|
||||
"width": 1024,
|
||||
"scrollWidth": 1024,
|
||||
"count": 12,
|
||||
"headingY": 292.234375,
|
||||
"sidebarVisible": true,
|
||||
"groups": [
|
||||
"Corredores6",
|
||||
"Clusters8",
|
||||
"Projectos âncora15"
|
||||
]
|
||||
},
|
||||
{
|
||||
"width": 768,
|
||||
"scrollWidth": 768,
|
||||
"count": 12,
|
||||
"headingY": 368.078125,
|
||||
"sidebarVisible": false,
|
||||
"groups": [
|
||||
"Corredores6",
|
||||
"Clusters8",
|
||||
"Projectos âncora15"
|
||||
]
|
||||
},
|
||||
{
|
||||
"width": 390,
|
||||
"scrollWidth": 390,
|
||||
"count": 12,
|
||||
"headingY": 395.265625,
|
||||
"sidebarVisible": false,
|
||||
"groups": [
|
||||
"Corredores6",
|
||||
"Clusters8",
|
||||
"Projectos âncora15"
|
||||
]
|
||||
},
|
||||
{
|
||||
"width": 320,
|
||||
"scrollWidth": 320,
|
||||
"count": 12,
|
||||
"headingY": 425.96875,
|
||||
"sidebarVisible": false,
|
||||
"groups": [
|
||||
"Corredores6",
|
||||
"Clusters8",
|
||||
"Projectos âncora15"
|
||||
]
|
||||
}
|
||||
],
|
||||
"checks": [
|
||||
"All 12 sample titles, full descriptions and territorial caveats preserved at every width; expanded filter controls fit 320/390/1024px.",
|
||||
"Missing currency error remains visible on mobile.",
|
||||
"Keyboard opens mobile filters; search preserved through collapse, reopen and reload.",
|
||||
"Hierarchical territory selector still loads and updates filter context (synthetic QA territory).",
|
||||
"Investment selection and dossier link survive reload.",
|
||||
"Comparison still limits four selections and renders the existing comparison table.",
|
||||
"All 29 territorial reference cards remain accessible in three expandable groups.",
|
||||
"All five views activate and fit mobile width; map uses explicit no-coordinates preview data."
|
||||
],
|
||||
"pageErrors": 0
|
||||
},
|
||||
"logic": [
|
||||
{
|
||||
"file": "resources/js/pages/investment/catalogue.tsx",
|
||||
"existingNonPresentationLogicBlocks": 33,
|
||||
"missing": 0,
|
||||
"excludes": "JSX and its inline handlers; those reviewed in source diff and directed browser checks."
|
||||
},
|
||||
{
|
||||
"file": "resources/js/components/opportunity-search-filters.tsx",
|
||||
"existingNonPresentationLogicBlocks": 5,
|
||||
"missing": 0,
|
||||
"excludes": "JSX and its inline handlers; those reviewed in source diff and directed browser checks."
|
||||
}
|
||||
]
|
||||
},
|
||||
"preservation": {
|
||||
"schema": "Sem alterações.",
|
||||
"data": "Sem acesso à base de dados; prévia baseada nos documentos locais e referências públicas já guardadas.",
|
||||
"configuration": "Sem alterações.",
|
||||
"permissions": "Sem alterações.",
|
||||
"queries": "Filtros, endpoints e regras preservados; testes de backend anteriores reutilizados, sem nova prova de backend ou autenticação.",
|
||||
"sourceFiles": [
|
||||
{
|
||||
"file": "resources/js/pages/investment/catalogue.tsx",
|
||||
"sha256": "d4697cb83c2f92a786108286c7743401b44d61c5b367e9ff322b05d0424b0d70"
|
||||
},
|
||||
{
|
||||
"file": "resources/js/components/opportunity-search-filters.tsx",
|
||||
"sha256": "d5b75fc78f7dc272b745117d37e040f1bb921cec2783c3f50ddaaafff7e2df66"
|
||||
},
|
||||
{
|
||||
"file": "resources/js/components/catalogue-filter-group.tsx",
|
||||
"sha256": "f2728dfc2393de7d4f4338d3ea1057ed84317603980a2dc44f8a208d225cda45"
|
||||
},
|
||||
{
|
||||
"file": "resources/css/investment-catalogue.css",
|
||||
"sha256": "034a79a62ba13220f814027afd62e43c49e2947afd1d9e25a87ba37d3648fd93"
|
||||
}
|
||||
]
|
||||
},
|
||||
"evidence": {
|
||||
"directory": "outputs/catalogue-layout-20261029/",
|
||||
"screenshots": [
|
||||
"catalogue-1440.png",
|
||||
"catalogue-1024.png",
|
||||
"catalogue-768.png",
|
||||
"catalogue-390.png",
|
||||
"catalogue-320.png",
|
||||
"filters-expanded-390.png",
|
||||
"territorial-expanded.png",
|
||||
"list-1440.png"
|
||||
]
|
||||
},
|
||||
"matrix": [
|
||||
"RF-MN-010",
|
||||
"RF-PII-003",
|
||||
"RNF-EDU-008",
|
||||
"MASTER-471012ab-0124"
|
||||
],
|
||||
"deployment": "Não realizada; alteração activa fora desta entrega local.",
|
||||
"dynamicMoreFilters": {
|
||||
"origin": "Pedido expresso da Tempo, 29/10/2026",
|
||||
"collapsed": "Mais filtros",
|
||||
"expanded": "Menos filtros",
|
||||
"verification": {
|
||||
"result": "passed",
|
||||
"checks": [
|
||||
"Mais filtros quando recolhido",
|
||||
"Menos filtros quando aberto",
|
||||
"Alternância por clique e teclado",
|
||||
"Escolhas e contagem conservadas"
|
||||
],
|
||||
"scope": "Componente React real, compilado e exercitado em Chromium; sem backend ou base de dados."
|
||||
},
|
||||
"deployment": "Alteração local; sem instalação."
|
||||
}
|
||||
}
|
||||
@@ -2524,7 +2524,7 @@ As estimativas são **horas de trabalho técnico**, não calendário nem mediç
|
||||
| L5 — retenções IRPC e guias | Documentos de compras/vendas e guia M/39 como exemplar | Rendimento pago/recebido, entidade que retém, residente/não residente/EP, evento temporal, excepções e casos digitais/e-money; guia e comprovativo ligados à operação | Contrapartes, facturas, pagamentos, período, moeda, oportunidade | Artigos aplicáveis por rendimento, taxa/convenção se invocada; corrigir remissões do exemplar. Sem submissão electrónica AT presumida | 32–56 h |
|
||||
| L6 — IRPC anual: regime normal | Disponível5aaf1a56:percurso normal demonstrado atécolecta,períodos/moedas e preparação parcialM20/M22 | Operacional no âmbito demonstrado por decisãoTempo26/10;limitações explícitas;5grupos código+5documentais preservados;sem conclusão integral | Plano financeiro,dados comuns,activos/livros e histórico;retenções/pagamentos/créditos anuaisL8 | Pendências bloqueiam só os casos dependentes;L7/L8 próprios | Estimativa inicial48–80h;saldo não reestimado |
|
||||
| L7 — IRPC: tratamentos específicos | f8d57bdd instalado;632dc069 e a7434cd2 preservados no percurso | Cumulações demonstradas disponíveis;7famílias de saldo e documentos por caso discriminados;L7parcial | Activos/períodos/saldos/benefícios reutilizados;ordem,limites e incompatibilidades explícitos | Outras combinações/específicos/mistos/transporte próprios;L8delimitado separadamente | Inicial48–80h;saldo não reestimado |
|
||||
| L8 — IRPC: liquidação e pagamentos | Primeiro saldo com retenções/PPC entregue em9fda6d6e;dedução de PEC corrente comprovado emQA,sem instalação | Residente geral2026/MZN;PEC limitado à colecta,sem reembolso do excedente;ausência/zero/falta explícitos | ColectaL6/L7,L5received/effective/on_account,comprovativos e histórico anual reutilizados | Transporte/obrigaçãoPEC,créditos próprios,autónomos,períodos/moedas eM20M22 específicos;pendências só dependentes | Inicial32–56h;não é previsão actual do saldo |
|
||||
| L8 — IRPC: liquidação e pagamentos | PEC comprovado corrente de7fdb6b42 entregue eme182d1d7,sobre669cb897;saldo RF/PPC preservado | Residente geral2026/MZN;deduçãoPEC até à colecta,sem reembolso do excedente;L8parcial | ColectaL6/L7,L5RF,PPC/PEC comprovados,documentos e histórico anual | Créditos próprios,transporte/obrigaçãoPEC,autónomos,períodos/moedas eM20M22 próprios;primeiro crédito internacional delimitado,sem código novo | Inicial32–56h;não é previsão actual do saldo |
|
||||
| L9 — INSS: contribuição social | Massa salarial agregada e referência TCO3%+4% | Trabalhadores, remuneração/base contributiva, exclusões, empregador/trabalhador, TCO/TCP, declaração e encargos por período | Equipa/custos, entidade e calendário; cadastro de pessoa partilhado com L10 | Regulamento e alterações aplicáveis, natureza do vínculo; confirmar base antes da taxa. Contribuição social, distinta dos impostos | 24–40 h |
|
||||
| L10 — IRPS: retenção mensal e líquido | Entrada IRPS, custos salariais e escalões anuais documentais | Tabela mensal própria, remunerações/benefícios, situação pessoal relevante, retenção, salário líquido e contribuição ligada a L9 | Mesmo trabalhador/folha salarial, pagamentos e retenções | Tabela mensal do período, residência e condições familiares necessárias; não dividir escalões anuais por12 | 40–64 h |
|
||||
| L11 — IRPS: apuramento anual e outras categorias | Escalões anuais e exemplares M/19/M/20/anexos | Categorias aplicáveis aos rendimentos documentados, actividade independente, capitais/prediais/mais-valias, englobamento/tratamento autónomo, deduções, retenções e saldo | Dados pessoais autorizados, rendimentos/despesas, activos e L10 | Código IRPS/Lei11/2025, âmbito/categoria/período e deduções pessoais; diferenças de edição dos anexos. Não copiar regras IRPC | 48–80 h |
|
||||
@@ -7033,3 +7033,96 @@ QA dirigida:3testes/319asserções, transacções com rollback em loopback55441;
|
||||
Capacidade antes:88,3GiB e23,76milhões de inodes livres;novamente conferida após backup. Backup fresco `/var/backups/investmoz-sector-navigation-20261027/backup`,dumpSHA256`9b2437017495fe449cfe0c869da62870bd0fc4bddde596660a37392b8dbdaaba`;restauro das174tabelas com contagens/checksums idênticos,em contentor sem rede,porta55441.369ficheiros persistentes/configuração verificados;172tabelas de negócio intactas depois da instalação;cache/sessões operacionais reconciliados por identidade/expiração/pedidos públicos. Schema,papéis,grants epermissões iguais. Sem migrations,importações ou publicação de pilotos;storageQA fica separado da release servida. Songo/Gurué privados;L8 e percurso proactivo anteriores preservados. PEC`7fdb6b42` continua emQA separado e não foi instalado nesta passagem. Avaliação real da equipa continua dependente do retorno dos participantes.
|
||||
|
||||
Recibo consolidado: `docs/investmoz/unification/sector-navigation-delivery-20261027.json`. Cópia remota: `/var/backups/investmoz-sector-navigation-20261027/installed-receipt.json`,SHA256`cd95142b7f85e40a0f86e0f7d3dca513e7bc208c89aa91b8e3ad213191d8465f`. Provas locais: `outputs/sector-navigation-delivery-20261027/`. Os registos anteriores de QA/transferência são históricos;esta correcção já não está pendente de instalação. Não se declara concluído o âmbito global dos requisitos sectoriais ou do simulador.
|
||||
|
||||
|
||||
## 27/10/2026 — PEC entregue e retoma dos créditos próprios de L8
|
||||
|
||||
**Instalado e conferido em `e182d1d79dc945f35d2079c6b8ca2ac93048cec3`**, incluindo o PEC aceite emQA`7fdb6b42` e preservando integralmente a correcção dos sectores`669cb897`. A reconciliação alterou apenas conflitos documentais, conservando os históricos das duas linhas e o recibo sectorial`4ee427ba`. Os4ficheiros de aplicação PEC ficaram idênticos à QA;os ficheiros sectoriais e seus testes idênticos ao instalado. Fonte/configuração/routes/schema fora do delta preservados. A matriz mantém as4actualizações documentais aceites da avaliação pela equipa,além da linhaPEC;sem nova revisão funcional do percurso proactivo.
|
||||
|
||||
**Âmbito entregue:** residente geral,ano civil2026,MZN;PEC efectivamente pago do próprio exercício,titular/data/prova/parcelas e uso anterior documentados. Dedução até à colecta disponível antes de retenções/PPC;créditos precedentes ausentes ou conhecidos zero. ExcedentePEC não gera reembolso nem saldo oficial transportado. Cálculo da obrigação,prestações,transporte/caducidade anteriores,créditos próprios positivos e imposto autónomo continuam separados. Informação em falta não vira zero;históricos não são recalculados. Reutilizadas as5recuperações e relatórios QA aceites:1 408−200−500=708 a pagar;PEC2 000 deduz1 408 e deixa592 não deduzidos;os500 a recuperar no caso comPPC provêm doPPC,sem reembolsar oPEC.
|
||||
|
||||
**Entrega:** capacidade87,16GiB e inodes suficientes antes,e novamente conferida após backup. Dump frescoSHA256`eff57769cda1e9d0f3d507348b57fc455c0bbc6e38beeb3688135109a6e219fd`,em`/var/backups/investmoz-irpc-l8-pec-20261027/backup`;restauro174tabelas com contagens/checksums iguais,contentor sem rede,porta55441.369ficheiros persistentes/configuração e172tabelas de negócio intactos;schema,papéis,grants e permissões iguais. Cache/sessões operacionais reconciliados:inclui1sessão anónima preexistente,sem mudança de identidade,com token efémero/URL anterior e IP/actividade actualizados,correlacionados individualmente comGET200de documento público pelo mesmoUA/IP/instante;nenhuma sessão sobrescrita pelo comparador. Sem migrations,importações,fixtures activas ou publicação de pilotos. Guardas do instalador mantidas;release anterior em serviço até troca atómica.1000fontes antes/1002depois conferidas comGit;delta de aplicação4ficheiros. Manifest e5marcadoresPEC servidos conferidos;10cartões dos sectores,3páginas/guias/oportunidades e filtroAgronegócio idênticos antes/depois.
|
||||
|
||||
**Provas reutilizadas:**12testesPEC+19do anual,API102asserções/5casos e relatórios aceites,sem outra ronda manual. Controlos obrigatórios do instalador aprovados:PostgreSQL1/3106,Unit59/317,frontend1092pass/0fail,TypeScript ebuild30,51s. Recibo consolidado:`docs/investmoz/simulations/irpc-l8-pec-delivery-20261027.json`;cópia remota:`/var/backups/investmoz-irpc-l8-pec-20261027/installed-receipt.json`,SHA256`a970266625807803ce73f1e63d0da1a540cff264ab88a19d3a8a387a85b26c34`. Provas locais:`outputs/irpc-l8-pec-delivery-20261027/`. Os recibosQA anteriores permanecem históricos;este PEC deixa de ser pendência de instalação.
|
||||
|
||||
### Retoma concreta — créditos próprios e saldo restante
|
||||
|
||||
O primeiro recorte para implementaçãoQA será o crédito por dupla tributação internacional do próprio exercício. Retoma desta passagem:fonte e contrato de dados/cálculo delimitados,**ainda sem novo código ou cálculo de crédito activado**. Reutilizado oCIRPC65,Lei34/2007PDF18/p768-(72),já no acervo aceite;ordem face aoPEC em66/RIRPC21. Não se exige revalidação genérica da fonte. Rendimento estrangeiro incluído na matéria colectável,imposto sobre o rendimento efectivamente pago,titular/país/exercício/prova e montante disponível devem corresponder. O crédito é limitado pela fracção nacional correspondente e,pela convenção quando aplicável;esse limite não pode ser presumido a partir do montante recebido. Exemplo sintético para provar o novo delta,**não implementado**:imposto estrangeiro10,limite nacional documentado8,ausência documentada deCDTaplicável→crédito8;colecta1 408→1 400;PEC200→1 200;PPC500→saldo700,sem retenções. Os2acima do limite não se tornam automaticamente crédito a transportar.
|
||||
|
||||
| Código ainda por implementar | Condição concreta de retoma |
|
||||
| --- | --- |
|
||||
| Qualificação,limites e dedução do crédito internacional corrente | Implementar o contrato acima,com estado conhecido/ausente/em falta,identidade da prova,ordem antes doPEC,limites e prevenção de uso duplicado comPEC/PPC/RF;demonstrar só novos efeitos,gravação/recuperação/relatório e preservação dos históricos. |
|
||||
| Crédito por dupla tributação económica e crédito de investimento/benefício | Grupos distintos;art64 e fundamentoCBFpróprio,qualificaçãoL7,titular/período,lucro/imposto/activos elegíveis,limite,cumulação e utilização documentados. Localização não concede benefício automaticamente. |
|
||||
| Transporte/utilização/caducidade dePEC e créditos anteriores | Proveniência por exercício e utilizações reais;PEC66 distinto do crédito65 e seu prazo próprio. Não confundir excesso sobre limite de elegibilidade com falta de colecta,nem criar saldos oficiais a partir de simulações. |
|
||||
| ObrigaçãoPPC/PEC,calendário,juros/multas/guias | Volume/PPC anteriores e demais factos pertinentes,edição normativa/vencimentos próprios;separado da dedução dePECjá pago agora entregue. |
|
||||
| Imposto autónomo,períodos especiais,outras moedas eM20/M22/submissão | Mantêm as dependências próprias já delimitadas;reutilizar periodização/câmbio quando a regra do caso estiver correspondida,sem compensação ou códigos oficiais presumidos. |
|
||||
|
||||
| Evidência/documento do caso em falta | Exemplo e condição concreta de retoma |
|
||||
| --- | --- |
|
||||
| Prova e inclusão do rendimento estrangeiro | Imposto10MZN sem rendimento identificado ou fracção nacional demonstrada:reutilizar dados/documentos existentes e identificar a correspondência;subtotal não resolve o saldo dependente. Não é falta de autenticação da fonte normativa. |
|
||||
| Convenção aplicável e limite | País/CDT conhecidos mas artigo,período ou imposto pago nos termos da convenção em falta:corresponder esses elementos;bloqueia apenas o caso dependente. |
|
||||
| Regulamentação2026para obrigação/calendário | Anúncio sem articulado publicado:retomar com diploma,artigos e vigência dos parâmetros afectados;sem bloquear oPECcorrente ou crédito independente cujo fundamento já está disponível. |
|
||||
|
||||
L8 permanece parcial. A avaliação real do percurso proactivo continua a aguardar retorno da equipa;dificuldades observadas serão correcções concretas. Songo eGurué permanecem privados;L3/ISPC/câmbio/L6/L7 eSGFTEMPO preservados. Sem nova estimativa global ou declaração de IRPC completo.
|
||||
|
||||
|
||||
## 27/10/2026 — Crédito internacional corrente: percurso implementado em QA
|
||||
|
||||
**Estado actual: implementado e demonstrado em QA, sem instalação.** Base `814fe0a9`, descendente do PEC instalado `e182d1d7` e da correcção dos sectores `669cb897`. Os registos anteriores de delimitação são históricos: o crédito corrente abaixo já tem código executável; os restantes grupos continuam separados. Ramo `codex/irpc-l8-international-credit-qa-20261027`. Recibo: `docs/investmoz/simulations/irpc-l8-international-credit-qa-20261027.json`.
|
||||
|
||||
**Âmbito e origem das restrições:** pedido expresso da Tempo para implementar o crédito internacional em QA, preservando o PEC e os históricos. Reutilizado CIRPC65(1–2), Lei34/2007, PDF18/p768-(72), e ordem antes do PEC em66/RIRPC21, do acervo aceite. Escolha incremental de implementação: residente geral, ano civil2026 e valores comprovados emMZN; inclusão do rendimento e fracção nacional documentadas, sem determinação automática dessa fracção, de vigência/aplicabilidade deCDT ou de conversão cambial. A selecção do país não concede crédito. A mudança de país/colecta exige reconfirmar a correspondência dos limites, conservando os valores.
|
||||
|
||||
**Percurso:** a interface permite preparar explicitamente o detalhe, reutilizando entidade/exercício/colecta e o resumo anterior quando este declara ausência ou zero; mantém esse resumo e os resultados anteriores. Uma posição por país/exercício agrega rendimentos e provas sob um só limite nacional. Regista natureza do imposto, pagamento efectivo, titular, suporte e utilização anterior real; data fora do exercício exige correspondência documental expressa, sem inferir transporte. O crédito elegível é o menor entre imposto seleccionado comprovado, fracção nacional e limiteCDT quando aplicável; desconta utilização anterior e limita a dedução à colecta. Seguem PEC, retenções ePPC existentes. Não transforma simulações históricas em utilização fiscal. Limites admitem fracção exacta; apresentação decimal não é regra de arredondamento fiscal.
|
||||
|
||||
| Caso sintético recuperado da API | Novo efeito demonstrado em MZN |
|
||||
| --- | --- |
|
||||
| Imposto estrangeiro10, limite nacional8, não aplicaçãoCDT documentada | Crédito8; 1 408−8=1 400; PEC200→1 200; PPC500→**700 a pagar, simulado**. Os2 acima do limite não são transporte. |
|
||||
| LimiteCDT documentado6 | Crédito6; saldo simulado702. Os dados de país/CDT são artificiais, sem afirmar uma convenção real. |
|
||||
| Utilização anterior comprovada3 | Elegível8, disponível5; saldo simulado703. Não somar utilizações de simulações. |
|
||||
| Crédito disponível2 000 e colecta1 408 | Deduz1 408; insuficiência592 identificada, sem transporte; PEC200 não deduzido. Os500 a recuperar provêm doPPC, sem reembolso do crédito/PEC. |
|
||||
| Ausência internacional expressa e documentada | Crédito0, saldo708; não confundir ausência com informação em falta. |
|
||||
| AplicabilidadeCDT em falta ou mesma prova usada comoPPC e imposto estrangeiro | Saldo e dedução dependentes indeterminados, com motivo; não preencher por presunção. |
|
||||
|
||||
**Provas do delta:**18testes novos e31anuais/PEC afectados,49aprovados; API privada1teste/171asserções com transacção revertida na baseQA guardada, porta55441. Sete casos porPOST/PUT/GET, recalculados após recuperação e exportados pelos relatóriosHTML e dossier existentes; histórico anterior congelado. Wayfinder `routes/actions`, TypeScript e compilação isolada aprovados. Esta passagem não inclui uma nova prova manual de utilização no browser nem uma avaliação pela equipa. Não se repetiram as suites independentes aceites. As7tabelas de registos anteriores ficaram intactas;30PDFs originais e11consumidores protegidos iguais ao instalado. Sem migrations, novas permissões ou configuração activa; nada enviado para a base do portal. Os testes usam fixtures sintéticas portáteis, sem dados comerciais ou pilotos reais.
|
||||
|
||||
**Prevenção de dupla dedução:** identidade física da prova por emitente/documento, independentemente da data; confronto entre imposto estrangeiro,RF,PPC ePEC e entre mapas do mesmo snapshot; país/entidade/exercício e montantes disponíveis coerentes. Posições repetidas do mesmo país/ano exigem consolidação, evitando repetir a quota nacional. Não existe consumo de saldos oficiais nem reconciliação global entre dossiers independentes. Valores conhecidos, ausência declarada e informação em falta permanecem distintos. Créditos económicos e benefícios positivos ou desconhecidos deixam apenas o saldo dependente indeterminado, preservando a qualificação internacional conhecida.
|
||||
|
||||
### Saldo concreto de L8 após este incremento
|
||||
|
||||
| Código por implementar | Condição de retoma |
|
||||
| --- | --- |
|
||||
| Determinação automática da fracção nacional e limites específicosCDT | Corresponder componentes da base/imposto e rendimento estrangeiro e regras específicas do caso; substituir entradas documentadas apenas quando essa correspondência estiver demonstrada. A regra corrente do menor/ordem já está implementada. |
|
||||
| Crédito económico e créditos de investimento/benefício | Aplicar art64/CBF próprio, qualificaçãoL7, base elegível, limite, cumulação e uso real; não os converter em crédito internacional. |
|
||||
| Transporte/caducidade e utilização interanual | Proveniência por exercício, utilização real e prazo próprio de65(3), distinto doPEC66; sem transformar imposto acima do limite em crédito transportável. PEC excedente/transporte continuam fora do âmbito entregue. |
|
||||
| Obrigação/calendárioPPC/PEC, autónomos, períodos especiais, outras moedas eM20/M22 | Retomar cada grupo com factos e regra de período/compensação/câmbio/campo correspondidos; reutilizar motores existentes sem alterar o cálculo independente aceite. |
|
||||
|
||||
| Informação documental externa em falta | Exemplo e condição de retoma |
|
||||
| --- | --- |
|
||||
| Inclusão e fracção nacional do caso | Imposto10 sem prova da inclusão/base: identificar o rendimento incluído e o suporte da quota; apenas o saldo desse caso fica indeterminado. Não exige nova autenticação da fonte oficial. |
|
||||
| Convenção, período e imposto elegível | País conhecido sem artigo/limite aplicável: corresponder artigo, vigência e imposto pago nos termos daCDT. O limite6 da QA não é uma correspondência oficial. |
|
||||
| Pagamento/titular/uso anterior e correspondência temporal | Pagamento em2027 afecto a2026 sem suporte: anexar/identificar correspondência expressa; sem presumir transporte ou utilização zero. |
|
||||
|
||||
**L8 permanece parcial.** Crédito internacional apenas emQA; PEC instalado em`e182d1d7` mantém o âmbito demonstrado. Songo eGurué privados; L3,ISPC,câmbio,L5–L7 eSGFTEMPO preservados. Avaliação de utilização do percurso proactivo continua a aguardar retorno da equipa. Sem instalação, publicação ou nova estimativa global nesta passagem.
|
||||
|
||||
|
||||
## 29/10/2026 — ergonomia do catálogo: inventário antes da verificação
|
||||
|
||||
Origem: pedido expresso da Tempo para analisar alternativas e reorganizar a página sem alterar conteúdos. Escolha de implementação: painel lateral no computador, filtros expansíveis no móvel, grupos por finalidade e cartões com hierarquia visual; corredores, clusters e projectos âncora agrupados em secções expansíveis. Não introduz regra organizacional. Alternativas ponderadas: formulário integral no topo conserva o bloqueio vertical; janela sobreposta afasta o contexto dos resultados; painel responsivo permite consulta lado a lado e mantém os campos montados ao recolher.
|
||||
|
||||
Inventário do concluído consultado antes de nova ronda: selectores públicos independentes dos resultados e provas 22/10; agronegócio e escolha múltipla/dossier 23/10; vista por corredor e percurso proactivo 27/10; registos de reposição territorial e carteira mantidos. Preservar pesquisa combinada AND, filtros simples/avançados e geográficos, classificação histórica, montantes/moedas sem conversão, estados/erros, cinco vistas, CSV, favoritos/pedidos, comparação, escolha para investimento, paginação, guias e todas as fichas territoriais. Não existe eliminação funcional confirmada neste delta de código; não se infere disponibilidade activa pela apresentação local. O título dos resultados e o aviso provincial fornecidos no pedido estavam ausentes no componente local e são recuperados textualmente.
|
||||
|
||||
Comparação delimitada: só componentes de apresentação e CSS; schema, dados, configuração, fontes, relações e permissões sem alteração. Não se ligou à base activa nem se declarou perda por leitura sem actor. A candidata não modifica aceitação anterior ou limitações de outros incrementos. Matriz existente: RF-MN-010, RF-PII-003, RNF-EDU-008 e MASTER-471012ab-0124; sem nova matriz.
|
||||
|
||||
Verificação do delta por realizar: compilação/tipos, apresentação 320/390/768/1024/1440px, teclado, expansão sem perda de campos, vistas, conservação das acções/conteúdo e ausência de transbordo horizontal. Preparação local, sem instalação ou alteração de dados activos.
|
||||
|
||||
### Resultado do delta de apresentação — 29/10/2026
|
||||
|
||||
Concluído localmente. TypeScript e build isolado aprovados, sem instalação. Navegador Chromium com a aplicação React compilada e respostas HTTP de prévia locais, sem base de dados nem pedidos externos:320/390/768/1024/1440px sem transbordo horizontal; campos expandidos cabem no painel em320/390/1024px. Conferidas integralmente as descrições e avisos territoriais dos12cartões da amostra em cada largura, teclado para expandir, erro de moeda, recolher/reabrir/recarregar sem perder pesquisa, selectores hierárquicos, escolha persistente para dossier, limite/comparação de4, cinco vistas e acesso às29fichas(6corredores,8clusters,15âncoras). Zero erros JavaScript. Capturas efectivamente inspeccionadas:1440/1024/390/320px, filtros expandidos390px e lista1440px.
|
||||
|
||||
Comparação estrutural:33blocos preexistentes de lógica da página e5auxiliares dos filtros preservados; JSX/callbacks revistos no delta e nas interacções acima. Os avisos de ausência, a consulta pública e as ligações anteriores mantêm-se. Favoritos autenticados, backend de pesquisa/mapa, guias e permissões conservam os contratos/provas anteriores; esta prévia não é nova demonstração desses serviços nem da disponibilidade activa. Mapa exercitado com ausência explícita de coordenadas, sem criar pontos.
|
||||
|
||||
Recibo:docs/investmoz/unification/catalogue-layout-qa-20261029.json. Evidência local:outputs/catalogue-layout-20261029/. Nenhuma redução funcional pretendida; todas as fichas estão nos grupos expansíveis. Sem publicação, dados alterados, migrações, configuração ou permissões novas. Não encerra os critérios globais das quatro linhas da matriz.
|
||||
|
||||
Ajuste solicitado pela Tempo em29/10/2026: o controlo dos filtros avançados alterna entre “Mais filtros” (recolhido) e “Menos filtros” (aberto). O estado segue a abertura nativa da secção; os campos e escolhas continuam montados. Prova dirigida no componente React real em Chromium: clique/teclado, ambos os textos, valor editado e contagem conservados; sem errosJavaScript. Recibo local:outputs/catalogue-layout-20261029/toggle-receipt.json. Sem nova ronda global, instalação ou alteração de dados.
|
||||
|
||||
Ajuste visual solicitado pela Tempo em29/10/2026: títulos, cabeçalhos, rótulos de grupos e conteúdo do catálogo em negrito apresentados em vermelho; os botões com fundo colorido mantêm texto legível. CSS validado por análise sintáctica; alteração local de apresentação, sem instalação.
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,445 @@
|
||||
/* Presentation only: catalogue queries, records and permissions retain their contracts. */
|
||||
.investment-catalogue {
|
||||
--catalogue-accent: #c9141b;
|
||||
--catalogue-ink: #17324d;
|
||||
max-width: 1440px;
|
||||
color: var(--catalogue-ink);
|
||||
}
|
||||
.investment-catalogue > h1 {
|
||||
font-size: clamp(1.6rem, 3vw, 2.15rem);
|
||||
letter-spacing: -0.035em;
|
||||
}
|
||||
.investment-catalogue .catalogue-intro {
|
||||
margin-top: 0.65rem;
|
||||
max-width: 76ch;
|
||||
color: #526477;
|
||||
line-height: 1.7;
|
||||
}
|
||||
.catalogue-workspace {
|
||||
display: grid;
|
||||
gap: 1.5rem;
|
||||
align-items: start;
|
||||
}
|
||||
.catalogue-workspace > *,
|
||||
.catalogue-results > *,
|
||||
.catalogue-opportunity > * {
|
||||
min-width: 0;
|
||||
}
|
||||
.catalogue-filters {
|
||||
border: 1px solid #dce3eb;
|
||||
border-radius: 1rem;
|
||||
background: #fff;
|
||||
overflow: clip;
|
||||
}
|
||||
.catalogue-filters-toggle,
|
||||
.catalogue-filters-heading {
|
||||
align-items: center;
|
||||
gap: 0.65rem;
|
||||
padding: 1rem 1.15rem;
|
||||
font-weight: 650;
|
||||
}
|
||||
.catalogue-filters-toggle {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
min-height: 52px;
|
||||
}
|
||||
.catalogue-filters-toggle > svg:last-child {
|
||||
margin-left: auto;
|
||||
transition: transform 0.15s;
|
||||
}
|
||||
.catalogue-filters-toggle[aria-expanded='true'] > svg:last-child {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
.catalogue-filters-heading {
|
||||
display: none;
|
||||
}
|
||||
#catalogue-filter-fields {
|
||||
padding: 0 1.15rem 1.15rem;
|
||||
}
|
||||
.catalogue-filters input:not([type='checkbox']),
|
||||
.catalogue-filters select {
|
||||
min-height: 44px;
|
||||
max-width: 100%;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
.catalogue-filter-group {
|
||||
border-top: 1px solid #e5eaf0;
|
||||
}
|
||||
.catalogue-filter-group > summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.6rem;
|
||||
min-height: 52px;
|
||||
padding: 0.65rem 0;
|
||||
cursor: pointer;
|
||||
list-style: none;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 650;
|
||||
}
|
||||
.catalogue-filter-group > summary::-webkit-details-marker {
|
||||
display: none;
|
||||
}
|
||||
.catalogue-filter-group > summary > svg {
|
||||
margin-left: auto;
|
||||
flex-shrink: 0;
|
||||
transition: transform 0.15s;
|
||||
}
|
||||
.catalogue-filter-group[open] > summary > svg {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
.catalogue-filter-group-content {
|
||||
padding: 0.4rem 0 1rem;
|
||||
display: grid;
|
||||
gap: 1rem;
|
||||
}
|
||||
.catalogue-count {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 1.5rem;
|
||||
padding: 0.15rem 0.45rem;
|
||||
border-radius: 99px;
|
||||
background: #f0f3f7;
|
||||
color: #526477;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
.catalogue-filters .catalogue-filter-group {
|
||||
margin-top: 0;
|
||||
}
|
||||
.catalogue-active-filters:empty {
|
||||
display: none;
|
||||
}
|
||||
.catalogue-active-filters button {
|
||||
border-radius: 0.5rem;
|
||||
background: #f5f7fa;
|
||||
border-color: #dce3eb;
|
||||
font-size: 0.75rem;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.catalogue-filter-submit > button:first-of-type {
|
||||
gap: 0.5rem;
|
||||
background: var(--catalogue-accent);
|
||||
min-height: 44px;
|
||||
}
|
||||
.catalogue-filter-submit > button:last-child {
|
||||
min-height: 44px;
|
||||
color: #526477;
|
||||
font-size: 0.875rem;
|
||||
border: 0;
|
||||
text-decoration: none;
|
||||
}
|
||||
.catalogue-results {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.25rem;
|
||||
scroll-margin-top: 2rem;
|
||||
}
|
||||
.catalogue-results-heading {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.35rem 1rem;
|
||||
}
|
||||
.catalogue-results-heading > h2 {
|
||||
font-size: 1.125rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
.catalogue-results-heading > [role] {
|
||||
border: 0;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
color: #526477;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
.catalogue-results-toolbar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.8rem 1.25rem;
|
||||
padding-bottom: 1.1rem;
|
||||
border-bottom: 1px solid #dce3eb;
|
||||
}
|
||||
.catalogue-view-options {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.2rem;
|
||||
padding: 0.25rem;
|
||||
border: 1px solid #dce3eb;
|
||||
border-radius: 0.75rem;
|
||||
background: #fff;
|
||||
}
|
||||
.catalogue-view-button {
|
||||
display: inline-flex;
|
||||
gap: 0.4rem;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 42px;
|
||||
padding: 0.5rem 0.7rem;
|
||||
border-radius: 0.5rem;
|
||||
color: #526477;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
.catalogue-view-button[aria-pressed='true'] {
|
||||
background: #17324d;
|
||||
color: #fff;
|
||||
}
|
||||
.catalogue-view-button:not(:disabled):hover {
|
||||
color: var(--catalogue-accent);
|
||||
}
|
||||
.catalogue-view-button[aria-pressed='true']:not(:disabled):hover {
|
||||
background: var(--catalogue-accent);
|
||||
color: #fff;
|
||||
}
|
||||
.catalogue-view-button:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: wait;
|
||||
}
|
||||
.catalogue-utility-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.25rem 1.25rem;
|
||||
}
|
||||
.catalogue-utility-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
min-height: 44px;
|
||||
font-size: 0.8rem;
|
||||
color: #526477;
|
||||
}
|
||||
.catalogue-utility-link[aria-disabled='true'] {
|
||||
opacity: 0.5;
|
||||
}
|
||||
.catalogue-cards {
|
||||
display: grid;
|
||||
gap: 1rem;
|
||||
}
|
||||
.catalogue-opportunity {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border: 1px solid #dce3eb;
|
||||
border-radius: 1rem;
|
||||
background: white;
|
||||
overflow: clip;
|
||||
transition:
|
||||
border-color 0.15s,
|
||||
box-shadow 0.15s;
|
||||
}
|
||||
.catalogue-opportunity:hover,
|
||||
.catalogue-opportunity:focus-within {
|
||||
border-color: #9cabbc;
|
||||
box-shadow: 0 5px 18px #17324d0a;
|
||||
}
|
||||
.catalogue-opportunity-body {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
align-items: start;
|
||||
gap: 0.85rem;
|
||||
padding: 1.25rem;
|
||||
}
|
||||
.catalogue-sector {
|
||||
padding: 0.25rem 0.6rem;
|
||||
background: #f0f4f8;
|
||||
color: #3d5268;
|
||||
border-radius: 0.4rem;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
.catalogue-location {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.4rem;
|
||||
color: #526477;
|
||||
font-size: 0.8rem;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.catalogue-location svg {
|
||||
flex-shrink: 0;
|
||||
margin-top: 0.2rem;
|
||||
}
|
||||
.catalogue-opportunity h2 {
|
||||
font-size: 1.125rem;
|
||||
line-height: 1.45;
|
||||
letter-spacing: -0.015em;
|
||||
color: var(--catalogue-ink);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.catalogue-summary {
|
||||
color: #526477;
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.7;
|
||||
}
|
||||
.catalogue-opportunity-facts {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.65rem;
|
||||
width: 100%;
|
||||
margin-top: auto;
|
||||
padding-top: 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
.catalogue-maturity {
|
||||
padding: 0.25rem 0.6rem;
|
||||
border-radius: 99px;
|
||||
background: #f5f6f8;
|
||||
color: #526477;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
.catalogue-opportunity-actions {
|
||||
padding: 0.45rem 1.25rem 0.75rem;
|
||||
border-top: 1px solid #e5eaf0;
|
||||
}
|
||||
.catalogue-opportunity-links {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.25rem 0.75rem;
|
||||
}
|
||||
.catalogue-detail-link,
|
||||
.catalogue-favourite {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
min-height: 44px;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
.catalogue-detail-link {
|
||||
color: var(--catalogue-accent);
|
||||
font-weight: 650;
|
||||
}
|
||||
.catalogue-favourite {
|
||||
color: #526477;
|
||||
text-align: left;
|
||||
}
|
||||
.catalogue-favourite[aria-pressed='true'] {
|
||||
color: var(--catalogue-accent);
|
||||
}
|
||||
.catalogue-opportunity-choices {
|
||||
display: grid;
|
||||
gap: 0.15rem;
|
||||
padding-top: 0.35rem;
|
||||
border-top: 1px solid #eef1f5;
|
||||
}
|
||||
.catalogue-opportunity-choices label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.6rem;
|
||||
min-height: 44px;
|
||||
font-size: 0.8rem;
|
||||
line-height: 1.5;
|
||||
cursor: pointer;
|
||||
}
|
||||
.catalogue-opportunity-choices input {
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
flex-shrink: 0;
|
||||
accent-color: var(--catalogue-accent);
|
||||
}
|
||||
.catalogue-pagination {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
.catalogue-pagination a {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 44px;
|
||||
padding: 0.5rem 1rem;
|
||||
border: 1px solid #dce3eb;
|
||||
border-radius: 0.5rem;
|
||||
background: #fff;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
.catalogue-territorial {
|
||||
padding-top: 1.5rem;
|
||||
border-top: 1px solid #dce3eb;
|
||||
}
|
||||
.catalogue-territorial > h2 {
|
||||
font-size: 1.125rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
.catalogue-territorial > p {
|
||||
margin: 0.5rem 0 1.2rem;
|
||||
color: #526477;
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.7;
|
||||
}
|
||||
.catalogue-territorial-links {
|
||||
display: grid;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
.catalogue-territorial-link {
|
||||
border: 1px solid #e5eaf0;
|
||||
border-radius: 0.65rem;
|
||||
padding: 0.85rem 1rem;
|
||||
background: #fff;
|
||||
}
|
||||
.catalogue-territorial-link > span {
|
||||
color: #526477;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
.catalogue-territorial-link h3 {
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.6;
|
||||
}
|
||||
/* Headings and emphasized catalogue content use Tempo's red. */
|
||||
.investment-catalogue :is(h1, h2, h3, h4, h5, h6, caption, th, strong),
|
||||
.investment-catalogue :is(p.font-bold, p.font-semibold),
|
||||
.investment-catalogue .catalogue-sector,
|
||||
.investment-catalogue .catalogue-filters-toggle,
|
||||
.investment-catalogue .catalogue-territorial .catalogue-filter-group > summary {
|
||||
color: var(--catalogue-accent);
|
||||
}
|
||||
.investment-catalogue :is(a, button, summary, input, select):focus-visible {
|
||||
outline: 2px solid #17324d;
|
||||
outline-offset: 3px;
|
||||
}
|
||||
.investment-catalogue :is(a, button, summary):hover {
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 3px;
|
||||
}
|
||||
@media (min-width: 640px) {
|
||||
.catalogue-cards-grid,
|
||||
.catalogue-territorial-links {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
@media (min-width: 1024px) {
|
||||
.catalogue-workspace {
|
||||
grid-template-columns: 290px minmax(0, 1fr);
|
||||
gap: 2rem;
|
||||
}
|
||||
.catalogue-filters-toggle {
|
||||
display: none;
|
||||
}
|
||||
.catalogue-filters-heading {
|
||||
display: flex;
|
||||
}
|
||||
.catalogue-results-heading {
|
||||
min-height: 48px;
|
||||
}
|
||||
.catalogue-cards-list .catalogue-opportunity {
|
||||
flex-direction: row;
|
||||
}
|
||||
.catalogue-cards-list .catalogue-opportunity-actions {
|
||||
flex: 0 0 235px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
border-top: 0;
|
||||
border-left: 1px solid #e5eaf0;
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.investment-catalogue * {
|
||||
transition: none;
|
||||
scroll-behavior: auto;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { ChevronDown } from 'lucide-react';
|
||||
import { useState, type ReactNode } from 'react';
|
||||
|
||||
export default function CatalogueFilterGroup({
|
||||
title,
|
||||
expandedTitle,
|
||||
count = 0,
|
||||
children,
|
||||
}: {
|
||||
title: string;
|
||||
expandedTitle?: string;
|
||||
count?: number;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<details
|
||||
className="catalogue-filter-group"
|
||||
onToggle={(event) => setOpen(event.currentTarget.open)}
|
||||
>
|
||||
<summary>
|
||||
<span>{open && expandedTitle ? expandedTitle : title}</span>
|
||||
{count > 0 && <span className="catalogue-count">{count}</span>}
|
||||
<ChevronDown size={16} aria-hidden="true" />
|
||||
</summary>
|
||||
<div className="catalogue-filter-group-content">{children}</div>
|
||||
</details>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
import { Field, input, button, groupLabels } from '@/pages/investment/shared';
|
||||
import type { References } from '@/pages/investment/shared';
|
||||
import { TerritoryLevel, type TerritoryOption } from './investment-territory';
|
||||
import CatalogueFilterGroup from './catalogue-filter-group';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { ChevronDown, Search, SlidersHorizontal } from 'lucide-react';
|
||||
|
||||
export const modalityLabels: Record<string, string> = {
|
||||
investment_project: 'Projecto de investimento',
|
||||
@@ -50,14 +53,19 @@ const labels: Record<string, string> = {
|
||||
publication_state: 'Critério herdado',
|
||||
};
|
||||
const specialisedEmpty: Record<string, string> = {
|
||||
corridor_id: 'Não existem corredores públicos cadastrados para esta localização.',
|
||||
cluster_id: 'Não existem clusters públicos cadastrados para esta localização.',
|
||||
corridor_id:
|
||||
'Não existem corredores públicos cadastrados para esta localização.',
|
||||
cluster_id:
|
||||
'Não existem clusters públicos cadastrados para esta localização.',
|
||||
zee_id: 'Não existem ZEE públicas cadastradas para esta localização.',
|
||||
zfi_id: 'Não existem ZFI públicas cadastradas para esta localização.',
|
||||
park_id: 'Não existem parques industriais públicos cadastrados para esta localização.',
|
||||
project_id: 'Não existem projectos âncora públicos cadastrados para esta localização.',
|
||||
park_id:
|
||||
'Não existem parques industriais públicos cadastrados para esta localização.',
|
||||
project_id:
|
||||
'Não existem projectos âncora públicos cadastrados para esta localização.',
|
||||
subsector_id: 'Não existem actividades disponíveis no catálogo público.',
|
||||
chain_id: 'Não existem cadeias de valor públicas cadastradas para esta localização.',
|
||||
chain_id:
|
||||
'Não existem cadeias de valor públicas cadastradas para esta localização.',
|
||||
};
|
||||
export default function OpportunitySearchFilters({
|
||||
data,
|
||||
@@ -78,6 +86,10 @@ export default function OpportunitySearchFilters({
|
||||
clear: () => void;
|
||||
errors: Record<string, string>;
|
||||
}) {
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
useEffect(() => {
|
||||
if (Object.keys(errors).length) setExpanded(true);
|
||||
}, [errors]);
|
||||
const select = (
|
||||
key: string,
|
||||
choices: { value: string; label: string }[],
|
||||
@@ -87,8 +99,14 @@ export default function OpportunitySearchFilters({
|
||||
<select
|
||||
className={input}
|
||||
aria-label={labels[key]}
|
||||
aria-describedby={specialisedEmpty[key] ? `filter-help-${key}` : undefined}
|
||||
disabled={Boolean(specialisedEmpty[key]) && choices.length === 0 && !data[key]}
|
||||
aria-describedby={
|
||||
specialisedEmpty[key] ? `filter-help-${key}` : undefined
|
||||
}
|
||||
disabled={
|
||||
Boolean(specialisedEmpty[key]) &&
|
||||
choices.length === 0 &&
|
||||
!data[key]
|
||||
}
|
||||
value={String(data[key] ?? '')}
|
||||
onChange={(e) =>
|
||||
change({
|
||||
@@ -100,9 +118,13 @@ export default function OpportunitySearchFilters({
|
||||
}
|
||||
>
|
||||
<option value="">Todos</option>
|
||||
{data[key] && !choices.some((o) => o.value === String(data[key])) && (
|
||||
<option value={String(data[key])}>Selecção indisponível neste contexto — remova o filtro</option>
|
||||
)}
|
||||
{data[key] &&
|
||||
!choices.some((o) => o.value === String(data[key])) && (
|
||||
<option value={String(data[key])}>
|
||||
Selecção indisponível neste contexto — remova o
|
||||
filtro
|
||||
</option>
|
||||
)}
|
||||
{choices.map((o) => (
|
||||
<option key={o.value} value={o.value}>
|
||||
{o.label}
|
||||
@@ -114,7 +136,9 @@ export default function OpportunitySearchFilters({
|
||||
{choices.length === 0
|
||||
? specialisedEmpty[key]
|
||||
: `${choices.length} opções públicas disponíveis, mesmo sem oportunidades associadas.`}
|
||||
{key === 'subsector_id' && choices.length > 0 && ' Classificação de actividades; não confirma a existência de investimentos nesta localização.'}
|
||||
{key === 'subsector_id' &&
|
||||
choices.length > 0 &&
|
||||
' Classificação de actividades; não confirma a existência de investimentos nesta localização.'}
|
||||
</p>
|
||||
)}
|
||||
{hint && <p className="text-sm text-slate-600">{hint}</p>}
|
||||
@@ -200,306 +224,394 @@ export default function OpportunitySearchFilters({
|
||||
);
|
||||
return (
|
||||
<form
|
||||
className="space-y-5 rounded-xl border bg-white p-4 sm:p-6"
|
||||
className="catalogue-filters"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
submit();
|
||||
}}
|
||||
aria-label="Pesquisar oportunidades"
|
||||
>
|
||||
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
|
||||
<Field label="O que procura">
|
||||
<input
|
||||
className={input}
|
||||
value={String(data.q)}
|
||||
placeholder="Palavras do título ou da descrição"
|
||||
onChange={(e) => change({ q: e.target.value })}
|
||||
/>
|
||||
</Field>
|
||||
{select('perspective', [{value:'exists',label:'O que existe'},{value:'needs',label:'Necessidades identificadas'},{value:'ideas',label:'Ideias de investimento'},{value:'opportunities',label:'Oportunidades cadastradas — disponibilidade na ficha'}])}
|
||||
{select('sector', choicesFor('sector'))}
|
||||
{select('category', choicesFor('category'))}
|
||||
</div>
|
||||
<fieldset className="grid gap-3 sm:grid-cols-2 lg:grid-cols-4">
|
||||
<legend className="mb-2 font-semibold">Localização</legend>
|
||||
{(
|
||||
[
|
||||
'province_id',
|
||||
'district_id',
|
||||
'admin_post_id',
|
||||
'locality_id',
|
||||
] as const
|
||||
).map((key, index) => (
|
||||
<TerritoryLevel
|
||||
key={`${key}-${path[index - 1]?.id ?? ''}`}
|
||||
index={index}
|
||||
parent={path[index - 1]?.id ?? ''}
|
||||
selected={path[index]}
|
||||
endpoint="/api/v1/investment/territory-options"
|
||||
onChange={(value) =>
|
||||
territory([
|
||||
...path.slice(0, index),
|
||||
...(value ? [value] : []),
|
||||
])
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</fieldset>
|
||||
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
||||
<Field label="Estado de preparação">
|
||||
<select
|
||||
className={input}
|
||||
value={String(data.preparation ?? '')}
|
||||
onChange={(e) =>
|
||||
change({
|
||||
preparation: e.target.value,
|
||||
maturity_level: '',
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="">Todos os estados</option>
|
||||
{[
|
||||
'Etapas de preparação',
|
||||
'Classificações históricas',
|
||||
].map((group) => (
|
||||
<optgroup key={group} label={group}>
|
||||
{(references.preparationOptions ?? [])
|
||||
.filter((o) => o.group === group)
|
||||
.map((o) => (
|
||||
<option key={o.value} value={o.value}>
|
||||
{o.label}
|
||||
</option>
|
||||
))}
|
||||
</optgroup>
|
||||
))}
|
||||
</select>
|
||||
<p className="text-sm text-slate-600">
|
||||
Os registos históricos são apresentados separadamente e
|
||||
conservam a classificação indicada na ficha.
|
||||
</p>
|
||||
</Field>
|
||||
{(['min_amount', 'max_amount'] as const).map((key) => (
|
||||
<Field key={key} label={labels[key]}>
|
||||
<input
|
||||
className={input}
|
||||
type="number"
|
||||
min="0"
|
||||
step="0.01"
|
||||
value={String(data[key])}
|
||||
onChange={(e) => change({ [key]: e.target.value })}
|
||||
/>
|
||||
</Field>
|
||||
))}
|
||||
{select(
|
||||
'currency',
|
||||
['MZN', 'USD', 'EUR', 'ZAR'].map((c) => ({
|
||||
value: c,
|
||||
label: c,
|
||||
})),
|
||||
'Seleccione uma moeda para comparar montantes. Não se efectuam conversões cambiais.',
|
||||
<button
|
||||
type="button"
|
||||
className="catalogue-filters-toggle"
|
||||
aria-expanded={expanded}
|
||||
aria-controls="catalogue-filter-fields"
|
||||
onClick={() => setExpanded((value) => !value)}
|
||||
>
|
||||
<SlidersHorizontal size={18} aria-hidden="true" />
|
||||
<span>Filtros</span>
|
||||
{active.length + path.length > 0 && (
|
||||
<span className="catalogue-count">
|
||||
{active.length + path.length}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<details>
|
||||
<summary className="cursor-pointer rounded border p-3 font-semibold focus-visible:outline-2">
|
||||
Mais filtros
|
||||
</summary>
|
||||
<div className="mt-4 grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{[
|
||||
'corridor_id',
|
||||
'cluster_id',
|
||||
'zee_id',
|
||||
'zfi_id',
|
||||
'park_id',
|
||||
'project_id',
|
||||
'subsector_id',
|
||||
'chain_id',
|
||||
].map((key) => select(key, choicesFor(key)))}
|
||||
<Field label="Data-alvo até">
|
||||
<ChevronDown size={18} aria-hidden="true" />
|
||||
</button>
|
||||
<h2 className="catalogue-filters-heading">
|
||||
<SlidersHorizontal size={17} aria-hidden="true" />
|
||||
Filtros
|
||||
</h2>
|
||||
<div
|
||||
id="catalogue-filter-fields"
|
||||
className={`${expanded ? 'block' : 'hidden'} space-y-5 lg:block`}
|
||||
>
|
||||
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-1">
|
||||
<Field label="O que procura">
|
||||
<input
|
||||
className={input}
|
||||
type="date"
|
||||
value={String(data.before)}
|
||||
onChange={(e) => change({ before: e.target.value })}
|
||||
value={String(data.q)}
|
||||
placeholder="Palavras do título ou da descrição"
|
||||
onChange={(e) => change({ q: e.target.value })}
|
||||
/>
|
||||
</Field>
|
||||
{select('perspective', [
|
||||
{ value: 'exists', label: 'O que existe' },
|
||||
{ value: 'needs', label: 'Necessidades identificadas' },
|
||||
{ value: 'ideas', label: 'Ideias de investimento' },
|
||||
{
|
||||
value: 'opportunities',
|
||||
label: 'Oportunidades cadastradas — disponibilidade na ficha',
|
||||
},
|
||||
])}
|
||||
{select('sector', choicesFor('sector'))}
|
||||
{select('category', choicesFor('category'))}
|
||||
</div>
|
||||
<p className="my-3 text-sm">
|
||||
Estes filtros procuram associações documentadas. Estar perto
|
||||
de um parque ou no mesmo distrito não constitui associação,
|
||||
nem confirma incentivos ou disponibilidade.
|
||||
</p>
|
||||
<label className="flex gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={Boolean(data.include_national)}
|
||||
onChange={(e) =>
|
||||
change({ include_national: e.target.checked })
|
||||
}
|
||||
/>
|
||||
Incluir oportunidades de âmbito nacional
|
||||
</label>
|
||||
<details className="mt-3">
|
||||
<summary className="cursor-pointer font-medium">
|
||||
Outras características
|
||||
</summary>
|
||||
<div className="mt-3 grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
|
||||
<CatalogueFilterGroup title="Localização" count={path.length}>
|
||||
<p className="text-sm leading-relaxed text-slate-600">
|
||||
A província inclui as oportunidades dos seus distritos,
|
||||
postos administrativos e localidades. Não é necessário
|
||||
escolher todos os níveis. O contexto provincial de um
|
||||
corredor é identificado nos resultados; não confirma uma
|
||||
implantação distrital.
|
||||
</p>
|
||||
<fieldset className="grid gap-3 sm:grid-cols-2 lg:grid-cols-1">
|
||||
<legend className="sr-only">Localização</legend>
|
||||
{(
|
||||
[
|
||||
'province_id',
|
||||
'district_id',
|
||||
'admin_post_id',
|
||||
'locality_id',
|
||||
] as const
|
||||
).map((key, index) => (
|
||||
<TerritoryLevel
|
||||
key={`${key}-${path[index - 1]?.id ?? ''}`}
|
||||
index={index}
|
||||
parent={path[index - 1]?.id ?? ''}
|
||||
selected={path[index]}
|
||||
endpoint="/api/v1/investment/territory-options"
|
||||
onChange={(value) =>
|
||||
territory([
|
||||
...path.slice(0, index),
|
||||
...(value ? [value] : []),
|
||||
])
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</fieldset>
|
||||
</CatalogueFilterGroup>
|
||||
<CatalogueFilterGroup
|
||||
title="Preparação e investimento"
|
||||
count={
|
||||
[
|
||||
'preparation',
|
||||
'min_amount',
|
||||
'max_amount',
|
||||
'currency',
|
||||
].filter((key) => data[key]).length
|
||||
}
|
||||
>
|
||||
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-1">
|
||||
<Field label="Estado de preparação">
|
||||
<select
|
||||
className={input}
|
||||
value={String(data.preparation ?? '')}
|
||||
onChange={(e) =>
|
||||
change({
|
||||
preparation: e.target.value,
|
||||
maturity_level: '',
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="">Todos os estados</option>
|
||||
{[
|
||||
'Etapas de preparação',
|
||||
'Classificações históricas',
|
||||
].map((group) => (
|
||||
<optgroup key={group} label={group}>
|
||||
{(references.preparationOptions ?? [])
|
||||
.filter((o) => o.group === group)
|
||||
.map((o) => (
|
||||
<option
|
||||
key={o.value}
|
||||
value={o.value}
|
||||
>
|
||||
{o.label}
|
||||
</option>
|
||||
))}
|
||||
</optgroup>
|
||||
))}
|
||||
</select>
|
||||
<p className="text-sm text-slate-600">
|
||||
Os registos históricos são apresentados
|
||||
separadamente e conservam a classificação
|
||||
indicada na ficha.
|
||||
</p>
|
||||
</Field>
|
||||
{(['min_amount', 'max_amount'] as const).map((key) => (
|
||||
<Field key={key} label={labels[key]}>
|
||||
<input
|
||||
className={input}
|
||||
type="number"
|
||||
min="0"
|
||||
step="0.01"
|
||||
value={String(data[key])}
|
||||
onChange={(e) =>
|
||||
change({ [key]: e.target.value })
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
))}
|
||||
{select(
|
||||
'currency',
|
||||
['MZN', 'USD', 'EUR', 'ZAR'].map((c) => ({
|
||||
value: c,
|
||||
label: c,
|
||||
})),
|
||||
'Seleccione uma moeda para comparar montantes. Não se efectuam conversões cambiais.',
|
||||
)}
|
||||
</div>
|
||||
</CatalogueFilterGroup>
|
||||
<CatalogueFilterGroup
|
||||
title="Mais filtros"
|
||||
expandedTitle="Menos filtros"
|
||||
count={
|
||||
active.filter(([key]) =>
|
||||
[
|
||||
'corridor_id',
|
||||
'cluster_id',
|
||||
'zee_id',
|
||||
'zfi_id',
|
||||
'park_id',
|
||||
'project_id',
|
||||
'subsector_id',
|
||||
'chain_id',
|
||||
'before',
|
||||
'include_national',
|
||||
'facets',
|
||||
].includes(key),
|
||||
).length
|
||||
}
|
||||
>
|
||||
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-1">
|
||||
{[
|
||||
'education',
|
||||
'infrastructure',
|
||||
'labour',
|
||||
'qualification',
|
||||
'support',
|
||||
'impact',
|
||||
'partnership',
|
||||
]
|
||||
.filter((group) =>
|
||||
references.options.some(
|
||||
(o) => o.group === group,
|
||||
),
|
||||
)
|
||||
.map((group) => (
|
||||
<fieldset
|
||||
key={group}
|
||||
className="rounded border p-3"
|
||||
>
|
||||
<legend>{groupLabels[group]}</legend>
|
||||
{references.options
|
||||
.filter((o) => o.group === group)
|
||||
.map((option) => (
|
||||
<label
|
||||
key={option.id}
|
||||
className="flex gap-2 py-1"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={
|
||||
Array.isArray(
|
||||
data.facets,
|
||||
) &&
|
||||
data.facets.includes(
|
||||
option.id,
|
||||
)
|
||||
}
|
||||
onChange={(e) => {
|
||||
const selected =
|
||||
'corridor_id',
|
||||
'cluster_id',
|
||||
'zee_id',
|
||||
'zfi_id',
|
||||
'park_id',
|
||||
'project_id',
|
||||
'subsector_id',
|
||||
'chain_id',
|
||||
].map((key) => select(key, choicesFor(key)))}
|
||||
<Field label="Data-alvo até">
|
||||
<input
|
||||
className={input}
|
||||
type="date"
|
||||
value={String(data.before)}
|
||||
onChange={(e) =>
|
||||
change({ before: e.target.value })
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
</div>
|
||||
<p className="my-3 text-sm">
|
||||
Estes filtros procuram associações documentadas. Estar
|
||||
perto de um parque ou no mesmo distrito não constitui
|
||||
associação, nem confirma incentivos ou disponibilidade.
|
||||
</p>
|
||||
<label className="flex gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={Boolean(data.include_national)}
|
||||
onChange={(e) =>
|
||||
change({ include_national: e.target.checked })
|
||||
}
|
||||
/>
|
||||
Incluir oportunidades de âmbito nacional
|
||||
</label>
|
||||
<details className="mt-3">
|
||||
<summary className="cursor-pointer font-medium">
|
||||
Outras características
|
||||
</summary>
|
||||
<div className="mt-3 grid gap-3 sm:grid-cols-2 lg:grid-cols-1">
|
||||
{[
|
||||
'education',
|
||||
'infrastructure',
|
||||
'labour',
|
||||
'qualification',
|
||||
'support',
|
||||
'impact',
|
||||
'partnership',
|
||||
]
|
||||
.filter((group) =>
|
||||
references.options.some(
|
||||
(o) => o.group === group,
|
||||
),
|
||||
)
|
||||
.map((group) => (
|
||||
<fieldset
|
||||
key={group}
|
||||
className="rounded border p-3"
|
||||
>
|
||||
<legend>{groupLabels[group]}</legend>
|
||||
{references.options
|
||||
.filter((o) => o.group === group)
|
||||
.map((option) => (
|
||||
<label
|
||||
key={option.id}
|
||||
className="flex gap-2 py-1"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={
|
||||
Array.isArray(
|
||||
data.facets,
|
||||
) &&
|
||||
data.facets.includes(
|
||||
option.id,
|
||||
)
|
||||
? data.facets
|
||||
: [];
|
||||
change({
|
||||
facets: e.target
|
||||
.checked
|
||||
? [
|
||||
...selected,
|
||||
option.id,
|
||||
]
|
||||
: selected.filter(
|
||||
(id) =>
|
||||
id !==
|
||||
}
|
||||
onChange={(e) => {
|
||||
const selected =
|
||||
Array.isArray(
|
||||
data.facets,
|
||||
)
|
||||
? data.facets
|
||||
: [];
|
||||
change({
|
||||
facets: e.target
|
||||
.checked
|
||||
? [
|
||||
...selected,
|
||||
option.id,
|
||||
),
|
||||
});
|
||||
}}
|
||||
/>
|
||||
{option.label}
|
||||
</label>
|
||||
))}
|
||||
</fieldset>
|
||||
))}
|
||||
</div>
|
||||
</details>
|
||||
</details>
|
||||
<section
|
||||
aria-label="Filtros activos"
|
||||
className="flex flex-wrap gap-2"
|
||||
>
|
||||
{path.map((node, index) => (
|
||||
<button
|
||||
className="rounded border px-3 py-2"
|
||||
type="button"
|
||||
key={node.id}
|
||||
aria-label={`Remover localização ${node.name}`}
|
||||
onClick={() => territory(path.slice(0, index))}
|
||||
>
|
||||
{node.name} ×
|
||||
</button>
|
||||
))}
|
||||
{active.flatMap(([key, value]) =>
|
||||
key === 'facets' && Array.isArray(value)
|
||||
? value.map((id) => (
|
||||
<button
|
||||
key={`facet-${id}`}
|
||||
type="button"
|
||||
className="rounded border px-3 py-2"
|
||||
onClick={() =>
|
||||
change({
|
||||
facets: value.filter((x) => x !== id),
|
||||
})
|
||||
}
|
||||
>
|
||||
{' '}
|
||||
{references.options.find((o) => o.id === id)
|
||||
?.label ?? 'Critério adicional'}{' '}
|
||||
×
|
||||
</button>
|
||||
))
|
||||
: [
|
||||
<button
|
||||
key={key}
|
||||
type="button"
|
||||
className="rounded border px-3 py-2 text-left"
|
||||
aria-label={`Remover ${labels[key] ?? 'critério adicional'}`}
|
||||
onClick={() => remove(key)}
|
||||
>
|
||||
{labels[key] ?? 'Critério adicional'}:{' '}
|
||||
{typeof value === 'boolean'
|
||||
? 'Sim'
|
||||
: (choicesFor(key).find(
|
||||
(o) => o.value === String(value),
|
||||
)?.label ??
|
||||
([
|
||||
'q',
|
||||
'min_amount',
|
||||
'max_amount',
|
||||
'currency',
|
||||
'before',
|
||||
'province',
|
||||
'district',
|
||||
].includes(key)
|
||||
? String(value)
|
||||
: 'seleccionado'))}{' '}
|
||||
×
|
||||
</button>,
|
||||
],
|
||||
)}
|
||||
</section>
|
||||
{Object.entries(errors).map(([key, value]) => (
|
||||
<p key={key} role="alert">
|
||||
{value}
|
||||
</p>
|
||||
))}
|
||||
<div className="flex flex-wrap items-end gap-4">
|
||||
{select('sort', [
|
||||
{ value: 'recent', label: 'Mais recentes' },
|
||||
{ value: 'title', label: 'Título' },
|
||||
{
|
||||
value: 'amount_asc',
|
||||
label: 'Montante crescente, por moeda',
|
||||
},
|
||||
{
|
||||
value: 'amount_desc',
|
||||
label: 'Montante decrescente, por moeda',
|
||||
},
|
||||
])}
|
||||
<button className={button}>Pesquisar</button>
|
||||
<button
|
||||
type="button"
|
||||
className="rounded border px-4 py-2 underline"
|
||||
onClick={clear}
|
||||
]
|
||||
: selected.filter(
|
||||
(
|
||||
id,
|
||||
) =>
|
||||
id !==
|
||||
option.id,
|
||||
),
|
||||
});
|
||||
}}
|
||||
/>
|
||||
{option.label}
|
||||
</label>
|
||||
))}
|
||||
</fieldset>
|
||||
))}
|
||||
</div>
|
||||
</details>
|
||||
</CatalogueFilterGroup>
|
||||
<section
|
||||
aria-label="Filtros activos"
|
||||
className="catalogue-active-filters flex flex-wrap gap-2"
|
||||
>
|
||||
Limpar filtros
|
||||
</button>
|
||||
{path.map((node, index) => (
|
||||
<button
|
||||
className="rounded border px-3 py-2"
|
||||
type="button"
|
||||
key={node.id}
|
||||
aria-label={`Remover localização ${node.name}`}
|
||||
onClick={() => territory(path.slice(0, index))}
|
||||
>
|
||||
{node.name} ×
|
||||
</button>
|
||||
))}
|
||||
{active.flatMap(([key, value]) =>
|
||||
key === 'facets' && Array.isArray(value)
|
||||
? value.map((id) => (
|
||||
<button
|
||||
key={`facet-${id}`}
|
||||
type="button"
|
||||
className="rounded border px-3 py-2"
|
||||
onClick={() =>
|
||||
change({
|
||||
facets: value.filter(
|
||||
(x) => x !== id,
|
||||
),
|
||||
})
|
||||
}
|
||||
>
|
||||
{' '}
|
||||
{references.options.find(
|
||||
(o) => o.id === id,
|
||||
)?.label ?? 'Critério adicional'}{' '}
|
||||
×
|
||||
</button>
|
||||
))
|
||||
: [
|
||||
<button
|
||||
key={key}
|
||||
type="button"
|
||||
className="rounded border px-3 py-2 text-left"
|
||||
aria-label={`Remover ${labels[key] ?? 'critério adicional'}`}
|
||||
onClick={() => remove(key)}
|
||||
>
|
||||
{labels[key] ?? 'Critério adicional'}:{' '}
|
||||
{typeof value === 'boolean'
|
||||
? 'Sim'
|
||||
: (choicesFor(key).find(
|
||||
(o) =>
|
||||
o.value === String(value),
|
||||
)?.label ??
|
||||
([
|
||||
'q',
|
||||
'min_amount',
|
||||
'max_amount',
|
||||
'currency',
|
||||
'before',
|
||||
'province',
|
||||
'district',
|
||||
].includes(key)
|
||||
? String(value)
|
||||
: 'seleccionado'))}{' '}
|
||||
×
|
||||
</button>,
|
||||
],
|
||||
)}
|
||||
</section>
|
||||
{Object.entries(errors).map(([key, value]) => (
|
||||
<p key={key} role="alert">
|
||||
{value}
|
||||
</p>
|
||||
))}
|
||||
<div className="catalogue-filter-submit grid gap-3">
|
||||
{select('sort', [
|
||||
{ value: 'recent', label: 'Mais recentes' },
|
||||
{ value: 'title', label: 'Título' },
|
||||
{
|
||||
value: 'amount_asc',
|
||||
label: 'Montante crescente, por moeda',
|
||||
},
|
||||
{
|
||||
value: 'amount_desc',
|
||||
label: 'Montante decrescente, por moeda',
|
||||
},
|
||||
])}
|
||||
<button className={button}>
|
||||
<Search size={16} aria-hidden="true" />
|
||||
Pesquisar
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="rounded border px-4 py-2 underline"
|
||||
onClick={clear}
|
||||
>
|
||||
Limpar filtros
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import {SimulationIrpcInternational} from './simulation-irpc-international';
|
||||
import {SimulationIrpcPec} from './simulation-irpc-pec';
|
||||
import {useState} from 'react';
|
||||
import {annualBook,newAnnualBook,saveAnnualBook,reuseAnnualAssessment,annualAssessment,annualWithholdingOptions,reuseAnnualWithholding,newAnnualPpc,recordAnnual,annualReportRows,annualHtml,annualSource,type AnnualBook,type AnnualPpc} from '@/lib/irpc-annual-settlement';
|
||||
@@ -19,7 +20,7 @@ export function SimulationIrpcAnnual({draft,onChange}:Props){
|
||||
{b.withholdings.rows.map((r,index)=>{const change=(p:Partial<typeof r>)=>patch({withholdings:{...b.withholdings,rows:b.withholdings.rows.map(x=>x.id===r.id?{...x,...p}:x)}});return<fieldset key={r.id} className="rounded border p-2"><legend>Retenção seleccionada {index+1}</legend><p>Rendimento:{r.rowId};prova:{r.paymentId};NUIT:{r.subjectNuit};exercício:{r.year}. Fonte conservada. Se mudou, retire esta selecção e seleccione a prova actual. O histórico mantém-se.</p><label className="block">Parcela a abater<input aria-label={'Parcela da retenção L8 '+(index+1)} value={r.amount} onChange={e=>change({amount:e.target.value})}/></label><label className="block">O próprio sujeito é beneficiário e o rendimento está incluído na base deste exercício<select aria-label={'Rendimento incluído L8 '+(index+1)} value={r.incomeIncluded} onChange={e=>change({incomeIncluded:e.target.value as ''|'yes'|'no'})}><option value="">Informação em falta</option><option value="yes">Sim — documentado</option><option value="no">Não — crédito não aplicável neste fecho</option></select></label><label className="block">Suporte da titularidade e inclusão<input aria-label={'Suporte da retenção L8 '+(index+1)} value={r.reference} onChange={e=>change({reference:e.target.value})}/></label><button type="button" onClick={()=>patch({withholdings:{...b.withholdings,rows:b.withholdings.rows.filter(x=>x.id!==r.id)}})}>Retirar selecção L8 da retenção {index+1}</button></fieldset>;})}</fieldset>
|
||||
<fieldset className="space-y-2 rounded border p-3"><legend>PPC efectivamente pagos</legend>{group('ppc','PPC efectuados')}<p>Regista comprovativos de pagamentos por conta; não calcula automaticamente a obrigação PPC nem usa pagamentos previstos no plano.</p><button type="button" onClick={()=>patch({ppc:{...b.ppc,rows:[...b.ppc.rows,{...newAnnualPpc(crypto.randomUUID()),subjectNuit:b.subjectNuit,year:b.year}]}})}>Registar comprovativo PPC</button>
|
||||
{b.ppc.rows.map((r,index)=>{const change=(p:Partial<AnnualPpc>)=>patch({ppc:{...b.ppc,rows:b.ppc.rows.map(x=>x.id===r.id?{...x,...p}:x)}});return<fieldset key={r.id} className="rounded border p-2"><legend>PPC {index+1}</legend>{([['document','Comprovativo'],['issuer','Emitente'],['date','Data (AAAA-MM-DD)'],['subjectNuit','NUIT beneficiário'],['year','Exercício do comprovativo'],['currency','Moeda do comprovativo'],['proofAmount','Montante comprovado'],['amount','Parcela a abater'],['reference','Suporte do pagamento e afectação']]as const).map(([key,label])=><label key={key} className="block">{label}<input aria-label={'PPC L8 '+(index+1)+' — '+label} value={r[key]} onChange={e=>change({[key]:e.target.value})}/></label>)}<label className="block">Pagamento efectivamente comprovado<select aria-label={'PPC L8 '+(index+1)+' — Efectivo'} value={r.effective} onChange={e=>change({effective:e.target.value as ''|'yes'|'no'})}><option value="">Informação em falta</option><option value="yes">Sim — comprovativo reconciliado</option><option value="no">Não — apenas previsão/outro estado</option></select></label><button type="button" onClick={()=>patch({ppc:{...b.ppc,rows:b.ppc.rows.filter(x=>x.id!==r.id)}})}>Retirar PPC {index+1}</button></fieldset>;})}</fieldset>
|
||||
<SimulationIrpcPec book={b} save={save}/>{([...(b.pecPayments?[]:[['pec','PEC']as const]),['credits','Créditos com regras próprias']as const]).map(([key,label])=><fieldset key={key} className="rounded border p-3"><legend>{label} — tratamento separado</legend><label className="block">Estado — {label}<select aria-label={'Estado L8 — '+label} value={b[key].state} onChange={e=>patch({[key]:{...b[key],state:e.target.value as ''|'known'|'absent'}})}><option value="">Informação em falta</option><option value="absent">Ausência declarada com suporte</option><option value="known">Valor conhecido — positivo exige regra própria</option></select></label>{(b[key].state==='known'||b[key].amount)&&<label className="block">Montante declarado<input aria-label={'Montante L8 — '+label} value={b[key].amount} onChange={e=>patch({[key]:{...b[key],amount:e.target.value}})}/></label>}<label className="block">Suporte<input aria-label={'Suporte L8 — '+label} value={b[key].reference} onChange={e=>patch({[key]:{...b[key],reference:e.target.value}})}/></label></fieldset>)}
|
||||
<SimulationIrpcInternational book={b} save={save}/><SimulationIrpcPec book={b} save={save}/>{([...(b.pecPayments?[]:[['pec','PEC']as const]),...(b.internationalCredits?[]:[['credits','Créditos com regras próprias']as const])]).map(([key,label])=><fieldset key={key} className="rounded border p-3"><legend>{label} — tratamento separado</legend><label className="block">Estado — {label}<select aria-label={'Estado L8 — '+label} value={b[key].state} onChange={e=>patch({[key]:{...b[key],state:e.target.value as ''|'known'|'absent'}})}><option value="">Informação em falta</option><option value="absent">Ausência declarada com suporte</option><option value="known">Valor conhecido — positivo exige regra própria</option></select></label>{(b[key].state==='known'||b[key].amount)&&<label className="block">Montante declarado<input aria-label={'Montante L8 — '+label} value={b[key].amount} onChange={e=>patch({[key]:{...b[key],amount:e.target.value}})}/></label>}<label className="block">Suporte<input aria-label={'Suporte L8 — '+label} value={b[key].reference} onChange={e=>patch({[key]:{...b[key],reference:e.target.value}})}/></label></fieldset>)}
|
||||
<button type="button" onClick={()=>{try{save(recordAnnual(draft,b));}catch(e){setError(String(e));}}}>Calcular e guardar saldo anual L8</button><button type="button" onClick={()=>{try{const html=annualHtml(draft),url=URL.createObjectURL(new Blob([html],{type:'text/html;charset=utf-8'})),link=document.createElement('a');link.href=url;link.download='IRPC-L8-saldo-simulado.html';link.click();URL.revokeObjectURL(url);setError('');}catch(e){setError(String(e));}}}>Exportar saldo anual L8</button>
|
||||
{annualReportRows(draft).map((r,n)=><p key={n}>{r[1]} — {r[2]} — {r[3]}</p>)}</section>;
|
||||
}catch(e){return<p role="alert">PreparaçãoL8 não recuperável:{String(e)}. Originais e históricos conservados.</p>;}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
import CountrySelect, {type Country} from '@/components/country-select';
|
||||
import {countryIsoCodes} from '@/lib/country-iso-codes';
|
||||
import {newInternationalProof, prepareInternationalBook, type AnnualBook} from '@/lib/irpc-annual-settlement';
|
||||
import {newInternationalPosition, internationalCreditSource, type CreditEvidence, type InternationalCredits, type InternationalPosition, type InternationalTaxProof} from '@/lib/irpc-international-credit';
|
||||
|
||||
const pt = new Intl.DisplayNames(['pt'], {type: 'region'}), en = new Intl.DisplayNames(['en'], {type: 'region'});
|
||||
const countries: Country[] = countryIsoCodes.filter(code => code !== 'MZ').map(code => ({code, name: pt.of(code) ?? code, name_en: en.of(code) ?? code})).sort((a, b) => a.name.localeCompare(b.name, 'pt'));
|
||||
function Evidence({value, label, change}: {value: CreditEvidence; label: string; change: (value: CreditEvidence) => void}) {
|
||||
return <fieldset className="rounded border p-2"><legend>{label}</legend>
|
||||
<label className="block">Estado<select aria-label={label + ' — Estado'} value={value.state} onChange={e => change({...value, state: e.target.value as CreditEvidence['state']})}><option value="">Informação em falta</option><option value="known">Valor conhecido</option><option value="absent">Ausência declarada</option></select></label>
|
||||
{(value.state === 'known' || value.amount) && <label className="block">Montante MZN<input aria-label={label + ' — Montante'} value={value.amount} onChange={e => change({...value, amount: e.target.value})}/></label>}
|
||||
<label className="block">Suporte<input aria-label={label + ' — Suporte'} value={value.reference} onChange={e => change({...value, reference: e.target.value})}/></label>
|
||||
</fieldset>;
|
||||
}
|
||||
export function SimulationIrpcInternational({book, save}: {book: AnnualBook; save: (book: AnnualBook) => void}) {
|
||||
const c = book.internationalCredits;
|
||||
if (!c) return <fieldset className="rounded border p-3"><legend>Crédito internacional — próprio exercício</legend><p>Prepare a inclusão do imposto estrangeiro comprovado e dos limites documentados, antes do PEC. O resumo anterior de créditos e os históricos ficam conservados. A escolha do país não confirma uma convenção ou benefício.</p><button type="button" onClick={() => save(prepareInternationalBook(book))}>Preparar crédito internacional</button></fieldset>;
|
||||
const update = (next: InternationalCredits) => save({...book, internationalCredits: next});
|
||||
const positionChange = (p: InternationalPosition) => update({...c, positions: c.positions.map(x => x.id === p.id ? p : x)});
|
||||
return <fieldset className="space-y-3 rounded border p-3"><legend>Crédito por dupla tributação internacional</legend>
|
||||
<p>{internationalCreditSource}</p>
|
||||
<p>Reúna os comprovativos de cada país numa posição por exercício. Indique a fracção nacional e a convenção conforme o suporte do caso. Limites admitem decimal ou fracção exacta n/d; a apresentação não constitui arredondamento fiscal. Valores MZN exigem correspondência documental; uma previsão de câmbio ou de pagamento não comprova o crédito.</p>
|
||||
<label className="block">Estado internacional<select aria-label="Estado do crédito internacional L8" value={c.state} onChange={e => update({...c, state: e.target.value as InternationalCredits['state']})}><option value="">Informação em falta</option><option value="known">Posições conhecidas</option><option value="absent">Ausência declarada</option></select></label>
|
||||
<label className="block">Suporte do inventário<input aria-label="Suporte do crédito internacional L8" value={c.reference} onChange={e => update({...c, reference: e.target.value})}/></label>
|
||||
<Evidence label="Crédito económico — regra própria" value={c.economic} change={economic => update({...c, economic})}/>
|
||||
<Evidence label="Benefícios/créditos próprios — regra própria" value={c.benefits} change={benefits => update({...c, benefits})}/>
|
||||
<p>Créditos económicos e benefícios positivos exigem regras próprias; informação em falta mantém o saldo dependente indeterminado.</p>
|
||||
<button type="button" onClick={() => update({...c, state: 'known', positions: [...c.positions, {...newInternationalPosition(crypto.randomUUID()), subjectNuit: book.subjectNuit, year: book.year, assessmentKey: book.assessmentKey}]})}>Registar posição internacional</button>
|
||||
{c.positions.map((p, index) => {
|
||||
const patch = (v: Partial<InternationalPosition>) => positionChange({...p, ...v});
|
||||
const paymentChange = (r: InternationalTaxProof) => patch({payments: p.payments.map(x => x.id === r.id ? r : x)});
|
||||
return <fieldset key={p.id} className="space-y-2 rounded border p-3"><legend>Posição internacional {index + 1}</legend>
|
||||
<CountrySelect countries={countries} label={'País do imposto estrangeiro ' + (index + 1)} value={p.country} onChange={country => patch({country})} allowLegacyValue/>
|
||||
{([['subjectNuit', 'NUIT titular'], ['year', 'Exercício'], ['incomeAmount', 'Rendimento incluído — MZN'], ['incomeReference', 'Suporte da inclusão na matéria colectável'], ['nationalLimit', 'Fracção nacional correspondente — MZN'], ['nationalLimitReference', 'Suporte da fracção nacional e exercício']] as const).map(([key, label]) => <label key={key} className="block">{label}<input aria-label={'Internacional ' + (index + 1) + ' — ' + label} value={p[key]} onChange={e => patch({[key]: e.target.value})}/></label>)}
|
||||
<label className="block">Rendimento incluído na matéria colectável<select aria-label={'Internacional ' + (index + 1) + ' — Inclusão'} value={p.incomeIncluded} onChange={e => patch({incomeIncluded: e.target.value as InternationalPosition['incomeIncluded']})}><option value="">Informação em falta</option><option value="yes">Sim — documentado</option><option value="no">Não — crédito não aplicável nesta base</option></select></label>
|
||||
<button type="button" onClick={() => patch({assessmentKey: book.assessmentKey, qualificationCountry: p.country})}>Vincular inclusão e limites ao país e à colecta seleccionados</button>
|
||||
<label className="block">Convenção aplicável<select aria-label={'Internacional ' + (index + 1) + ' — Convenção'} value={p.treaty} onChange={e => patch({treaty: e.target.value as InternationalPosition['treaty']})}><option value="">Informação em falta</option><option value="yes">Sim — artigo, período e limite documentados</option><option value="no">Não — ausência de aplicação documentada</option></select></label>
|
||||
{(p.treaty === 'yes' || p.treatyLimit) && <label className="block">Imposto pago elegível nos termos da convenção — limite MZN<input aria-label={'Internacional ' + (index + 1) + ' — Limite CDT'} value={p.treatyLimit} onChange={e => patch({treatyLimit: e.target.value})}/></label>}
|
||||
<label className="block">Suporte da convenção ou da não aplicação<input aria-label={'Internacional ' + (index + 1) + ' — Suporte CDT'} value={p.treatyReference} onChange={e => patch({treatyReference: e.target.value})}/></label>
|
||||
<Evidence label={'Utilização anterior do crédito — país ' + (index + 1)} value={p.previousUse} change={previousUse => patch({previousUse})}/>
|
||||
<p>Utilização anterior é crédito já deduzido e documentado. Não é a soma de simulações históricas nem o imposto pago acima dos limites.</p>
|
||||
<button type="button" onClick={() => patch({payments: [...p.payments, {...newInternationalProof(crypto.randomUUID()), subjectNuit: p.subjectNuit, year: p.year}]})}>Registar imposto estrangeiro na posição {index + 1}</button>
|
||||
{p.payments.map((r, ri) => {
|
||||
const change = (v: Partial<InternationalTaxProof>) => paymentChange({...r, ...v});
|
||||
return <fieldset key={r.id} className="rounded border p-2"><legend>Imposto estrangeiro {index + 1}.{ri + 1}</legend>
|
||||
{([['document', 'Comprovativo'], ['issuer', 'Emitente'], ['date', 'Data (AAAA-MM-DD)'], ['subjectNuit', 'NUIT titular'], ['year', 'Exercício do pagamento'], ['currency', 'Moeda'], ['proofAmount', 'Total comprovado — MZN'], ['amount', 'Parcela de imposto seleccionado — MZN'], ['reference', 'Suporte do pagamento e afectação'], ['taxReference', 'Suporte da natureza de imposto sobre o rendimento']] as const).map(([key, label]) => <label key={key} className="block">{label}<input aria-label={'Imposto estrangeiro ' + (index + 1) + '.' + (ri + 1) + ' — ' + label} value={r[key]} onChange={e => change({[key]: e.target.value})}/></label>)}
|
||||
{(r.exerciseReference || r.date && !r.date.startsWith(p.year + '-')) && <label className="block">Suporte da correspondência da data ao exercício<input aria-label={'Imposto estrangeiro ' + (index + 1) + '.' + (ri + 1) + ' — Correspondência temporal'} value={r.exerciseReference} onChange={e => change({exerciseReference: e.target.value})}/></label>}
|
||||
<label className="block">Pagamento efectivo<select aria-label={'Imposto estrangeiro ' + (index + 1) + '.' + (ri + 1) + ' — Efectivo'} value={r.effective} onChange={e => change({effective: e.target.value as InternationalTaxProof['effective']})}><option value="">Informação em falta</option><option value="yes">Sim — comprovado</option><option value="no">Não — previsão/outra situação</option></select></label>
|
||||
<label className="block">Imposto sobre o rendimento elegível<select aria-label={'Imposto estrangeiro ' + (index + 1) + '.' + (ri + 1) + ' — Natureza'} value={r.incomeTax} onChange={e => change({incomeTax: e.target.value as InternationalTaxProof['incomeTax']})}><option value="">Informação em falta</option><option value="yes">Sim — natureza documentada</option><option value="no">Não — outra natureza, sem crédito presumido</option></select></label>
|
||||
<button type="button" onClick={() => patch({payments: p.payments.filter(x => x.id !== r.id)})}>Retirar imposto estrangeiro {index + 1}.{ri + 1}</button>
|
||||
</fieldset>;
|
||||
})}
|
||||
<button type="button" onClick={() => update({...c, positions: c.positions.filter(x => x.id !== p.id)})}>Retirar posição internacional {index + 1}</button>
|
||||
</fieldset>;
|
||||
})}
|
||||
</fieldset>;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
// Derived code projection of resources/data/iso3166.tab; keep the existing PHP catalogue authoritative.
|
||||
// Source SHA256 (LF): 837c80785080c8433fd9d4ea87e78f161ac7a40389301c5153d4f90198baeb2a; regenerate with node tools/country-iso-projection.mjs
|
||||
export const countryIsoCodes = 'AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IQ IR IS IT JE JM JO JP KE KG KH KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV SX SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS YE YT ZA ZM ZW'.split(' ');
|
||||
@@ -1,3 +1,4 @@
|
||||
import {validateInternational,internationalProofValue,internationalGroupPending,internationalPosition,internationalDeduction,internationalCreditSource,newInternationalCredits,type InternationalCredits,type InternationalTaxProof} from './irpc-international-credit.ts';
|
||||
import {validatePec,pecPaymentValue,pecDeduction,pecSource,type PecPayments} from './irpc-pec.ts';
|
||||
import {normalBook,normalCurrent} from './irpc-normal.ts';
|
||||
import {irpcBook,irpcCurrent} from './irpc-withholdings.ts';
|
||||
@@ -13,11 +14,25 @@ type Group={state:State;reference:string};
|
||||
export type AnnualWithholding={id:string;rowId:string;paymentId:string;sourceKey:string;subjectNuit:string;year:string;amount:string;incomeIncluded:''|'yes'|'no';reference:string};
|
||||
export type AnnualPpc={id:string;document:string;issuer:string;date:string;subjectNuit:string;year:string;currency:string;proofAmount:string;amount:string;effective:''|'yes'|'no';reference:string};
|
||||
type AnnualRecord={version:typeof annualSettlementVersion;key:string;createdAt:string;model:AnnualModel};
|
||||
export type AnnualBook={version:1;subjectNuit:string;year:string;reference:string;assessment:''|'normal'|'special';assessmentKey:string;assessmentReference:string;withholdings:Group&{rows:AnnualWithholding[]};ppc:Group&{rows:AnnualPpc[]};pec:Evidence;pecPayments?:PecPayments;credits:Evidence;result?:AnnualRecord;history:AnnualRecord[]};
|
||||
export const annualSource=(b:AnnualBook)=>b.pecPayments?annualSettlementSource.replace('PEC/créditos positivos','Créditos próprios positivos')+' '+pecSource:annualSettlementSource;
|
||||
export type AnnualBook={version:1;subjectNuit:string;year:string;reference:string;assessment:''|'normal'|'special';assessmentKey:string;assessmentReference:string;withholdings:Group&{rows:AnnualWithholding[]};ppc:Group&{rows:AnnualPpc[]};pec:Evidence;pecPayments?:PecPayments;credits:Evidence;internationalCredits?:InternationalCredits;result?:AnnualRecord;history:AnnualRecord[]};
|
||||
export const annualSource=(b:AnnualBook)=>{
|
||||
const excluded=b.internationalCredits?(b.pecPayments?'Créditos económicos/benefícios positivos':'PEC/créditos económicos/benefícios positivos'):(b.pecPayments?'Créditos próprios positivos':'PEC/créditos positivos');
|
||||
return annualSettlementSource.replace('PEC/créditos positivos',excluded)+(b.pecPayments?' '+pecSource:'')+(b.internationalCredits?' '+internationalCreditSource:'');
|
||||
};
|
||||
export function prepareInternationalBook(b:AnnualBook):AnnualBook{
|
||||
if(b.internationalCredits)return b;
|
||||
const c=newInternationalCredits(),old=b.credits;
|
||||
if(old.state==='absent'||old.state==='known'&&old.amount==='0'){
|
||||
c.economic=structuredClone(old);c.benefits=structuredClone(old);
|
||||
if(old.state==='absent'){c.state='absent';c.reference=old.reference;}
|
||||
}
|
||||
return{...b,internationalCredits:c};
|
||||
}
|
||||
|
||||
const evidence=():Evidence=>({state:'',amount:'',reference:''});
|
||||
export const newAnnualBook=():AnnualBook=>({version:1,subjectNuit:'',year:'',reference:'',assessment:'',assessmentKey:'',assessmentReference:'',withholdings:{state:'',reference:'',rows:[]},ppc:{state:'',reference:'',rows:[]},pec:evidence(),credits:evidence(),history:[]});
|
||||
export const newAnnualPpc=(id:string):AnnualPpc=>({id,document:'',issuer:'',date:'',subjectNuit:'',year:'',currency:'MZN',proofAmount:'',amount:'',effective:'',reference:''});
|
||||
export const newInternationalProof=(id:string):InternationalTaxProof=>({...newAnnualPpc(id),incomeTax:'',taxReference:'',exerciseReference:''});
|
||||
const zero=()=>fraction(0n),cmp=(a:FiscalFraction,b:FiscalFraction)=>BigInt(a.numerator)*BigInt(b.denominator)-BigInt(b.numerator)*BigInt(a.denominator);
|
||||
const iso=(s:string)=>/^20\d{2}-\d{2}-\d{2}$/.test(s)&&Number.isFinite(Date.parse(s))&&new Date(s).toISOString().slice(0,10)===s;
|
||||
const moneyInput=(s:string)=>{if(!/^\d{1,18}(\.\d{1,2})?$/.test(s))throw Error('MontanteMZN em falta/inválido;máximo dois decimais,sem zero presumido.');return decimalFraction(s);};
|
||||
@@ -27,6 +42,7 @@ function store(d:Record<string,unknown>){const s=JSON.parse(String(d.modelo_a_sn
|
||||
function books(d:Record<string,unknown>):Record<string,AnnualBook>{const m=store(d).irpcAnnual;if(m===undefined)return{};if(!m||typeof m!=='object'||Array.isArray(m))throw Error('MapaL8 não recuperável;originais conservados.');return m;}
|
||||
export function validateAnnual(b:AnnualBook){
|
||||
if(b?.pecPayments!==undefined)validatePec(b.pecPayments);
|
||||
if(b?.internationalCredits!==undefined)validateInternational(b.internationalCredits);
|
||||
if(!b||b.version!==1||['subjectNuit','year','reference','assessmentKey','assessmentReference'].some(k=>typeof b[k as 'year']!=='string')||!['','normal','special'].includes(b.assessment)||!Array.isArray(b.history))throw Error('PreparaçãoL8 não recuperável.');
|
||||
for(const g of[b.withholdings,b.ppc,b.pec,b.credits])if(!g||!['','known','absent'].includes(g.state)||typeof g.reference!=='string')throw Error('EstadoL8 não recuperável.');
|
||||
for(const g of[b.pec,b.credits])if(typeof g.amount!=='string')throw Error('CréditoL8 não recuperável.');
|
||||
@@ -56,7 +72,7 @@ export function reuseAnnualWithholding(d:Record<string,unknown>,b:AnnualBook,row
|
||||
if(b.withholdings.rows.some(r=>r.rowId===rowId&&r.paymentId===paymentId))throw Error('Retenção/prova já seleccionada;altere a parcela existente sem duplicar.');
|
||||
return{...b,withholdings:{...b.withholdings,rows:[...b.withholdings.rows,{id,rowId,paymentId,sourceKey:o.key,subjectNuit:b.subjectNuit,year:o.year,amount:o.amount,incomeIncluded:'',reference:''}]}};
|
||||
}
|
||||
function dependencies(d:Record<string,unknown>){let normal:unknown,L5:unknown;try{const a=annualAssessment(d);normal=[a.record,a.current];}catch(e){normal=String(e);}try{const b=irpcBook(d);L5=[b.rows,b.payments,b.result,irpcCurrent(d,b)];}catch(e){L5=String(e);}return[normal,L5,Object.entries(books(d)).filter(([k])=>k!==acquisitionScope(d)).map(([k,b])=>[k,b.subjectNuit,b.year,b.withholdings,b.ppc,...(b.pecPayments?[b.pecPayments]:[])])];}
|
||||
function dependencies(d:Record<string,unknown>){let normal:unknown,L5:unknown;try{const a=annualAssessment(d);normal=[a.record,a.current];}catch(e){normal=String(e);}try{const b=irpcBook(d);L5=[b.rows,b.payments,b.result,irpcCurrent(d,b)];}catch(e){L5=String(e);}return[normal,L5,Object.entries(books(d)).filter(([k])=>k!==acquisitionScope(d)).map(([k,b])=>[k,b.subjectNuit,b.year,b.withholdings,b.ppc,...(b.pecPayments?[b.pecPayments]:[]),...(b.internationalCredits?[b.internationalCredits]:[])])];}
|
||||
function key(d:Record<string,unknown>,b:AnnualBook){const{result:_,history:__,...input}=b;return closureFingerprint([annualSettlementVersion,acquisitionScope(d),input,dependencies(d)]);}
|
||||
export function annualCurrent(d:Record<string,unknown>,b:AnnualBook){return !!b.result&&b.result.key===key(d,b);}
|
||||
export function calculateAnnual(d:Record<string,unknown>,b:AnnualBook){
|
||||
@@ -72,8 +88,8 @@ export function calculateAnnual(d:Record<string,unknown>,b:AnnualBook){
|
||||
const group=(g:Group,rows:unknown[],label:string)=>{if(!g.state||!g.reference.trim())pending.push(label+':identifique valor conhecido,ausência declarada ou informação em falta com suporte.');if(g.state==='absent'&&rows.length)pending.push(label+':ausência declarada contradiz parcelas presentes;conserve e reconcilie.');if(g.state==='known'&&!rows.length)pending.push(label+':não há comprovativos seleccionados;ausência exige declaração própria.');};
|
||||
group(b.withholdings,b.withholdings.rows,'Retenções sofridas por conta');group(b.ppc,b.ppc.rows,'PPC efectuados');
|
||||
try{if(b.withholdings.state==='absent'&&options.some(o=>o.ready&&o.year===b.year&&cmp(moneyInput(o.amount),zero())>0n))pending.push('Ausência de retenções sofridas contradiz provaL5 efectiva por conta no exercício;reconcilie sem a ignorar.');}catch(e){pending.push('Reconciliação da ausência de retenções: '+String(e));}
|
||||
for(const[label,e]of[...(b.pecPayments?[]:[['PEC',b.pec]as const]),['Créditos com regras próprias',b.credits]as const]){try{if(!e.state||!e.reference.trim())throw Error('presença/ausência e suporte em falta');if(e.state==='absent'){if(e.amount.trim())throw Error('ausência contradiz montante preenchido');}else if(cmp(moneyInput(e.amount),zero())!==0n)throw Error('montante positivo fora deste recorte:corresponder ordem,limite e transporte próprios;sem abatimento ou reembolso automático');}catch(err){pending.push(label+': '+String(err));}}
|
||||
const claims:Array<{id:string;kind:'withholding'|'ppc'|'pec';previouslyUsed?:FiscalFraction;identity:string;proofAmount:FiscalFraction|null;value:FiscalFraction|null;sourceKey:string;allocationAmount:FiscalFraction|null;document:string;issuer:string;date:string;subjectNuit:string;year:string;reason:string}>=[];
|
||||
for(const[label,e]of[...(b.pecPayments?[]:[['PEC',b.pec]as const]),...(b.internationalCredits?[]:[['Créditos com regras próprias',b.credits]as const])]){try{if(!e.state||!e.reference.trim())throw Error('presença/ausência e suporte em falta');if(e.state==='absent'){if(e.amount.trim())throw Error('ausência contradiz montante preenchido');}else if(cmp(moneyInput(e.amount),zero())!==0n)throw Error('montante positivo fora deste recorte:corresponder ordem,limite e transporte próprios;sem abatimento ou reembolso automático');}catch(err){pending.push(label+': '+String(err));}}
|
||||
const claims:Array<{id:string;kind:'withholding'|'ppc'|'pec'|'foreign_credit';country?:string;positionId?:string;previouslyUsed?:FiscalFraction;identity:string;proofAmount:FiscalFraction|null;value:FiscalFraction|null;sourceKey:string;allocationAmount:FiscalFraction|null;document:string;issuer:string;date:string;subjectNuit:string;year:string;reason:string}>=[];
|
||||
for(const r of b.withholdings.rows){const o=options.find(o=>o.rowId===r.rowId&&o.paymentId===r.paymentId),issues:string[]=[];let value:FiscalFraction|null=null,proofAmount:FiscalFraction|null=null;
|
||||
try{if(!o||!o.ready||r.sourceKey!==o.key)throw Error(o?.reason||'provaL5 ausente ou alterada;reutilize sem duplicar');if(r.subjectNuit!==b.subjectNuit||r.year!==b.year||o.year!==b.year||!o.date.startsWith(b.year+'-'))throw Error('entidade/exercício da retenção não correspondem ao fecho');if(r.incomeIncluded!=='yes'||!r.reference.trim())throw Error('confirme o próprio beneficiário/NUIT e inclusão do rendimento na base do exercício com suporte');value=moneyInput(r.amount);proofAmount=moneyInput(o.proofAmount);if(cmp(value,moneyInput(o.amount))>0n)throw Error('parcela ultrapassa a retenção efectivamente comprovada e afectada emL5');if(b.withholdings.rows.filter(x=>x.rowId===r.rowId&&x.paymentId===r.paymentId).length!==1)throw Error('retenção/prova repetida;uma afectação por linhaL5');if(assessment?.record?.model.special?.cooperative.status==='calculated'&&cmp(value,zero())>0n)throw Error('cooperativa integralmente elegível declara ausência de rendimentos retidos;segregue o casoL7 antes do crédito anual');}catch(e){issues.push(String(e));value=null;}
|
||||
claims.push({id:r.id,kind:'withholding',identity:o?.identity??'',proofAmount,value,sourceKey:r.sourceKey,allocationAmount:o&&value?moneyInput(o.amount):null,document:o?.document??r.paymentId,issuer:o?.issuer??'',date:o?.date??'',subjectNuit:r.subjectNuit,year:r.year,reason:issues.join(' ')});
|
||||
@@ -83,23 +99,33 @@ export function calculateAnnual(d:Record<string,unknown>,b:AnnualBook){
|
||||
claims.push({id:r.id,kind:'ppc',identity:proofIdentity(r.issuer,r.document,r.date),proofAmount,value,sourceKey:'',allocationAmount:null,document:r.document,issuer:r.issuer,date:r.date,subjectNuit:r.subjectNuit,year:r.year,reason:issues.join(' ')});
|
||||
}
|
||||
if(b.pecPayments){group(b.pecPayments,b.pecPayments.rows,'PEC pagos no próprio exercício');for(const r of b.pecPayments.rows){let value:FiscalFraction|null=null,proofAmount:FiscalFraction|null=null,previouslyUsed:FiscalFraction|undefined;let reason='';try{({value,proofAmount,previouslyUsed}=pecPaymentValue(r,b.subjectNuit,b.year));}catch(e){reason=String(e);}claims.push({id:r.id,kind:'pec',identity:proofIdentity(r.issuer,r.document,r.date),value,proofAmount,previouslyUsed,sourceKey:'',allocationAmount:null,document:r.document,issuer:r.issuer,date:r.date,subjectNuit:r.subjectNuit,year:r.year,reason});}}
|
||||
const elsewhere:Array<{identity:string;subjectNuit:string;year:string;value:FiscalFraction;proofAmount:FiscalFraction;sourceKey:string;kind:'ppc'|'pec'|'withholding';previouslyUsed?:FiscalFraction}>=[];
|
||||
for(const[scope,other]of Object.entries(books(d))){if(scope===acquisitionScope(d))continue;try{validateAnnual(other);for(const r of other.pecPayments?.rows??[]){const p=pecPaymentValue(r,other.subjectNuit,other.year);elsewhere.push({identity:proofIdentity(r.issuer,r.document,r.date),subjectNuit:r.subjectNuit,year:r.year,...p,sourceKey:'',kind:'pec'});}for(const r of other.ppc.rows)elsewhere.push({identity:proofIdentity(r.issuer,r.document,r.date),subjectNuit:r.subjectNuit,year:r.year,value:moneyInput(r.amount),proofAmount:moneyInput(r.proofAmount),sourceKey:'',kind:'ppc'});for(const r of other.withholdings.rows){const source=(store(d).irpcWithholdings??{})[scope];const row=source?.rows?.find((x:{id:string})=>x.id===r.rowId),p=source?.payments?.find((x:{id:string})=>x.id===r.paymentId);if(row&&p)elsewhere.push({identity:proofIdentity(row.counterparty,p.reference,p.date),subjectNuit:r.subjectNuit,year:r.year,value:moneyInput(r.amount),proofAmount:moneyInput(p.amount),sourceKey:r.sourceKey,kind:'withholding'});}}catch(e){if(other?.subjectNuit===b.subjectNuit)pending.push('Outro mapa da mesma entidade não recuperável para conferir duplicações: '+scope+';'+String(e));}}
|
||||
if(b.internationalCredits){
|
||||
pending.push(...internationalGroupPending(b.internationalCredits));
|
||||
const countries=b.internationalCredits.positions.map(p=>p.country);
|
||||
if(new Set(countries).size!==countries.length)pending.push('Um país/exercício tem várias posições;consolide rendimentos e comprovativos sob uma única fracção nacional,sem repetir o limite.');
|
||||
for(const p of b.internationalCredits.positions)for(const r of p.payments){let value:FiscalFraction|null=null,proofAmount:FiscalFraction|null=null,reason='';try{({value,proofAmount}=internationalProofValue(r,b.subjectNuit,b.year));}catch(e){reason=String(e);}claims.push({id:r.id,kind:'foreign_credit',country:p.country,positionId:p.id,identity:proofIdentity(r.issuer,r.document,r.date),proofAmount,value,sourceKey:'',allocationAmount:null,document:r.document,issuer:r.issuer,date:r.date,subjectNuit:r.subjectNuit,year:r.year,reason});}
|
||||
}
|
||||
const elsewhere:Array<{identity:string;subjectNuit:string;year:string;value:FiscalFraction;proofAmount:FiscalFraction;sourceKey:string;kind:'ppc'|'pec'|'withholding'|'foreign_credit';country?:string;previouslyUsed?:FiscalFraction}>=[];
|
||||
for(const[scope,other]of Object.entries(books(d))){if(scope===acquisitionScope(d))continue;try{validateAnnual(other);for(const p of other.internationalCredits?.positions??[]){if(other.subjectNuit===b.subjectNuit&&other.year===b.year&&b.internationalCredits?.positions.some(x=>x.country===p.country))pending.push('País '+p.country+' já preparado noutro mapa da entidade/exercício;consolide a fracção nacional e usos sem duplicar quotas.');for(const r of p.payments){const v=internationalProofValue(r,other.subjectNuit,other.year);elsewhere.push({identity:proofIdentity(r.issuer,r.document,r.date),subjectNuit:r.subjectNuit,year:r.year,...v,sourceKey:'',kind:'foreign_credit',country:p.country});}}for(const r of other.pecPayments?.rows??[]){const p=pecPaymentValue(r,other.subjectNuit,other.year);elsewhere.push({identity:proofIdentity(r.issuer,r.document,r.date),subjectNuit:r.subjectNuit,year:r.year,...p,sourceKey:'',kind:'pec'});}for(const r of other.ppc.rows)elsewhere.push({identity:proofIdentity(r.issuer,r.document,r.date),subjectNuit:r.subjectNuit,year:r.year,value:moneyInput(r.amount),proofAmount:moneyInput(r.proofAmount),sourceKey:'',kind:'ppc'});for(const r of other.withholdings.rows){const source=(store(d).irpcWithholdings??{})[scope];const row=source?.rows?.find((x:{id:string})=>x.id===r.rowId),p=source?.payments?.find((x:{id:string})=>x.id===r.paymentId);if(row&&p)elsewhere.push({identity:proofIdentity(row.counterparty,p.reference,p.date),subjectNuit:r.subjectNuit,year:r.year,value:moneyInput(r.amount),proofAmount:moneyInput(p.amount),sourceKey:r.sourceKey,kind:'withholding'});}}catch(e){if(other?.subjectNuit===b.subjectNuit)pending.push('Outro mapa da mesma entidade não recuperável para conferir duplicações: '+scope+';'+String(e));}}
|
||||
for(const c of claims){if(!c.value||!c.proofAmount)continue;const same=claims.filter(x=>x.identity===c.identity&&x.value),other=elsewhere.filter(x=>x.identity===c.identity);let issue='';
|
||||
if(same.filter(x=>x.kind!=='withholding').length>1||new Set(same.map(x=>x.kind)).size>1)issue='Mesmo comprovativo repetido ou usado com naturezas diferentes (retenção/PPC/PEC);reconcilie sem dedução dupla.';
|
||||
if(same.filter(x=>x.kind!=='withholding').length>1||new Set(same.map(x=>x.kind)).size>1)issue='Mesmo comprovativo repetido ou usado com naturezas diferentes (retenção/PPC/PEC/crédito internacional);reconcilie sem dedução dupla.';
|
||||
if(other.some(x=>x.subjectNuit!==b.subjectNuit||x.year!==b.year))issue='Mesmo comprovativo já associado a outra entidade/exercício;reconcilie a titularidade e a afectação.';
|
||||
if([...same,...other].some(x=>x.proofAmount&&cmp(x.proofAmount,c.proofAmount!)!==0n)||cmp(addFractions([...same.flatMap(x=>x.value?[x.value]:[]),...other.map(x=>x.value)]),c.proofAmount)>0n)issue='Comprovativo utilizado além do montante disponível ou com montantes divergentes neste/outro mapa.';
|
||||
if(c.kind==='pec'&&c.previouslyUsed){if(other.some(x=>x.kind!=='pec')||other.some(x=>!x.previouslyUsed||cmp(x.previouslyUsed,c.previouslyUsed!)!==0n)||cmp(addFractions([c.previouslyUsed,...same.flatMap(x=>x.value?[x.value]:[]),...other.map(x=>x.value)]),c.proofAmount)>0n)issue='PEC com utilização anterior divergente, natureza incompatível ou parcelas acima do saldo disponível.';}
|
||||
if(other.some(x=>x.kind!==c.kind))issue='Comprovativo já afectado a outra natureza (retenção/PPC/PEC);sem dupla dedução.';
|
||||
if(other.some(x=>x.kind!==c.kind))issue='Comprovativo já afectado a outra natureza (retenção/PPC/PEC/crédito internacional);sem dupla dedução.';
|
||||
if(c.kind==='foreign_credit'&&other.some(x=>x.country!==c.country))issue='Comprovativo estrangeiro associado a outro país/natureza;reconcilie sem duplicação.';
|
||||
if(c.kind==='withholding'&&c.sourceKey&&c.allocationAmount&&cmp(addFractions([...same.filter(x=>x.sourceKey===c.sourceKey).flatMap(x=>x.value?[x.value]:[]),...other.filter(x=>x.sourceKey===c.sourceKey).map(x=>x.value)]),c.allocationAmount)>0n)issue='Mesma afectação L5 reutilizada além da parcela disponível, ainda que o comprovativo global seja maior.';
|
||||
if(issue)c.reason=[c.reason,issue].filter(Boolean).join(' ');
|
||||
}
|
||||
for(const c of claims)if(c.reason)pending.push((c.document||c.id)+': '+c.reason);
|
||||
const knownWithholdings=addFractions(claims.filter(c=>c.kind==='withholding'&&!c.reason&&c.value).map(c=>c.value!)),knownPpc=addFractions(claims.filter(c=>c.kind==='ppc'&&!c.reason&&c.value).map(c=>c.value!));
|
||||
const ready=pending.length===0&&colecta!==null,pec=b.pecPayments?pecDeduction(addFractions(claims.filter(c=>c.kind==='pec'&&!c.reason&&c.value).map(c=>c.value!)),colecta,ready):null,arithmeticBalance=ready?subtractFractions(subtractFractions(pec?.afterPec??colecta!,knownWithholdings),knownPpc):null;
|
||||
const positions=b.internationalCredits?.positions.map(p=>{const own=claims.filter(c=>c.kind==='foreign_credit'&&c.positionId===p.id);const m=internationalPosition(p,addFractions(own.filter(c=>!c.reason&&c.value).map(c=>c.value!)),own.filter(c=>c.reason).map(c=>c.reason),b.subjectNuit,b.year,b.assessmentKey);pending.push(...m.pending.map(e=>'País '+p.country+': '+e));return m;})??[];
|
||||
const ready=pending.length===0&&colecta!==null,international=b.internationalCredits?internationalDeduction(positions,colecta,ready):null,creditCollecta=international?.afterCredit??colecta;
|
||||
const pec=b.pecPayments?pecDeduction(addFractions(claims.filter(c=>c.kind==='pec'&&!c.reason&&c.value).map(c=>c.value!)),creditCollecta,ready):null,arithmeticBalance=ready?subtractFractions(subtractFractions(pec?.afterPec??creditCollecta!,knownWithholdings),knownPpc):null;
|
||||
if(international&&international.insufficientCollecta&&cmp(international.insufficientCollecta,zero())>0n)warn.push('Crédito elegível sem colecta suficiente:sem reembolso,transporte ou escolha automática da afectação por país.');
|
||||
let payable:FiscalFraction|null=null,recoverable:FiscalFraction|null=null,belowMinimum:FiscalFraction|null=null;let status:'payable'|'recoverable'|'balanced'|'below_minimum'|'indeterminate'='indeterminate';
|
||||
if(arithmeticBalance){const n=BigInt(arithmeticBalance.numerator),abs=fraction(n<0n?-n:n,BigInt(arithmeticBalance.denominator));payable=zero();recoverable=zero();belowMinimum=zero();if(!n)status='balanced';else if(cmp(abs,fraction(100n))<0n){status='below_minimum';belowMinimum=abs;warn.push('Art27(6):saldo inferior a100MZN,sem cobrança/reembolso neste recorte;aritmética conservada,não é transporte de crédito.');}else if(n>0n){status='payable';payable=abs;}else{status='recoverable';recoverable=abs;}}
|
||||
return{version:annualSettlementVersion,input:structuredClone(input),subjectNuit:b.subjectNuit,year:b.year,assessment:assessment?.record?{key:b.assessmentKey,kind:b.assessment,version:assessment.record.model.version,createdAt:assessment.record.createdAt,colecta,period:assessment.period,origin:assessment.record.model.origin}:null,claims,pecDeduction:pec,knownWithholdings,knownPpc,arithmeticBalance,payable,recoverable,belowMinimum,status,pending:[...new Set(pending)],warnings:warn,source:annualSource(b),officialBalancesConsumed:false,submitted:false,refundReceived:false,limitations:[b.pecPayments?'L8 parcial:transporte/caducidade de PEC, cálculo da obrigação, créditos próprios positivos, tributação autónoma, períodos especiais e outras moedas separados. Excedente PEC não é reembolso nem saldo transportado oficialmente.':'L8 parcial:PEC e créditos positivos,tributação autónoma,períodos especiais e pagamentos noutra moeda exigem regras próprias.','PPC aqui é pagamento comprovado;não cálculo automático da obrigação ou calendário.','Retenção sofrida não é retenção entregue pela empresa por conta de terceiros.','Valores racionais exactos;camposM20/M22 e representação não presumidos.','Saldo simulado por colecta projectada;sem pagamento,submissão ou reembolso automático.']};
|
||||
return{version:annualSettlementVersion,input:structuredClone(input),subjectNuit:b.subjectNuit,year:b.year,assessment:assessment?.record?{key:b.assessmentKey,kind:b.assessment,version:assessment.record.model.version,createdAt:assessment.record.createdAt,colecta,period:assessment.period,origin:assessment.record.model.origin}:null,claims,internationalCredit:international,pecDeduction:pec,knownWithholdings,knownPpc,arithmeticBalance,payable,recoverable,belowMinimum,status,pending:[...new Set(pending)],warnings:warn,source:annualSource(b),officialBalancesConsumed:false,submitted:false,refundReceived:false,limitations:[...(b.internationalCredits?['Crédito internacional do próprio exercício:fracção nacional,convenção e montantes MZN são documentados;sem cálculo presumido,transporte ou consumo oficial. Créditos económicos/benefícios positivos ficam separados.']:[]),b.internationalCredits?'L8 parcial:créditos económicos/benefícios positivos,transporte/caducidade,obrigações,tributação autónoma,períodos especiais e outras moedas separados. PEC sem reembolso ou transporte automático.':(b.pecPayments?'L8 parcial:transporte/caducidade de PEC, cálculo da obrigação, créditos próprios positivos, tributação autónoma, períodos especiais e outras moedas separados. Excedente PEC não é reembolso nem saldo transportado oficialmente.':'L8 parcial:PEC e créditos positivos,tributação autónoma,períodos especiais e pagamentos noutra moeda exigem regras próprias.'),'PPC aqui é pagamento comprovado;não cálculo automático da obrigação ou calendário.','Retenção sofrida não é retenção entregue pela empresa por conta de terceiros.','Valores racionais exactos;camposM20/M22 e representação não presumidos.','Saldo simulado por colecta projectada;sem pagamento,submissão ou reembolso automático.']};
|
||||
}
|
||||
export type AnnualModel=ReturnType<typeof calculateAnnual>;
|
||||
export function recordAnnual(d:Record<string,unknown>,b:AnnualBook,now=new Date().toISOString()):AnnualBook{return{...b,history:b.result?[...b.history,structuredClone(b.result)]:b.history,result:{version:annualSettlementVersion,key:key(d,b),createdAt:now,model:calculateAnnual(d,b)}};}
|
||||
@@ -114,10 +140,14 @@ export function annualReportRows(d:Record<string,unknown>):Array<[string,string,
|
||||
'NUIT: '+m.subjectNuit+'; exercício: '+m.year+'; colecta: '+show(m.assessment?.colecta??null)+'; origem: '+(m.assessment?.kind==='special'?'L7 qualificado':'L6 normal')+'. '+(annualCurrent(d,b)?'Entradas correspondentes.':'Histórico; origem/entradas alteradas: recalcule o saldo corrente.')+' Saldo simulado, não liquidação submetida.',
|
||||
m.input.reference+'; '+m.input.assessmentReference+'; '+m.source],
|
||||
...m.claims.map(c=>[
|
||||
'IRPC — L8',(c.kind==='withholding'?'Retenção sofrida':c.kind==='pec'?'PEC':'PPC')+' — '+(c.document||c.id),
|
||||
'IRPC — L8',(c.kind==='withholding'?'Retenção sofrida':c.kind==='pec'?'PEC':c.kind==='foreign_credit'?'Imposto estrangeiro':'PPC')+' — '+(c.document||c.id),
|
||||
'Entidade: '+c.subjectNuit+'; exercício: '+c.year+'; emitente: '+c.issuer+'; data: '+c.date+'; comprovado: '+show(c.proofAmount)+'; parcela: '+(c.reason?'Indeterminado':show(c.value))+'. '+(c.reason||'Reconciliada sem utilização duplicada.'),
|
||||
c.kind==='withholding'?m.input.withholdings.reference+'; '+(m.input.withholdings.rows.find(r=>r.id===c.id)?.reference??''):c.kind==='pec'?(m.input.pecPayments?.reference??'')+'; '+(m.input.pecPayments?.rows.find(r=>r.id===c.id)?.reference??'')+'; utilizações anteriores: '+(m.input.pecPayments?.rows.find(r=>r.id===c.id)?.previouslyUsed??'')+' MZN; '+(m.input.pecPayments?.rows.find(r=>r.id===c.id)?.priorUseReference??''):m.input.ppc.reference+'; '+(m.input.ppc.rows.find(r=>r.id===c.id)?.reference??'')
|
||||
c.kind==='withholding'?m.input.withholdings.reference+'; '+(m.input.withholdings.rows.find(r=>r.id===c.id)?.reference??''):c.kind==='foreign_credit'?(m.input.internationalCredits?.reference??'')+'; '+(m.input.internationalCredits?.positions.flatMap(p=>p.payments).find(r=>r.id===c.id)?.reference??'')+'; '+(m.input.internationalCredits?.positions.flatMap(p=>p.payments).find(r=>r.id===c.id)?.exerciseReference??''):c.kind==='pec'?(m.input.pecPayments?.reference??'')+'; '+(m.input.pecPayments?.rows.find(r=>r.id===c.id)?.reference??'')+'; utilizações anteriores: '+(m.input.pecPayments?.rows.find(r=>r.id===c.id)?.previouslyUsed??'')+' MZN; '+(m.input.pecPayments?.rows.find(r=>r.id===c.id)?.priorUseReference??''):m.input.ppc.reference+'; '+(m.input.ppc.rows.find(r=>r.id===c.id)?.reference??'')
|
||||
]as[string,string,string,string]),
|
||||
...(m.internationalCredit?[
|
||||
...m.internationalCredit.positions.map(p=>['IRPC — L8','Crédito internacional — '+p.country,'Imposto pago seleccionado: '+show(p.paid)+'; fracção nacional: '+show(p.nationalLimit)+'; limite CDT: '+(p.input.treaty==='no'?'Não aplicável documentado':show(p.treatyLimit))+'; elegível: '+show(p.eligible)+'; utilização anterior: '+show(p.previousUse)+'; disponível: '+show(p.available)+'; imposto acima dos limites: '+show(p.aboveLimit)+'. '+p.pending.join(' | '),p.input.incomeReference+'; '+p.input.nationalLimitReference+'; '+p.input.treatyReference+'; '+p.input.previousUse.reference]as[string,string,string,string]),
|
||||
['IRPC — L8','Crédito internacional — antes do PEC','Disponível conhecido: '+show(m.internationalCredit.available)+'; dedução: '+show(m.internationalCredit.deducted)+'; colecta após crédito: '+show(m.internationalCredit.afterCredit)+'; elegível não deduzido por insuficiência de colecta: '+show(m.internationalCredit.insufficientCollecta)+'. Sem reembolso,transporte ou afectação oficial por país. Estado: '+stateLabel(m.input.internationalCredits?.state??'')+'. Créditos económicos/benefícios: '+stateLabel(m.input.internationalCredits?.economic.state??'')+' / '+stateLabel(m.input.internationalCredits?.benefits.state??'')+'.',m.internationalCredit.source+'; '+(m.input.internationalCredits?.reference??'')+'; '+(m.input.internationalCredits?.economic.reference??'')+'; '+(m.input.internationalCredits?.benefits.reference??'')]as[string,string,string,string]
|
||||
]:[]),
|
||||
...(m.pecDeduction?[[
|
||||
'IRPC — L8','PEC — dedução limitada à colecta',
|
||||
'Estado: '+stateLabel(m.input.pecPayments?.state??'')+'; parcelas disponíveis: '+show(m.pecDeduction.available)+'; dedução: '+show(m.pecDeduction.deducted)+'; colecta após PEC, antes de retenções/PPC: '+show(m.pecDeduction.afterPec)+'; parcela seleccionada não deduzida: '+show(m.pecDeduction.remaining)+'. Excedente sem reembolso PEC; transporte/caducidade não automáticos. Subtotais não resolvem informação em falta.',
|
||||
@@ -128,7 +158,7 @@ export function annualReportRows(d:Record<string,unknown>):Array<[string,string,
|
||||
['IRPC — L8','Estados dos comprovativos',
|
||||
'Retenções sofridas: '+stateLabel(m.input.withholdings.state)+'; PPC: '+stateLabel(m.input.ppc.state)+'. Subtotais conhecidos não substituem informação em falta.',m.input.withholdings.reference+'; '+m.input.ppc.reference],
|
||||
['IRPC — L8','PEC e créditos separados',
|
||||
(m.input.pecPayments?'Declaração PEC anterior conservada (substituída nesta execução pelo detalhe comprovado): ':'PEC: ')+stateLabel(m.input.pec.state)+'; montante declarado: '+(m.input.pec.amount||'Não preenchido')+'; créditos: '+stateLabel(m.input.credits.state)+'; montante declarado: '+(m.input.credits.amount||'Não preenchido')+'. Sem dedução, transporte ou reembolso presumidos. '+m.limitations.join(' '),m.input.pec.reference+'; '+m.input.credits.reference]
|
||||
(m.input.pecPayments?'Declaração PEC anterior conservada (substituída nesta execução pelo detalhe comprovado): ':'PEC: ')+stateLabel(m.input.pec.state)+'; montante declarado: '+(m.input.pec.amount||'Não preenchido')+(m.input.internationalCredits?'; resumo anterior de créditos conservado,substituído nesta execução pelo detalhe: ':'; créditos: ')+stateLabel(m.input.credits.state)+'; montante declarado: '+(m.input.credits.amount||'Não preenchido')+'. Sem dedução, transporte ou reembolso presumidos. '+m.limitations.join(' '),m.input.pec.reference+'; '+m.input.credits.reference]
|
||||
];
|
||||
}catch(e){return[['IRPC — L8','Não recuperável',String(e),'Originais e históricos conservados.']];}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
import type {AnnualPpc} from './irpc-annual-settlement.ts';
|
||||
import {countryIsoCodes} from './country-iso-codes.ts';
|
||||
import {addFractions, subtractFractions, decimalFraction, fraction, type FiscalFraction} from './fiscal-rational.ts';
|
||||
|
||||
export const internationalCreditVersion = 'IRPC-international-credit/1';
|
||||
export const internationalCreditSource = 'CIRPC art. 65(1–2), Lei 34/2007, PDF18/p.768-(72); ordem face ao PEC: art.66 e RIRPC21. Recorte: próprio exercício 2026, residente geral, ano civil, valores comprovados em MZN. Menor entre imposto sobre o rendimento pago no estrangeiro, fracção nacional documentada e limite da convenção quando aplicável; depois utilizações anteriores comprovadas e limite da colecta. Não determina a fracção nacional, a aplicabilidade da convenção ou a conversão cambial por presunção. Sem transporte, reembolso do excedente ou consumo de saldos oficiais.';
|
||||
export type CreditState = '' | 'known' | 'absent';
|
||||
export type CreditEvidence = {state: CreditState; amount: string; reference: string};
|
||||
export type InternationalTaxProof = AnnualPpc & {incomeTax: '' | 'yes' | 'no'; taxReference: string; exerciseReference: string};
|
||||
export type InternationalPosition = {
|
||||
id: string; country: string; subjectNuit: string; year: string; assessmentKey: string; qualificationCountry: string;
|
||||
incomeAmount: string; incomeIncluded: '' | 'yes' | 'no'; incomeReference: string;
|
||||
nationalLimit: string; nationalLimitReference: string;
|
||||
treaty: '' | 'yes' | 'no'; treatyLimit: string; treatyReference: string;
|
||||
previousUse: CreditEvidence; payments: InternationalTaxProof[];
|
||||
};
|
||||
export type InternationalCredits = {
|
||||
version: 1; state: CreditState; reference: string; positions: InternationalPosition[];
|
||||
economic: CreditEvidence; benefits: CreditEvidence;
|
||||
};
|
||||
const emptyEvidence = (): CreditEvidence => ({state: '', amount: '', reference: ''});
|
||||
export const newInternationalCredits = (): InternationalCredits => ({version: 1, state: '', reference: '', positions: [], economic: emptyEvidence(), benefits: emptyEvidence()});
|
||||
export const newInternationalPosition = (id: string): InternationalPosition => ({id, country: '', subjectNuit: '', year: '', assessmentKey: '', qualificationCountry: '', incomeAmount: '', incomeIncluded: '', incomeReference: '', nationalLimit: '', nationalLimitReference: '', treaty: '', treatyLimit: '', treatyReference: '', previousUse: emptyEvidence(), payments: []});
|
||||
const states = ['', 'known', 'absent'];
|
||||
const yesNo = ['', 'yes', 'no'];
|
||||
const evidenceValid = (e: CreditEvidence) => e && states.includes(e.state) && typeof e.amount === 'string' && typeof e.reference === 'string';
|
||||
const proofKeys = ['id','document','issuer','date','subjectNuit','year','currency','proofAmount','amount','effective','reference','incomeTax','taxReference','exerciseReference'];
|
||||
const positionKeys = ['id','country','subjectNuit','year','assessmentKey','qualificationCountry','incomeAmount','incomeIncluded','incomeReference','nationalLimit','nationalLimitReference','treaty','treatyLimit','treatyReference'];
|
||||
export function validateInternational(c: InternationalCredits) {
|
||||
if (!c || c.version !== 1 || !states.includes(c.state) || typeof c.reference !== 'string' || !evidenceValid(c.economic) || !evidenceValid(c.benefits) || !Array.isArray(c.positions) || new Set(c.positions.map(p => p?.id)).size !== c.positions.length) throw Error('Créditos internacionais não recuperáveis; originais conservados.');
|
||||
const proofIds: string[] = [];
|
||||
for (const p of c.positions) {
|
||||
if (!p || positionKeys.some(k => typeof (p as unknown as Record<string, unknown>)[k] !== 'string') || !yesNo.includes(p.incomeIncluded) || !yesNo.includes(p.treaty) || !evidenceValid(p.previousUse) || !Array.isArray(p.payments)) throw Error('Posição internacional não recuperável; originais conservados.');
|
||||
for (const r of p.payments) {
|
||||
if (!r || proofKeys.some(k => typeof (r as unknown as Record<string, unknown>)[k] !== 'string') || !yesNo.includes(r.effective) || !yesNo.includes(r.incomeTax)) throw Error('Comprovativo internacional não recuperável.');
|
||||
proofIds.push(r.id);
|
||||
}
|
||||
}
|
||||
if (new Set(proofIds).size !== proofIds.length) throw Error('Identificador de comprovativo internacional repetido.');
|
||||
}
|
||||
export const creditMoney = (raw: string) => {
|
||||
if (!/^\d{1,18}(\.\d{1,2})?$/.test(raw)) throw Error('Montante MZN em falta/inválido; zero exige declaração própria.');
|
||||
return decimalFraction(raw);
|
||||
};
|
||||
export const creditCompare = (a: FiscalFraction, b: FiscalFraction) => BigInt(a.numerator) * BigInt(b.denominator) - BigInt(b.numerator) * BigInt(a.denominator);
|
||||
const creditLimit = (raw: string) => {
|
||||
const rational = /^(\d{1,18})\/(\d{1,18})$/.exec(raw);
|
||||
if (rational) return fraction(BigInt(rational[1]), BigInt(rational[2]));
|
||||
if (!/^\d{1,18}(\.\d{1,6})?$/.test(raw)) throw Error('Limite documentado em falta/inválido; use decimal ou fracção exacta n/d, sem arredondamento presumido.');
|
||||
return decimalFraction(raw);
|
||||
};
|
||||
const zero = () => fraction(0n);
|
||||
const minimum = (...values: FiscalFraction[]) => values.reduce((a, b) => creditCompare(a, b) < 0n ? a : b);
|
||||
const isDate = (s: string) => /^20\d{2}-\d{2}-\d{2}$/.test(s) && Number.isFinite(Date.parse(s)) && new Date(s).toISOString().slice(0, 10) === s;
|
||||
export function internationalProofValue(r: InternationalTaxProof, subjectNuit: string, year: string) {
|
||||
if (!r.id.trim() || !r.document.trim() || !r.issuer.trim() || !r.reference.trim() || !r.taxReference.trim() || r.incomeTax !== 'yes' || r.effective !== 'yes' || r.currency !== 'MZN' || !isDate(r.date) || r.subjectNuit !== subjectNuit || r.year !== year || year !== '2026') throw Error('Crédito internacional: exige imposto sobre o rendimento efectivamente pago, prova/titular/exercício 2026 e MZN; previsões, outras naturezas e conversões não correspondidas ficam separados.');
|
||||
if (!r.date.startsWith(year + '-') && !r.exerciseReference.trim()) throw Error('Data de pagamento fora do exercício: falta correspondência documental com o rendimento e imposto deste exercício; não é transporte presumido.');
|
||||
const value = creditMoney(r.amount), proofAmount = creditMoney(r.proofAmount);
|
||||
if (creditCompare(value, proofAmount) > 0n) throw Error('Parcela estrangeira ultrapassa o montante comprovado.');
|
||||
return {value, proofAmount};
|
||||
}
|
||||
export function internationalGroupPending(c: InternationalCredits) {
|
||||
const pending: string[] = [];
|
||||
if (!c.state || !c.reference.trim()) pending.push('Crédito internacional: declare pagamentos conhecidos, ausência ou informação em falta, com suporte.');
|
||||
if (c.state === 'absent' && c.positions.length) pending.push('Ausência de crédito internacional contradiz posições presentes; conserve e reconcilie.');
|
||||
if (c.state === 'known' && !c.positions.length) pending.push('Crédito internacional conhecido sem posição/comprovativo; zero não é ausência presumida.');
|
||||
for (const [label, e] of [['Dupla tributação económica', c.economic], ['Benefícios/créditos próprios', c.benefits]] as const) {
|
||||
try {
|
||||
if (!e.state || !e.reference.trim()) throw Error('estado e suporte em falta');
|
||||
if (e.state === 'absent') {if (e.amount.trim()) throw Error('ausência contradiz montante');}
|
||||
else if (creditCompare(creditMoney(e.amount), zero()) !== 0n) throw Error('valor positivo exige regra própria; não é deduzido nem ignorado');
|
||||
} catch (e) {pending.push(label + ': ' + String(e));}
|
||||
}
|
||||
return pending;
|
||||
}
|
||||
export function internationalPosition(p: InternationalPosition, paid: FiscalFraction, proofIssues: string[], subjectNuit: string, year: string, assessmentKey: string) {
|
||||
const pending = [...proofIssues];
|
||||
let nationalLimit: FiscalFraction | null = null, treatyLimit: FiscalFraction | null = null, previousUse: FiscalFraction | null = null, eligible: FiscalFraction | null = null, available: FiscalFraction | null = null, aboveLimit: FiscalFraction | null = null;
|
||||
try {
|
||||
if (!p.id.trim() || !countryIsoCodes.includes(p.country) || p.country === 'MZ' || p.subjectNuit !== subjectNuit || p.year !== year || year !== '2026') throw Error('País estrangeiro do catálogo, titular e exercício não correspondem.');
|
||||
if (p.qualificationCountry !== p.country) throw Error('O país mudou; confirme a inclusão e os limites documentados para o país seleccionado.');
|
||||
if (p.assessmentKey !== assessmentKey || !p.assessmentKey) throw Error('Confirme a inclusão e a fracção nacional na colecta corrente; a origem mudou.');
|
||||
if (p.incomeIncluded !== 'yes' || !p.incomeReference.trim()) throw Error('Falta inclusão documentada do rendimento estrangeiro na matéria colectável.');
|
||||
const income = creditMoney(p.incomeAmount);
|
||||
nationalLimit = creditLimit(p.nationalLimit);
|
||||
if (!p.nationalLimitReference.trim()) throw Error('Fracção nacional exige suporte próprio; não é calculada nem presumida pelo portal.');
|
||||
if (creditCompare(income, zero()) === 0n && creditCompare(nationalLimit, zero()) !== 0n) throw Error('Rendimento incluído zero contradiz fracção nacional positiva.');
|
||||
if (!p.treaty || !p.treatyReference.trim()) throw Error('Aplicabilidade da convenção e suporte em falta.');
|
||||
if (p.treaty === 'yes') treatyLimit = creditLimit(p.treatyLimit);
|
||||
else if (p.treatyLimit.trim()) throw Error('Ausência de convenção contradiz limite preenchido.');
|
||||
if (!p.previousUse.state || !p.previousUse.reference.trim()) throw Error('Utilizações anteriores do crédito em falta; histórico de simulação não é consumo oficial.');
|
||||
if (p.previousUse.state === 'absent') {if (p.previousUse.amount.trim()) throw Error('Ausência de uso anterior contradiz montante');previousUse = zero();}
|
||||
else previousUse = creditMoney(p.previousUse.amount);
|
||||
if (!p.payments.length) throw Error('Sem comprovativos de imposto estrangeiro nesta posição.');
|
||||
if (!pending.length) {
|
||||
eligible = minimum(paid, nationalLimit, ...(treatyLimit ? [treatyLimit] : []));
|
||||
aboveLimit = subtractFractions(paid, eligible);
|
||||
if (creditCompare(previousUse, eligible) > 0n) throw Error('Utilização anterior excede o crédito elegível; reconcilie o saldo.');
|
||||
available = subtractFractions(eligible, previousUse);
|
||||
}
|
||||
} catch (e) {pending.push(String(e));available = null;}
|
||||
return {id: p.id, country: p.country, paid, nationalLimit, treatyLimit, previousUse, eligible, available, aboveLimit, pending, input: structuredClone(p)};
|
||||
}
|
||||
export function internationalDeduction(positions: ReturnType<typeof internationalPosition>[], colecta: FiscalFraction | null, ready: boolean) {
|
||||
const available = addFractions(positions.flatMap(p => p.available && !p.pending.length ? [p.available] : []));
|
||||
const deducted = ready && colecta ? minimum(available, colecta) : null;
|
||||
return {version: internationalCreditVersion, positions, available, deducted, afterCredit: deducted && colecta ? subtractFractions(colecta, deducted) : null, insufficientCollecta: deducted ? subtractFractions(available, deducted) : null, source: internationalCreditSource, countryAllocationCreated: false, carryCreated: false, officialBalancesConsumed: false};
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
use Tests\TestCase;
|
||||
|
||||
final class IrpcInternationalCreditDraftTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
public function test_international_credit_delta_round_trips_with_frozen_history_and_unchanged_existing_records(): void
|
||||
{
|
||||
$target=DB::selectOne('select current_database() as name,inet_server_port() as port');
|
||||
$this->assertSame('proactive_investment_20261027_test',$target->name);
|
||||
$this->assertSame(55441,(int)$target->port);
|
||||
$snapshot=static fn(string $table):array=>collect(DB::select('select id::text as id,md5(row_to_json(t)::text) as hash from public."'.$table.'" t order by id'))->pluck('hash','id')->all();
|
||||
$protected=[];
|
||||
foreach(['opportunities','documents','opportunity_documents','simulation_form_drafts','users','organizations','audit_events']as$table)$protected[$table]=$snapshot($table);
|
||||
config(['investor-path.enabled'=>true,'suitecrm.enabled'=>false]);
|
||||
$this->actingAs(User::findOrFail(1021)); // Existing synthetic QA actor, no new grants.
|
||||
$base=json_decode(file_get_contents(base_path('tests/frontend/fixtures/irpc-assessment-preserved.json')),true,flags:JSON_THROW_ON_ERROR);
|
||||
$fixture=json_decode(file_get_contents(base_path('tests/frontend/fixtures/irpc-international-preserved.json')),true,flags:JSON_THROW_ON_ERROR);
|
||||
$this->assertTrue($fixture['synthetic']);$this->assertFalse($fixture['actualConventionData']);
|
||||
$personal=['person_type'=>$base['person_type']];unset($base['person_type']);
|
||||
$id=null;$etag=null;$previous=null;
|
||||
foreach($fixture['cases']as$name=>$book){
|
||||
$draft=$base;$s=json_decode($draft['modelo_a_snapshot'],true,flags:JSON_THROW_ON_ERROR);
|
||||
if($previous!==null)$book['history']=[$previous];
|
||||
$s['irpcAnnual'][$draft['context_opportunity']]=$book;
|
||||
$draft['modelo_a_snapshot']=json_encode($s,JSON_THROW_ON_ERROR|JSON_UNESCAPED_UNICODE);
|
||||
$payload=['personal_snapshot'=>$personal,'economic_snapshot'=>$draft];
|
||||
if($id===null)$id=$this->postJson('/api/v1/simulation-drafts',$payload,['Idempotency-Key'=>(string)Str::uuid()])->assertCreated()->json('data.id');
|
||||
else $this->putJson('/api/v1/simulation-drafts/'.$id,$payload,['If-Match'=>$etag])->assertOk();
|
||||
$response=$this->getJson('/api/v1/simulation-drafts/'.$id)->assertOk();$etag=$response->headers->get('ETag');$back=$response->json('data.economic_snapshot');
|
||||
$this->assertSame($draft['modelo_a_snapshot'],$back['modelo_a_snapshot']);$this->assertSame($draft['business_plan_snapshot'],$back['business_plan_snapshot']);
|
||||
$recovered=json_decode($back['modelo_a_snapshot'],true,flags:JSON_THROW_ON_ERROR);
|
||||
foreach(['irpcNormal','irpcWithholdings','books','currencyEvents','ispcQuarters']as$map)$this->assertSame($s[$map],$recovered[$map]);
|
||||
$saved=$recovered['irpcAnnual'][$draft['context_opportunity']];$m=$saved['result']['model'];$credit=$m['internationalCredit'];
|
||||
$this->assertSame($book,$saved);$this->assertSame('IRPC-international-credit/1',$credit['version']);$this->assertFalse($credit['carryCreated']);$this->assertFalse($credit['officialBalancesConsumed']);$this->assertFalse($credit['countryAllocationCreated']);$this->assertFalse($m['submitted']);
|
||||
$this->assertSame(['numerator'=>'1408','denominator'=>'1'],$m['assessment']['colecta']);
|
||||
if(in_array($name,['missing','duplicate'],true)){
|
||||
$this->assertSame('indeterminate',$m['status']);$this->assertNull($m['arithmeticBalance']);$this->assertNull($credit['deducted']);$this->assertNull($m['pecDeduction']['deducted']);$this->assertNotEmpty($m['pending']);
|
||||
}else{
|
||||
$expected=['payable'=>['payable','700','8','1400','200'],'treaty'=>['payable','702','6','1402','200'],'limited-collecta'=>['recoverable','-500','1408','0','0'],'absent'=>['payable','708','0','1408','200'],'prior-use'=>['payable','703','5','1403','200']][$name];
|
||||
$this->assertSame($expected[0],$m['status']);$this->assertEmpty($m['pending']);
|
||||
$this->assertSame(['numerator'=>$expected[1],'denominator'=>'1'],$m['arithmeticBalance']);
|
||||
$this->assertSame(['numerator'=>$expected[2],'denominator'=>'1'],$credit['deducted']);
|
||||
$this->assertSame(['numerator'=>$expected[3],'denominator'=>'1'],$credit['afterCredit']);
|
||||
$this->assertSame(['numerator'=>$expected[4],'denominator'=>'1'],$m['pecDeduction']['deducted']);
|
||||
if($name==='limited-collecta'){$this->assertSame(['numerator'=>'592','denominator'=>'1'],$credit['insufficientCollecta']);$this->assertSame(['numerator'=>'200','denominator'=>'1'],$m['pecDeduction']['remaining']);}
|
||||
}
|
||||
if($previous!==null)$this->assertSame($previous,$saved['history'][0]);$previous=$saved['result'];
|
||||
if(getenv('INVESTMOZ_INTERNATIONAL_QA_OUTPUT')==='1')file_put_contents(base_path('outputs/irpc-l8-international-20261027/recovered-'.$name.'.json'),json_encode($back,JSON_THROW_ON_ERROR|JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
$preserved=[];
|
||||
foreach($protected as$table=>$before){$this->assertSame($before,array_intersect_key($snapshot($table),$before),'Existing records changed: '.$table);$preserved[$table]=['existing_rows'=>count($before),'unchanged'=>true];}
|
||||
if(getenv('INVESTMOZ_INTERNATIONAL_QA_OUTPUT')==='1')file_put_contents(base_path('outputs/irpc-l8-international-20261027/existing-records-preservation.json'),json_encode(['database'=>$target->name,'tables'=>$preserved,'transaction_rollback'=>true],JSON_THROW_ON_ERROR|JSON_PRETTY_PRINT));
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,9 @@
|
||||
import {pecCase} from './irpc-pec-case.mjs';
|
||||
import {prepareInternationalBook,newInternationalProof} from '../../../resources/js/lib/irpc-annual-settlement.ts';
|
||||
import {newInternationalPosition} from '../../../resources/js/lib/irpc-international-credit.ts';
|
||||
export function internationalCase(tax='10',national='8',pec='200',ppc='500',rf='0') {
|
||||
const c=pecCase(pec,ppc,rf);c.b=prepareInternationalBook(c.b);
|
||||
const p={...newInternationalPosition('country-za'),country:'ZA',qualificationCountry:'ZA',subjectNuit:c.b.subjectNuit,year:c.b.year,assessmentKey:c.b.assessmentKey,incomeAmount:'100',incomeIncluded:'yes',incomeReference:'SYNTHETIC QA: foreign income included in valid 2026 base',nationalLimit:national,nationalLimitReference:'SYNTHETIC QA: documented national fraction, no automatic derivation',treaty:'no',treatyReference:'SYNTHETIC QA assumption only; not an assertion about actual ZA convention applicability',previousUse:{state:'known',amount:'0',reference:'SYNTHETIC QA: actual previous credit use known zero'},payments:[{...newInternationalProof('foreign-tax'),document:'SYNTHETIC-FOREIGN-TAX-2026',issuer:'SYNTHETIC QA foreign authority',date:'2026-09-30',subjectNuit:c.b.subjectNuit,year:c.b.year,proofAmount:tax,amount:tax,effective:'yes',incomeTax:'yes',reference:'SYNTHETIC QA paid MZN tax amount, no real receipt',taxReference:'SYNTHETIC QA income tax nature and entitlement'}]};
|
||||
Object.assign(c.b.internationalCredits,{state:'known',reference:'SYNTHETIC QA complete inventory for entity/year',positions:[p]});
|
||||
return c;
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import crypto from 'node:crypto';
|
||||
import {countryIsoCodes} from '../../resources/js/lib/country-iso-codes.ts';
|
||||
import {internationalCase} from './helpers/irpc-international-case.mjs';
|
||||
import {calculateAnnual,annualBook,recordAnnual,saveAnnualBook,annualCurrent,annualHtml,annualReportRows,prepareInternationalBook} from '../../resources/js/lib/irpc-annual-settlement.ts';
|
||||
import {createProjectDossierReport} from '../../resources/js/lib/project-dossier-report.ts';
|
||||
const value=v=>v?Number(v.numerator)/Number(v.denominator):null;
|
||||
const now='2026-10-27T17:00:00+02:00';
|
||||
const calc=({d,b})=>calculateAnnual(d,b);
|
||||
const pending=c=>{const m=calc(c);assert.equal(m.status,'indeterminate',JSON.stringify(m.pending));assert.equal(m.arithmeticBalance,null);assert.equal(m.internationalCredit.deducted,null);assert.equal(m.pecDeduction.deducted,null);return m;};
|
||||
const position=c=>c.b.internationalCredits.positions[0];
|
||||
const proof=c=>position(c).payments[0];
|
||||
|
||||
test('country code projection exactly reuses the existing master and its source hash',()=>{
|
||||
const raw=Buffer.from(fs.readFileSync(new URL('../../resources/data/iso3166.tab',import.meta.url),'utf8').replace(/\r\n/g,'\n'));
|
||||
const codes=raw.toString('utf8').split(/\r?\n/).filter(l=>l&&!l.startsWith('#')).map(l=>l.split('\t')[0]);
|
||||
assert.deepEqual(countryIsoCodes,codes);const source=fs.readFileSync(new URL('../../resources/js/lib/country-iso-codes.ts',import.meta.url),'utf8');assert.ok(source.includes(crypto.createHash('sha256').update(raw).digest('hex')));
|
||||
});
|
||||
test('10 paid capped at documented national8 precedes PEC200/PPC500:1408-8-200-500=700',()=>{
|
||||
const m=calc(internationalCase());assert.deepEqual(m.pending,[]);const p=m.internationalCredit.positions[0];
|
||||
assert.equal(value(p.paid),10);assert.equal(value(p.eligible),8);assert.equal(value(p.aboveLimit),2);assert.equal(value(m.internationalCredit.deducted),8);assert.equal(value(m.internationalCredit.afterCredit),1400);assert.equal(value(m.pecDeduction.deducted),200);assert.equal(value(m.payable),700);assert.equal(m.internationalCredit.carryCreated,false);assert.equal(m.officialBalancesConsumed,false);
|
||||
});
|
||||
test('documented treaty limit6 caps credit without country-based automatic entitlement',()=>{
|
||||
const c=internationalCase();Object.assign(position(c),{treaty:'yes',treatyLimit:'6',treatyReference:'SYNTHETIC QA convention/article/exercise/limit, not real treaty data'});
|
||||
const m=calc(c);assert.equal(value(m.internationalCredit.deducted),6);assert.equal(value(m.payable),702);assert.equal(value(m.internationalCredit.positions[0].aboveLimit),4);
|
||||
position(c).treatyLimit='';pending(c);position(c).treatyLimit='6';position(c).treatyReference='';pending(c);
|
||||
});
|
||||
test('multiple actual receipts share one country limit;two countries keep separate limits',()=>{
|
||||
const c=internationalCase();proof(c).amount='6';proof(c).proofAmount='6';position(c).payments.push({...proof(c),id:'foreign-second',document:'OTHER-RECEIPT',amount:'4',proofAmount:'4'});assert.equal(value(calc(c).internationalCredit.deducted),8);
|
||||
const other=structuredClone(position(c));other.id='country-pt';other.country='PT';other.qualificationCountry='PT';other.nationalLimit='4';other.payments=[{...other.payments[0],id:'pt-tax',document:'PT-OTHER-RECEIPT',proofAmount:'5',amount:'5'}];c.b.internationalCredits.positions.push(other);assert.equal(value(calc(c).internationalCredit.deducted),12);assert.equal(value(calc(c).payable),696);
|
||||
});
|
||||
test('same country cannot multiply the national fraction across positions or other context maps',()=>{
|
||||
const a=internationalCase(),copy=structuredClone(position(a));copy.id='duplicate-country';copy.payments[0].id='other-proof';copy.payments[0].document='OTHER';a.b.internationalCredits.positions.push(copy);assert.match(pending(a).pending.join(' '),/país\/exercício/);
|
||||
const b=internationalCase(),other=structuredClone(b.b);other.internationalCredits.positions[0].payments[0].id='elsewhere';other.internationalCredits.positions[0].payments[0].document='ELSEWHERE-RECEIPT';const s=JSON.parse(b.d.modelo_a_snapshot);s.irpcAnnual={'opportunity:other':other};b.d.modelo_a_snapshot=JSON.stringify(s);assert.match(pending(b).pending.join(' '),/noutro mapa/);
|
||||
});
|
||||
test('actual previous credit use reduces eligible credit,not gross tax or simulated history',()=>{
|
||||
const c=internationalCase();position(c).previousUse.amount='3';let m=calc(c);assert.equal(value(m.internationalCredit.positions[0].eligible),8);assert.equal(value(m.internationalCredit.positions[0].available),5);assert.equal(value(m.payable),703);
|
||||
position(c).previousUse.amount='9';assert.match(pending(c).pending.join(' '),/excede/);position(c).previousUse={state:'absent',amount:'',reference:'QA no actual previous use'};assert.equal(value(calc(c).payable),700);
|
||||
});
|
||||
test('lack of collecta is separated from tax above eligibility limits and never refunds credit or PEC',()=>{
|
||||
const c=internationalCase('2000','2000','200','0'),m=calc(c);assert.equal(m.status,'balanced');assert.equal(value(m.internationalCredit.deducted),1408);assert.equal(value(m.internationalCredit.insufficientCollecta),592);assert.equal(value(m.internationalCredit.positions[0].aboveLimit),0);assert.equal(value(m.pecDeduction.deducted),0);assert.equal(value(m.pecDeduction.remaining),200);assert.equal(value(m.recoverable),0);assert.equal(m.internationalCredit.countryAllocationCreated,false);
|
||||
c.b.ppc={...internationalCase().b.ppc};const recovered=calc(c);assert.equal(value(recovered.recoverable),500);assert.equal(value(recovered.internationalCredit.insufficientCollecta),592);assert.equal(recovered.internationalCredit.carryCreated,false);
|
||||
});
|
||||
test('known zero,declared absence and missing retain distinct inputs and outcomes',()=>{
|
||||
const zero=internationalCase('0');assert.equal(value(calc(zero).internationalCredit.deducted),0);assert.equal(value(calc(zero).payable),708);
|
||||
const a=internationalCase();a.b.internationalCredits.state='absent';a.b.internationalCredits.positions=[];assert.equal(value(calc(a).payable),708);
|
||||
a.b.internationalCredits.state='';pending(a);a.b.internationalCredits.state='known';pending(a);
|
||||
const b=internationalCase();b.b.internationalCredits.state='absent';pending(b);position(b).previousUse={state:'absent',amount:'0',reference:'QA contradiction'};pending(b);
|
||||
});
|
||||
test('country,entity,year,inclusion,current assessment,domestic fraction and convention require support',()=>{
|
||||
for(const patch of [{country:'MZ'},{country:'ZZ'},{country:''},{country:'PT'},{qualificationCountry:''},{subjectNuit:'999999999'},{year:'2025'},{incomeIncluded:''},{incomeIncluded:'no'},{incomeAmount:''},{incomeAmount:'0'},{incomeReference:''},{nationalLimit:''},{nationalLimitReference:''},{assessmentKey:'stale'},{treaty:''},{treaty:'no',treatyLimit:'0'},{treatyReference:''}]){const c=internationalCase();Object.assign(position(c),patch);pending(c);}
|
||||
for(const patch of [{state:''},{amount:''},{reference:''}]){const c=internationalCase();Object.assign(position(c).previousUse,patch);pending(c);}
|
||||
});
|
||||
test('actual foreign income tax proof is required,not projections,other taxes,wrong exercise or unsupported currency',()=>{
|
||||
for(const patch of [{effective:''},{effective:'no'},{incomeTax:''},{incomeTax:'no'},{taxReference:''},{document:''},{issuer:''},{reference:''},{subjectNuit:'999999999'},{year:'2025'},{date:'2026-02-30'},{date:'2025-09-30'},{currency:'USD'},{amount:'10.01'},{amount:'0.001'}]){const c=internationalCase();Object.assign(proof(c),patch);pending(c);}
|
||||
const c=internationalCase();position(c).payments=[];pending(c);
|
||||
});
|
||||
test('payment date differs from income exercise only with explicit correspondence,never an automatic carry',()=>{
|
||||
const c=internationalCase();proof(c).date='2027-01-15';pending(c);proof(c).exerciseReference='SYNTHETIC QA own-exercise2026 assessment and payment relation';const m=calc(c);assert.equal(value(m.payable),700);assert.equal(m.internationalCredit.carryCreated,false);
|
||||
});
|
||||
test('same physical foreign receipt cannot be duplicated,re-dated or used as PPC/PEC/RF',()=>{
|
||||
const a=internationalCase();position(a).payments.push({...proof(a),id:'other-date',date:'2026-10-01'});pending(a);
|
||||
for(const kind of ['ppc','pec','rf']){const c=internationalCase('10','8','200','500',kind==='rf'?'300':'0');const physical=kind==='ppc'?c.b.ppc.rows[0]:kind==='pec'?c.b.pecPayments.rows[0]:{issuer:'QA AT',document:'QA-RF-PEC-2026',proofAmount:'300'};Object.assign(proof(c),{issuer:physical.issuer,document:physical.document,proofAmount:physical.proofAmount});assert.match(pending(c).pending.join(' '),/naturez|comprovativo/i);}
|
||||
});
|
||||
test('a foreign receipt cannot move country/entity across context maps;external changes invalidate current result',()=>{
|
||||
const c=internationalCase(),other=structuredClone(c.b);other.ppc.rows=[];other.ppc.state='absent';other.pecPayments.rows=[];other.pecPayments.state='absent';other.internationalCredits.positions[0].country='PT';const s=JSON.parse(c.d.modelo_a_snapshot);s.irpcAnnual={'opportunity:other':other};c.d.modelo_a_snapshot=JSON.stringify(s);pending(c);
|
||||
other.internationalCredits.positions[0].payments[0].document='OTHER-PT';c.d.modelo_a_snapshot=JSON.stringify(s);assert.equal(value(calc(c).payable),700);c.d.modelo_a_snapshot=saveAnnualBook(c.d,recordAnnual(c.d,c.b,now));const saved=annualBook(c.d);assert.equal(annualCurrent(c.d,saved),true);
|
||||
const edit=JSON.parse(c.d.modelo_a_snapshot);edit.irpcAnnual['opportunity:other'].internationalCredits.positions[0].country='ZA';c.d.modelo_a_snapshot=JSON.stringify(edit);assert.equal(annualCurrent(c.d,saved),false);pending({...c,b:saved});
|
||||
});
|
||||
test('economic/benefit positive or missing states block only the dependent annual balance,not known eligibility',()=>{
|
||||
for(const kind of ['economic','benefits'])for(const patch of [{state:''},{state:'known',amount:'1'},{reference:''}]){const c=internationalCase();Object.assign(c.b.internationalCredits[kind],patch);const m=pending(c);assert.equal(value(m.internationalCredit.positions[0].eligible),8);assert.equal(value(m.assessment.colecta),1408);}
|
||||
});
|
||||
test('exact decimals and withholding are included once after credit and PEC',()=>{
|
||||
const c=internationalCase('10.25','8.15','200','500','300');position(c).previousUse.amount='3.01';const m=calc(c);assert.deepEqual(m.internationalCredit.deducted,{numerator:'257',denominator:'50'});assert.equal(value(m.payable),402.86);assert.equal(value(m.knownWithholdings),300);
|
||||
});
|
||||
test('documented fractional ceilings retain exact arithmetic without assumed tax rounding',()=>{
|
||||
const c=internationalCase('10','1/3');const m=calc(c);assert.deepEqual(m.internationalCredit.deducted,{numerator:'1',denominator:'3'});assert.deepEqual(m.payable,{numerator:'2123',denominator:'3'});
|
||||
position(c).nationalLimit='1/0';pending(c);
|
||||
});
|
||||
test('prepare preserves deliberate prior summary and history;save/recover/report appends frozen records',()=>{
|
||||
const c=internationalCase(),detail=structuredClone(c.b.internationalCredits);delete c.b.internationalCredits;const original=JSON.parse(c.d.modelo_a_snapshot),plan=c.d.business_plan_snapshot;c.d.modelo_a_snapshot=saveAnnualBook(c.d,recordAnnual(c.d,c.b,now));const prior=structuredClone(annualBook(c.d).result);assert.equal(value(prior.model.payable),708);
|
||||
let next=prepareInternationalBook(annualBook(c.d));next.internationalCredits=detail;c.d.modelo_a_snapshot=saveAnnualBook(c.d,recordAnnual(c.d,next,now));const back=annualBook(JSON.parse(JSON.stringify(c.d)));assert.deepEqual(back.history,[prior]);assert.equal(annualCurrent(c.d,back),true);assert.equal(value(back.result.model.payable),700);assert.deepEqual(back.credits,{state:'known',amount:'0',reference:'QA créditos precedentes conhecidos zero'});
|
||||
const after=JSON.parse(c.d.modelo_a_snapshot);delete after.irpcAnnual;assert.deepEqual(after,original);assert.equal(c.d.business_plan_snapshot,plan);
|
||||
const html=annualHtml(c.d);assert.match(html,/Crédito internacional — antes do PEC/);assert.match(html,/700.00/);assert.match(html,/1400.00/);assert.match(JSON.stringify(createProjectDossierReport(c.d,{selectedSections:new Set(['finance'])})),/Crédito internacional — ZA/);
|
||||
const frozen=structuredClone(back.result);back.internationalCredits.positions[0].nationalLimit='7';c.d.modelo_a_snapshot=saveAnnualBook(c.d,back);assert.equal(annualCurrent(c.d,back),false);assert.deepEqual(back.result,frozen);assert.match(annualReportRows(c.d).flat().join(' '),/Histórico/);assert.throws(()=>annualHtml(c.d),/fontes actuais/);
|
||||
});
|
||||
test('malformed optional international detail never resets existing snapshots',()=>{
|
||||
const c=internationalCase(),snapshot=c.d.modelo_a_snapshot;proof(c).incomeTax=null;assert.throws(()=>saveAnnualBook(c.d,c.b),/não recuperável/);assert.equal(c.d.modelo_a_snapshot,snapshot);
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import fs from 'node:fs';
|
||||
import crypto from 'node:crypto';
|
||||
const source = new URL('../resources/data/iso3166.tab', import.meta.url);
|
||||
const text = fs.readFileSync(source, 'utf8').replace(/\r\n/g, '\n');
|
||||
const codes = text.split('\n').filter(line => line && !line.startsWith('#')).map(line => line.split('\t')[0]);
|
||||
if (new Set(codes).size !== codes.length || codes.some(code => !/^[A-Z]{2}$/.test(code))) throw Error('Invalid existing ISO catalogue');
|
||||
const hash = crypto.createHash('sha256').update(text).digest('hex');
|
||||
fs.writeFileSync(new URL('../resources/js/lib/country-iso-codes.ts', import.meta.url),
|
||||
'// Derived code projection of resources/data/iso3166.tab; keep the existing PHP catalogue authoritative.\n' +
|
||||
'// Source SHA256 (LF): ' + hash + '; regenerate with node tools/country-iso-projection.mjs\n' +
|
||||
"export const countryIsoCodes = '" + codes.join(' ') + "'.split(' ');\n");
|
||||
@@ -0,0 +1,16 @@
|
||||
import fs from 'node:fs';
|
||||
import {internationalCase} from '../tests/frontend/helpers/irpc-international-case.mjs';
|
||||
import {recordAnnual} from '../resources/js/lib/irpc-annual-settlement.ts';
|
||||
const cases = {};
|
||||
for (const name of ['payable','treaty','missing','limited-collecta','duplicate','absent','prior-use']) {
|
||||
const c = name === 'limited-collecta' ? internationalCase('2000','2000') : internationalCase();
|
||||
const p = c.b.internationalCredits.positions[0];
|
||||
if (name === 'treaty') Object.assign(p, {treaty: 'yes', treatyLimit: '6', treatyReference: 'SYNTHETIC QA convention ceiling only, no actual treaty assertion'});
|
||||
if (name === 'missing') p.treaty = '';
|
||||
if (name === 'limited-collecta') p.incomeAmount = '6250';
|
||||
if (name === 'duplicate') Object.assign(p.payments[0], {issuer: c.b.ppc.rows[0].issuer, document: c.b.ppc.rows[0].document, proofAmount: '500'});
|
||||
if (name === 'absent') {c.b.internationalCredits.state = 'absent';c.b.internationalCredits.positions = [];}
|
||||
if (name === 'prior-use') Object.assign(p.previousUse, {amount: '3', reference: 'SYNTHETIC QA: documented actual previous credit use of 3 MZN'});
|
||||
cases[name] = recordAnnual(c.d, c.b, '2026-10-27T17:00:00+02:00');
|
||||
}
|
||||
fs.writeFileSync(new URL('../tests/frontend/fixtures/irpc-international-preserved.json', import.meta.url), JSON.stringify({synthetic: true, actualConventionData: false, base: 'irpc-assessment-preserved.json', cases}));
|
||||
@@ -0,0 +1,26 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import {annualBook,annualCurrent,calculateAnnual,annualHtml,annualReportRows} from '../resources/js/lib/irpc-annual-settlement.ts';
|
||||
import {createProjectDossierReport} from '../resources/js/lib/project-dossier-report.ts';
|
||||
const root=path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
||||
assert.equal(path.basename(root),'portal-investidor-irpc-international-qa-20261027');
|
||||
const output=path.join(root,'outputs/irpc-l8-international-20261027');
|
||||
const results=[];
|
||||
for(const name of ['payable','treaty','missing','limited-collecta','duplicate','absent','prior-use']){
|
||||
const d=JSON.parse(fs.readFileSync(path.join(output,'recovered-'+name+'.json'),'utf8'));
|
||||
const book=annualBook(d),m=book.result.model;
|
||||
assert.equal(annualCurrent(d,book),true);
|
||||
const fresh=calculateAnnual(d,book);assert.equal(fresh.status,m.status);assert.deepEqual(fresh.arithmeticBalance,m.arithmeticBalance);assert.deepEqual(fresh.internationalCredit,m.internationalCredit);
|
||||
const html=annualHtml(d),rows=annualReportRows(d);
|
||||
const dossier=createProjectDossierReport(d,{selectedSections:new Set(['finance']),generatedAt:'2026-10-27T17:00:00+02:00'});
|
||||
assert.match(html,/Crédito internacional — antes do PEC/);assert.match(JSON.stringify(dossier),/Crédito internacional — antes do PEC/);
|
||||
if(['missing','duplicate'].includes(name)){assert.match(html,/Indeterminado/);assert.equal(m.arithmeticBalance,null);}
|
||||
if(name==='payable'){assert.match(html,/700.00/);assert.match(html,/1400.00/);assert.match(html,/1200.00/);}
|
||||
fs.writeFileSync(path.join(output,'report-'+name+'.html'),html);
|
||||
fs.writeFileSync(path.join(output,'dossier-'+name+'.json'),JSON.stringify(dossier));
|
||||
results.push({case:name,status:m.status,balance:m.arithmeticBalance,international:m.internationalCredit,pec:m.pecDeduction,reportRows:rows.length,history:book.history.length,apiRoundTrip:true,current:true,dossier:true});
|
||||
}
|
||||
fs.writeFileSync(path.join(output,'recovered-report-receipt.json'),JSON.stringify({synthetic:true,activeChanged:false,results},null,2));
|
||||
console.log(JSON.stringify(results.map(({case:name,status,balance,history})=>({case:name,status,balance,history})),null,2));
|
||||
Reference in New Issue
Block a user