Binary file not shown.
BIN
Binary file not shown.
@@ -20,7 +20,7 @@ jobs:
|
|||||||
POSTGRES_USER: investmoz_test
|
POSTGRES_USER: investmoz_test
|
||||||
POSTGRES_PASSWORD: test-only-password
|
POSTGRES_PASSWORD: test-only-password
|
||||||
ports:
|
ports:
|
||||||
- 5432:5432
|
- 55441:5432
|
||||||
options: >-
|
options: >-
|
||||||
--health-cmd "pg_isready -U investmoz_test -d investmoz_test"
|
--health-cmd "pg_isready -U investmoz_test -d investmoz_test"
|
||||||
--health-interval 10s --health-timeout 5s --health-retries 5
|
--health-interval 10s --health-timeout 5s --health-retries 5
|
||||||
@@ -28,7 +28,7 @@ jobs:
|
|||||||
APP_ENV: testing
|
APP_ENV: testing
|
||||||
DB_CONNECTION: pgsql
|
DB_CONNECTION: pgsql
|
||||||
DB_HOST: 127.0.0.1
|
DB_HOST: 127.0.0.1
|
||||||
DB_PORT: 5432
|
DB_PORT: 55441
|
||||||
DB_DATABASE: investmoz_test
|
DB_DATABASE: investmoz_test
|
||||||
DB_USERNAME: investmoz_test
|
DB_USERNAME: investmoz_test
|
||||||
DB_PASSWORD: test-only-password
|
DB_PASSWORD: test-only-password
|
||||||
@@ -71,5 +71,5 @@ jobs:
|
|||||||
INVESTMOZ_SCHEMA_TESTS: '1'
|
INVESTMOZ_SCHEMA_TESTS: '1'
|
||||||
run: php vendor/bin/phpunit --configuration=phpunit.investmoz.xml --do-not-cache-result
|
run: php vendor/bin/phpunit --configuration=phpunit.investmoz.xml --do-not-cache-result
|
||||||
|
|
||||||
- name: Test frontend API contracts
|
- name: Test all frontend contracts and calculators
|
||||||
run: node --test tests/frontend/portal-api.test.mjs
|
run: node --test tests/frontend/*.test.mjs
|
||||||
|
|||||||
+329
-81
@@ -57,7 +57,8 @@ paths:
|
|||||||
description: Página do catálogo na versão solicitada
|
description: Página do catálogo na versão solicitada
|
||||||
headers:
|
headers:
|
||||||
ETag: { $ref: '#/components/headers/ETag' }
|
ETag: { $ref: '#/components/headers/ETag' }
|
||||||
X-Correlation-ID: {$ref: '#/components/headers/CorrelationId'}
|
X-Correlation-ID:
|
||||||
|
{ $ref: '#/components/headers/CorrelationId' }
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema: { $ref: '#/components/schemas/CatalogPage' }
|
schema: { $ref: '#/components/schemas/CatalogPage' }
|
||||||
@@ -79,10 +80,14 @@ paths:
|
|||||||
description: Questionário publicado em pt-MZ
|
description: Questionário publicado em pt-MZ
|
||||||
headers:
|
headers:
|
||||||
ETag: { $ref: '#/components/headers/ETag' }
|
ETag: { $ref: '#/components/headers/ETag' }
|
||||||
X-Correlation-ID: {$ref: '#/components/headers/CorrelationId'}
|
X-Correlation-ID:
|
||||||
|
{ $ref: '#/components/headers/CorrelationId' }
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema: {$ref: '#/components/schemas/QuestionnaireResponse'}
|
schema:
|
||||||
|
{
|
||||||
|
$ref: '#/components/schemas/QuestionnaireResponse',
|
||||||
|
}
|
||||||
'404': { $ref: '#/components/responses/NotFound' }
|
'404': { $ref: '#/components/responses/NotFound' }
|
||||||
'429': { $ref: '#/components/responses/RateLimited' }
|
'429': { $ref: '#/components/responses/RateLimited' }
|
||||||
'500': { $ref: '#/components/responses/ServerError' }
|
'500': { $ref: '#/components/responses/ServerError' }
|
||||||
@@ -116,18 +121,26 @@ paths:
|
|||||||
headers:
|
headers:
|
||||||
ETag: { $ref: '#/components/headers/ETag' }
|
ETag: { $ref: '#/components/headers/ETag' }
|
||||||
Location: { $ref: '#/components/headers/Location' }
|
Location: { $ref: '#/components/headers/Location' }
|
||||||
X-Correlation-ID: {$ref: '#/components/headers/CorrelationId'}
|
X-Correlation-ID:
|
||||||
|
{ $ref: '#/components/headers/CorrelationId' }
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema: {$ref: '#/components/schemas/SimulationAccepted'}
|
schema:
|
||||||
|
{
|
||||||
|
$ref: '#/components/schemas/SimulationAccepted',
|
||||||
|
}
|
||||||
'200':
|
'200':
|
||||||
description: Repetição idempotente da resposta original
|
description: Repetição idempotente da resposta original
|
||||||
headers:
|
headers:
|
||||||
ETag: { $ref: '#/components/headers/ETag' }
|
ETag: { $ref: '#/components/headers/ETag' }
|
||||||
X-Correlation-ID: {$ref: '#/components/headers/CorrelationId'}
|
X-Correlation-ID:
|
||||||
|
{ $ref: '#/components/headers/CorrelationId' }
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema: {$ref: '#/components/schemas/SimulationAccepted'}
|
schema:
|
||||||
|
{
|
||||||
|
$ref: '#/components/schemas/SimulationAccepted',
|
||||||
|
}
|
||||||
'401': { $ref: '#/components/responses/Unauthorized' }
|
'401': { $ref: '#/components/responses/Unauthorized' }
|
||||||
'403': { $ref: '#/components/responses/Forbidden' }
|
'403': { $ref: '#/components/responses/Forbidden' }
|
||||||
'409': { $ref: '#/components/responses/Conflict' }
|
'409': { $ref: '#/components/responses/Conflict' }
|
||||||
@@ -153,10 +166,14 @@ paths:
|
|||||||
description: Simulação dentro do âmbito autorizado
|
description: Simulação dentro do âmbito autorizado
|
||||||
headers:
|
headers:
|
||||||
ETag: { $ref: '#/components/headers/ETag' }
|
ETag: { $ref: '#/components/headers/ETag' }
|
||||||
X-Correlation-ID: {$ref: '#/components/headers/CorrelationId'}
|
X-Correlation-ID:
|
||||||
|
{ $ref: '#/components/headers/CorrelationId' }
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema: {$ref: '#/components/schemas/SimulationResponse'}
|
schema:
|
||||||
|
{
|
||||||
|
$ref: '#/components/schemas/SimulationResponse',
|
||||||
|
}
|
||||||
'401': { $ref: '#/components/responses/Unauthorized' }
|
'401': { $ref: '#/components/responses/Unauthorized' }
|
||||||
'403': { $ref: '#/components/responses/Forbidden' }
|
'403': { $ref: '#/components/responses/Forbidden' }
|
||||||
'404': { $ref: '#/components/responses/NotFound' }
|
'404': { $ref: '#/components/responses/NotFound' }
|
||||||
@@ -181,13 +198,15 @@ paths:
|
|||||||
required: true
|
required: true
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema: {$ref: '#/components/schemas/UpdateScenarioInput'}
|
schema:
|
||||||
|
{ $ref: '#/components/schemas/UpdateScenarioInput' }
|
||||||
responses:
|
responses:
|
||||||
'202':
|
'202':
|
||||||
description: Alteração aceite e reexecução colocada em fila
|
description: Alteração aceite e reexecução colocada em fila
|
||||||
headers:
|
headers:
|
||||||
ETag: { $ref: '#/components/headers/ETag' }
|
ETag: { $ref: '#/components/headers/ETag' }
|
||||||
X-Correlation-ID: {$ref: '#/components/headers/CorrelationId'}
|
X-Correlation-ID:
|
||||||
|
{ $ref: '#/components/headers/CorrelationId' }
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema: { $ref: '#/components/schemas/Scenario' }
|
schema: { $ref: '#/components/schemas/Scenario' }
|
||||||
@@ -217,10 +236,12 @@ paths:
|
|||||||
'200':
|
'200':
|
||||||
description: Jobs visíveis no âmbito autorizado
|
description: Jobs visíveis no âmbito autorizado
|
||||||
headers:
|
headers:
|
||||||
X-Correlation-ID: {$ref: '#/components/headers/CorrelationId'}
|
X-Correlation-ID:
|
||||||
|
{ $ref: '#/components/headers/CorrelationId' }
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema: {$ref: '#/components/schemas/JobCollection'}
|
schema:
|
||||||
|
{ $ref: '#/components/schemas/JobCollection' }
|
||||||
'401': { $ref: '#/components/responses/Unauthorized' }
|
'401': { $ref: '#/components/responses/Unauthorized' }
|
||||||
'403': { $ref: '#/components/responses/Forbidden' }
|
'403': { $ref: '#/components/responses/Forbidden' }
|
||||||
'404': { $ref: '#/components/responses/NotFound' }
|
'404': { $ref: '#/components/responses/NotFound' }
|
||||||
@@ -244,10 +265,12 @@ paths:
|
|||||||
'200':
|
'200':
|
||||||
description: Snapshot e hash do relatório
|
description: Snapshot e hash do relatório
|
||||||
headers:
|
headers:
|
||||||
X-Correlation-ID: {$ref: '#/components/headers/CorrelationId'}
|
X-Correlation-ID:
|
||||||
|
{ $ref: '#/components/headers/CorrelationId' }
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema: {$ref: '#/components/schemas/ReportResponse'}
|
schema:
|
||||||
|
{ $ref: '#/components/schemas/ReportResponse' }
|
||||||
'401': { $ref: '#/components/responses/Unauthorized' }
|
'401': { $ref: '#/components/responses/Unauthorized' }
|
||||||
'403': { $ref: '#/components/responses/Forbidden' }
|
'403': { $ref: '#/components/responses/Forbidden' }
|
||||||
'404': { $ref: '#/components/responses/NotFound' }
|
'404': { $ref: '#/components/responses/NotFound' }
|
||||||
@@ -271,10 +294,12 @@ paths:
|
|||||||
description: Fontes legais publicadas
|
description: Fontes legais publicadas
|
||||||
headers:
|
headers:
|
||||||
ETag: { $ref: '#/components/headers/ETag' }
|
ETag: { $ref: '#/components/headers/ETag' }
|
||||||
X-Correlation-ID: {$ref: '#/components/headers/CorrelationId'}
|
X-Correlation-ID:
|
||||||
|
{ $ref: '#/components/headers/CorrelationId' }
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema: {$ref: '#/components/schemas/LegislationPage'}
|
schema:
|
||||||
|
{ $ref: '#/components/schemas/LegislationPage' }
|
||||||
'404': { $ref: '#/components/responses/NotFound' }
|
'404': { $ref: '#/components/responses/NotFound' }
|
||||||
'422': { $ref: '#/components/responses/ValidationError' }
|
'422': { $ref: '#/components/responses/ValidationError' }
|
||||||
'429': { $ref: '#/components/responses/RateLimited' }
|
'429': { $ref: '#/components/responses/RateLimited' }
|
||||||
@@ -292,10 +317,14 @@ paths:
|
|||||||
'200':
|
'200':
|
||||||
description: Lista de fontes legais
|
description: Lista de fontes legais
|
||||||
headers:
|
headers:
|
||||||
X-Correlation-ID: {$ref: '#/components/headers/CorrelationId'}
|
X-Correlation-ID:
|
||||||
|
{ $ref: '#/components/headers/CorrelationId' }
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema: {$ref: '#/components/schemas/AdminLegalSourcePage'}
|
schema:
|
||||||
|
{
|
||||||
|
$ref: '#/components/schemas/AdminLegalSourcePage',
|
||||||
|
}
|
||||||
'401': { $ref: '#/components/responses/Unauthorized' }
|
'401': { $ref: '#/components/responses/Unauthorized' }
|
||||||
'403': { $ref: '#/components/responses/Forbidden' }
|
'403': { $ref: '#/components/responses/Forbidden' }
|
||||||
'429': { $ref: '#/components/responses/RateLimited' }
|
'429': { $ref: '#/components/responses/RateLimited' }
|
||||||
@@ -312,13 +341,15 @@ paths:
|
|||||||
required: true
|
required: true
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema: {$ref: '#/components/schemas/LegalSourceInput'}
|
schema:
|
||||||
|
{ $ref: '#/components/schemas/LegalSourceInput' }
|
||||||
responses:
|
responses:
|
||||||
'201':
|
'201':
|
||||||
description: Fonte legal registada
|
description: Fonte legal registada
|
||||||
headers:
|
headers:
|
||||||
Location: { $ref: '#/components/headers/Location' }
|
Location: { $ref: '#/components/headers/Location' }
|
||||||
X-Correlation-ID: {$ref: '#/components/headers/CorrelationId'}
|
X-Correlation-ID:
|
||||||
|
{ $ref: '#/components/headers/CorrelationId' }
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema: { $ref: '#/components/schemas/LegalSource' }
|
schema: { $ref: '#/components/schemas/LegalSource' }
|
||||||
@@ -346,12 +377,16 @@ paths:
|
|||||||
required: true
|
required: true
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema: {$ref: '#/components/schemas/LegalSourceTransitionInput'}
|
schema:
|
||||||
|
{
|
||||||
|
$ref: '#/components/schemas/LegalSourceTransitionInput',
|
||||||
|
}
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Estado actualizado
|
description: Estado actualizado
|
||||||
headers:
|
headers:
|
||||||
X-Correlation-ID: {$ref: '#/components/headers/CorrelationId'}
|
X-Correlation-ID:
|
||||||
|
{ $ref: '#/components/headers/CorrelationId' }
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema: { $ref: '#/components/schemas/LegalSource' }
|
schema: { $ref: '#/components/schemas/LegalSource' }
|
||||||
@@ -375,15 +410,22 @@ paths:
|
|||||||
required: true
|
required: true
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema: {$ref: '#/components/schemas/InterestRequestInput'}
|
schema:
|
||||||
|
{
|
||||||
|
$ref: '#/components/schemas/InterestRequestInput',
|
||||||
|
}
|
||||||
responses:
|
responses:
|
||||||
'201':
|
'201':
|
||||||
description: Manifestação submetida
|
description: Manifestação submetida
|
||||||
headers:
|
headers:
|
||||||
X-Correlation-ID: {$ref: '#/components/headers/CorrelationId'}
|
X-Correlation-ID:
|
||||||
|
{ $ref: '#/components/headers/CorrelationId' }
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema: {$ref: '#/components/schemas/InterestRequestResponse'}
|
schema:
|
||||||
|
{
|
||||||
|
$ref: '#/components/schemas/InterestRequestResponse',
|
||||||
|
}
|
||||||
'401': { $ref: '#/components/responses/Unauthorized' }
|
'401': { $ref: '#/components/responses/Unauthorized' }
|
||||||
'403': { $ref: '#/components/responses/Forbidden' }
|
'403': { $ref: '#/components/responses/Forbidden' }
|
||||||
'409': { $ref: '#/components/responses/Conflict' }
|
'409': { $ref: '#/components/responses/Conflict' }
|
||||||
@@ -407,10 +449,14 @@ paths:
|
|||||||
'200':
|
'200':
|
||||||
description: Oportunidade publicada
|
description: Oportunidade publicada
|
||||||
headers:
|
headers:
|
||||||
X-Correlation-ID: {$ref: '#/components/headers/CorrelationId'}
|
X-Correlation-ID:
|
||||||
|
{ $ref: '#/components/headers/CorrelationId' }
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema: {$ref: '#/components/schemas/OpportunityResponse'}
|
schema:
|
||||||
|
{
|
||||||
|
$ref: '#/components/schemas/OpportunityResponse',
|
||||||
|
}
|
||||||
'404': { $ref: '#/components/responses/NotFound' }
|
'404': { $ref: '#/components/responses/NotFound' }
|
||||||
'429': { $ref: '#/components/responses/RateLimited' }
|
'429': { $ref: '#/components/responses/RateLimited' }
|
||||||
'500': { $ref: '#/components/responses/ServerError' }
|
'500': { $ref: '#/components/responses/ServerError' }
|
||||||
@@ -426,7 +472,11 @@ components:
|
|||||||
name: catalog
|
name: catalog
|
||||||
in: path
|
in: path
|
||||||
required: true
|
required: true
|
||||||
schema: {type: string, enum: [authorities, jurisdictions, economic-activities]}
|
schema:
|
||||||
|
{
|
||||||
|
type: string,
|
||||||
|
enum: [authorities, jurisdictions, economic-activities],
|
||||||
|
}
|
||||||
Version:
|
Version:
|
||||||
name: version
|
name: version
|
||||||
in: query
|
in: query
|
||||||
@@ -438,7 +488,11 @@ components:
|
|||||||
in: query
|
in: query
|
||||||
required: false
|
required: false
|
||||||
description: Obrigatório para jurisdictions.
|
description: Obrigatório para jurisdictions.
|
||||||
schema: {type: string, enum: [country, province, district, admin_post, locality]}
|
schema:
|
||||||
|
{
|
||||||
|
type: string,
|
||||||
|
enum: [country, province, district, admin_post, locality],
|
||||||
|
}
|
||||||
ParentId:
|
ParentId:
|
||||||
name: parent_id
|
name: parent_id
|
||||||
in: query
|
in: query
|
||||||
@@ -530,23 +584,55 @@ components:
|
|||||||
responses:
|
responses:
|
||||||
Unauthorized:
|
Unauthorized:
|
||||||
description: Autenticação necessária ou sessão inválida
|
description: Autenticação necessária ou sessão inválida
|
||||||
headers: {X-Correlation-ID: {$ref: '#/components/headers/CorrelationId'}}
|
headers:
|
||||||
content: {application/json: {schema: {$ref: '#/components/schemas/Problem'}}}
|
{
|
||||||
|
X-Correlation-ID:
|
||||||
|
{ $ref: '#/components/headers/CorrelationId' },
|
||||||
|
}
|
||||||
|
content:
|
||||||
|
{
|
||||||
|
application/json:
|
||||||
|
{ schema: { $ref: '#/components/schemas/Problem' } },
|
||||||
|
}
|
||||||
Forbidden:
|
Forbidden:
|
||||||
description: Actor autenticado sem autorização para a operação
|
description: Actor autenticado sem autorização para a operação
|
||||||
headers: {X-Correlation-ID: {$ref: '#/components/headers/CorrelationId'}}
|
headers:
|
||||||
content: {application/json: {schema: {$ref: '#/components/schemas/Problem'}}}
|
{
|
||||||
|
X-Correlation-ID:
|
||||||
|
{ $ref: '#/components/headers/CorrelationId' },
|
||||||
|
}
|
||||||
|
content:
|
||||||
|
{
|
||||||
|
application/json:
|
||||||
|
{ schema: { $ref: '#/components/schemas/Problem' } },
|
||||||
|
}
|
||||||
NotFound:
|
NotFound:
|
||||||
description: Recurso inexistente ou fora do âmbito visível
|
description: Recurso inexistente ou fora do âmbito visível
|
||||||
headers: {X-Correlation-ID: {$ref: '#/components/headers/CorrelationId'}}
|
headers:
|
||||||
content: {application/json: {schema: {$ref: '#/components/schemas/Problem'}}}
|
{
|
||||||
|
X-Correlation-ID:
|
||||||
|
{ $ref: '#/components/headers/CorrelationId' },
|
||||||
|
}
|
||||||
|
content:
|
||||||
|
{
|
||||||
|
application/json:
|
||||||
|
{ schema: { $ref: '#/components/schemas/Problem' } },
|
||||||
|
}
|
||||||
Conflict:
|
Conflict:
|
||||||
description: Conflito de estado, versão ou chave idempotente
|
description: Conflito de estado, versão ou chave idempotente
|
||||||
headers: {X-Correlation-ID: {$ref: '#/components/headers/CorrelationId'}}
|
headers:
|
||||||
|
{
|
||||||
|
X-Correlation-ID:
|
||||||
|
{ $ref: '#/components/headers/CorrelationId' },
|
||||||
|
}
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema: { $ref: '#/components/schemas/Problem' }
|
schema: { $ref: '#/components/schemas/Problem' }
|
||||||
example: {message: A chave foi reutilizada com conteúdo diferente., code: idempotency_conflict}
|
example:
|
||||||
|
{
|
||||||
|
message: A chave foi reutilizada com conteúdo diferente.,
|
||||||
|
code: idempotency_conflict,
|
||||||
|
}
|
||||||
PreconditionFailed:
|
PreconditionFailed:
|
||||||
description: If-Match não corresponde ao ETag actual
|
description: If-Match não corresponde ao ETag actual
|
||||||
headers:
|
headers:
|
||||||
@@ -555,25 +641,62 @@ components:
|
|||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema: { $ref: '#/components/schemas/Problem' }
|
schema: { $ref: '#/components/schemas/Problem' }
|
||||||
example: {message: A representação mudou; volte a consultar o recurso., code: stale_etag}
|
example:
|
||||||
|
{
|
||||||
|
message: A representação mudou; volte a consultar o recurso.,
|
||||||
|
code: stale_etag,
|
||||||
|
}
|
||||||
ValidationError:
|
ValidationError:
|
||||||
description: Dados inválidos
|
description: Dados inválidos
|
||||||
headers: {X-Correlation-ID: {$ref: '#/components/headers/CorrelationId'}}
|
headers:
|
||||||
content: {application/json: {schema: {$ref: '#/components/schemas/ValidationProblem'}}}
|
{
|
||||||
|
X-Correlation-ID:
|
||||||
|
{ $ref: '#/components/headers/CorrelationId' },
|
||||||
|
}
|
||||||
|
content:
|
||||||
|
{
|
||||||
|
application/json:
|
||||||
|
{
|
||||||
|
schema:
|
||||||
|
{
|
||||||
|
$ref: '#/components/schemas/ValidationProblem',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
RateLimited:
|
RateLimited:
|
||||||
description: Limite de pedidos excedido
|
description: Limite de pedidos excedido
|
||||||
headers:
|
headers:
|
||||||
Retry-After: { $ref: '#/components/headers/RetryAfter' }
|
Retry-After: { $ref: '#/components/headers/RetryAfter' }
|
||||||
X-Correlation-ID: { $ref: '#/components/headers/CorrelationId' }
|
X-Correlation-ID: { $ref: '#/components/headers/CorrelationId' }
|
||||||
content: {application/json: {schema: {$ref: '#/components/schemas/Problem'}}}
|
content:
|
||||||
|
{
|
||||||
|
application/json:
|
||||||
|
{ schema: { $ref: '#/components/schemas/Problem' } },
|
||||||
|
}
|
||||||
ServerError:
|
ServerError:
|
||||||
description: Erro interno; resposta não contém detalhes sensíveis
|
description: Erro interno; resposta não contém detalhes sensíveis
|
||||||
headers: {X-Correlation-ID: {$ref: '#/components/headers/CorrelationId'}}
|
headers:
|
||||||
content: {application/json: {schema: {$ref: '#/components/schemas/Problem'}}}
|
{
|
||||||
|
X-Correlation-ID:
|
||||||
|
{ $ref: '#/components/headers/CorrelationId' },
|
||||||
|
}
|
||||||
|
content:
|
||||||
|
{
|
||||||
|
application/json:
|
||||||
|
{ schema: { $ref: '#/components/schemas/Problem' } },
|
||||||
|
}
|
||||||
PreconditionRequired:
|
PreconditionRequired:
|
||||||
description: Header obrigatório em falta, como If-Match ou Idempotency-Key
|
description: Header obrigatório em falta, como If-Match ou Idempotency-Key
|
||||||
headers: {X-Correlation-ID: {$ref: '#/components/headers/CorrelationId'}}
|
headers:
|
||||||
content: {application/json: {schema: {$ref: '#/components/schemas/Problem'}}}
|
{
|
||||||
|
X-Correlation-ID:
|
||||||
|
{ $ref: '#/components/headers/CorrelationId' },
|
||||||
|
}
|
||||||
|
content:
|
||||||
|
{
|
||||||
|
application/json:
|
||||||
|
{ schema: { $ref: '#/components/schemas/Problem' } },
|
||||||
|
}
|
||||||
schemas:
|
schemas:
|
||||||
Problem:
|
Problem:
|
||||||
type: object
|
type: object
|
||||||
@@ -600,11 +723,27 @@ components:
|
|||||||
id: { type: string, format: uuid }
|
id: { type: string, format: uuid }
|
||||||
value: { type: string }
|
value: { type: string }
|
||||||
code: { type: string }
|
code: { type: string }
|
||||||
name: {type: string, description: Rótulo apresentado em português de Moçambique.}
|
name:
|
||||||
|
{
|
||||||
|
type: string,
|
||||||
|
description: Rótulo apresentado em português de Moçambique.,
|
||||||
|
}
|
||||||
label: { type: string }
|
label: { type: string }
|
||||||
locale: { type: string, const: pt-MZ }
|
locale: { type: string, const: pt-MZ }
|
||||||
parent_id: { type: [string, 'null'] }
|
parent_id: { type: [string, 'null'] }
|
||||||
type: {type: [string, 'null'], enum: [country, province, district, admin_post, locality, 'null']}
|
type:
|
||||||
|
{
|
||||||
|
type: [string, 'null'],
|
||||||
|
enum:
|
||||||
|
[
|
||||||
|
country,
|
||||||
|
province,
|
||||||
|
district,
|
||||||
|
admin_post,
|
||||||
|
locality,
|
||||||
|
'null',
|
||||||
|
],
|
||||||
|
}
|
||||||
authority_type: { type: [string, 'null'] }
|
authority_type: { type: [string, 'null'] }
|
||||||
organization_id: { type: [string, 'null'], format: uuid }
|
organization_id: { type: [string, 'null'], format: uuid }
|
||||||
jurisdiction_id: { type: [string, 'null'], format: uuid }
|
jurisdiction_id: { type: [string, 'null'], format: uuid }
|
||||||
@@ -616,12 +755,17 @@ components:
|
|||||||
type: object
|
type: object
|
||||||
required: [data, meta]
|
required: [data, meta]
|
||||||
properties:
|
properties:
|
||||||
data: {type: array, items: {$ref: '#/components/schemas/CatalogItem'}}
|
data:
|
||||||
|
{
|
||||||
|
type: array,
|
||||||
|
items: { $ref: '#/components/schemas/CatalogItem' },
|
||||||
|
}
|
||||||
links:
|
links:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
next: { type: [string, 'null'], format: uri-reference }
|
next: { type: [string, 'null'], format: uri-reference }
|
||||||
previous: {type: [string, 'null'], format: uri-reference}
|
previous:
|
||||||
|
{ type: [string, 'null'], format: uri-reference }
|
||||||
next_page_url: { type: [string, 'null'], format: uri-reference }
|
next_page_url: { type: [string, 'null'], format: uri-reference }
|
||||||
prev_page_url: { type: [string, 'null'], format: uri-reference }
|
prev_page_url: { type: [string, 'null'], format: uri-reference }
|
||||||
current_page: { type: integer }
|
current_page: { type: integer }
|
||||||
@@ -637,7 +781,11 @@ components:
|
|||||||
version: { type: [integer, 'null'] }
|
version: { type: [integer, 'null'] }
|
||||||
locale: { type: string, const: pt-MZ }
|
locale: { type: string, const: pt-MZ }
|
||||||
source_version: { type: [string, 'null'] }
|
source_version: { type: [string, 'null'] }
|
||||||
status: {type: string, enum: [published, not_published]}
|
status:
|
||||||
|
{
|
||||||
|
type: string,
|
||||||
|
enum: [published, not_published],
|
||||||
|
}
|
||||||
Pagination:
|
Pagination:
|
||||||
type: object
|
type: object
|
||||||
required: [current_page, per_page, total]
|
required: [current_page, per_page, total]
|
||||||
@@ -652,13 +800,15 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
data:
|
data:
|
||||||
type: object
|
type: object
|
||||||
required: [id, code, version_no, locale, schema_snapshot, status]
|
required:
|
||||||
|
[id, code, version_no, locale, schema_snapshot, status]
|
||||||
properties:
|
properties:
|
||||||
id: { type: string, format: uuid }
|
id: { type: string, format: uuid }
|
||||||
code: { type: string }
|
code: { type: string }
|
||||||
version_no: { type: integer, minimum: 1 }
|
version_no: { type: integer, minimum: 1 }
|
||||||
locale: { type: string, const: pt-MZ }
|
locale: { type: string, const: pt-MZ }
|
||||||
schema_snapshot: {type: object, additionalProperties: true}
|
schema_snapshot:
|
||||||
|
{ type: object, additionalProperties: true }
|
||||||
status: { type: string, const: published }
|
status: { type: string, const: published }
|
||||||
valid_from: { type: [string, 'null'], format: date }
|
valid_from: { type: [string, 'null'], format: date }
|
||||||
valid_to: { type: [string, 'null'], format: date }
|
valid_to: { type: [string, 'null'], format: date }
|
||||||
@@ -666,9 +816,21 @@ components:
|
|||||||
type: object
|
type: object
|
||||||
required: [base, rate]
|
required: [base, rate]
|
||||||
properties:
|
properties:
|
||||||
base: {type: number, minimum: 0, description: Valor de entrada sem moeda inferida.}
|
base:
|
||||||
rate: {type: number, minimum: 0, maximum: 100, description: Parâmetro fornecido pelo utilizador; não representa taxa oficial.}
|
{
|
||||||
reduction: {type: number, minimum: 0, maximum: 100, default: 0}
|
type: number,
|
||||||
|
minimum: 0,
|
||||||
|
description: Valor de entrada sem moeda inferida.,
|
||||||
|
}
|
||||||
|
rate:
|
||||||
|
{
|
||||||
|
type: number,
|
||||||
|
minimum: 0,
|
||||||
|
maximum: 100,
|
||||||
|
description: Parâmetro fornecido pelo utilizador; não representa taxa oficial.,
|
||||||
|
}
|
||||||
|
reduction:
|
||||||
|
{ type: number, minimum: 0, maximum: 100, default: 0 }
|
||||||
organization_id: { type: [string, 'null'], format: uuid }
|
organization_id: { type: [string, 'null'], format: uuid }
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
UpdateScenarioInput:
|
UpdateScenarioInput:
|
||||||
@@ -678,7 +840,8 @@ components:
|
|||||||
label: { type: string, minLength: 1, maxLength: 100 }
|
label: { type: string, minLength: 1, maxLength: 100 }
|
||||||
base: { type: number, minimum: 0 }
|
base: { type: number, minimum: 0 }
|
||||||
rate: { type: number, minimum: 0, maximum: 100 }
|
rate: { type: number, minimum: 0, maximum: 100 }
|
||||||
reduction: {type: number, minimum: 0, maximum: 100, default: 0}
|
reduction:
|
||||||
|
{ type: number, minimum: 0, maximum: 100, default: 0 }
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
SimulationAccepted:
|
SimulationAccepted:
|
||||||
type: object
|
type: object
|
||||||
@@ -686,7 +849,13 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
data: { $ref: '#/components/schemas/Simulation' }
|
data: { $ref: '#/components/schemas/Simulation' }
|
||||||
replayed: { type: boolean }
|
replayed: { type: boolean }
|
||||||
access_token: {type: string, minLength: 32, maxLength: 256, description: Devolvido apenas para execução anónima.}
|
access_token:
|
||||||
|
{
|
||||||
|
type: string,
|
||||||
|
minLength: 32,
|
||||||
|
maxLength: 256,
|
||||||
|
description: Devolvido apenas para execução anónima.,
|
||||||
|
}
|
||||||
SimulationResponse:
|
SimulationResponse:
|
||||||
type: object
|
type: object
|
||||||
required: [data]
|
required: [data]
|
||||||
@@ -697,14 +866,25 @@ components:
|
|||||||
required: [id, status, version_no, created_at, updated_at]
|
required: [id, status, version_no, created_at, updated_at]
|
||||||
properties:
|
properties:
|
||||||
id: { type: string, format: uuid }
|
id: { type: string, format: uuid }
|
||||||
questionnaire_version_id: {type: [string, 'null'], format: uuid}
|
questionnaire_version_id:
|
||||||
|
{ type: [string, 'null'], format: uuid }
|
||||||
organization_id: { type: [string, 'null'], format: uuid }
|
organization_id: { type: [string, 'null'], format: uuid }
|
||||||
version_no: { type: integer, minimum: 1 }
|
version_no: { type: integer, minimum: 1 }
|
||||||
status: {type: string, enum: [queued, running, completed, failed, cancelled]}
|
status:
|
||||||
|
{
|
||||||
|
type: string,
|
||||||
|
enum: [queued, running, completed, failed, cancelled],
|
||||||
|
}
|
||||||
input_snapshot: { type: object, additionalProperties: true }
|
input_snapshot: { type: object, additionalProperties: true }
|
||||||
result_snapshot: {type: [object, 'null'], additionalProperties: true}
|
result_snapshot:
|
||||||
calculation_snapshot: {type: [object, 'null'], additionalProperties: true}
|
{ type: [object, 'null'], additionalProperties: true }
|
||||||
scenarios: {type: array, items: {$ref: '#/components/schemas/Scenario'}}
|
calculation_snapshot:
|
||||||
|
{ type: [object, 'null'], additionalProperties: true }
|
||||||
|
scenarios:
|
||||||
|
{
|
||||||
|
type: array,
|
||||||
|
items: { $ref: '#/components/schemas/Scenario' },
|
||||||
|
}
|
||||||
created_at: { type: string, format: date-time }
|
created_at: { type: string, format: date-time }
|
||||||
updated_at: { type: string, format: date-time }
|
updated_at: { type: string, format: date-time }
|
||||||
Scenario:
|
Scenario:
|
||||||
@@ -720,15 +900,24 @@ components:
|
|||||||
type: object
|
type: object
|
||||||
required: [data]
|
required: [data]
|
||||||
properties:
|
properties:
|
||||||
data: {type: array, items: {$ref: '#/components/schemas/SimulationJob'}}
|
data:
|
||||||
|
{
|
||||||
|
type: array,
|
||||||
|
items: { $ref: '#/components/schemas/SimulationJob' },
|
||||||
|
}
|
||||||
SimulationJob:
|
SimulationJob:
|
||||||
type: object
|
type: object
|
||||||
required: [id, simulation_id, job_type, status, attempts, available_at]
|
required:
|
||||||
|
[id, simulation_id, job_type, status, attempts, available_at]
|
||||||
properties:
|
properties:
|
||||||
id: { type: string, format: uuid }
|
id: { type: string, format: uuid }
|
||||||
simulation_id: { type: string, format: uuid }
|
simulation_id: { type: string, format: uuid }
|
||||||
job_type: { type: string, enum: [execute, report] }
|
job_type: { type: string, enum: [execute, report] }
|
||||||
status: {type: string, enum: [pending, running, succeeded, failed]}
|
status:
|
||||||
|
{
|
||||||
|
type: string,
|
||||||
|
enum: [pending, running, succeeded, failed],
|
||||||
|
}
|
||||||
attempts: { type: integer, minimum: 0, maximum: 3 }
|
attempts: { type: integer, minimum: 0, maximum: 3 }
|
||||||
available_at: { type: string, format: date-time }
|
available_at: { type: string, format: date-time }
|
||||||
started_at: { type: [string, 'null'], format: date-time }
|
started_at: { type: [string, 'null'], format: date-time }
|
||||||
@@ -747,33 +936,51 @@ components:
|
|||||||
simulation_id: { type: string, format: uuid }
|
simulation_id: { type: string, format: uuid }
|
||||||
version_no: { type: integer, minimum: 1 }
|
version_no: { type: integer, minimum: 1 }
|
||||||
status: { type: string, enum: [queued, ready, failed] }
|
status: { type: string, enum: [queued, ready, failed] }
|
||||||
report_snapshot: {type: [object, 'null'], additionalProperties: true}
|
report_snapshot:
|
||||||
report_sha256: {type: [string, 'null'], pattern: '^[0-9a-f]{64}$'}
|
{ type: [object, 'null'], additionalProperties: true }
|
||||||
|
report_sha256:
|
||||||
|
{ type: [string, 'null'], pattern: '^[0-9a-f]{64}$' }
|
||||||
LegislationPage:
|
LegislationPage:
|
||||||
type: object
|
type: object
|
||||||
required: [data, meta]
|
required: [data, meta]
|
||||||
properties:
|
properties:
|
||||||
data: {type: array, items: {$ref: '#/components/schemas/LegalSource'}}
|
data:
|
||||||
|
{
|
||||||
|
type: array,
|
||||||
|
items: { $ref: '#/components/schemas/LegalSource' },
|
||||||
|
}
|
||||||
meta: { $ref: '#/components/schemas/Pagination' }
|
meta: { $ref: '#/components/schemas/Pagination' }
|
||||||
AdminLegalSourcePage:
|
AdminLegalSourcePage:
|
||||||
type: object
|
type: object
|
||||||
required: [data]
|
required: [data]
|
||||||
properties:
|
properties:
|
||||||
data: {type: array, items: {$ref: '#/components/schemas/LegalSource'}}
|
data:
|
||||||
|
{
|
||||||
|
type: array,
|
||||||
|
items: { $ref: '#/components/schemas/LegalSource' },
|
||||||
|
}
|
||||||
current_page: { type: integer }
|
current_page: { type: integer }
|
||||||
per_page: { type: integer }
|
per_page: { type: integer }
|
||||||
total: { type: integer }
|
total: { type: integer }
|
||||||
last_page: { type: integer }
|
last_page: { type: integer }
|
||||||
first_page_url: {type: [string, 'null'], format: uri-reference}
|
first_page_url:
|
||||||
|
{ type: [string, 'null'], format: uri-reference }
|
||||||
last_page_url: { type: [string, 'null'], format: uri-reference }
|
last_page_url: { type: [string, 'null'], format: uri-reference }
|
||||||
next_page_url: { type: [string, 'null'], format: uri-reference }
|
next_page_url: { type: [string, 'null'], format: uri-reference }
|
||||||
prev_page_url: { type: [string, 'null'], format: uri-reference }
|
prev_page_url: { type: [string, 'null'], format: uri-reference }
|
||||||
LegalSourceInput:
|
LegalSourceInput:
|
||||||
type: object
|
type: object
|
||||||
required: [title, url, diploma, article, competent_entity, valid_from]
|
required:
|
||||||
|
[title, url, diploma, article, competent_entity, valid_from]
|
||||||
properties:
|
properties:
|
||||||
title: { type: string, minLength: 1, maxLength: 255 }
|
title: { type: string, minLength: 1, maxLength: 255 }
|
||||||
url: {type: string, format: uri, pattern: '^https://', maxLength: 2000}
|
url:
|
||||||
|
{
|
||||||
|
type: string,
|
||||||
|
format: uri,
|
||||||
|
pattern: '^https://',
|
||||||
|
maxLength: 2000,
|
||||||
|
}
|
||||||
diploma: { type: string, maxLength: 255 }
|
diploma: { type: string, maxLength: 255 }
|
||||||
article: { type: string, maxLength: 255 }
|
article: { type: string, maxLength: 255 }
|
||||||
competent_entity: { type: string, maxLength: 255 }
|
competent_entity: { type: string, maxLength: 255 }
|
||||||
@@ -795,7 +1002,8 @@ components:
|
|||||||
diploma: { type: string }
|
diploma: { type: string }
|
||||||
article: { type: string }
|
article: { type: string }
|
||||||
competent_entity: { type: string }
|
competent_entity: { type: string }
|
||||||
validation_status: {type: string, enum: [pending, validated, revoked]}
|
validation_status:
|
||||||
|
{ type: string, enum: [pending, validated, revoked] }
|
||||||
version_no: { type: integer }
|
version_no: { type: integer }
|
||||||
valid_until: { type: [string, 'null'], format: date }
|
valid_until: { type: [string, 'null'], format: date }
|
||||||
validator_id: { type: [integer, 'null'] }
|
validator_id: { type: [integer, 'null'] }
|
||||||
@@ -803,19 +1011,58 @@ components:
|
|||||||
valid_from: { type: [string, 'null'], format: date }
|
valid_from: { type: [string, 'null'], format: date }
|
||||||
InterestRequestInput:
|
InterestRequestInput:
|
||||||
type: object
|
type: object
|
||||||
required: [fullName, email, investorType, country, sectorInterest, message, privacyConsent]
|
required:
|
||||||
|
[
|
||||||
|
fullName,
|
||||||
|
email,
|
||||||
|
investorType,
|
||||||
|
country,
|
||||||
|
sectorInterest,
|
||||||
|
message,
|
||||||
|
privacyConsent,
|
||||||
|
]
|
||||||
properties:
|
properties:
|
||||||
fullName: {type: string, minLength: 3, maxLength: 150, writeOnly: true}
|
fullName:
|
||||||
email: {type: string, format: email, maxLength: 150, writeOnly: true}
|
{
|
||||||
phone: {type: [string, 'null'], maxLength: 30, writeOnly: true}
|
type: string,
|
||||||
investorType: {type: string, enum: [individual, empresa, fundo, entidade_publica, outro]}
|
minLength: 3,
|
||||||
|
maxLength: 150,
|
||||||
|
writeOnly: true,
|
||||||
|
}
|
||||||
|
email:
|
||||||
|
{
|
||||||
|
type: string,
|
||||||
|
format: email,
|
||||||
|
maxLength: 150,
|
||||||
|
writeOnly: true,
|
||||||
|
}
|
||||||
|
phone:
|
||||||
|
{ type: [string, 'null'], maxLength: 30, writeOnly: true }
|
||||||
|
investorType:
|
||||||
|
{
|
||||||
|
type: string,
|
||||||
|
enum:
|
||||||
|
[
|
||||||
|
individual,
|
||||||
|
empresa,
|
||||||
|
fundo,
|
||||||
|
entidade_publica,
|
||||||
|
outro,
|
||||||
|
],
|
||||||
|
}
|
||||||
country: { type: string, maxLength: 100 }
|
country: { type: string, maxLength: 100 }
|
||||||
sectorInterest: { type: string, maxLength: 150 }
|
sectorInterest: { type: string, maxLength: 150 }
|
||||||
opportunityReference: { type: [string, 'null'], maxLength: 80 }
|
opportunityReference: { type: [string, 'null'], maxLength: 80 }
|
||||||
existingBusinessId: { type: [string, 'null'], format: uuid }
|
existingBusinessId: { type: [string, 'null'], format: uuid }
|
||||||
modality: { type: [string, 'null'], maxLength: 50 }
|
modality: { type: [string, 'null'], maxLength: 50 }
|
||||||
investmentRange: { type: [string, 'null'], maxLength: 80 }
|
investmentRange: { type: [string, 'null'], maxLength: 80 }
|
||||||
message: {type: string, minLength: 20, maxLength: 2000, writeOnly: true}
|
message:
|
||||||
|
{
|
||||||
|
type: string,
|
||||||
|
minLength: 20,
|
||||||
|
maxLength: 2000,
|
||||||
|
writeOnly: true,
|
||||||
|
}
|
||||||
privacyConsent: { type: boolean, const: true }
|
privacyConsent: { type: boolean, const: true }
|
||||||
shareWithProponent: { type: boolean, default: false }
|
shareWithProponent: { type: boolean, default: false }
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
@@ -835,7 +1082,8 @@ components:
|
|||||||
then:
|
then:
|
||||||
required: [modality]
|
required: [modality]
|
||||||
properties:
|
properties:
|
||||||
modality: {type: string, minLength: 1, maxLength: 50}
|
modality:
|
||||||
|
{ type: string, minLength: 1, maxLength: 50 }
|
||||||
InterestRequestResponse:
|
InterestRequestResponse:
|
||||||
type: object
|
type: object
|
||||||
required: [success, message, data]
|
required: [success, message, data]
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ class CheckDocumentLibrarySchema extends Command
|
|||||||
foreach ($required as $table => $columns) {
|
foreach ($required as $table => $columns) {
|
||||||
if (! Schema::hasTable($table)) {
|
if (! Schema::hasTable($table)) {
|
||||||
$missing[] = "tabela {$table}";
|
$missing[] = "tabela {$table}";
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class CheckMalwareScanner extends Command
|
|||||||
public function handle(MalwareScanner $scanner): int
|
public function handle(MalwareScanner $scanner): int
|
||||||
{
|
{
|
||||||
$health = $scanner->health();
|
$health = $scanner->health();
|
||||||
$this->line('Scanner: '.($health['engine'] ?? 'ClamAV'));
|
$this->line('Scanner: '.($health['engine']));
|
||||||
$this->line('Available: '.($health['available'] ? 'yes' : 'no'));
|
$this->line('Available: '.($health['available'] ? 'yes' : 'no'));
|
||||||
$this->line('Engine version: '.($health['engine_version'] ?? 'unavailable'));
|
$this->line('Engine version: '.($health['engine_version'] ?? 'unavailable'));
|
||||||
$this->line('Signatures UTC: '.($health['signatures_at']?->format(DATE_ATOM) ?? 'unavailable'));
|
$this->line('Signatures UTC: '.($health['signatures_at']?->format(DATE_ATOM) ?? 'unavailable'));
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ class ImportDocumentBatch extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$resourceId = DB::transaction(function () use ($validated, $documentId, $storageKey, $hash, $identity, $disk, $actorId): int {
|
$resourceId = DB::transaction(function () use ($validated, $documentId, $storageKey, $hash, $identity, $actorId): int {
|
||||||
DB::select('SELECT pg_advisory_xact_lock(hashtext(?))', ['document-batch:'.$hash]);
|
DB::select('SELECT pg_advisory_xact_lock(hashtext(?))', ['document-batch:'.$hash]);
|
||||||
DB::select('SELECT pg_advisory_xact_lock(hashtext(?))', ['document-batch-identity:'.$identity]);
|
DB::select('SELECT pg_advisory_xact_lock(hashtext(?))', ['document-batch-identity:'.$identity]);
|
||||||
if (DB::table('documents')->where('sha256', $hash)->whereNull('deleted_at')->exists()) {
|
if (DB::table('documents')->where('sha256', $hash)->whereNull('deleted_at')->exists()) {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class ImportIndustrialParkCandidates extends Command
|
|||||||
|
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
{
|
{
|
||||||
$document = json_decode(file_get_contents(database_path('data/industrial-park-candidate-drafts.json')), true, flags: JSON_THROW_ON_ERROR);
|
$document = json_decode($this->readSource(database_path('data/industrial-park-candidate-drafts.json')), true, flags: JSON_THROW_ON_ERROR);
|
||||||
if (($document['source_document_attached'] ?? null) !== true
|
if (($document['source_document_attached'] ?? null) !== true
|
||||||
|| ($document['source_document_reconciled'] ?? null) !== true) {
|
|| ($document['source_document_reconciled'] ?? null) !== true) {
|
||||||
$this->error('The source document must be attached and reconciled before importing drafts. No records written.');
|
$this->error('The source document must be attached and reconciled before importing drafts. No records written.');
|
||||||
@@ -106,4 +106,14 @@ class ImportIndustrialParkCandidates extends Command
|
|||||||
{
|
{
|
||||||
return Str::upper(Str::ascii(trim($value)));
|
return Str::upper(Str::ascii(trim($value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function readSource(string $path): string
|
||||||
|
{
|
||||||
|
$bytes = file_get_contents($path);
|
||||||
|
if ($bytes === false) {
|
||||||
|
throw new RuntimeException('Source file is unavailable: '.$path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $bytes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class ImportInvestmentZones extends Command
|
|||||||
public function handle(): int
|
public function handle(): int
|
||||||
{
|
{
|
||||||
$path = database_path('data/investment-zones-initial.json');
|
$path = database_path('data/investment-zones-initial.json');
|
||||||
$document = json_decode(file_get_contents($path), true, flags: JSON_THROW_ON_ERROR);
|
$document = json_decode($this->readSource($path), true, flags: JSON_THROW_ON_ERROR);
|
||||||
$rows = [];
|
$rows = [];
|
||||||
foreach ($document['records'] as $record) {
|
foreach ($document['records'] as $record) {
|
||||||
$existing = DB::table('investment_zones')->where('code', $record['code'])->first(['id', 'name', 'category', 'publication_status']);
|
$existing = DB::table('investment_zones')->where('code', $record['code'])->first(['id', 'name', 'category', 'publication_status']);
|
||||||
@@ -59,12 +59,12 @@ class ImportInvestmentZones extends Command
|
|||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$record = collect($document['records'])->firstWhere('code', $row['code']);
|
$record = collect(is_array($document['records'] ?? null) ? $document['records'] : [])->firstWhere('code', $row['code']);
|
||||||
$requiresLegalSource = in_array($record['category'], ['zee', 'zfi'], true);
|
$requiresLegalSource = in_array($record['category'], ['zee', 'zfi'], true);
|
||||||
$source = $requiresLegalSource
|
$source = $requiresLegalSource
|
||||||
? DB::table('investment_legal_sources')->where('url', $record['source']['url'])->where('diploma', $record['source']['diploma'])->first()
|
? DB::table('investment_legal_sources')->where('url', $record['source']['url'])->where('diploma', $record['source']['diploma'])->first()
|
||||||
: null;
|
: null;
|
||||||
$sourceId = $requiresLegalSource ? ($source?->id ?? (string) Str::uuid()) : null;
|
$sourceId = $requiresLegalSource ? ($source->id ?? (string) Str::uuid()) : null;
|
||||||
if ($requiresLegalSource && ! $source) {
|
if ($requiresLegalSource && ! $source) {
|
||||||
DB::table('investment_legal_sources')->insert([
|
DB::table('investment_legal_sources')->insert([
|
||||||
'id' => $sourceId, ...$record['source'], 'validation_status' => 'pending', 'owner_id' => $actor,
|
'id' => $sourceId, ...$record['source'], 'validation_status' => 'pending', 'owner_id' => $actor,
|
||||||
@@ -120,4 +120,14 @@ class ImportInvestmentZones extends Command
|
|||||||
{
|
{
|
||||||
return Str::upper(Str::ascii(trim($value)));
|
return Str::upper(Str::ascii(trim($value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function readSource(string $path): string
|
||||||
|
{
|
||||||
|
$bytes = file_get_contents($path);
|
||||||
|
if ($bytes === false) {
|
||||||
|
throw new RuntimeException('Source file is unavailable: '.$path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $bytes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,8 +36,7 @@ class ImportLegalSourceArchive extends Command
|
|||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$withinApprovedRoot = $realSource && collect($approvedRoots)->contains(fn (string $root) =>
|
$withinApprovedRoot = $realSource && collect($approvedRoots)->contains(fn (string $root) => str_starts_with(strtolower($realSource), strtolower($root.DIRECTORY_SEPARATOR)));
|
||||||
str_starts_with(strtolower($realSource), strtolower($root.DIRECTORY_SEPARATOR)));
|
|
||||||
if (! $realSource || ! $withinApprovedRoot || ! is_file($realSource)) {
|
if (! $realSource || ! $withinApprovedRoot || ! is_file($realSource)) {
|
||||||
$this->error($record['external_id'].': archive file missing or outside the approved source archive.');
|
$this->error($record['external_id'].': archive file missing or outside the approved source archive.');
|
||||||
$failures++;
|
$failures++;
|
||||||
@@ -83,7 +82,7 @@ class ImportLegalSourceArchive extends Command
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$missingEvidence = collect($record['associations'])->filter(fn (array $association) => $association['target_type'] === 'requirement')
|
$missingEvidence = collect(is_array($record['associations'] ?? null) ? $record['associations'] : [])->filter(fn (array $association) => $association['target_type'] === 'requirement')
|
||||||
->reject(fn (array $association) => DB::table('portal_resource_links')->where('resource_id', $resource->id)
|
->reject(fn (array $association) => DB::table('portal_resource_links')->where('resource_id', $resource->id)
|
||||||
->where('target_type', 'requirement')->where('target_key', $association['target_key'])->exists())->values();
|
->where('target_type', 'requirement')->where('target_key', $association['target_key'])->exists())->values();
|
||||||
if ($apply && $missingEvidence->isNotEmpty()) {
|
if ($apply && $missingEvidence->isNotEmpty()) {
|
||||||
@@ -110,6 +109,7 @@ class ImportLegalSourceArchive extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->line($record['external_id'].' | reused/reconciled | document='.$existing->id.' | published='.($resource->published ? 'yes' : 'no'));
|
$this->line($record['external_id'].' | reused/reconciled | document='.$existing->id.' | published='.($resource->published ? 'yes' : 'no'));
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,4 +310,3 @@ class ImportLegalSourceArchive extends Command
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class InvestmentZoneAttachmentController extends Controller
|
|||||||
|
|
||||||
return DB::transaction(function () use ($request, $id, $action, $data): JsonResponse {
|
return DB::transaction(function () use ($request, $id, $action, $data): JsonResponse {
|
||||||
$attachment = DB::table('investment_zone_attachments')->where('id', $id)->lockForUpdate()->first();
|
$attachment = DB::table('investment_zone_attachments')->where('id', $id)->lockForUpdate()->first();
|
||||||
abort_unless($attachment, 404);
|
abort_unless($attachment !== null, 404);
|
||||||
abort_if((int) $attachment->version_no !== (int) $data['version_no'], 409, 'O anexo foi alterado. Recarregue antes de continuar.');
|
abort_if((int) $attachment->version_no !== (int) $data['version_no'], 409, 'O anexo foi alterado. Recarregue antes de continuar.');
|
||||||
$version = (int) $attachment->version_no + 1;
|
$version = (int) $attachment->version_no + 1;
|
||||||
$changes = ['version_no' => $version, 'updated_at' => now()];
|
$changes = ['version_no' => $version, 'updated_at' => now()];
|
||||||
@@ -137,7 +137,7 @@ class InvestmentZoneAttachmentController extends Controller
|
|||||||
->where('a.id', $id)->where('a.zone_id', $zoneId)->where('d.status', 'active')->whereNull('d.deleted_at')
|
->where('a.id', $id)->where('a.zone_id', $zoneId)->where('d.status', 'active')->whereNull('d.deleted_at')
|
||||||
->where('d.malware_scan_status', 'clean')->whereColumn('d.malware_scanned_sha256', 'd.sha256')
|
->where('d.malware_scan_status', 'clean')->whereColumn('d.malware_scanned_sha256', 'd.sha256')
|
||||||
->first(['d.file_name', 'd.storage_key', 'd.sha256', 'd.media_type', 'd.malware_scanned_sha256']);
|
->first(['d.file_name', 'd.storage_key', 'd.sha256', 'd.media_type', 'd.malware_scanned_sha256']);
|
||||||
abort_unless($record, 404);
|
abort_unless($record !== null, 404);
|
||||||
|
|
||||||
return $this->verifiedDownload($zoneId, $record);
|
return $this->verifiedDownload($zoneId, $record);
|
||||||
}
|
}
|
||||||
@@ -150,7 +150,7 @@ class InvestmentZoneAttachmentController extends Controller
|
|||||||
->where('a.review_status', 'reviewed')->where('a.rights_status', 'confirmed')->where('a.personal_data_status', 'none')
|
->where('a.review_status', 'reviewed')->where('a.rights_status', 'confirmed')->where('a.personal_data_status', 'none')
|
||||||
->where('d.status', 'active')->whereNull('d.deleted_at')->where('d.malware_scan_status', 'clean')
|
->where('d.status', 'active')->whereNull('d.deleted_at')->where('d.malware_scan_status', 'clean')
|
||||||
->whereColumn('d.malware_scanned_sha256', 'd.sha256')->first(['d.file_name', 'd.storage_key', 'd.sha256', 'd.media_type', 'd.malware_scanned_sha256']);
|
->whereColumn('d.malware_scanned_sha256', 'd.sha256')->first(['d.file_name', 'd.storage_key', 'd.sha256', 'd.media_type', 'd.malware_scanned_sha256']);
|
||||||
abort_unless($record, 404);
|
abort_unless($record !== null, 404);
|
||||||
|
|
||||||
$extension = match ($record->media_type) {
|
$extension = match ($record->media_type) {
|
||||||
'application/pdf' => 'pdf', 'image/jpeg' => 'jpg', 'image/png' => 'png', 'image/webp' => 'webp', default => 'bin'
|
'application/pdf' => 'pdf', 'image/jpeg' => 'jpg', 'image/png' => 'png', 'image/webp' => 'webp', default => 'bin'
|
||||||
@@ -159,7 +159,7 @@ class InvestmentZoneAttachmentController extends Controller
|
|||||||
return $this->verifiedDownload($zoneId, $record, str_starts_with($record->media_type, 'image/'), 'zone-attachment-'.$id.'.'.$extension);
|
return $this->verifiedDownload($zoneId, $record, str_starts_with($record->media_type, 'image/'), 'zone-attachment-'.$id.'.'.$extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function verifiedDownload(string $zoneId, object $document, bool $inline = false, ?string $downloadName = null): BinaryFileResponse
|
private function verifiedDownload(string $zoneId, \stdClass $document, bool $inline = false, ?string $downloadName = null): BinaryFileResponse
|
||||||
{
|
{
|
||||||
$root = realpath(Storage::disk('local')->path('investment-zones/'.$zoneId));
|
$root = realpath(Storage::disk('local')->path('investment-zones/'.$zoneId));
|
||||||
$path = realpath(Storage::disk('local')->path($document->storage_key));
|
$path = realpath(Storage::disk('local')->path($document->storage_key));
|
||||||
@@ -195,6 +195,7 @@ class InvestmentZoneAttachmentController extends Controller
|
|||||||
abort_unless($expected !== null && $image[2] === $expected, 422, 'O conteúdo da imagem não corresponde ao formato declarado.');
|
abort_unless($expected !== null && $image[2] === $expected, 422, 'O conteúdo da imagem não corresponde ao formato declarado.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @param array<string,mixed> $metadata */
|
||||||
private function event(string $attachmentId, int $actor, string $action, int $version, array $metadata = []): void
|
private function event(string $attachmentId, int $actor, string $action, int $version, array $metadata = []): void
|
||||||
{
|
{
|
||||||
DB::table('investment_zone_attachment_events')->insert([
|
DB::table('investment_zone_attachment_events')->insert([
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ use Illuminate\Validation\Rule;
|
|||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
use Inertia\Inertia;
|
use Inertia\Inertia;
|
||||||
use Inertia\Response;
|
use Inertia\Response;
|
||||||
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
|
|
||||||
class InvestmentZoneController extends Controller
|
class InvestmentZoneController extends Controller
|
||||||
{
|
{
|
||||||
@@ -92,7 +93,7 @@ class InvestmentZoneController extends Controller
|
|||||||
$publicColumns = array_values(array_filter($publicColumns, fn ($column) => Schema::hasColumn('investment_zones', $column)));
|
$publicColumns = array_values(array_filter($publicColumns, fn ($column) => Schema::hasColumn('investment_zones', $column)));
|
||||||
$rows = $zones->search($filters, $management)->orderBy('name')->orderBy('id')
|
$rows = $zones->search($filters, $management)->orderBy('name')->orderBy('id')
|
||||||
->paginate(12, $management ? ['*'] : $publicColumns)->withQueryString();
|
->paginate(12, $management ? ['*'] : $publicColumns)->withQueryString();
|
||||||
$rows->getCollection()->transform(function ($zone) use ($management) {
|
$rows->getCollection()->transform(function (InvestmentZone $zone) use ($management) {
|
||||||
$territoryPath = app(InvestmentGeography::class)->path($zone->primary_territory_id, $management);
|
$territoryPath = app(InvestmentGeography::class)->path($zone->primary_territory_id, $management);
|
||||||
$zone->setAttribute('province', collect($territoryPath)->firstWhere('location_type', 'province')->name ?? $zone->province);
|
$zone->setAttribute('province', collect($territoryPath)->firstWhere('location_type', 'province')->name ?? $zone->province);
|
||||||
$zone->setAttribute('district', collect($territoryPath)->firstWhere('location_type', 'district')->name ?? $zone->district);
|
$zone->setAttribute('district', collect($territoryPath)->firstWhere('location_type', 'district')->name ?? $zone->district);
|
||||||
@@ -110,7 +111,7 @@ class InvestmentZoneController extends Controller
|
|||||||
return $request->is('api/*') ? response()->json($props) : Inertia::render('investment/zones', $props);
|
return $request->is('api/*') ? response()->json($props) : Inertia::render('investment/zones', $props);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function export(Request $request, InvestmentZones $zones)
|
public function export(Request $request, InvestmentZones $zones): StreamedResponse
|
||||||
{
|
{
|
||||||
$filters = $request->validate(['category' => ['nullable', 'in:zee,zfi,industrial_park'], 'physical_category' => ['nullable', 'in:economic_zone,industrial_park,agro_industrial_park,industrial_logistics_park,industrial_free_zone,integrated_tourism_area,other,unknown'],
|
$filters = $request->validate(['category' => ['nullable', 'in:zee,zfi,industrial_park'], 'physical_category' => ['nullable', 'in:economic_zone,industrial_park,agro_industrial_park,industrial_logistics_park,industrial_free_zone,integrated_tourism_area,other,unknown'],
|
||||||
'legal_regime' => ['nullable', 'in:zee,zfi,general,pending,not_applicable'], 'development_status' => ['nullable', 'in:announced,planned,in_development,partially_operational,operational,suspended,unknown'],
|
'legal_regime' => ['nullable', 'in:zee,zfi,general,pending,not_applicable'], 'development_status' => ['nullable', 'in:announced,planned,in_development,partially_operational,operational,suspended,unknown'],
|
||||||
@@ -123,6 +124,9 @@ class InvestmentZoneController extends Controller
|
|||||||
return response()->streamDownload(function () use ($query): void {
|
return response()->streamDownload(function () use ($query): void {
|
||||||
$geography = app(InvestmentGeography::class);
|
$geography = app(InvestmentGeography::class);
|
||||||
$stream = fopen('php://output', 'wb');
|
$stream = fopen('php://output', 'wb');
|
||||||
|
if ($stream === false) {
|
||||||
|
throw new \RuntimeException('CSV output stream unavailable.');
|
||||||
|
}
|
||||||
fwrite($stream, "\xEF\xBB\xBF");
|
fwrite($stream, "\xEF\xBB\xBF");
|
||||||
fputcsv($stream, ['Código', 'Nome', 'Categoria física', 'Regime', 'Desenvolvimento', 'Disponibilidade', 'Província', 'Distrito', 'Área declarada', 'Unidade', 'Fontes'], ';');
|
fputcsv($stream, ['Código', 'Nome', 'Categoria física', 'Regime', 'Desenvolvimento', 'Disponibilidade', 'Província', 'Distrito', 'Área declarada', 'Unidade', 'Fontes'], ';');
|
||||||
$query->chunk(200, function ($zones) use ($stream, $geography): void {
|
$query->chunk(200, function ($zones) use ($stream, $geography): void {
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Services\Ai\EvidenceRepository;
|
||||||
|
use App\Services\Ai\InvestorGuidance;
|
||||||
|
use App\Services\VirtualDesk;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class InvestorGuidanceController extends Controller
|
||||||
|
{
|
||||||
|
public function contexts(Request $request, VirtualDesk $desk): JsonResponse
|
||||||
|
{
|
||||||
|
$actor = $request->user();
|
||||||
|
$organizations = DB::table('memberships')->where('user_id', $actor->id)->whereNull('deleted_at')->pluck('organization_id');
|
||||||
|
$cases = DB::table('desk_cases')->whereNull('closed_at')->where(fn ($q) => $q->where(fn ($p) => $p->where('user_id', $actor->id)->whereNull('organization_id'))->orWhereIn('organization_id', $organizations))
|
||||||
|
->orderByDesc('updated_at')->get(['id', 'title']);
|
||||||
|
|
||||||
|
return response()->json(['cases' => $cases]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(Request $request, string $id, InvestorGuidance $guidance): JsonResponse
|
||||||
|
{
|
||||||
|
return response()->json($guidance->view($request->user(), $id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assumptions(Request $request, string $id, InvestorGuidance $guidance): JsonResponse|RedirectResponse
|
||||||
|
{
|
||||||
|
$guidance->assumptions($request->user(), $id, $request->all());
|
||||||
|
|
||||||
|
return $this->completed($request, 'Pressupostos corrigidos; os dados dos módulos de origem foram preservados.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function feedback(Request $request, string $id, InvestorGuidance $guidance): JsonResponse|RedirectResponse
|
||||||
|
{
|
||||||
|
$guidance->feedback($request->user(), $id, $request->all());
|
||||||
|
|
||||||
|
return $this->completed($request, 'Revisão registada. Assumir uma tarefa continua a ser uma acção separada.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function task(Request $request, string $id, InvestorGuidance $guidance): JsonResponse|RedirectResponse
|
||||||
|
{
|
||||||
|
$task = $guidance->acceptTask($request->user(), $id, $request->all());
|
||||||
|
|
||||||
|
return $request->expectsJson() ? response()->json(['id' => $task->id], 201) : back()->with('success', 'Tarefa assumida no CRM interno. Sincronização externa pendente de finalidade e autorização.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateTask(Request $request, string $id, string $task, InvestorGuidance $guidance): JsonResponse|RedirectResponse
|
||||||
|
{
|
||||||
|
$guidance->updateTask($request->user(), $id, $task, $request->all());
|
||||||
|
|
||||||
|
return $this->completed($request, 'Resultado da tarefa registado no mesmo histórico do dossier.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function search(Request $request, string $id, VirtualDesk $desk, EvidenceRepository $evidence): JsonResponse
|
||||||
|
{
|
||||||
|
$desk->case($request->user(), $id);
|
||||||
|
$data = $request->validate(['query' => 'required|string|min:3|max:300']);
|
||||||
|
$enabled = config('investmoz_ai.enabled') && Schema::hasTable('ai_controls') && DB::table('ai_controls')->where('capability', 'search')->where('suspended', false)->exists();
|
||||||
|
$items = $enabled ? $evidence->search($data['query'], 'pt', ['public_only' => true]) : [];
|
||||||
|
|
||||||
|
return response()->json(['mode' => 'lexical_evidence', 'model' => null, 'status' => ! $enabled ? 'unavailable' : ($items ? 'evidence_found' : 'no_evidence'),
|
||||||
|
'consulted' => $items, 'limitations' => ['Apenas excertos das fontes públicas autorizadas indexadas; não é uma consulta exaustiva nem validação jurídica.']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function completed(Request $request, string $message): JsonResponse|RedirectResponse
|
||||||
|
{
|
||||||
|
return $request->expectsJson() ? response()->json(['message' => $message]) : back()->with('success', $message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,8 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Jobs\ScanDocumentForMalware;
|
|
||||||
use App\Http\Requests\StoreLandAssistanceCaseRequest;
|
use App\Http\Requests\StoreLandAssistanceCaseRequest;
|
||||||
|
use App\Jobs\ScanDocumentForMalware;
|
||||||
use App\Models\InterestRequest;
|
use App\Models\InterestRequest;
|
||||||
use App\Models\LandAssistanceCase;
|
use App\Models\LandAssistanceCase;
|
||||||
use App\Services\InterestSubmission;
|
use App\Services\InterestSubmission;
|
||||||
|
|||||||
@@ -8,10 +8,11 @@ use App\Models\Sector;
|
|||||||
use App\Services\IdempotencyConflict;
|
use App\Services\IdempotencyConflict;
|
||||||
use App\Services\InterestSubmission;
|
use App\Services\InterestSubmission;
|
||||||
use App\Services\Malware\MalwareScanner;
|
use App\Services\Malware\MalwareScanner;
|
||||||
|
use App\Services\VirtualDesk;
|
||||||
use Illuminate\Database\Query\Builder;
|
use Illuminate\Database\Query\Builder;
|
||||||
use Illuminate\Database\QueryException;
|
use Illuminate\Database\QueryException;
|
||||||
use Illuminate\Http\RedirectResponse;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
@@ -47,7 +48,7 @@ class PortalServicesController extends Controller
|
|||||||
->where('d.malware_scan_status', 'clean')->whereColumn('d.malware_scanned_sha256', 'd.sha256');
|
->where('d.malware_scan_status', 'clean')->whereColumn('d.malware_scanned_sha256', 'd.sha256');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function page(Request $request): Response|JsonResponse
|
public function page(Request $request): Response|JsonResponse|RedirectResponse
|
||||||
{
|
{
|
||||||
$page = $request->route()->defaults['page'];
|
$page = $request->route()->defaults['page'];
|
||||||
if ($page === 'partnerships' && Schema::hasColumn('portal_partnerships', 'partnership_type')) {
|
if ($page === 'partnerships' && Schema::hasColumn('portal_partnerships', 'partnership_type')) {
|
||||||
@@ -153,6 +154,9 @@ class PortalServicesController extends Controller
|
|||||||
$props['partnerships'] = $query->orderByDesc('id')->select(['id', 'title', 'sector', 'province', 'offer', 'seeking'])->paginate(20)->withQueryString();
|
$props['partnerships'] = $query->orderByDesc('id')->select(['id', 'title', 'sector', 'province', 'offer', 'seeking'])->paginate(20)->withQueryString();
|
||||||
}
|
}
|
||||||
if ($page === 'desk') {
|
if ($page === 'desk') {
|
||||||
|
if (app(VirtualDesk::class)->installed()) {
|
||||||
|
return redirect('/balcao-virtual/painel');
|
||||||
|
}
|
||||||
$props['requests'] = InterestRequest::where('metadata->portal_user_id', $request->user()->id)->latest()->limit(100)->get(['reference', 'status', 'created_at', 'metadata']);
|
$props['requests'] = InterestRequest::where('metadata->portal_user_id', $request->user()->id)->latest()->limit(100)->get(['reference', 'status', 'created_at', 'metadata']);
|
||||||
$props['myPartnerships'] = DB::table('portal_partnerships')->where('user_id', $request->user()->id)->latest()->limit(100)->get(['id', 'title', 'status']);
|
$props['myPartnerships'] = DB::table('portal_partnerships')->where('user_id', $request->user()->id)->latest()->limit(100)->get(['id', 'title', 'status']);
|
||||||
}
|
}
|
||||||
@@ -161,7 +165,7 @@ class PortalServicesController extends Controller
|
|||||||
return Inertia::render('portal/services', $props);
|
return Inertia::render('portal/services', $props);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function recommendations(Request $request)
|
public function recommendations(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$data = $request->validate([
|
$data = $request->validate([
|
||||||
'activity_id' => ['nullable', 'string', 'max:180'], 'province_id' => ['nullable', 'uuid'],
|
'activity_id' => ['nullable', 'string', 'max:180'], 'province_id' => ['nullable', 'uuid'],
|
||||||
@@ -199,10 +203,11 @@ class PortalServicesController extends Controller
|
|||||||
? DB::table('portal_resource_links')->where('resource_id', $resource->id)->where('target_type', 'requirement')
|
? DB::table('portal_resource_links')->where('resource_id', $resource->id)->where('target_type', 'requirement')
|
||||||
->where('review_status', 'confirmed')->orderBy('target_key')->get(['target_key', 'basis_reference', 'review_status'])
|
->where('review_status', 'confirmed')->orderBy('target_key')->get(['target_key', 'basis_reference', 'review_status'])
|
||||||
: collect();
|
: collect();
|
||||||
|
|
||||||
return [...(array) $resource,
|
return [...(array) $resource,
|
||||||
'download_url' => route('services.download', ['id' => $resource->id]),
|
'download_url' => route('services.download', ['id' => $resource->id]),
|
||||||
'recommendation_reason' => $matched?->condition_text ?? ('Relacionado com '.$matched?->target_type.' '.$matched?->target_key.'; confirme a aplicabilidade ao seu projecto.'),
|
'recommendation_reason' => $matched->condition_text ?? ('Relacionado com '.$matched?->target_type.' '.$matched?->target_key.'; confirme a aplicabilidade ao seu projecto.'),
|
||||||
'applicability' => $matched?->applicability ?? 'support',
|
'applicability' => $matched->applicability ?? 'support',
|
||||||
'basis_reference' => $matched?->basis_reference,
|
'basis_reference' => $matched?->basis_reference,
|
||||||
'documentary_evidence' => $evidence->map(fn ($link) => ['key' => $link->target_key,
|
'documentary_evidence' => $evidence->map(fn ($link) => ['key' => $link->target_key,
|
||||||
'label' => config('document-requirements.catalogue.'.$link->target_key.'.label', $link->target_key),
|
'label' => config('document-requirements.catalogue.'.$link->target_key.'.label', $link->target_key),
|
||||||
@@ -357,7 +362,7 @@ class PortalServicesController extends Controller
|
|||||||
|
|
||||||
return Inertia::render('portal/manage', ['resources' => $resources,
|
return Inertia::render('portal/manage', ['resources' => $resources,
|
||||||
'requirementCatalogue' => $this->requirementEvidenceEnabled()
|
'requirementCatalogue' => $this->requirementEvidenceEnabled()
|
||||||
? collect(config('document-requirements.catalogue'))->map(fn ($item, $key) => ['key' => $key, ...$item])->values()
|
? collect(is_array($catalogue = config('document-requirements.catalogue', [])) ? $catalogue : [])->map(fn ($item, $key) => ['key' => $key, ...$item])->values()
|
||||||
: collect(),
|
: collect(),
|
||||||
'requirementAssociationsEnabled' => $this->requirementEvidenceEnabled(),
|
'requirementAssociationsEnabled' => $this->requirementEvidenceEnabled(),
|
||||||
'partnerships' => DB::table('portal_partnerships')->latest()->limit(100)->get(),
|
'partnerships' => DB::table('portal_partnerships')->latest()->limit(100)->get(),
|
||||||
@@ -548,10 +553,12 @@ class PortalServicesController extends Controller
|
|||||||
]);
|
]);
|
||||||
if ($resource === null) {
|
if ($resource === null) {
|
||||||
$skipped[$resourceId] = 'Registo ou ficheiro inexistente.';
|
$skipped[$resourceId] = 'Registo ou ficheiro inexistente.';
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($resource->published && $resource->data_classification === 'public' && $resource->resource_rights === 'authorized' && $resource->file_rights === 'authorized') {
|
if ($resource->published && $resource->data_classification === 'public' && $resource->resource_rights === 'authorized' && $resource->file_rights === 'authorized') {
|
||||||
$published[$resourceId] = 'Já publicado.';
|
$published[$resourceId] = 'Já publicado.';
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$path = Storage::disk('local')->path($resource->storage_key);
|
$path = Storage::disk('local')->path($resource->storage_key);
|
||||||
@@ -565,12 +572,14 @@ class PortalServicesController extends Controller
|
|||||||
|| ! hash_equals((string) $resource->sha256, $actualHash)
|
|| ! hash_equals((string) $resource->sha256, $actualHash)
|
||||||
|| ! hash_equals((string) $resource->sha256, (string) $resource->malware_scanned_sha256)) {
|
|| ! hash_equals((string) $resource->sha256, (string) $resource->malware_scanned_sha256)) {
|
||||||
$skipped[$resourceId] = 'Ficheiro indisponível, não limpo ou diferente dos bytes analisados.';
|
$skipped[$resourceId] = 'Ficheiro indisponível, não limpo ou diferente dos bytes analisados.';
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (in_array($resource->resource_rights, ['restricted'], true) || in_array($resource->file_rights, ['restricted'], true)
|
if (in_array($resource->resource_rights, ['restricted'], true) || in_array($resource->file_rights, ['restricted'], true)
|
||||||
|| $resource->source_confirmation === 'unconfirmed' || ! filter_var($resource->source_url, FILTER_VALIDATE_URL)
|
|| $resource->source_confirmation === 'unconfirmed' || ! filter_var($resource->source_url, FILTER_VALIDATE_URL)
|
||||||
|| parse_url($resource->source_url, PHP_URL_SCHEME) !== 'https') {
|
|| parse_url($resource->source_url, PHP_URL_SCHEME) !== 'https') {
|
||||||
$skipped[$resourceId] = 'Restrição de divulgação ou origem identificada em falta.';
|
$skipped[$resourceId] = 'Restrição de divulgação ou origem identificada em falta.';
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -600,6 +609,7 @@ class PortalServicesController extends Controller
|
|||||||
->with('disclosureResults', ['published' => $published, 'skipped' => $skipped]);
|
->with('disclosureResults', ['published' => $published, 'skipped' => $skipped]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @param array<string,mixed> $additional */
|
||||||
private function audit(Request $request, string $action, string $table, int $id, array $additional = []): void
|
private function audit(Request $request, string $action, string $table, int $id, array $additional = []): void
|
||||||
{
|
{
|
||||||
DB::table('audit_events')->insert(['source_system' => 'portal-services', 'entity_type' => $table,
|
DB::table('audit_events')->insert(['source_system' => 'portal-services', 'entity_type' => $table,
|
||||||
@@ -641,6 +651,7 @@ class PortalServicesController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return array<string,mixed> */
|
||||||
private function validateResource(Request $request): array
|
private function validateResource(Request $request): array
|
||||||
{
|
{
|
||||||
$data = $this->validateManagement($request, [
|
$data = $this->validateManagement($request, [
|
||||||
@@ -691,6 +702,9 @@ class PortalServicesController extends Controller
|
|||||||
|
|
||||||
/** Keep validation redirects on the management GET page even if the request
|
/** Keep validation redirects on the management GET page even if the request
|
||||||
* arrived with a stale Referer pointing at a write-only resource endpoint.
|
* arrived with a stale Referer pointing at a write-only resource endpoint.
|
||||||
|
*
|
||||||
|
* @param array<string,mixed> $rules
|
||||||
|
* @return array<string,mixed>
|
||||||
*/
|
*/
|
||||||
private function validateManagement(Request $request, array $rules): array
|
private function validateManagement(Request $request, array $rules): array
|
||||||
{
|
{
|
||||||
@@ -701,6 +715,7 @@ class PortalServicesController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @param array<string,string|list<string>> $errors */
|
||||||
private function managementValidationException(array $errors): ValidationException
|
private function managementValidationException(array $errors): ValidationException
|
||||||
{
|
{
|
||||||
$exception = ValidationException::withMessages($errors);
|
$exception = ValidationException::withMessages($errors);
|
||||||
@@ -709,6 +724,8 @@ class PortalServicesController extends Controller
|
|||||||
return $exception;
|
return $exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @param array<string,mixed> $data
|
||||||
|
* @return array<string,mixed> */
|
||||||
private function resourceFields(array $data, int $actor, ?string $identity, ?int $duplicate, bool $creating): array
|
private function resourceFields(array $data, int $actor, ?string $identity, ?int $duplicate, bool $creating): array
|
||||||
{
|
{
|
||||||
unset($data['associations'], $data['issuer'], $data['data_classification']);
|
unset($data['associations'], $data['issuer'], $data['data_classification']);
|
||||||
@@ -725,6 +742,7 @@ class PortalServicesController extends Controller
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @param list<array<string,mixed>> $links */
|
||||||
private function syncResourceLinks(int $resourceId, array $links): void
|
private function syncResourceLinks(int $resourceId, array $links): void
|
||||||
{
|
{
|
||||||
foreach ($links as $link) {
|
foreach ($links as $link) {
|
||||||
@@ -741,7 +759,8 @@ class PortalServicesController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function assertPublicClassificationEligible(array $data, object $document): void
|
/** @param array<string,mixed> $data */
|
||||||
|
private function assertPublicClassificationEligible(array $data, \stdClass $document): void
|
||||||
{
|
{
|
||||||
if (($data['data_classification'] ?? $document->data_classification) !== 'public') {
|
if (($data['data_classification'] ?? $document->data_classification) !== 'public') {
|
||||||
return;
|
return;
|
||||||
@@ -756,6 +775,7 @@ class PortalServicesController extends Controller
|
|||||||
'Identifique e confirme a fonte antes de classificar o ficheiro como público.');
|
'Identifique e confirme a fonte antes de classificar o ficheiro como público.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @param array<string,mixed> $data */
|
||||||
private function identityKey(array $data): ?string
|
private function identityKey(array $data): ?string
|
||||||
{
|
{
|
||||||
if (empty($data['issuer']) || empty($data['document_number'])) {
|
if (empty($data['issuer']) || empty($data['document_number'])) {
|
||||||
@@ -782,6 +802,7 @@ class PortalServicesController extends Controller
|
|||||||
&& DB::table('migrations')->where('migration', '2026_10_06_200000_add_document_requirement_evidence_links')->exists();
|
&& DB::table('migrations')->where('migration', '2026_10_06_200000_add_document_requirement_evidence_links')->exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return list<string> */
|
||||||
private function resourceLinkColumns(): array
|
private function resourceLinkColumns(): array
|
||||||
{
|
{
|
||||||
$columns = ['target_type', 'target_key', 'relationship', 'applicability', 'condition_text', 'basis_reference'];
|
$columns = ['target_type', 'target_key', 'relationship', 'applicability', 'condition_text', 'basis_reference'];
|
||||||
@@ -792,9 +813,10 @@ class PortalServicesController extends Controller
|
|||||||
return $columns;
|
return $columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return list<string> */
|
||||||
private function territoryScopeIds(string $id): array
|
private function territoryScopeIds(string $id): array
|
||||||
{
|
{
|
||||||
return collect(DB::select(<<<'SQL'
|
$rows = DB::select(<<<'SQL'
|
||||||
WITH RECURSIVE territory_tree AS (
|
WITH RECURSIVE territory_tree AS (
|
||||||
SELECT id FROM geo_locations WHERE id = ? AND deleted_at IS NULL AND data_classification = 'public'
|
SELECT id FROM geo_locations WHERE id = ? AND deleted_at IS NULL AND data_classification = 'public'
|
||||||
UNION ALL
|
UNION ALL
|
||||||
@@ -803,6 +825,15 @@ WITH RECURSIVE territory_tree AS (
|
|||||||
WHERE child.deleted_at IS NULL AND child.data_classification = 'public'
|
WHERE child.deleted_at IS NULL AND child.data_classification = 'public'
|
||||||
)
|
)
|
||||||
SELECT id FROM territory_tree
|
SELECT id FROM territory_tree
|
||||||
SQL, [$id]))->pluck('id')->all() ?: [$id];
|
SQL, [$id]);
|
||||||
|
$ids = [];
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
if (! is_string($row->id)) {
|
||||||
|
throw new \RuntimeException('Territory identifier must be a string.');
|
||||||
|
}
|
||||||
|
$ids[] = $row->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ids ?: [$id];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,29 +4,41 @@ namespace App\Http\Controllers;
|
|||||||
|
|
||||||
use App\Jobs\ScanDocumentForMalware;
|
use App\Jobs\ScanDocumentForMalware;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use App\Services\Ai\InvestorGuidance;
|
||||||
|
use App\Services\InstitutionalLinkMonitor;
|
||||||
|
use App\Services\InvestmentGeography;
|
||||||
use App\Services\VirtualDesk;
|
use App\Services\VirtualDesk;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Facades\Crypt;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Inertia\Inertia;
|
use Inertia\Inertia;
|
||||||
|
use Inertia\Response;
|
||||||
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
|
|
||||||
class VirtualDeskController extends Controller
|
class VirtualDeskController extends Controller
|
||||||
{
|
{
|
||||||
public function catalogue(Request $request, VirtualDesk $desk)
|
public function catalogue(Request $request, VirtualDesk $desk): JsonResponse|Response
|
||||||
{
|
{
|
||||||
$filters = $request->validate(['q' => 'nullable|string|max:120', 'theme' => 'nullable|string|max:80', 'profile' => 'nullable|string|max:100']);
|
$filters = $request->validate(['q' => 'nullable|string|max:120', 'theme' => 'nullable|string|max:80', 'profile' => 'nullable|string|max:100']);
|
||||||
$installed = $desk->installed();
|
$installed = $desk->installed();
|
||||||
$services = $installed ? DB::table('desk_service_versions')->where('status', 'published')->orderBy('code')->orderByDesc('version')->get()->unique('code')->map(fn ($s) => ['id' => $s->id, 'version' => $s->version, 'definition' => json_decode($s->definition, true), 'source' => json_decode($s->source, true)])->values() : collect();
|
$services = $installed ? DB::table('desk_service_versions')->where('status', 'published')->orderBy('code')->orderByDesc('version')->get()->unique('code')->map(fn ($s) => ['id' => $s->id, 'version' => $s->version, 'definition' => json_decode($s->definition, true), 'source' => json_decode($s->source, true)])->values() : collect();
|
||||||
$services = $services->filter(fn ($s) => (! ($filters['q'] ?? '') || str_contains(mb_strtolower(json_encode($s['definition'], JSON_UNESCAPED_UNICODE)), mb_strtolower($filters['q'])))
|
$services = $services->filter(fn ($s) => (! ($filters['q'] ?? '') || str_contains(mb_strtolower(json_encode($s['definition'], JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR)), mb_strtolower($filters['q'])))
|
||||||
&& (! ($filters['theme'] ?? '') || $s['definition']['theme'] === $filters['theme']) && (! ($filters['profile'] ?? '') || $s['definition']['profile'] === $filters['profile']))->values();
|
&& (! ($filters['theme'] ?? '') || $s['definition']['theme'] === $filters['theme']) && (! ($filters['profile'] ?? '') || $s['definition']['profile'] === $filters['profile']))->values();
|
||||||
$page = max(1, (int) $request->query('page', 1));
|
$page = max(1, (int) $request->query('page', 1));
|
||||||
$data = ['installed' => $installed, 'services' => $services->slice(($page - 1) * 12, 12)->values(), 'total' => $services->count(), 'page' => $page, 'filters' => $filters,
|
$data = ['installed' => $installed, 'services' => $services->slice(($page - 1) * 12, 12)->values(), 'total' => $services->count(), 'page' => $page, 'filters' => $filters,
|
||||||
'prepared' => $installed ? [] : config('virtual-desk.services'), 'source' => config('virtual-desk.source'), 'authenticated' => (bool) $request->user(), 'support' => config('portal.support')];
|
'prepared' => $installed ? [] : config('virtual-desk.services'), 'source' => config('virtual-desk.source'), 'authenticated' => (bool) $request->user(), 'support' => config('portal.support')];
|
||||||
|
|
||||||
return $request->expectsJson() ? response()->json($data) : Inertia::render('desk/catalogue', $data);
|
return $request->expectsJson() ? response()->json($data) : Inertia::render('desk/catalogue', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function panel(Request $request, VirtualDesk $desk)
|
public function panel(Request $request, VirtualDesk $desk): JsonResponse|Response
|
||||||
{
|
{
|
||||||
$actor = $request->user();
|
$actor = $request->user();
|
||||||
$organizations = DB::table('memberships')->where('user_id', $actor->id)->whereNull('deleted_at')->pluck('organization_id');
|
$organizations = DB::table('memberships')->where('user_id', $actor->id)->whereNull('deleted_at')->pluck('organization_id');
|
||||||
@@ -34,188 +46,269 @@ class VirtualDeskController extends Controller
|
|||||||
$queue = DB::table('desk_requests as r')->join('desk_cases as c', 'c.id', '=', 'r.case_id')->whereNotIn('r.status', ['draft', 'cancelled'])->when(! $actor->can('manage-portal'), fn ($q) => $q->where('r.analyst_id', $actor->id))
|
$queue = DB::table('desk_requests as r')->join('desk_cases as c', 'c.id', '=', 'r.case_id')->whereNotIn('r.status', ['draft', 'cancelled'])->when(! $actor->can('manage-portal'), fn ($q) => $q->where('r.analyst_id', $actor->id))
|
||||||
->orderByRaw('r.due_at ASC NULLS LAST')->get(['r.id', 'r.protocol', 'r.status', 'r.version', 'r.analyst_id', 'r.due_at', 'c.title']);
|
->orderByRaw('r.due_at ASC NULLS LAST')->get(['r.id', 'r.protocol', 'r.status', 'r.version', 'r.analyst_id', 'r.due_at', 'c.title']);
|
||||||
$data = ['cases' => $cases, 'queue' => $queue, 'notifications' => DB::table('desk_notifications')->where('user_id', $actor->id)->orderByDesc('id')->limit(100)->get(),
|
$data = ['cases' => $cases, 'queue' => $queue, 'notifications' => DB::table('desk_notifications')->where('user_id', $actor->id)->orderByDesc('id')->limit(100)->get(),
|
||||||
'legacyRequests' => DB::table('interest_requests')->where('metadata->portal_user_id', $actor->id)->orderByDesc('created_at')->get(['reference', 'status', 'created_at']),
|
'legacyRequests' => DB::table('interest_requests')->where('metadata->portal_user_id', $actor->id)->whereNull('deleted_at')->orderByDesc('created_at')->get(['id', 'reference', 'status', 'created_at']),
|
||||||
'companies' => DB::table('investment_company_declarations')->where('user_id', $actor->id)->get(['id', 'payload'])->map(fn ($c) => ['id' => $c->id, 'name' => $desk->decode($c->payload)['name'] ?? 'Declaração empresarial']),
|
'companies' => DB::table('investment_company_declarations')->where('user_id', $actor->id)->get(['id', 'payload'])->map(fn ($c) => ['id' => $c->id, 'name' => $desk->decode($c->payload)['name'] ?? 'Declaração empresarial']),
|
||||||
'submissions' => DB::table('investment_submissions')->where('user_id', $actor->id)->get(['id', 'status']),
|
'submissions' => DB::table('investment_submissions')->where('user_id', $actor->id)->get(['id', 'status']),
|
||||||
|
'journeys' => DB::table('investor_journeys')->where('user_id', $actor->id)->whereNull('deleted_at')->get(['id', 'dossier_id', 'status']),
|
||||||
|
'simulationDrafts' => DB::table('simulation_form_drafts')->where('owner_user_id', $actor->id)->whereNull('deleted_at')->where(fn ($q) => $q->whereNull('expires_at')->orWhere('expires_at', '>', now()))->get(['id', 'version_no']),
|
||||||
|
'guidanceTasks' => app(InvestorGuidance::class)->installed() ? DB::table('tasks as t')->join('desk_cases as c', 'c.id', '=', 't.desk_case_id')
|
||||||
|
->whereNull('t.deleted_at')->when(! $actor->can('manage-portal'), fn ($q) => $q->where(fn ($p) => $p->where('t.assignee_user_id', $actor->id)->orWhere(fn ($s) => $s->where('c.user_id', $actor->id)->whereNull('c.organization_id'))->orWhereIn('c.organization_id', $organizations)))
|
||||||
|
->orderByRaw('t.due_at ASC NULLS LAST')->get(['t.id', 't.title', 't.status', 't.due_at', 'c.id as case_id', 'c.title as case_title']) : [],
|
||||||
'organizations' => DB::table('organizations')->whereIn('id', $organizations)->get(['id', 'name']), 'manager' => $actor->can('manage-portal'), 'states' => config('virtual-desk.request_states')];
|
'organizations' => DB::table('organizations')->whereIn('id', $organizations)->get(['id', 'name']), 'manager' => $actor->can('manage-portal'), 'states' => config('virtual-desk.request_states')];
|
||||||
|
|
||||||
return $request->expectsJson() ? response()->json($data) : Inertia::render('desk/panel', $data);
|
return $request->expectsJson() ? response()->json($data) : Inertia::render('desk/panel', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createCase(Request $request, VirtualDesk $desk)
|
public function createCase(Request $request, VirtualDesk $desk): JsonResponse|RedirectResponse
|
||||||
{
|
{
|
||||||
$case = $desk->createCase($request->user(), $request->all());
|
$case = $desk->createCase($request->user(), $request->all());
|
||||||
return $request->expectsJson() ? response()->json(['id' => $case->id, 'version' => $case->version], 201) : redirect('/balcao-virtual/dossiers/'.$case->id);
|
|
||||||
|
return $request->expectsJson() ? response()->json(['id' => $case->id, 'version' => $case->version], 201) : redirect('/balcao-virtual/dossiers/'.$case->id)
|
||||||
|
->with('success', 'Dossier guardado e disponível para continuar. Próxima ação: escolha um serviço publicado e prepare o rascunho de apoio. Nenhum pedido foi submetido.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showCase(Request $request, string $id, VirtualDesk $desk)
|
public function showCase(Request $request, string $id, VirtualDesk $desk): JsonResponse|Response
|
||||||
{
|
{
|
||||||
$case = $desk->case($request->user(), $id); $owner = $desk->owns($request->user(), $case, false);
|
$case = $desk->case($request->user(), $id);
|
||||||
|
$owner = $desk->owns($request->user(), $case, false);
|
||||||
$this->auditRead($request, 'desk_cases', $id);
|
$this->auditRead($request, 'desk_cases', $id);
|
||||||
$data = ['case' => [...(array) $case, 'payload' => \Illuminate\Support\Arr::except($desk->decode($case->payload), ['_creation_hash']), 'workflow' => json_decode($case->workflow, true)],
|
$data = ['case' => [...(array) $case, 'payload' => Arr::except($desk->decode($case->payload), $owner ? ['_creation_hash'] : ['_creation_hash', 'profile', 'company', 'investment', 'name', 'email']), 'workflow' => json_decode($case->workflow, true)],
|
||||||
|
'legacyRequest' => ($case->interest_request_id ?? null) ? DB::table('interest_requests as r')->leftJoin('users as u', 'u.id', '=', 'r.assigned_to')->where('r.id', $case->interest_request_id)->whereNull('r.deleted_at')
|
||||||
|
->when(! $request->user()->can('manage-portal'), fn ($q) => $q->where('r.metadata->portal_user_id', $request->user()->id))
|
||||||
|
->first(['r.id', 'r.reference', 'r.status', 'r.next_action', 'r.next_action_due_at', 'u.name as responsible_name']) : null,
|
||||||
'owner' => $owner, 'canWrite' => $desk->owns($request->user(), $case), 'manager' => $request->user()->can('manage-portal'),
|
'owner' => $owner, 'canWrite' => $desk->owns($request->user(), $case), 'manager' => $request->user()->can('manage-portal'),
|
||||||
'requests' => DB::table('desk_requests')->where('case_id', $id)->when(! $owner && ! $request->user()->can('manage-portal'), fn ($q) => $q->where('analyst_id', $request->user()->id))->orderByDesc('updated_at')->get(['id', 'status', 'protocol', 'service_version_id', 'version']),
|
'requests' => DB::table('desk_requests')->where('case_id', $id)->when(! $owner && ! $request->user()->can('manage-portal'), fn ($q) => $q->where('analyst_id', $request->user()->id))->orderByDesc('updated_at')->get(['id', 'status', 'protocol', 'service_version_id', 'version']),
|
||||||
'services' => DB::table('desk_service_versions')->where('status', 'published')->orderByDesc('version')->get(['id', 'code', 'version', 'definition'])->unique('code')->values()->map(fn ($s) => ['id' => $s->id, 'title' => json_decode($s->definition, true)['title'], 'version' => $s->version]),
|
'services' => DB::table('desk_service_versions')->where('status', 'published')->orderByDesc('version')->get(['id', 'code', 'version', 'definition'])->unique('code')->values()->map(fn ($s) => ['id' => $s->id, 'title' => json_decode($s->definition, true)['title'], 'version' => $s->version]),
|
||||||
'documents' => $this->documents($id), 'events' => $this->events($id, $desk), 'stepStates' => config('virtual-desk.step_states'), 'states' => config('virtual-desk.request_states'),
|
'documents' => $this->documents($id, $request->user()), 'events' => $this->events($id, $desk, $request->user()), 'stepStates' => config('virtual-desk.step_states'), 'states' => config('virtual-desk.request_states'),
|
||||||
'links' => DB::table('desk_institutional_links')->where('status', 'active')->whereNotNull('verified_at')->get(['id', 'stage', 'entity', 'purpose', 'contact', 'verified_at']), 'source' => config('virtual-desk.source')];
|
'links' => DB::table('desk_institutional_links')->get()->map(fn ($link) => [...(array) $link, 'monitor' => app(InstitutionalLinkMonitor::class)->status($link)]), 'source' => config('virtual-desk.source'), 'support' => config('portal.support'),
|
||||||
|
'guidance' => app(InvestorGuidance::class)->installed() ? app(InvestorGuidance::class)->view($request->user(), $id) : null];
|
||||||
|
|
||||||
return $request->expectsJson() ? response()->json($data) : Inertia::render('desk/case', $data);
|
return $request->expectsJson() ? response()->json($data) : Inertia::render('desk/case', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function documents(string $case)
|
/** @return Collection<int,\stdClass> */
|
||||||
|
private function documents(string $case, User $actor): Collection
|
||||||
{
|
{
|
||||||
return DB::table('desk_documents as l')->join('documents as d', 'd.id', '=', 'l.document_id')->where('l.case_id', $case)->whereNull('d.deleted_at')
|
return DB::table('desk_documents as l')->join('documents as d', 'd.id', '=', 'l.document_id')->where('l.case_id', $case)->whereNull('d.deleted_at')
|
||||||
|
->when(! app(VirtualDesk::class)->owns($actor, app(VirtualDesk::class)->case($actor, $case), false) && ! $actor->can('manage-portal'), fn ($q) => $q->where(fn ($p) => $p->whereNull('l.request_id')->orWhereIn('l.request_id', DB::table('desk_requests')->where('analyst_id', $actor->id)->select('id'))))
|
||||||
->get(['l.id', 'l.document_id', 'l.request_id', 'l.category', 'l.stage', 'l.source_reference', 'l.valid_until', 'd.file_name', 'd.status', 'd.malware_scan_status', 'd.sha256']);
|
->get(['l.id', 'l.document_id', 'l.request_id', 'l.category', 'l.stage', 'l.source_reference', 'l.valid_until', 'd.file_name', 'd.status', 'd.malware_scan_status', 'd.sha256']);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function events(string $case, VirtualDesk $desk)
|
/** @return Collection<int,array{id:mixed,request_id:mixed,action:mixed,version:mixed,created_at:mixed,name:mixed,payload:array<string,mixed>}> */
|
||||||
|
private function events(string $case, VirtualDesk $desk, User $actor): Collection
|
||||||
{
|
{
|
||||||
return DB::table('desk_events as e')->join('users as u', 'u.id', '=', 'e.actor_id')->where('e.case_id', $case)->orderBy('e.created_at')->get(['e.id', 'e.request_id', 'e.action', 'e.payload', 'e.version', 'e.created_at', 'u.name'])->map(fn ($e) => [...(array) $e, 'payload' => $desk->decode($e->payload)]);
|
return DB::table('desk_events as e')->join('users as u', 'u.id', '=', 'e.actor_id')->where('e.case_id', $case)
|
||||||
|
->when(! $desk->owns($actor, $desk->case($actor, $case), false) && ! $actor->can('manage-portal'), fn ($q) => $q->where(fn ($p) => $p->whereNull('e.request_id')->orWhereIn('e.request_id', DB::table('desk_requests')->where('analyst_id', $actor->id)->select('id'))))
|
||||||
|
->orderBy('e.event_order')->get(['e.id', 'e.request_id', 'e.action', 'e.payload', 'e.version', 'e.created_at', 'u.name'])->map(fn ($e) => ['id' => $e->id, 'request_id' => $e->request_id, 'action' => $e->action, 'version' => $e->version, 'created_at' => $e->created_at, 'name' => $e->name, 'payload' => $desk->decode($e->payload)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stage(Request $request, string $id, VirtualDesk $desk)
|
public function stage(Request $request, string $id, VirtualDesk $desk): JsonResponse|RedirectResponse
|
||||||
{
|
{
|
||||||
$case = $desk->stage($request->user(), $id, $request->all());
|
$case = $desk->stage($request->user(), $id, $request->all());
|
||||||
|
|
||||||
return $request->expectsJson() ? response()->json(['version' => $case->version]) : back()->with('success', 'Etapa e evidência registadas.');
|
return $request->expectsJson() ? response()->json(['version' => $case->version]) : back()->with('success', 'Etapa e evidência registadas.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createRequest(Request $request, string $id, VirtualDesk $desk)
|
public function createRequest(Request $request, string $id, VirtualDesk $desk): JsonResponse|RedirectResponse
|
||||||
{
|
{
|
||||||
$data = $request->validate(['service_version_id' => 'required|uuid', 'client_key' => 'required|uuid']);
|
$data = $request->validate(['service_version_id' => 'required|uuid', 'client_key' => 'required|uuid']);
|
||||||
$row = $desk->createRequest($request->user(), $id, $data['service_version_id'], $data['client_key']);
|
$row = $desk->createRequest($request->user(), $id, $data['service_version_id'], $data['client_key']);
|
||||||
|
|
||||||
return $request->expectsJson() ? response()->json(['id' => $row->id, 'version' => $row->version], 201) : redirect('/balcao-virtual/pedidos/'.$row->id);
|
return $request->expectsJson() ? response()->json(['id' => $row->id, 'version' => $row->version], 201) : redirect('/balcao-virtual/pedidos/'.$row->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showRequest(Request $request, string $id, VirtualDesk $desk)
|
public function showRequest(Request $request, string $id, VirtualDesk $desk): JsonResponse|Response
|
||||||
{
|
{
|
||||||
$row = $desk->request($request->user(), $id); $case = $desk->case($request->user(), $row->case_id); $payload = $desk->decode($row->payload);
|
$row = $desk->request($request->user(), $id);
|
||||||
|
$case = $desk->case($request->user(), $row->case_id);
|
||||||
|
$payload = $desk->decode($row->payload);
|
||||||
|
$messageKinds = [];
|
||||||
|
foreach (DB::table('desk_events')->where('request_id', $id)->where('action', 'message_added')->get() as $event) {
|
||||||
|
$original = $desk->decode($event->payload);
|
||||||
|
if (isset($original['message_id'], $original['kind'])) {
|
||||||
|
$messageKinds[$original['message_id']] = $original['kind'];
|
||||||
|
}
|
||||||
|
}
|
||||||
$this->auditRead($request, 'desk_requests', $id);
|
$this->auditRead($request, 'desk_requests', $id);
|
||||||
$data = ['request' => [...(array) $row, 'payload' => $payload, 'submitted_snapshot' => $desk->decode($row->submitted_snapshot), 'editable_fields' => json_decode($row->editable_fields ?? '[]', true)],
|
$data = ['request' => [...(array) $row, 'payload' => $payload, 'submitted_snapshot' => $desk->decode($row->submitted_snapshot), 'editable_fields' => json_decode($row->editable_fields ?? '[]', true)],
|
||||||
'case' => ['id' => $case->id, 'title' => $case->title], 'definition' => $desk->definition($row),
|
'case' => ['id' => $case->id, 'title' => $case->title], 'caseVersion' => $case->version, 'definition' => $desk->definition($row),
|
||||||
'serviceSource' => json_decode(DB::table('desk_service_versions')->where('id', $row->service_version_id)->value('source'), true),
|
'serviceSource' => json_decode(DB::table('desk_service_versions')->where('id', $row->service_version_id)->value('source'), true),
|
||||||
'owner' => $desk->owns($request->user(), $case), 'manager' => $request->user()->can('manage-portal'), 'analyst' => (int) $row->analyst_id === $request->user()->id,
|
'owner' => $desk->owns($request->user(), $case), 'manager' => $request->user()->can('manage-portal'), 'analyst' => (int) $row->analyst_id === $request->user()->id,
|
||||||
'fieldsEditable' => in_array($row->status, ['draft', 'returned'], true), 'states' => config('virtual-desk.request_states'), 'transitions' => config('virtual-desk.transitions.'.$row->status, []),
|
'fieldsEditable' => in_array($row->status, ['draft', 'returned'], true), 'states' => config('virtual-desk.request_states'), 'transitions' => config('virtual-desk.transitions.'.$row->status, []),
|
||||||
'findings' => $desk->findings($payload), 'ai' => config('virtual-desk.ai'), 'documents' => $this->documents($case->id)->filter(fn ($d) => ! $d->request_id || $d->request_id === $id)->values(),
|
'findings' => $desk->findings($payload), 'ai' => config('virtual-desk.ai'), 'documents' => $this->documents($case->id, $request->user())->filter(fn ($d) => ! $d->request_id || $d->request_id === $id)->values(),
|
||||||
'messages' => DB::table('desk_messages as m')->join('users as u', 'u.id', '=', 'm.actor_id')->where('request_id', $id)->orderBy('m.created_at')->get(['m.id', 'm.body', 'm.created_at', 'u.name'])->map(fn ($m) => [...(array) $m, 'body' => \Illuminate\Support\Facades\Crypt::decryptString($m->body)]),
|
'messages' => DB::table('desk_messages as m')->join('users as u', 'u.id', '=', 'm.actor_id')->where('request_id', $id)->orderBy('m.created_at')->get(['m.id', 'm.actor_id', 'm.body', 'm.created_at', 'u.name'])->map(fn ($m) => [...(array) $m, 'body' => Crypt::decryptString($m->body),
|
||||||
'events' => $this->events($case->id, $desk)->filter(fn ($e) => $e['request_id'] === $id)->values(),
|
'kind' => $messageKinds[$m->id] ?? 'historical_unclassified']),
|
||||||
|
'events' => $this->events($case->id, $desk, $request->user())->filter(fn ($e) => $e['request_id'] === $id)->values(),
|
||||||
'revisions' => DB::table('desk_revisions')->where('request_id', $id)->orderByDesc('version')->get(['version', 'snapshot', 'created_at'])->map(fn ($r) => [...(array) $r, 'snapshot' => $desk->decode($r->snapshot)]),
|
'revisions' => DB::table('desk_revisions')->where('request_id', $id)->orderByDesc('version')->get(['version', 'snapshot', 'created_at'])->map(fn ($r) => [...(array) $r, 'snapshot' => $desk->decode($r->snapshot)]),
|
||||||
'payments' => DB::table('desk_payments')->where('request_id', $id)->get(),
|
'payments' => DB::table('desk_payments')->where('request_id', $id)->get(),
|
||||||
'analysts' => $request->user()->can('manage-portal') ? User::orderBy('name')->get(['id', 'name']) : [],
|
'analysts' => $request->user()->can('manage-portal') ? User::orderBy('name')->get(['id', 'name']) : [],
|
||||||
'territories' => app(\App\Services\InvestmentGeography::class)->publicReferences()->orderBy('name')->get(['id', 'name', 'location_type'])];
|
'territories' => app(InvestmentGeography::class)->publicReferences()->orderBy('name')->get(['id', 'name', 'location_type'])];
|
||||||
|
|
||||||
return $request->expectsJson() ? response()->json($data) : Inertia::render('desk/request', $data);
|
return $request->expectsJson() ? response()->json($data) : Inertia::render('desk/request', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function save(Request $request, string $id, VirtualDesk $desk)
|
public function save(Request $request, string $id, VirtualDesk $desk): JsonResponse|RedirectResponse
|
||||||
{
|
{
|
||||||
$row = $desk->save($request->user(), $id, $request->all(), $request->boolean('submit'));
|
$row = $desk->save($request->user(), $id, $request->all(), $request->boolean('submit'));
|
||||||
|
|
||||||
return $request->expectsJson() ? response()->json(['id' => $row->id, 'version' => $row->version, 'status' => $row->status, 'protocol' => $row->protocol]) : back()->with('success', $request->boolean('submit') ? 'Pedido submetido; protocolo disponível.' : 'Rascunho guardado.');
|
return $request->expectsJson() ? response()->json(['id' => $row->id, 'version' => $row->version, 'status' => $row->status, 'protocol' => $row->protocol]) : back()->with('success', $request->boolean('submit') ? 'Pedido submetido; protocolo disponível.' : 'Rascunho guardado.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function transition(Request $request, string $id, VirtualDesk $desk)
|
public function transition(Request $request, string $id, VirtualDesk $desk): JsonResponse|RedirectResponse
|
||||||
{
|
{
|
||||||
$row = $desk->transition($request->user(), $id, $request->all());
|
$row = $desk->transition($request->user(), $id, $request->all());
|
||||||
|
|
||||||
return $request->expectsJson() ? response()->json(['version' => $row->version, 'status' => $row->status]) : back()->with('success', 'Decisão interna registada.');
|
return $request->expectsJson() ? response()->json(['version' => $row->version, 'status' => $row->status]) : back()->with('success', 'Decisão interna registada.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function assign(Request $request, string $id, VirtualDesk $desk)
|
public function assign(Request $request, string $id, VirtualDesk $desk): JsonResponse|RedirectResponse
|
||||||
{
|
{
|
||||||
abort_unless($request->user()->can('manage-portal'), 403);
|
abort_unless($request->user()->can('manage-portal'), 403);
|
||||||
$data = $request->validate(['version' => 'required|integer', 'analyst_id' => 'required|integer|exists:users,id', 'reason' => 'required|string|min:3|max:3000', 'due_at' => 'nullable|date']);
|
$data = $request->validate(['version' => 'required|integer', 'analyst_id' => 'required|integer|exists:users,id', 'reason' => 'required|string|min:3|max:3000', 'due_at' => 'nullable|date']);
|
||||||
DB::transaction(function () use ($request, $id, $desk, $data) {
|
DB::transaction(function () use ($request, $id, $desk, $data) {
|
||||||
$row = $desk->request($request->user(), $id, false, true); $case = $desk->case($request->user(), $row->case_id);
|
$row = $desk->request($request->user(), $id, false, true);
|
||||||
|
$case = $desk->case($request->user(), $row->case_id);
|
||||||
abort_unless((int) $row->version === (int) $data['version'] && ! in_array($row->status, ['draft', 'cancelled', 'closed'], true), 409);
|
abort_unless((int) $row->version === (int) $data['version'] && ! in_array($row->status, ['draft', 'cancelled', 'closed'], true), 409);
|
||||||
$analyst = User::findOrFail($data['analyst_id']); abort_if($desk->owns($analyst, $case, false), 422, 'O proponente não pode ser o analista.');
|
$analyst = User::where('id', $data['analyst_id'])->firstOrFail();
|
||||||
|
abort_unless($analyst->hasVerifiedEmail(), 422, 'O responsável deve ter conta verificada.');
|
||||||
|
abort_if($desk->owns($analyst, $case, false), 422, 'O proponente não pode ser o analista.');
|
||||||
DB::table('desk_requests')->where('id', $id)->update(['analyst_id' => $analyst->id, 'due_at' => $data['due_at'] ?? null, 'version' => $row->version + 1, 'updated_at' => now()]);
|
DB::table('desk_requests')->where('id', $id)->update(['analyst_id' => $analyst->id, 'due_at' => $data['due_at'] ?? null, 'version' => $row->version + 1, 'updated_at' => now()]);
|
||||||
$desk->event($case, $request->user(), 'analyst_assigned', [...$data, 'deadline_basis' => 'internal_target_not_legal_deadline'], DB::table('desk_requests')->where('id', $id)->first());
|
$desk->event($case, $request->user(), 'analyst_assigned', [...$data, 'deadline_basis' => 'internal_target_not_legal_deadline'], DB::table('desk_requests')->where('id', $id)->first());
|
||||||
});
|
});
|
||||||
|
|
||||||
return $request->expectsJson() ? response()->json(['ok' => true]) : back()->with('success', 'Analista e meta interna atribuídos.');
|
return $request->expectsJson() ? response()->json(['ok' => true]) : back()->with('success', 'Analista e meta interna atribuídos.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function message(Request $request, string $id, VirtualDesk $desk)
|
public function message(Request $request, string $id, VirtualDesk $desk): JsonResponse|RedirectResponse
|
||||||
{
|
{
|
||||||
$data = $request->validate(['body' => 'required|string|min:1|max:10000', 'client_key' => 'required|uuid']);
|
$data = $request->validate(['body' => 'required|string|min:1|max:10000', 'client_key' => 'required|uuid']);
|
||||||
DB::transaction(function () use ($request, $id, $desk, $data) {
|
DB::transaction(function () use ($request, $id, $desk, $data) {
|
||||||
$row = $desk->request($request->user(), $id, false, true); $case = $desk->case($request->user(), $row->case_id);
|
$row = $desk->request($request->user(), $id, false, true);
|
||||||
|
$case = $desk->case($request->user(), $row->case_id);
|
||||||
abort_if(in_array($row->status, ['closed', 'cancelled'], true), 409, 'Pedido encerrado.');
|
abort_if(in_array($row->status, ['closed', 'cancelled'], true), 409, 'Pedido encerrado.');
|
||||||
|
abort_unless($desk->owns($request->user(), $case) || $request->user()->can('manage-portal') || (int) $row->analyst_id === $request->user()->id, 403);
|
||||||
$existing = DB::table('desk_messages')->where('request_id', $id)->where('actor_id', $request->user()->id)->where('client_key', $data['client_key'])->first();
|
$existing = DB::table('desk_messages')->where('request_id', $id)->where('actor_id', $request->user()->id)->where('client_key', $data['client_key'])->first();
|
||||||
if ($existing) { abort_unless(\Illuminate\Support\Facades\Crypt::decryptString($existing->body) === $data['body'], 409); return; }
|
if ($existing) {
|
||||||
DB::table('desk_messages')->insert(['id' => (string) Str::uuid(), 'request_id' => $id, 'actor_id' => $request->user()->id, 'client_key' => $data['client_key'], 'body' => \Illuminate\Support\Facades\Crypt::encryptString($data['body'])]);
|
abort_unless(Crypt::decryptString($existing->body) === $data['body'], 409);
|
||||||
$desk->event($case, $request->user(), 'message_added', [], $row);
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$messageId = (string) Str::uuid();
|
||||||
|
DB::table('desk_messages')->insert(['id' => $messageId, 'request_id' => $id, 'actor_id' => $request->user()->id, 'client_key' => $data['client_key'], 'body' => Crypt::encryptString($data['body'])]);
|
||||||
|
$desk->event($case, $request->user(), 'message_added', ['message_id' => $messageId,
|
||||||
|
'kind' => $desk->owns($request->user(), $case) ? 'investor_message' : 'responsible_response'], $row);
|
||||||
});
|
});
|
||||||
|
|
||||||
return $request->expectsJson() ? response()->json(['ok' => true]) : back()->with('success', 'Mensagem privada guardada.');
|
return $request->expectsJson() ? response()->json(['ok' => true]) : back()->with('success', 'Mensagem privada guardada.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function receipt(Request $request, string $id, VirtualDesk $desk)
|
public function receipt(Request $request, string $id, VirtualDesk $desk): StreamedResponse
|
||||||
{
|
{
|
||||||
$row = $desk->request($request->user(), $id); abort_unless($row->protocol && $row->submitted_snapshot, 404);
|
$row = $desk->request($request->user(), $id);
|
||||||
|
abort_unless($row->protocol && $row->submitted_snapshot, 404);
|
||||||
$snapshot = $desk->decode($row->submitted_snapshot);
|
$snapshot = $desk->decode($row->submitted_snapshot);
|
||||||
$this->auditRead($request, 'desk_requests', $id, 'receipt_downloaded');
|
$this->auditRead($request, 'desk_requests', $id, 'receipt_downloaded');
|
||||||
|
|
||||||
return response()->streamDownload(function () use ($row, $snapshot) {
|
return response()->streamDownload(function () use ($row, $snapshot) {
|
||||||
echo 'Balcão Virtual — recibo de submissão interna'.PHP_EOL.$row->protocol.PHP_EOL.'Data: '.$row->submitted_at.PHP_EOL.'Versão: '.$row->version.PHP_EOL;
|
echo 'Balcão Virtual — recibo de submissão interna'.PHP_EOL.$row->protocol.PHP_EOL.'Data: '.$row->submitted_at.PHP_EOL.'Versão: '.$row->version.PHP_EOL;
|
||||||
echo json_encode($snapshot, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR);
|
echo json_encode($snapshot, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR);
|
||||||
}, $row->protocol.'.txt', ['Content-Type' => 'text/plain; charset=utf-8', 'Cache-Control' => 'private, no-store']);
|
}, $row->protocol.'.txt', ['Content-Type' => 'text/plain; charset=utf-8', 'Cache-Control' => 'private, no-store']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function attach(Request $request, string $id, VirtualDesk $desk)
|
public function attach(Request $request, string $id, VirtualDesk $desk): JsonResponse|RedirectResponse
|
||||||
{
|
{
|
||||||
$data = $request->validate(['version' => 'required|integer', 'file' => 'nullable|required_without:document_id|file|mimetypes:application/pdf,image/png,image/jpeg,text/plain|max:10240',
|
$data = $request->validate(['version' => 'required|integer', 'file' => 'nullable|required_without:document_id|file|mimetypes:application/pdf,image/png,image/jpeg,text/plain|max:10240',
|
||||||
'document_id' => 'nullable|required_without:file|uuid', 'category' => 'required|string|max:80', 'stage' => 'nullable|string|max:3', 'request_id' => 'nullable|uuid', 'valid_until' => 'nullable|date_format:Y-m-d', 'source_reference' => 'required|string|max:3000', 'consent' => 'accepted']);
|
'document_id' => 'nullable|required_without:file|uuid', 'category' => 'required|string|max:80', 'stage' => 'nullable|string|max:3', 'request_id' => 'nullable|uuid', 'valid_until' => 'nullable|date_format:Y-m-d', 'source_reference' => 'required|string|max:3000', 'consent' => 'accepted']);
|
||||||
$key = null; $newId = null;
|
$key = null;
|
||||||
|
$newId = null;
|
||||||
try {
|
try {
|
||||||
DB::transaction(function () use ($request, $id, $desk, $data, &$key, &$newId) {
|
DB::transaction(function () use ($request, $id, $desk, $data, &$key, &$newId) {
|
||||||
$case = $desk->case($request->user(), $id, true, true); abort_unless((int) $case->version === (int) $data['version'], 409);
|
$case = $desk->case($request->user(), $id, true, true);
|
||||||
if ($data['stage'] ?? null) abort_unless(array_key_exists($data['stage'], config('virtual-desk.steps')), 422);
|
abort_if($case->closed_at, 409, 'Dossier encerrado.');
|
||||||
|
abort_unless((int) $case->version === (int) $data['version'], 409);
|
||||||
|
if ($data['stage'] ?? null) {
|
||||||
|
abort_unless(array_key_exists($data['stage'], config('virtual-desk.steps')), 422);
|
||||||
|
}
|
||||||
if ($data['request_id'] ?? null) {
|
if ($data['request_id'] ?? null) {
|
||||||
$row = $desk->request($request->user(), $data['request_id'], true, true);
|
$row = $desk->request($request->user(), $data['request_id'], true, true);
|
||||||
abort_unless($row->case_id === $id && in_array($row->status, ['draft', 'returned'], true), 409, 'Anexos de pedidos submetidos são imutáveis; use a devolução para corrigir.');
|
abort_unless($row->case_id === $id && in_array($row->status, ['draft', 'returned'], true), 409, 'Anexos de pedidos submetidos são imutáveis; use a devolução para corrigir.');
|
||||||
}
|
}
|
||||||
abort_if(DB::table('desk_documents')->where('case_id', $id)->count() >= 100, 422, 'Limite de anexos do dossier atingido.');
|
abort_if(DB::table('desk_documents')->where('case_id', $id)->count() >= 100, 422, 'Limite de anexos do dossier atingido.');
|
||||||
if ($request->hasFile('file')) {
|
if ($request->hasFile('file')) {
|
||||||
$file = $request->file('file'); $hash = hash_file('sha256', $file->getRealPath());
|
$file = $request->file('file');
|
||||||
|
$hash = hash_file('sha256', $file->getRealPath());
|
||||||
$duplicate = DB::table('desk_documents as l')->join('documents as d', 'd.id', '=', 'l.document_id')->where('l.case_id', $id)->where('d.sha256', $hash)->first();
|
$duplicate = DB::table('desk_documents as l')->join('documents as d', 'd.id', '=', 'l.document_id')->where('l.case_id', $id)->where('d.sha256', $hash)->first();
|
||||||
if ($duplicate) return;
|
if ($duplicate) {
|
||||||
$newId = (string) Str::uuid(); $key = $file->storeAs('virtual-desk/'.$id, $newId, 'local'); abort_unless($key, 500);
|
return;
|
||||||
|
}
|
||||||
|
$newId = (string) Str::uuid();
|
||||||
|
$key = $file->storeAs('virtual-desk/'.$id, $newId, 'local');
|
||||||
|
abort_unless(is_string($key) && $key !== '', 500);
|
||||||
DB::table('documents')->insert(['id' => $newId, 'source_system' => 'virtual-desk', 'file_name' => basename($file->getClientOriginalName()), 'media_type' => $file->getMimeType(), 'storage_key' => $key,
|
DB::table('documents')->insert(['id' => $newId, 'source_system' => 'virtual-desk', 'file_name' => basename($file->getClientOriginalName()), 'media_type' => $file->getMimeType(), 'storage_key' => $key,
|
||||||
'sha256' => $hash, 'size_bytes' => $file->getSize(), 'uploaded_by' => $request->user()->id, 'status' => 'quarantined', 'data_classification' => 'confidential']);
|
'sha256' => $hash, 'size_bytes' => $file->getSize(), 'uploaded_by' => $request->user()->id, 'status' => 'quarantined', 'data_classification' => 'confidential']);
|
||||||
$documentId = $newId;
|
$documentId = $newId;
|
||||||
} else {
|
} else {
|
||||||
$documentId = $data['document_id'];
|
$documentId = $data['document_id'];
|
||||||
$document = DB::table('documents')->where('id', $documentId)->whereNull('deleted_at')->first(); abort_unless($document, 404);
|
$document = DB::table('documents')->where('id', $documentId)->whereNull('deleted_at')->first();
|
||||||
|
abort_unless($document !== null, 404);
|
||||||
$owned = (int) $document->uploaded_by === $request->user()->id || DB::table('desk_documents as l')->join('desk_cases as c', 'c.id', '=', 'l.case_id')->where('l.document_id', $documentId)->where('c.user_id', $request->user()->id)->whereNull('c.organization_id')->exists();
|
$owned = (int) $document->uploaded_by === $request->user()->id || DB::table('desk_documents as l')->join('desk_cases as c', 'c.id', '=', 'l.case_id')->where('l.document_id', $documentId)->where('c.user_id', $request->user()->id)->whereNull('c.organization_id')->exists();
|
||||||
abort_unless($owned, 403, 'Não há autorização para reutilizar este documento.');
|
abort_unless($owned, 403, 'Não há autorização para reutilizar este documento.');
|
||||||
if (DB::table('desk_documents')->where('case_id', $id)->where('document_id', $documentId)->exists()) return;
|
if (DB::table('desk_documents')->where('case_id', $id)->where('document_id', $documentId)->exists()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
DB::table('desk_documents')->insert(['id' => (string) Str::uuid(), 'case_id' => $id, 'document_id' => $documentId, 'request_id' => $data['request_id'] ?? null,
|
DB::table('desk_documents')->insert(['id' => (string) Str::uuid(), 'case_id' => $id, 'document_id' => $documentId, 'request_id' => $data['request_id'] ?? null,
|
||||||
'category' => $data['category'], 'stage' => $data['stage'] ?? null, 'valid_until' => $data['valid_until'] ?? null, 'source_reference' => $data['source_reference'], 'linked_by' => $request->user()->id]);
|
'category' => $data['category'], 'stage' => $data['stage'] ?? null, 'valid_until' => $data['valid_until'] ?? null, 'source_reference' => $data['source_reference'], 'linked_by' => $request->user()->id]);
|
||||||
DB::table('desk_cases')->where('id', $id)->update(['version' => $case->version + 1, 'updated_at' => now()]);
|
DB::table('desk_cases')->where('id', $id)->update(['version' => $case->version + 1, 'updated_at' => now()]);
|
||||||
$desk->event(DB::table('desk_cases')->where('id', $id)->first(), $request->user(), 'document_linked', ['document_id' => $documentId, 'source' => $data['source_reference'], 'consent' => true]);
|
$desk->event(DB::table('desk_cases')->where('id', $id)->first(), $request->user(), 'document_linked', ['document_id' => $documentId, 'source' => $data['source_reference'], 'consent' => true]);
|
||||||
});
|
});
|
||||||
} catch (\Throwable $e) { if ($key) Storage::disk('local')->delete($key); throw $e; }
|
} catch (\Throwable $e) {
|
||||||
if ($newId) ScanDocumentForMalware::dispatch($newId)->afterCommit();
|
if ($key) {
|
||||||
|
Storage::disk('local')->delete($key);
|
||||||
|
} throw $e;
|
||||||
|
}
|
||||||
|
if ($newId) {
|
||||||
|
ScanDocumentForMalware::dispatch($newId)->afterCommit();
|
||||||
|
}
|
||||||
|
|
||||||
return $request->expectsJson() ? response()->json(['ok' => true]) : back()->with('success', 'Documento privado associado; consulte o estado da análise.');
|
return $request->expectsJson() ? response()->json(['ok' => true]) : back()->with('success', 'Documento privado associado; consulte o estado da análise.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function download(Request $request, string $id, string $document, VirtualDesk $desk)
|
public function download(Request $request, string $id, string $document, VirtualDesk $desk): BinaryFileResponse
|
||||||
{
|
{
|
||||||
$desk->case($request->user(), $id);
|
$desk->case($request->user(), $id);
|
||||||
$doc = DB::table('desk_documents as l')->join('documents as d', 'd.id', '=', 'l.document_id')->where('l.case_id', $id)->where('l.id', $document)->whereNull('d.deleted_at')->first(['d.*']);
|
$doc = DB::table('desk_documents as l')->join('documents as d', 'd.id', '=', 'l.document_id')->where('l.case_id', $id)->where('l.id', $document)->whereNull('d.deleted_at')->first(['d.*', 'l.request_id']);
|
||||||
|
if ($doc && $doc->request_id) {
|
||||||
|
$desk->request($request->user(), $doc->request_id);
|
||||||
|
}
|
||||||
abort_unless($doc && $doc->status === 'active' && $doc->malware_scan_status === 'clean' && trim($doc->sha256) === $doc->malware_scanned_sha256, 404);
|
abort_unless($doc && $doc->status === 'active' && $doc->malware_scan_status === 'clean' && trim($doc->sha256) === $doc->malware_scanned_sha256, 404);
|
||||||
$path = realpath(Storage::disk('local')->path($doc->storage_key)); $root = realpath(Storage::disk('local')->path(''));
|
$path = realpath(Storage::disk('local')->path($doc->storage_key));
|
||||||
abort_unless($path && $root && str_starts_with($path, $root.DIRECTORY_SEPARATOR) && is_file($path) && hash_equals(trim($doc->sha256), hash_file('sha256', $path)), 404);
|
$root = realpath(Storage::disk('local')->path(''));
|
||||||
|
abort_unless($path && $root && str_starts_with($path, $root.DIRECTORY_SEPARATOR) && is_file($path) && is_string($actualHash = hash_file('sha256', $path)) && hash_equals(trim($doc->sha256), $actualHash), 404);
|
||||||
$this->auditRead($request, 'documents', $doc->id, 'document_downloaded');
|
$this->auditRead($request, 'documents', $doc->id, 'document_downloaded');
|
||||||
|
|
||||||
return response()->download($path, $doc->file_name, ['Cache-Control' => 'private, no-store']);
|
return response()->download($path, $doc->file_name, ['Cache-Control' => 'private, no-store']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function notification(Request $request, int $id)
|
public function notification(Request $request, int $id): RedirectResponse
|
||||||
{
|
{
|
||||||
DB::table('desk_notifications')->where('id', $id)->where('user_id', $request->user()->id)->update(['read_at' => now()]);
|
DB::table('desk_notifications')->where('id', $id)->where('user_id', $request->user()->id)->update(['read_at' => now()]);
|
||||||
|
|
||||||
return back();
|
return back();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function redirectLink(Request $request, string $id, VirtualDesk $desk)
|
public function redirectLink(Request $request, string $id, VirtualDesk $desk): RedirectResponse
|
||||||
{
|
{
|
||||||
$case = $desk->case($request->user(), $request->validate(['case_id' => 'required|uuid'])['case_id']);
|
$case = $desk->case($request->user(), $request->validate(['case_id' => 'required|uuid'])['case_id']);
|
||||||
$link = DB::table('desk_institutional_links')->where('id', $id)->where('status', 'active')->whereNotNull('verified_at')->first(); abort_unless($link, 404);
|
$link = DB::table('desk_institutional_links')->where('id', $id)->first();
|
||||||
|
if (! $link || ! app(InstitutionalLinkMonitor::class)->status($link)['available'] || $request->boolean('unavailable')) {
|
||||||
|
$desk->event($case, $request->user(), 'institutional_link_unavailable', ['link_id' => $id, 'contact' => $link?->contact, 'scope' => 'internal_services_remain_available']);
|
||||||
|
|
||||||
|
return redirect('/balcao-virtual/dossiers/'.$case->id)->with('warning', 'Ligação indisponível ou por verificar. Contacto alternativo: '.($link?->contact ?: (config('portal.support.email') ?: 'utilize o pedido de apoio neste dossier')).'. Pode continuar a preparação e os serviços internos.');
|
||||||
|
}
|
||||||
abort_unless(filter_var($link->url, FILTER_VALIDATE_URL) && parse_url($link->url, PHP_URL_SCHEME) === 'https', 422);
|
abort_unless(filter_var($link->url, FILTER_VALIDATE_URL) && parse_url($link->url, PHP_URL_SCHEME) === 'https', 422);
|
||||||
$desk->event($case, $request->user(), 'institutional_referral', ['link_id' => $id, 'version' => $link->version, 'purpose' => $link->purpose]);
|
$desk->event($case, $request->user(), 'institutional_referral', ['link_id' => $id, 'version' => $link->version, 'purpose' => $link->purpose]);
|
||||||
|
|
||||||
// No personal data, case ID or protocol appended to the external URL.
|
// No personal data, case ID or protocol appended to the external URL.
|
||||||
return redirect()->away($link->url)->withHeaders(['Referrer-Policy' => 'no-referrer']);
|
return redirect()->away($link->url)->withHeaders(['Referrer-Policy' => 'no-referrer']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Services\VirtualDeskInstallation;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
use Inertia\Inertia;
|
||||||
|
use Inertia\Response;
|
||||||
|
|
||||||
|
class VirtualDeskInstallationController extends Controller
|
||||||
|
{
|
||||||
|
public function reviewLink(Request $request, string $id): JsonResponse|RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate(['version' => 'required|integer|min:1', 'available' => 'required|boolean',
|
||||||
|
'evidence' => 'required|string|min:10|max:3000', 'contact' => 'nullable|string|max:255']);
|
||||||
|
DB::transaction(function () use ($request, $id, $data) {
|
||||||
|
$link = DB::table('desk_institutional_links')->where('id', $id)->lockForUpdate()->first();
|
||||||
|
abort_unless($link !== null, 404);
|
||||||
|
abort_unless((int) $link->version === (int) $data['version'], 409);
|
||||||
|
abort_unless(filter_var($link->url, FILTER_VALIDATE_URL) && parse_url($link->url, PHP_URL_SCHEME) === 'https', 422);
|
||||||
|
DB::table('desk_institutional_links')->where('id', $id)->update(['status' => $data['available'] ? 'active' : 'unavailable',
|
||||||
|
'contact' => $data['contact'] ?? $link->contact, 'verified_at' => now(), 'verified_by' => $request->user()->id,
|
||||||
|
'version' => $link->version + 1, 'updated_at' => now()]);
|
||||||
|
DB::table('audit_events')->insert(['source_system' => 'virtual-desk', 'entity_type' => 'desk_institutional_links', 'entity_id' => $id,
|
||||||
|
'actor_user_id' => $request->user()->id, 'action' => 'institutional_link_checked',
|
||||||
|
'after_data' => json_encode(['url' => $link->url, 'prior_version' => $link->version, ...$data, 'scope' => 'availability_only_not_legal_approval'])]);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $request->expectsJson() ? response()->json(['checked' => true]) : back()->with('success', 'Conferência de disponibilidade registada por sete dias.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sources(Request $request): JsonResponse|Response
|
||||||
|
{
|
||||||
|
$read = function (string $name): array {
|
||||||
|
$file = storage_path('app/private/virtual-desk/'.$name.'.json');
|
||||||
|
if (! is_file($file)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$bytes = file_get_contents($file);
|
||||||
|
abort_unless(is_string($bytes), 503);
|
||||||
|
|
||||||
|
return json_decode($bytes, true, 512, JSON_THROW_ON_ERROR);
|
||||||
|
};
|
||||||
|
$inventory = $read('source-inventory');
|
||||||
|
$forms = $read('form-register');
|
||||||
|
$data = ['total' => count($inventory), 'attachmentCount' => array_sum(array_map(fn ($item) => count($item['attachments'] ?? []), $inventory)),
|
||||||
|
'forms' => array_map(fn ($item) => ['identifier' => $item['identifier'], 'sha256' => $item['sha256'], 'size' => $item['size'], 'edition' => $item['edition'],
|
||||||
|
'provenance' => str_contains($item['path'], DIRECTORY_SEPARATOR.'Scan'.DIRECTORY_SEPARATOR) ? 'Acervo disponibilizado — digitalização' : 'Acervo disponibilizado — fonte de desenho ou template',
|
||||||
|
'consultation' => $item['consultation'], 'legal_documentary_status' => $item['legal_documentary_status'], 'rule_use' => $item['rule_use'], 'official_confirmation' => $item['official_confirmation'], 'fields_status' => $item['fields_status']], $forms),
|
||||||
|
'source' => config('virtual-desk.source')];
|
||||||
|
|
||||||
|
return $request->expectsJson() ? response()->json($data) : Inertia::render('desk/sources', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function preview(Request $request, VirtualDeskInstallation $installation): JsonResponse|Response
|
||||||
|
{
|
||||||
|
$data = $installation->preview();
|
||||||
|
|
||||||
|
return $request->expectsJson() ? response()->json($data) : Inertia::render('desk/install', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function apply(Request $request, VirtualDeskInstallation $installation): JsonResponse|RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate(['hash' => 'required|string|size:64', 'confirm' => 'accepted']);
|
||||||
|
$installation->apply($data['hash'], $request->user());
|
||||||
|
|
||||||
|
return $request->expectsJson() ? response()->json(['installed' => true]) : back()->with('success', 'Instalação concluída; serviços ainda exigem publicação explícita.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function publishService(Request $request): JsonResponse|RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate(['code' => ['required', Rule::in(array_keys(config('virtual-desk.services')))], 'confirm' => 'accepted']);
|
||||||
|
$row = DB::transaction(function () use ($request, $data) {
|
||||||
|
DB::select('select pg_advisory_xact_lock(261008, 2)');
|
||||||
|
$definition = config('virtual-desk.services.'.$data['code']);
|
||||||
|
$existing = DB::table('desk_service_versions')->where('code', $data['code'])->orderByDesc('version')->first();
|
||||||
|
if ($existing && $existing->status === 'published' && json_decode($existing->definition, true) === $definition) {
|
||||||
|
return $existing;
|
||||||
|
}
|
||||||
|
$id = (string) Str::uuid();
|
||||||
|
DB::table('desk_service_versions')->insert(['id' => $id, 'code' => $data['code'], 'version' => ($existing->version ?? 0) + 1, 'status' => 'published',
|
||||||
|
'definition' => json_encode($definition), 'source' => json_encode(config('virtual-desk.source')), 'author_id' => $request->user()->id,
|
||||||
|
'published_by' => $request->user()->id, 'published_at' => now(), 'created_at' => now(), 'updated_at' => now()]);
|
||||||
|
DB::table('audit_events')->insert(['source_system' => 'virtual-desk', 'entity_type' => 'desk_service_versions', 'entity_id' => $id, 'actor_user_id' => $request->user()->id,
|
||||||
|
'action' => 'internal_service_published', 'after_data' => json_encode(['code' => $data['code'], 'nature' => 'digital_preparation_not_official_form'])]);
|
||||||
|
|
||||||
|
return DB::table('desk_service_versions')->where('id', $id)->first();
|
||||||
|
});
|
||||||
|
|
||||||
|
return $request->expectsJson() ? response()->json(['id' => $row->id], 201) : back()->with('success', 'Serviço de preparação interna publicado.');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Services\Ai\InvestorGuidanceEvidence;
|
||||||
|
use App\Services\VirtualDesk;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
/** Manual operations use the same requests, documents and encrypted audit history. */
|
||||||
|
class VirtualDeskOperationsController extends Controller
|
||||||
|
{
|
||||||
|
private function result(Request $request): JsonResponse|RedirectResponse
|
||||||
|
{
|
||||||
|
return $request->expectsJson() ? response()->json(['ok' => true]) : back()->with('success', 'Registo interno guardado; não constitui confirmação de uma instituição externa.');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function reviewer(Request $request, VirtualDesk $desk, \stdClass $case, ?\stdClass $row): void
|
||||||
|
{
|
||||||
|
abort_unless(! $desk->owns($request->user(), $case, false) && ($request->user()->can('manage-portal') || ($row && (int) $row->analyst_id === $request->user()->id)), 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function cleanDocument(string $caseId, string $documentId, ?string $requestId): \stdClass
|
||||||
|
{
|
||||||
|
$doc = DB::table('desk_documents as l')->join('documents as d', 'd.id', '=', 'l.document_id')
|
||||||
|
->where('l.case_id', $caseId)->where('d.id', $documentId)->whereNull('d.deleted_at')
|
||||||
|
->where(fn ($q) => $q->whereNull('l.request_id')->when($requestId, fn ($p) => $p->orWhere('l.request_id', $requestId)))
|
||||||
|
->first(['d.*', 'l.id as link_id']);
|
||||||
|
abort_unless($doc !== null && $doc->status === 'active' && $doc->malware_scan_status === 'clean' && trim($doc->sha256) === $doc->malware_scanned_sha256, 422, 'Documento indisponível para conferência: verifique autorização, integridade e análise antimalware.');
|
||||||
|
$path = realpath(Storage::disk('local')->path($doc->storage_key));
|
||||||
|
$root = realpath(Storage::disk('local')->path(''));
|
||||||
|
abort_unless($path && $root && str_starts_with($path, $root.DIRECTORY_SEPARATOR) && is_file($path) && is_string($hash = hash_file('sha256', $path)) && hash_equals(trim($doc->sha256), $hash), 422, 'O ficheiro original ou a sua integridade não pôde ser confirmado.');
|
||||||
|
|
||||||
|
return $doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function documentReview(Request $request, string $id, string $document, VirtualDesk $desk): JsonResponse|RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate(['version' => 'required|integer|min:1', 'request_id' => 'nullable|uuid', 'outcome' => 'required|in:internal_verified,internal_issue,contradiction_identified', 'what_checked' => 'required|string|min:3|max:3000', 'evidence' => 'required|string|min:3|max:5000', 'supports' => 'nullable|array|max:4', 'supports.*' => ['string', Rule::in(InvestorGuidanceEvidence::FIELDS)]]);
|
||||||
|
DB::transaction(function () use ($request, $id, $document, $desk, $data) {
|
||||||
|
$case = $desk->case($request->user(), $id, false, true);
|
||||||
|
abort_unless(! $case->closed_at && (int) $case->version === (int) $data['version'], 409);
|
||||||
|
$link = DB::table('desk_documents')->where('case_id', $id)->where('id', $document)->first();
|
||||||
|
abort_unless($link !== null, 404);
|
||||||
|
$requestId = $link->request_id ?: ($data['request_id'] ?? null);
|
||||||
|
$row = $requestId ? $desk->request($request->user(), $requestId, false, true) : null;
|
||||||
|
abort_if($row && $row->case_id !== $id, 422);
|
||||||
|
$this->reviewer($request, $desk, $case, $row);
|
||||||
|
$doc = $this->cleanDocument($id, $link->document_id, $requestId);
|
||||||
|
DB::table('desk_cases')->where('id', $id)->update(['version' => $case->version + 1, 'updated_at' => now()]);
|
||||||
|
$desk->event(DB::table('desk_cases')->where('id', $id)->firstOrFail(), $request->user(), 'document_reviewed', [
|
||||||
|
...$data, 'document_id' => $doc->id, 'link_id' => $link->id, 'sha256' => trim($doc->sha256), 'document_version' => (int) $doc->version_no, 'reviewer_id' => $request->user()->id,
|
||||||
|
'scope' => 'internal_documentary_check_not_official_approval_registration_or_license',
|
||||||
|
], $row);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $this->result($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function payment(Request $request, string $id, VirtualDesk $desk): JsonResponse|RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate(['reference' => 'required|string|max:255', 'amount' => ['required', 'regex:/^\d{1,12}(\.\d{1,2})?$/', 'numeric', 'gt:0'], 'currency' => 'required|in:MZN,USD,EUR', 'source_reference' => 'required|string|min:3|max:3000', 'document_id' => 'nullable|uuid', 'consent' => 'accepted']);
|
||||||
|
DB::transaction(function () use ($request, $id, $desk, $data) {
|
||||||
|
$row = $desk->request($request->user(), $id, true, true);
|
||||||
|
$case = $desk->case($request->user(), $row->case_id);
|
||||||
|
abort_if(in_array($row->status, ['closed', 'cancelled'], true), 409);
|
||||||
|
if ($data['document_id'] ?? null) {
|
||||||
|
abort_unless(DB::table('desk_documents')->where('case_id', $case->id)->where('document_id', $data['document_id'])->where(fn ($q) => $q->whereNull('request_id')->orWhere('request_id', $id))->exists(), 422);
|
||||||
|
}
|
||||||
|
// References are supplied by the investor; no bank reference or fee is generated.
|
||||||
|
$existing = DB::table('desk_payments')->where('reference', $data['reference'])->first();
|
||||||
|
if ($existing) {
|
||||||
|
$parts = explode('.', (string) $data['amount']);
|
||||||
|
$amount = (ltrim($parts[0], '0') ?: '0').'.'.str_pad($parts[1] ?? '', 2, '0');
|
||||||
|
abort_unless($existing->request_id === $id && (string) $existing->amount === $amount && $existing->currency === $data['currency'] && $existing->source_reference === $data['source_reference'] && $existing->document_id === ($data['document_id'] ?? null), 409);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$payment = (string) Str::uuid();
|
||||||
|
DB::table('desk_payments')->insert(['id' => $payment, 'request_id' => $id, 'reference' => $data['reference'], 'amount' => $data['amount'], 'currency' => $data['currency'], 'source_reference' => $data['source_reference'], 'document_id' => $data['document_id'] ?? null, 'status' => 'pending', 'created_at' => now(), 'updated_at' => now()]);
|
||||||
|
$desk->event($case, $request->user(), 'payment_declared', ['payment_id' => $payment, 'consent' => true, 'scope' => 'manual_declaration_no_bank_confirmation'], $row);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $this->result($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function paymentReview(Request $request, string $id, string $payment, VirtualDesk $desk): JsonResponse|RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate(['version' => 'required|integer|min:1', 'status' => 'required|in:internal_verified,internal_issue', 'reason' => 'required|string|min:3|max:3000', 'evidence' => 'required|string|min:3|max:5000']);
|
||||||
|
DB::transaction(function () use ($request, $id, $payment, $desk, $data) {
|
||||||
|
$row = $desk->request($request->user(), $id, false, true);
|
||||||
|
$case = $desk->case($request->user(), $row->case_id);
|
||||||
|
$this->reviewer($request, $desk, $case, $row);
|
||||||
|
abort_if(in_array($row->status, ['closed', 'cancelled'], true), 409);
|
||||||
|
$record = DB::table('desk_payments')->where('request_id', $id)->where('id', $payment)->lockForUpdate()->first();
|
||||||
|
abort_unless($record !== null, 404);
|
||||||
|
abort_unless((int) $record->version === (int) $data['version'], 409);
|
||||||
|
$doc = null;
|
||||||
|
if ($data['status'] === 'internal_verified') {
|
||||||
|
abort_unless($record->document_id, 422, 'A conferência exige um comprovativo autorizado.');
|
||||||
|
$doc = $this->cleanDocument($case->id, $record->document_id, $id);
|
||||||
|
}
|
||||||
|
DB::table('desk_payments')->where('id', $payment)->update(['status' => $data['status'], 'reason' => $data['reason'], 'verified_by' => $request->user()->id, 'version' => $record->version + 1, 'updated_at' => now()]);
|
||||||
|
$desk->event($case, $request->user(), 'payment_reviewed', [...$data, 'payment_id' => $payment, 'document_id' => $doc?->id, 'sha256' => $doc ? trim($doc->sha256) : null, 'reviewer_id' => $request->user()->id, 'scope' => 'internal_proof_check_no_bank_confirmation'], $row);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $this->result($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function communication(Request $request, string $id, VirtualDesk $desk): JsonResponse|RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate(['channel' => 'required|in:phone,email,sms,whatsapp,in_person', 'direction' => 'required|in:received,sent', 'occurred_at' => 'required|date|before_or_equal:now', 'summary' => 'required|string|min:3|max:5000', 'evidence' => 'required|string|min:3|max:3000', 'client_key' => 'required|uuid']);
|
||||||
|
DB::transaction(function () use ($request, $id, $desk, $data) {
|
||||||
|
$row = $desk->request($request->user(), $id, false, true);
|
||||||
|
$case = $desk->case($request->user(), $row->case_id);
|
||||||
|
abort_unless($desk->owns($request->user(), $case) || $request->user()->can('manage-portal') || (int) $row->analyst_id === $request->user()->id, 403);
|
||||||
|
abort_if(in_array($row->status, ['closed', 'cancelled'], true), 409);
|
||||||
|
foreach (DB::table('desk_events')->where('request_id', $id)->where('actor_id', $request->user()->id)->where('action', 'manual_communication_recorded')->get(['payload']) as $event) {
|
||||||
|
$saved = $desk->decode($event->payload);
|
||||||
|
if (($saved['client_key'] ?? null) === $data['client_key']) {
|
||||||
|
abort_unless(array_intersect_key($saved, $data) === $data, 409);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$desk->event($case, $request->user(), 'manual_communication_recorded', [...$data, 'scope' => 'manual_record_not_portal_delivery_confirmation'], $row);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $this->result($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ namespace App\Http\Middleware;
|
|||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
@@ -44,7 +45,7 @@ final class EnsureSimulationRecoveryCookie
|
|||||||
$expiry = is_array($payload) ? ($payload['expires_at'] ?? null) : null;
|
$expiry = is_array($payload) ? ($payload['expires_at'] ?? null) : null;
|
||||||
if (is_string($expiry)) {
|
if (is_string($expiry)) {
|
||||||
try {
|
try {
|
||||||
$secondsLeft = \Illuminate\Support\Carbon::parse($expiry)->getTimestamp() - now()->getTimestamp();
|
$secondsLeft = Carbon::parse($expiry)->getTimestamp() - now()->getTimestamp();
|
||||||
$minutes = max(1, (int) ceil($secondsLeft / 60));
|
$minutes = max(1, (int) ceil($secondsLeft / 60));
|
||||||
} catch (\Throwable) {
|
} catch (\Throwable) {
|
||||||
// Preserve the standard cookie lifetime if the response has no valid deadline.
|
// Preserve the standard cookie lifetime if the response has no valid deadline.
|
||||||
|
|||||||
@@ -38,10 +38,11 @@ class HandleInertiaRequests extends Middleware
|
|||||||
return [
|
return [
|
||||||
...parent::share($request),
|
...parent::share($request),
|
||||||
'name' => config('app.name'),
|
'name' => config('app.name'),
|
||||||
|
'portalOperator' => config('portal.operator_name'),
|
||||||
'educationEnabled' => (bool) config('education.enabled', false),
|
'educationEnabled' => (bool) config('education.enabled', false),
|
||||||
'aiEnabled' => (bool) config('investmoz_ai.enabled', false),
|
'aiEnabled' => (bool) config('investmoz_ai.enabled', false),
|
||||||
'existingBusinessEnabled' => (bool) config('existing-business.enabled', false),
|
'existingBusinessEnabled' => (bool) config('existing-business.enabled', false),
|
||||||
'flash' => ['success' => fn () => $request->session()->get('success')],
|
'flash' => ['success' => fn () => $request->session()->get('success'), 'warning' => fn () => $request->session()->get('warning')],
|
||||||
'auth' => [
|
'auth' => [
|
||||||
'user' => $request->user(),
|
'user' => $request->user(),
|
||||||
'canManagePortal' => $request->user()?->can('manage-portal') ?? false,
|
'canManagePortal' => $request->user()?->can('manage-portal') ?? false,
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use App\Services\VirtualDesk;
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class VirtualDeskInstalled
|
||||||
|
{
|
||||||
|
/** @param Closure(Request): Response $next */
|
||||||
|
public function handle(Request $request, Closure $next): Response
|
||||||
|
{
|
||||||
|
abort_unless(app(VirtualDesk::class)->installed(), 503, 'Balcão em preparação. A instalação autenticada exige backup/restauro e QA verificados. Os pedidos existentes continuam no painel anterior.');
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,7 +14,7 @@ use Illuminate\Support\Facades\Storage;
|
|||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
class ScanDocumentForMalware implements ShouldQueue, ShouldBeUnique
|
class ScanDocumentForMalware implements ShouldBeUnique, ShouldQueue
|
||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
@@ -31,6 +31,7 @@ class ScanDocumentForMalware implements ShouldQueue, ShouldBeUnique
|
|||||||
return $this->documentId;
|
return $this->documentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return list<int> */
|
||||||
public function backoff(): array
|
public function backoff(): array
|
||||||
{
|
{
|
||||||
return [15, 60];
|
return [15, 60];
|
||||||
@@ -38,7 +39,7 @@ class ScanDocumentForMalware implements ShouldQueue, ShouldBeUnique
|
|||||||
|
|
||||||
public function handle(MalwareScanner $scanner): void
|
public function handle(MalwareScanner $scanner): void
|
||||||
{
|
{
|
||||||
$document = DB::transaction(function (): ?object {
|
$document = DB::transaction(function (): ?\stdClass {
|
||||||
$row = DB::table('documents')->where('id', $this->documentId)->lockForUpdate()->first();
|
$row = DB::table('documents')->where('id', $this->documentId)->lockForUpdate()->first();
|
||||||
if (! $row || $row->status === 'deleted' || $row->deleted_at !== null) {
|
if (! $row || $row->status === 'deleted' || $row->deleted_at !== null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -66,8 +67,8 @@ class ScanDocumentForMalware implements ShouldQueue, ShouldBeUnique
|
|||||||
$disk = Storage::disk('local');
|
$disk = Storage::disk('local');
|
||||||
$root = $disk->path('');
|
$root = $disk->path('');
|
||||||
$path = $disk->path($document->storage_key);
|
$path = $disk->path($document->storage_key);
|
||||||
$beforeHash = is_file($path) ? hash_file('sha256', $path) : false;
|
$beforeHash = $this->fileHash($path);
|
||||||
if (! is_string($beforeHash) || ! hash_equals(trim($document->sha256), $beforeHash)) {
|
if ($beforeHash === null || ! hash_equals(trim($document->sha256), $beforeHash)) {
|
||||||
$this->record($document, [
|
$this->record($document, [
|
||||||
'result' => 'inconclusive', 'reason_code' => 'file_hash_mismatch', 'engine' => 'ClamAV',
|
'result' => 'inconclusive', 'reason_code' => 'file_hash_mismatch', 'engine' => 'ClamAV',
|
||||||
'engine_version' => 'unknown', 'signatures_at' => null, 'duration_ms' => 0, 'detail' => null,
|
'engine_version' => 'unknown', 'signatures_at' => null, 'duration_ms' => 0, 'detail' => null,
|
||||||
@@ -78,8 +79,8 @@ class ScanDocumentForMalware implements ShouldQueue, ShouldBeUnique
|
|||||||
|
|
||||||
$result = $scanner->scan($path, (int) ($document->size_bytes ?? filesize($path)), $root);
|
$result = $scanner->scan($path, (int) ($document->size_bytes ?? filesize($path)), $root);
|
||||||
|
|
||||||
$afterHash = is_file($path) ? hash_file('sha256', $path) : false;
|
$afterHash = $this->fileHash($path);
|
||||||
if (! is_string($afterHash) || ! hash_equals(trim($document->sha256), $afterHash)) {
|
if ($afterHash === null || ! hash_equals(trim($document->sha256), $afterHash)) {
|
||||||
$result['result'] = 'inconclusive';
|
$result['result'] = 'inconclusive';
|
||||||
$result['reason_code'] = 'file_changed_during_scan';
|
$result['reason_code'] = 'file_changed_during_scan';
|
||||||
$result['detail'] = null;
|
$result['detail'] = null;
|
||||||
@@ -102,7 +103,17 @@ class ScanDocumentForMalware implements ShouldQueue, ShouldBeUnique
|
|||||||
], now(), 'failed');
|
], now(), 'failed');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function record(object $document, array $result, \DateTimeInterface $startedAt, string $state): void
|
private function fileHash(string $path): ?string
|
||||||
|
{
|
||||||
|
// Re-read the filesystem after the scanner; files may change meanwhile.
|
||||||
|
clearstatcache(true, $path);
|
||||||
|
$hash = is_file($path) ? hash_file('sha256', $path) : false;
|
||||||
|
|
||||||
|
return is_string($hash) ? $hash : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @param array<string,mixed> $result */
|
||||||
|
private function record(\stdClass $document, array $result, \DateTimeInterface $startedAt, string $state): void
|
||||||
{
|
{
|
||||||
DB::transaction(function () use ($document, $result, $startedAt, $state): void {
|
DB::transaction(function () use ($document, $result, $startedAt, $state): void {
|
||||||
$locked = DB::table('documents')->where('id', $this->documentId)->lockForUpdate()->first();
|
$locked = DB::table('documents')->where('id', $this->documentId)->lockForUpdate()->first();
|
||||||
|
|||||||
@@ -2,7 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
/** @property string|null $lead_id */
|
use Carbon\CarbonImmutable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property string|null $lead_id
|
||||||
|
* @property CarbonImmutable|null $due_at
|
||||||
|
*/
|
||||||
class CrmTask extends CrmRecord
|
class CrmTask extends CrmRecord
|
||||||
{
|
{
|
||||||
protected $table = 'tasks';
|
protected $table = 'tasks';
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace App\Models;
|
|||||||
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/** @property array<string,mixed> $payload */
|
||||||
class InvestmentSubmission extends Model
|
class InvestmentSubmission extends Model
|
||||||
{
|
{
|
||||||
use HasUuids;
|
use HasUuids;
|
||||||
|
|||||||
@@ -5,6 +5,21 @@ namespace App\Models;
|
|||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property string $id
|
||||||
|
* @property string $code
|
||||||
|
* @property string $name
|
||||||
|
* @property ?string $primary_territory_id
|
||||||
|
* @property ?string $province
|
||||||
|
* @property ?string $district
|
||||||
|
* @property ?string $physical_category
|
||||||
|
* @property ?string $legal_regime
|
||||||
|
* @property ?string $development_status
|
||||||
|
* @property ?string $availability_status
|
||||||
|
* @property ?string $area_value
|
||||||
|
* @property ?string $area_unit
|
||||||
|
* @property array<int,array<string,mixed>>|null $source_evidence
|
||||||
|
*/
|
||||||
class InvestmentZone extends DomainRecord
|
class InvestmentZone extends DomainRecord
|
||||||
{
|
{
|
||||||
protected $casts = ['version_no' => 'integer', 'published_at' => 'datetime', 'aliases' => 'array', 'activities' => 'array', 'resources' => 'array', 'historical_territory' => 'array', 'area_components' => 'array', 'source_evidence' => 'array', 'area_value' => 'decimal:4', 'data_as_of' => 'date', 'sources_consulted_at' => 'date'];
|
protected $casts = ['version_no' => 'integer', 'published_at' => 'datetime', 'aliases' => 'array', 'activities' => 'array', 'resources' => 'array', 'historical_territory' => 'array', 'area_components' => 'array', 'source_evidence' => 'array', 'area_value' => 'decimal:4', 'data_as_of' => 'date', 'sources_consulted_at' => 'date'];
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ namespace App\Providers;
|
|||||||
use App\Models\Opportunity;
|
use App\Models\Opportunity;
|
||||||
use App\Models\Sector;
|
use App\Models\Sector;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Services\Mne\BusinessRepository;
|
|
||||||
use App\Services\Mne\CompatibleBusinessRepository;
|
|
||||||
use App\Services\Malware\ClamDScanner;
|
use App\Services\Malware\ClamDScanner;
|
||||||
use App\Services\Malware\MalwareScanner;
|
use App\Services\Malware\MalwareScanner;
|
||||||
|
use App\Services\Mne\BusinessRepository;
|
||||||
|
use App\Services\Mne\CompatibleBusinessRepository;
|
||||||
use Carbon\CarbonImmutable;
|
use Carbon\CarbonImmutable;
|
||||||
use Illuminate\Cache\RateLimiting\Limit;
|
use Illuminate\Cache\RateLimiting\Limit;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ final class EvidenceRepository
|
|||||||
if (! empty($filters['nature'])) {
|
if (! empty($filters['nature'])) {
|
||||||
$builder->where('s.nature', $filters['nature']);
|
$builder->where('s.nature', $filters['nature']);
|
||||||
}
|
}
|
||||||
|
if ($filters['public_only'] ?? false) {
|
||||||
|
$builder->where('d.data_classification', 'public')->where('d.rights_status', '!=', 'restricted')
|
||||||
|
->whereExists(fn ($q) => $q->selectRaw('1')->from('portal_resources as r')->whereColumn('r.document_id', 'd.id')->where('r.published', true)->where('r.rights_status', '!=', 'restricted'));
|
||||||
|
}
|
||||||
|
|
||||||
return array_values($builder->orderByDesc('rank')->orderBy('c.id')->limit((int) config('investmoz_ai.retrieval_limit', 5))
|
return array_values($builder->orderByDesc('rank')->orderBy('c.id')->limit((int) config('investmoz_ai.retrieval_limit', 5))
|
||||||
->get()->map(fn ($row) => (array) $row)->all());
|
->get()->map(fn ($row) => (array) $row)->all());
|
||||||
|
|||||||
@@ -0,0 +1,255 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Ai;
|
||||||
|
|
||||||
|
use App\Models\CrmTask;
|
||||||
|
use App\Models\InvestmentSubmission;
|
||||||
|
use App\Models\SimulationFormDraft;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Services\InvestmentGeography;
|
||||||
|
use App\Services\VirtualDesk;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
class InvestorGuidance
|
||||||
|
{
|
||||||
|
public function __construct(private VirtualDesk $desk, private InvestorGuidanceRules $rules) {}
|
||||||
|
|
||||||
|
public function installed(): bool
|
||||||
|
{
|
||||||
|
return Schema::hasColumn('tasks', 'desk_case_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Reads each linked module with its own owner rule; case membership does not grant access to a private simulator. */
|
||||||
|
/** @return array<string,mixed> */
|
||||||
|
public function context(User $actor, \stdClass $case): array
|
||||||
|
{
|
||||||
|
$base = $this->desk->decode($case->payload);
|
||||||
|
$facts = Arr::only($base['guidance']['assumptions'] ?? [], InvestorGuidanceRules::FIELDS);
|
||||||
|
$consulted = [];
|
||||||
|
$unavailable = [];
|
||||||
|
$financialDraft = null;
|
||||||
|
$checks = [];
|
||||||
|
$revision = ['case' => (int) $case->version];
|
||||||
|
$submission = $case->submission_id ? InvestmentSubmission::where('id', $case->submission_id)->where('user_id', $actor->id)->first() : null;
|
||||||
|
if ($submission) {
|
||||||
|
$input = $submission->payload;
|
||||||
|
$mapped = ['project_title' => $input['title'] ?? $case->title, 'project_summary' => $input['objective'] ?? '',
|
||||||
|
'activity' => $input['activity_description'] ?? '', 'schedule' => $input['schedule'] ?? ''];
|
||||||
|
$facts = [...$mapped, ...$facts];
|
||||||
|
$consulted[] = ['module' => 'investment_submission', 'id' => $submission->id, 'version' => $submission->version, 'date' => $submission->updated_at?->toIso8601String(), 'status' => 'investor_declaration'];
|
||||||
|
$revision['submission'] = $submission->version;
|
||||||
|
} elseif ($case->submission_id) {
|
||||||
|
$unavailable[] = 'investment_submission_permission_or_availability';
|
||||||
|
}
|
||||||
|
if ($case->simulation_id) {
|
||||||
|
$draft = SimulationFormDraft::where('id', $case->simulation_id)->where('owner_user_id', $actor->id)->whereNull('deleted_at')
|
||||||
|
->where(fn ($q) => $q->whereNull('expires_at')->orWhere('expires_at', '>', now()))->first();
|
||||||
|
if ($draft) {
|
||||||
|
$economic = SimulationFormDraft::decryptSnapshot($draft->economic_snapshot);
|
||||||
|
$mapped = Arr::only($economic, InvestorGuidanceRules::FIELDS);
|
||||||
|
$mapped['activity'] = $economic['selection_labels']['activity_id'] ?? $economic['products_services'] ?? '';
|
||||||
|
// A market assumption is not evidence of demand.
|
||||||
|
if (! empty($economic['market_source'])) {
|
||||||
|
$mapped['market_evidence'] = $economic['market_source'];
|
||||||
|
}
|
||||||
|
$mapped['location'] = $economic['selection_labels']['province_id'] ?? '';
|
||||||
|
$mapped['location_evidence'] = $economic['location_rationale'] ?? '';
|
||||||
|
if (! empty($economic['skills_needed'])) {
|
||||||
|
$mapped['resource_plan'] = $economic['skills_needed'];
|
||||||
|
}
|
||||||
|
$checks = $this->catalogueChecks($economic);
|
||||||
|
$facts = [...$mapped, ...$facts];
|
||||||
|
// Only economic fields needed by existing deterministic calculators, never personal_snapshot.
|
||||||
|
$financialDraft = Arr::only($economic, ['business_plan_snapshot', 'financial_tools_snapshot', 'currency']);
|
||||||
|
$consulted[] = ['module' => 'simulation_form_draft', 'id' => $draft->id, 'version' => $draft->version_no, 'hash' => $draft->snapshot_sha256,
|
||||||
|
'date' => $draft->updated_at?->toIso8601String(), 'status' => 'declared_assumptions_and_versioned_snapshots'];
|
||||||
|
$revision['simulation'] = [$draft->version_no, $draft->snapshot_sha256];
|
||||||
|
} else {
|
||||||
|
$unavailable[] = 'simulation_draft_permission_or_availability';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$facts['project_title'] = $facts['project_title'] ?? $case->title;
|
||||||
|
$evidence = app(InvestorGuidanceEvidence::class)->forCase($actor, $case, $this->desk);
|
||||||
|
$fingerprint = hash('sha256', json_encode([InvestorGuidanceRules::VERSION, $revision, Arr::sortRecursive($facts), $checks, $evidence], JSON_THROW_ON_ERROR));
|
||||||
|
|
||||||
|
return ['facts' => $facts, 'consulted' => $consulted, 'unavailable' => $unavailable, 'financial_draft' => $financialDraft, 'fingerprint' => $fingerprint, 'catalogue_checks' => $checks, 'evidence' => $evidence];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @param array<string,mixed> $economic
|
||||||
|
* @return list<array<string,mixed>> */
|
||||||
|
private function catalogueChecks(array $economic): array
|
||||||
|
{
|
||||||
|
$checks = [];
|
||||||
|
if (! empty($economic['activity_id'])) {
|
||||||
|
$activity = DB::table('economic_activities as a')->join('reference_catalog_versions as v', 'v.id', '=', 'a.catalog_version_id')
|
||||||
|
->where('a.id', $economic['activity_id'])->where('a.status', 'published')->where('v.status', 'published')
|
||||||
|
->whereDate('a.valid_from', '<=', today())->where(fn ($q) => $q->whereNull('a.valid_to')->orWhereDate('a.valid_to', '>', today()))
|
||||||
|
->first(['a.id', 'a.sector_id', 'a.catalog_version_id']);
|
||||||
|
$classification = ! $activity || empty($economic['sector_id']) ? 'insufficient_information'
|
||||||
|
: ((int) $activity->sector_id === (int) $economic['sector_id'] ? 'catalogue_consistent' : 'documented_incompatibility');
|
||||||
|
$checks[] = ['code' => 'activity_sector', 'classification' => $classification, 'restriction' => false,
|
||||||
|
'explanation' => match ($classification) {
|
||||||
|
'documented_incompatibility' => 'A actividade e o sector seleccionados não correspondem no catálogo publicado consultado.',
|
||||||
|
'catalogue_consistent' => 'Actividade e sector correspondem no catálogo consultado; isto não prova mercado ou elegibilidade.',
|
||||||
|
default => 'Sem referência actual autorizada suficiente para verificar actividade e sector.',
|
||||||
|
}, 'source' => $activity ? ['module' => 'economic_activities', 'id' => $activity->id, 'version_id' => $activity->catalog_version_id] : null];
|
||||||
|
}
|
||||||
|
$parents = ['district_id' => 'province_id', 'admin_post_id' => 'district_id', 'locality_id' => 'admin_post_id'];
|
||||||
|
foreach ($parents as $child => $parent) {
|
||||||
|
if (empty($economic[$child])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$location = app(InvestmentGeography::class)->publicReferences()->where('id', $economic[$child])->first(['id', 'parent_id']);
|
||||||
|
$classification = ! $location || empty($economic[$parent]) ? 'insufficient_information'
|
||||||
|
: ($location->parent_id === $economic[$parent] ? 'catalogue_consistent' : 'documented_incompatibility');
|
||||||
|
$checks[] = ['code' => 'territory_'.$child, 'classification' => $classification, 'restriction' => false,
|
||||||
|
'explanation' => match ($classification) {
|
||||||
|
'documented_incompatibility' => 'A hierarquia territorial declarada contradiz a referência publicada consultada.',
|
||||||
|
'catalogue_consistent' => 'Hierarquia territorial coerente na referência consultada; disponibilidade e infraestrutura continuam por confirmar.',
|
||||||
|
default => 'Referência territorial insuficiente ou indisponível para esta verificação.',
|
||||||
|
}, 'source' => $location ? ['module' => 'geo_locations', 'id' => $location->id, 'parent_id' => $location->parent_id] : null];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $checks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return array<string,mixed> */
|
||||||
|
public function view(User $actor, string $id): array
|
||||||
|
{
|
||||||
|
$case = $this->desk->case($actor, $id);
|
||||||
|
abort_unless($this->installed(), 503, 'A extensão do acompanhamento aguarda instalação autenticada.');
|
||||||
|
$context = $this->context($actor, $case);
|
||||||
|
$choices = [];
|
||||||
|
foreach (DB::table('desk_events')->where('case_id', $id)->where('action', 'recommendation_reviewed')->orderBy('event_order')->get() as $event) {
|
||||||
|
$data = $this->desk->decode($event->payload);
|
||||||
|
$choices[$data['code']] = [...$data, 'actor_id' => $event->actor_id, 'date' => $event->created_at, 'stale' => $data['context_hash'] !== $context['fingerprint']];
|
||||||
|
}
|
||||||
|
$actions = ['opportunities' => '/oportunidades', 'locations' => '/oportunidades?view=map', 'partners' => '/parcerias',
|
||||||
|
'documents' => '/documentos', 'plan' => $case->submission_id && (int) $case->user_id === $actor->id ? '/investidor/manifestacoes/'.$case->submission_id : '/balcao-virtual/dossiers/'.$id,
|
||||||
|
'simulator' => '/simulador-fiscal', 'support' => '/balcao-virtual/dossiers/'.$id];
|
||||||
|
// The simulator recovers its current owner-scoped draft; do not pass private payload in URLs.
|
||||||
|
if ($case->simulation_id && $context['financial_draft'] !== null) {
|
||||||
|
$actions['plan'] = '/simulador-fiscal';
|
||||||
|
}
|
||||||
|
$phases = $this->rules->evaluate($context['facts'], $context['evidence']);
|
||||||
|
foreach ($phases as &$phase) {
|
||||||
|
foreach ($phase['recommendations'] as &$recommendation) {
|
||||||
|
$recommendation['review'] = $choices[$recommendation['code']] ?? null;
|
||||||
|
$recommendation['href'] = $actions[$recommendation['action']];
|
||||||
|
}
|
||||||
|
unset($recommendation);
|
||||||
|
}
|
||||||
|
unset($phase);
|
||||||
|
$tasks = DB::table('tasks as t')->leftJoin('users as u', 'u.id', '=', 't.assignee_user_id')->where('t.desk_case_id', $id)->whereNull('t.deleted_at')
|
||||||
|
->when(! $this->desk->owns($actor, $case, false) && ! $actor->can('manage-portal'), fn ($q) => $q->where('t.assignee_user_id', $actor->id))
|
||||||
|
->get(['t.id', 't.title', 't.status', 't.due_at', 't.version_no', 't.desk_request_id', 't.accepted_by', 't.accepted_at', 't.assignee_user_id', 'u.name as assignee_name', 't.external_sync_status']);
|
||||||
|
|
||||||
|
return ['version' => $case->version, 'rules_version' => InvestorGuidanceRules::VERSION, 'computed_at' => now()->toIso8601String(),
|
||||||
|
...$context, 'phases' => $phases, 'tasks' => $tasks, 'actions' => $actions, 'can_write' => $this->desk->owns($actor, $case),
|
||||||
|
'external_ai' => ['status' => 'not_configured', 'model' => null, 'consulted' => []],
|
||||||
|
'calculator_versions' => ['business_financial_plan' => hash_file('sha256', resource_path('js/lib/business-financial-plan.ts')), 'financial_calculators' => hash_file('sha256', resource_path('js/lib/financial-calculators.ts')), 'project_dossier' => hash_file('sha256', resource_path('js/lib/project-dossier.ts'))],
|
||||||
|
'crm' => ['internal' => 'available', 'external' => 'out_of_scope', 'reason' => 'O acompanhamento usa o CRM interno existente. A sincronização externa está fora desta fase; nenhum contacto, mensagem ou documento é transmitido.']];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @param array<string,mixed> $input */
|
||||||
|
public function assumptions(User $actor, string $id, array $input): void
|
||||||
|
{
|
||||||
|
$rules = ['version' => 'required|integer|min:1', 'assumptions' => ['required', 'array:'.implode(',', InvestorGuidanceRules::FIELDS)]];
|
||||||
|
foreach (InvestorGuidanceRules::FIELDS as $field) {
|
||||||
|
$rules['assumptions.'.$field] = in_array($field, ['expected_start_date', 'ready_date', 'funding_ready_date', 'completion_date'], true) ? 'nullable|date_format:Y-m-d' : 'nullable|string|max:3000';
|
||||||
|
}
|
||||||
|
$data = Validator::make($input, $rules)->validate();
|
||||||
|
DB::transaction(function () use ($actor, $id, $data) {
|
||||||
|
$case = $this->desk->case($actor, $id, true, true);
|
||||||
|
abort_if($case->closed_at, 409);
|
||||||
|
abort_unless((int) $case->version === (int) $data['version'], 409, 'Dossier alterado; recarregue antes de corrigir.');
|
||||||
|
$base = $this->desk->decode($case->payload);
|
||||||
|
$base['guidance']['assumptions'] = $data['assumptions'];
|
||||||
|
DB::table('desk_cases')->where('id', $id)->update(['payload' => $this->desk->encode($base), 'version' => $case->version + 1, 'updated_at' => now()]);
|
||||||
|
$this->desk->event(DB::table('desk_cases')->where('id', $id)->first(), $actor, 'assumptions_corrected', ['assumptions' => $data['assumptions'], 'origin' => 'investor_correction_not_official_data']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @param array<string,mixed> $input */
|
||||||
|
public function feedback(User $actor, string $id, array $input): void
|
||||||
|
{
|
||||||
|
$data = Validator::make($input, ['code' => 'required|string|max:100', 'context_hash' => 'required|string|size:64',
|
||||||
|
'decision' => ['required', Rule::in(['accepted', 'rejected', 'corrected'])], 'reason' => 'required|string|min:3|max:3000'])->validate();
|
||||||
|
DB::transaction(function () use ($actor, $id, $data) {
|
||||||
|
$case = $this->desk->case($actor, $id, true, true);
|
||||||
|
abort_if($case->closed_at, 409);
|
||||||
|
$view = $this->view($actor, $id);
|
||||||
|
abort_unless(hash_equals($view['fingerprint'], $data['context_hash']), 409, 'Pressupostos alterados; reveja a recomendação actual.');
|
||||||
|
$recommendations = array_merge(...array_column($view['phases'], 'recommendations'));
|
||||||
|
abort_unless(in_array($data['code'], array_column($recommendations, 'code'), true), 422);
|
||||||
|
$this->desk->event($case, $actor, 'recommendation_reviewed', [...$data, 'rules_version' => InvestorGuidanceRules::VERSION, 'creates_task' => false]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @param array<string,mixed> $input */
|
||||||
|
public function acceptTask(User $actor, string $id, array $input): CrmTask
|
||||||
|
{
|
||||||
|
$data = Validator::make($input, ['code' => 'required|string|max:100', 'context_hash' => 'required|string|size:64', 'consent' => 'accepted',
|
||||||
|
'due_at' => 'required|date|after:now', 'request_id' => 'nullable|uuid'])->validate();
|
||||||
|
|
||||||
|
return DB::transaction(function () use ($actor, $id, $data) {
|
||||||
|
$case = $this->desk->case($actor, $id, true, true);
|
||||||
|
abort_if($case->closed_at, 409);
|
||||||
|
$view = $this->view($actor, $id);
|
||||||
|
abort_unless(hash_equals($view['fingerprint'], $data['context_hash']), 409);
|
||||||
|
$recommendations = array_merge(...array_column($view['phases'], 'recommendations'));
|
||||||
|
$suggestion = collect($recommendations)->firstWhere('code', $data['code']);
|
||||||
|
abort_unless($suggestion && ($suggestion['review']['decision'] ?? null) === 'accepted' && ! $suggestion['review']['stale'], 422, 'Aceite a recomendação actual antes de assumir a tarefa.');
|
||||||
|
if ($data['request_id'] ?? null) {
|
||||||
|
$request = $this->desk->request($actor, $data['request_id'], true);
|
||||||
|
abort_unless($request->case_id === $id, 422);
|
||||||
|
}
|
||||||
|
// One accepted action per suggestion, even after corrections or retries.
|
||||||
|
$existing = CrmTask::where('desk_case_id', $id)->where('guidance_key', $data['code'])->first();
|
||||||
|
if ($existing) {
|
||||||
|
abort_unless($existing->getAttribute('desk_request_id') === ($data['request_id'] ?? null)
|
||||||
|
&& (int) $existing->getAttribute('accepted_by') === $actor->id && $existing->due_at !== null && $existing->due_at->equalTo(Carbon::parse($data['due_at'])), 409, 'A tarefa já foi assumida com outros dados; reveja o registo existente.');
|
||||||
|
|
||||||
|
return $existing;
|
||||||
|
}
|
||||||
|
$task = CrmTask::create(['desk_case_id' => $id, 'desk_request_id' => $data['request_id'] ?? null, 'guidance_key' => $data['code'],
|
||||||
|
'title' => $suggestion['explanation'], 'status' => 'open', 'due_at' => $data['due_at'], 'assignee_user_id' => $actor->id,
|
||||||
|
'accepted_by' => $actor->id, 'accepted_at' => now(), 'external_sync_status' => 'pending_authorization',
|
||||||
|
'source_system' => 'investor-guidance', 'data_classification' => 'confidential']);
|
||||||
|
$this->desk->event($case, $actor, 'guidance_task_accepted', ['task_id' => $task->id, 'code' => $data['code'], 'context_hash' => $data['context_hash'], 'due_at' => $data['due_at'], 'scope' => 'internal_crm']);
|
||||||
|
|
||||||
|
return $task;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @param array<string,mixed> $input */
|
||||||
|
public function updateTask(User $actor, string $id, string $taskId, array $input): void
|
||||||
|
{
|
||||||
|
$data = Validator::make($input, ['version' => 'required|integer|min:1', 'status' => ['required', Rule::in(['open', 'in_progress', 'done', 'cancelled'])],
|
||||||
|
'reason' => 'required|string|min:3|max:3000', 'assignee_user_id' => 'nullable|integer|exists:users,id', 'due_at' => 'nullable|date|after:now'])->validate();
|
||||||
|
DB::transaction(function () use ($actor, $id, $taskId, $data) {
|
||||||
|
$case = $this->desk->case($actor, $id);
|
||||||
|
$task = CrmTask::where('desk_case_id', $id)->whereKey($taskId)->lockForUpdate()->firstOrFail();
|
||||||
|
abort_unless($actor->can('manage-portal') || (int) $task->getAttribute('assignee_user_id') === $actor->id, 403);
|
||||||
|
abort_unless((int) $task->getAttribute('version_no') === (int) $data['version'], 409);
|
||||||
|
$updates = ['status' => $data['status'], 'version_no' => $data['version'] + 1];
|
||||||
|
if ($data['assignee_user_id'] ?? null) {
|
||||||
|
abort_unless($actor->can('manage-portal'), 403);
|
||||||
|
$assignee = User::where('id', $data['assignee_user_id'])->firstOrFail();
|
||||||
|
abort_unless($assignee->hasVerifiedEmail(), 422, 'Responsável sem conta verificada.');
|
||||||
|
abort_unless($assignee->can('manage-portal') || DB::table('desk_requests')->where('case_id', $id)->where('analyst_id', $assignee->id)->exists() || $this->desk->owns($assignee, $case), 422, 'Responsável sem acesso ao dossier.');
|
||||||
|
$updates['assignee_user_id'] = $assignee->id;
|
||||||
|
}
|
||||||
|
if ($data['due_at'] ?? null) {
|
||||||
|
$updates['due_at'] = $data['due_at'];
|
||||||
|
}
|
||||||
|
$task->update($updates);
|
||||||
|
$this->desk->event($case, $actor, 'guidance_task_updated', ['task_id' => $task->id, ...$data, 'kind' => $actor->can('manage-portal') ? 'responsible_response' : 'investor_action']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Ai;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Services\VirtualDesk;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class InvestorGuidanceEvidence
|
||||||
|
{
|
||||||
|
public const FIELDS = ['market_evidence', 'location_evidence', 'resource_evidence', 'funding_evidence'];
|
||||||
|
|
||||||
|
/** @return array<string,array<string,mixed>> */
|
||||||
|
public function forCase(User $actor, \stdClass $case, VirtualDesk $desk): array
|
||||||
|
{
|
||||||
|
$privateScope = ! $desk->owns($actor, $case, false) && ! $actor->can('manage-portal');
|
||||||
|
$documents = DB::table('desk_documents as l')->join('documents as d', 'd.id', '=', 'l.document_id')->where('l.case_id', $case->id)->whereNull('d.deleted_at')
|
||||||
|
->when($privateScope, fn ($q) => $q->where(fn ($p) => $p->whereNull('l.request_id')->orWhereIn('l.request_id', DB::table('desk_requests')->where('analyst_id', $actor->id)->select('id'))))
|
||||||
|
->get(['l.id as link_id', 'l.document_id', 'l.category', 'l.valid_until', 'd.file_name', 'd.version_no', 'd.sha256', 'd.status', 'd.malware_scan_status', 'd.malware_scanned_sha256', 'd.storage_key']);
|
||||||
|
$reviews = DB::table('desk_events as e')->join('users as u', 'u.id', '=', 'e.actor_id')->where('e.case_id', $case->id)->where('e.action', 'document_reviewed')
|
||||||
|
->when($privateScope, fn ($q) => $q->where(fn ($p) => $p->whereNull('e.request_id')->orWhereIn('e.request_id', DB::table('desk_requests')->where('analyst_id', $actor->id)->select('id'))))
|
||||||
|
->orderByDesc('e.event_order')->get(['e.id', 'e.payload', 'e.created_at', 'e.actor_id', 'u.name']);
|
||||||
|
$result = [];
|
||||||
|
foreach (self::FIELDS as $field) {
|
||||||
|
$records = [];
|
||||||
|
foreach ($documents as $doc) {
|
||||||
|
$latest = null;
|
||||||
|
foreach ($reviews as $review) {
|
||||||
|
$payload = $desk->decode($review->payload);
|
||||||
|
if (($payload['link_id'] ?? null) === $doc->link_id) {
|
||||||
|
$latest = ['id' => $review->id, 'author_id' => $review->actor_id, 'author' => $review->name, 'date' => $review->created_at, 'payload' => $payload];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($doc->category !== $field && ! ($latest && in_array($field, $latest['payload']['supports'] ?? [], true))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// A later review replaces the earlier scope. Merely choosing a
|
||||||
|
// document category does not verify a preparation assumption.
|
||||||
|
if ($latest && ! in_array($field, $latest['payload']['supports'] ?? [], true)) {
|
||||||
|
$latest = null;
|
||||||
|
}
|
||||||
|
$state = 'attached_unchecked';
|
||||||
|
if ($doc->valid_until && $doc->valid_until < now()->toDateString()) {
|
||||||
|
$state = 'expired';
|
||||||
|
} elseif ($latest && (($latest['payload']['sha256'] ?? null) !== trim($doc->sha256) || ($latest['payload']['document_version'] ?? null) !== (int) $doc->version_no)) {
|
||||||
|
$state = 'superseded';
|
||||||
|
} elseif ($latest) {
|
||||||
|
$path = realpath(Storage::disk('local')->path($doc->storage_key));
|
||||||
|
$root = realpath(Storage::disk('local')->path(''));
|
||||||
|
if (! $path || ! $root || ! str_starts_with($path, $root.DIRECTORY_SEPARATOR) || ! is_file($path) || ! is_string($hash = hash_file('sha256', $path)) || ! hash_equals(trim($doc->sha256), $hash)) {
|
||||||
|
$state = 'superseded';
|
||||||
|
} elseif ($doc->status !== 'active' || $doc->malware_scan_status !== 'clean' || trim($doc->sha256) !== $doc->malware_scanned_sha256) {
|
||||||
|
$state = 'technical_unavailable';
|
||||||
|
} else {
|
||||||
|
$state = match ($latest['payload']['outcome'] ?? '') {
|
||||||
|
'internal_verified' => 'internally_verified',
|
||||||
|
'contradiction_identified' => 'contradiction',
|
||||||
|
default => 'issue_identified',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$records[] = ['document_id' => $doc->document_id, 'link_id' => $doc->link_id, 'name' => $doc->file_name, 'state' => $state, 'version' => (int) $doc->version_no, 'hash' => trim($doc->sha256), 'valid_until' => $doc->valid_until,
|
||||||
|
'review' => $latest ? ['event_id' => $latest['id'], 'author_id' => $latest['author_id'], 'author' => $latest['author'], 'date' => $latest['date'], 'what_checked' => $latest['payload']['what_checked'], 'evidence' => $latest['payload']['evidence'], 'scope' => $latest['payload']['scope']] : null];
|
||||||
|
}
|
||||||
|
if ($records) {
|
||||||
|
// A specific current contradiction takes precedence; other valid evidence
|
||||||
|
// remains visible instead of erasing expired or replaced originals.
|
||||||
|
$states = array_column($records, 'state');
|
||||||
|
$state = 'attached_unchecked';
|
||||||
|
foreach (['contradiction', 'internally_verified', 'issue_identified', 'superseded', 'expired', 'technical_unavailable'] as $candidate) {
|
||||||
|
if (in_array($candidate, $states, true)) {
|
||||||
|
$state = $candidate;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$result[$field] = ['state' => $state, 'documents' => $records];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Ai;
|
||||||
|
|
||||||
|
/** Internal preparation rules; never calculate tax, returns or eligibility. */
|
||||||
|
class InvestorGuidanceRules
|
||||||
|
{
|
||||||
|
public const VERSION = 'investor-guidance-2026-10-08-v3';
|
||||||
|
|
||||||
|
public const FIELDS = ['project_title', 'project_summary', 'activity', 'target_customers', 'market_evidence', 'location',
|
||||||
|
'location_evidence', 'resource_plan', 'resource_evidence', 'funding_evidence', 'expected_start_date', 'ready_date', 'schedule',
|
||||||
|
'demand_quantity', 'capacity_quantity', 'quantity_unit', 'quantity_period', 'resources_required', 'resources_available', 'resource_unit',
|
||||||
|
'funding_required', 'funding_committed', 'funding_currency', 'funding_ready_date', 'completion_date'];
|
||||||
|
|
||||||
|
/** @param array<string,mixed> $facts
|
||||||
|
* @param array<string,array<string,mixed>> $evidence
|
||||||
|
* @return list<array<string,mixed>> */
|
||||||
|
public function evaluate(array $facts, array $evidence = []): array
|
||||||
|
{
|
||||||
|
$phases = [
|
||||||
|
'idea' => ['Definir a actividade e o objectivo', ['project_title', 'project_summary', 'activity'], 'Confirme o que pretende produzir ou prestar.', 'plan'],
|
||||||
|
'market' => ['Documentar clientes e hipóteses de mercado', ['target_customers', 'market_evidence'], 'Reúna evidência de clientes; uma hipótese não demonstra procura.', 'opportunities'],
|
||||||
|
'location' => ['Comparar locais e requisitos da actividade', ['location', 'location_evidence'], 'Confirme terreno, acesso, infraestrutura e licenciamento para cada alternativa.', 'locations'],
|
||||||
|
'resources' => ['Preparar recursos e equipa', ['resource_plan', 'resource_evidence'], 'Distinga recursos declarados de disponibilidade comprovada.', 'partners'],
|
||||||
|
'finance' => ['Explorar financiamento e cenários', ['funding_evidence'], 'Reveja os pressupostos e os cenários no simulador determinístico.', 'simulator'],
|
||||||
|
'execution' => ['Reconciliar calendário e dependências', ['expected_start_date', 'ready_date', 'schedule'], 'Confirme datas, dependências e responsáveis antes de assumir marcos.', 'plan'],
|
||||||
|
'support' => ['Preparar o pedido e acompanhar a resposta', [], 'Prepare um rascunho no Balcão; reveja e submeta pessoalmente.', 'support'],
|
||||||
|
];
|
||||||
|
$result = [];
|
||||||
|
foreach ($phases as $code => [$objective, $fields, $explanation, $action]) {
|
||||||
|
$known = [];
|
||||||
|
$unknown = [];
|
||||||
|
$phaseEvidence = [];
|
||||||
|
$risks = [];
|
||||||
|
foreach ($fields as $field) {
|
||||||
|
$value = trim((string) ($facts[$field] ?? ''));
|
||||||
|
$record = $evidence[$field] ?? null;
|
||||||
|
$state = $record['state'] ?? ($value !== '' ? 'investor_declared_not_verified' : 'absent');
|
||||||
|
if (in_array($field, InvestorGuidanceEvidence::FIELDS, true)) {
|
||||||
|
$phaseEvidence[] = ['field' => $field, 'state' => $state, 'documents' => $record['documents'] ?? []];
|
||||||
|
if ($state !== 'internally_verified') {
|
||||||
|
$message = match ($state) {
|
||||||
|
'absent' => 'Ainda não existe informação ou documento para este pressuposto.',
|
||||||
|
'investor_declared_not_verified' => 'A declaração do investidor ainda não foi conferida.',
|
||||||
|
'attached_unchecked' => 'Existe um documento associado, sem conferência interna deste pressuposto.',
|
||||||
|
'expired' => 'A validade documental registada terminou; actualize a evidência.',
|
||||||
|
'superseded' => 'O ficheiro ou a versão mudou depois da conferência; é necessária nova análise.',
|
||||||
|
'contradiction' => 'Uma conferência interna identificou contradição no âmbito descrito.',
|
||||||
|
'issue_identified' => 'Uma conferência interna identificou um problema no âmbito descrito.',
|
||||||
|
default => 'A evidência não está disponível para utilização; consulte o motivo documental.',
|
||||||
|
};
|
||||||
|
$risks[] = ['code' => $field.'_'.$state, 'classification' => $state === 'contradiction' ? 'documented_contradiction' : 'insufficient_information', 'explanation' => $message, 'field' => $field, 'restriction' => false];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($value !== '') {
|
||||||
|
$known[] = ['field' => $field, 'value' => $value, 'status' => 'investor_declared_not_verified'];
|
||||||
|
} elseif (! $record) {
|
||||||
|
$unknown[] = $field;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$result[] = ['id' => $code, 'objective' => $objective, 'known' => $known, 'questions' => $unknown,
|
||||||
|
'recommendations' => [[
|
||||||
|
'code' => $code.'_preparation', 'kind' => 'automatic_recommendation', 'classification' => $unknown ? 'insufficient_information' : 'verification_required',
|
||||||
|
'explanation' => $explanation, 'action' => $action, 'assumptions' => $known,
|
||||||
|
'source' => ['identifier' => self::VERSION, 'reference' => 'app/Services/Ai/InvestorGuidanceRules.php#'.$code, 'date' => '2026-10-08', 'nature' => 'internal_preparation_rule'],
|
||||||
|
'limitations' => ['Uma conferência interna só sustenta o âmbito descrito pelo verificador; não aprova procura, infraestrutura, financiamento, registo ou licença institucional.', 'Sem previsão de sucesso, taxa fiscal ou elegibilidade inferida.'],
|
||||||
|
]], 'evidence' => $phaseEvidence, 'risks' => $risks];
|
||||||
|
}
|
||||||
|
if (($facts['expected_start_date'] ?? '') && ($facts['ready_date'] ?? '') && $facts['expected_start_date'] < $facts['ready_date']) {
|
||||||
|
$result[5]['risks'][] = ['code' => 'schedule_contradiction', 'classification' => 'declared_contradiction',
|
||||||
|
'explanation' => 'O início indicado antecede a disponibilidade declarada dos recursos.', 'basis' => ['expected_start_date' => $facts['expected_start_date'], 'ready_date' => $facts['ready_date']],
|
||||||
|
'restriction' => false];
|
||||||
|
}
|
||||||
|
$result[4]['risks'][] = ['code' => 'tax_eligibility_not_inferred', 'classification' => 'insufficient_information', 'explanation' => 'A evidência do financiamento não determina taxas fiscais ou elegibilidade. Consulte os pressupostos, fontes e versões no simulador.', 'restriction' => false];
|
||||||
|
foreach ([
|
||||||
|
[1, 'demand_quantity', 'capacity_quantity', ['quantity_unit', 'quantity_period'], 'A procura declarada excede a capacidade declarada para a mesma unidade e período.'],
|
||||||
|
[3, 'resources_required', 'resources_available', ['resource_unit'], 'Os recursos disponíveis declarados são inferiores aos necessários declarados.'],
|
||||||
|
[4, 'funding_required', 'funding_committed', ['funding_currency'], 'O financiamento comprometido declarado é inferior ao necessário declarado na mesma moeda.'],
|
||||||
|
] as [$phase, $required, $available, $scope, $explanation]) {
|
||||||
|
$values = array_intersect_key($facts, array_flip([$required, $available, ...$scope]));
|
||||||
|
if (! array_filter($values, fn ($value) => $value !== null && $value !== '')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$complete = true;
|
||||||
|
foreach ([$required, $available, ...$scope] as $field) {
|
||||||
|
if (! isset($facts[$field]) || trim((string) $facts[$field]) === '') {
|
||||||
|
$complete = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Compare declared magnitudes only: this is no forecast, valuation or financial calculation.
|
||||||
|
$left = $facts[$required] ?? null;
|
||||||
|
$right = $facts[$available] ?? null;
|
||||||
|
$valid = is_scalar($left) && is_scalar($right)
|
||||||
|
&& preg_match('/^\d{1,12}(\.\d{1,2})?$/', (string) $left)
|
||||||
|
&& preg_match('/^\d{1,12}(\.\d{1,2})?$/', (string) $right);
|
||||||
|
if (! $complete || ! $valid) {
|
||||||
|
$result[$phase]['risks'][] = ['code' => $required.'_comparison_incomplete', 'classification' => 'insufficient_information',
|
||||||
|
'explanation' => 'Faltam valores comparáveis, unidade, período ou moeda para esta comparação.', 'basis' => $values, 'restriction' => false];
|
||||||
|
} elseif ($this->declaredMagnitude((string) $left) > $this->declaredMagnitude((string) $right)) {
|
||||||
|
$result[$phase]['risks'][] = ['code' => $required.'_declared_gap', 'classification' => 'declared_contradiction',
|
||||||
|
'explanation' => $explanation.' Estes valores são declarações, não disponibilidade comprovada.', 'basis' => $values, 'restriction' => false];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ([['completion_date', 'expected_start_date', 'A conclusão declarada antecede o início.'],
|
||||||
|
['expected_start_date', 'funding_ready_date', 'O início declarado antecede a disponibilidade declarada do financiamento.']] as [$first, $second, $explanation]) {
|
||||||
|
if (! empty($facts[$first]) && ! empty($facts[$second]) && $facts[$first] < $facts[$second]) {
|
||||||
|
$result[5]['risks'][] = ['code' => $first.'_'.$second.'_contradiction', 'classification' => 'declared_contradiction',
|
||||||
|
'explanation' => $explanation, 'basis' => [$first => $facts[$first], $second => $facts[$second]], 'restriction' => false];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function declaredMagnitude(string $value): int
|
||||||
|
{
|
||||||
|
$parts = explode('.', $value);
|
||||||
|
|
||||||
|
return (int) $parts[0] * 100 + (int) str_pad($parts[1] ?? '', 2, '0');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
|
/** Availability evidence is distinct from legal validity or institutional endorsement. */
|
||||||
|
class InstitutionalLinkMonitor
|
||||||
|
{
|
||||||
|
/** @return array{available:bool,reason:string,contact:string} */
|
||||||
|
public function status(\stdClass $link): array
|
||||||
|
{
|
||||||
|
$valid = filter_var($link->url, FILTER_VALIDATE_URL) && parse_url($link->url, PHP_URL_SCHEME) === 'https';
|
||||||
|
$fresh = $link->verified_at && Carbon::parse($link->verified_at)->between(now()->subDays(7), now());
|
||||||
|
|
||||||
|
return ['available' => (bool) ($valid && $fresh && $link->status === 'active'),
|
||||||
|
'reason' => ! $valid ? 'invalid_url' : (! $fresh ? 'verification_missing_or_expired' : ($link->status === 'active' ? 'recent_internal_check' : 'reported_unavailable')),
|
||||||
|
'contact' => $link->contact ?: (config('portal.support.email') ?: 'Utilize o pedido de apoio no mesmo dossier.')];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -52,7 +52,8 @@ class InvestmentZones
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param array<string, mixed> $filters */
|
/** @param array<string, mixed> $filters
|
||||||
|
* @return Builder<InvestmentZone> */
|
||||||
public function search(array $filters, bool $management = false): Builder
|
public function search(array $filters, bool $management = false): Builder
|
||||||
{
|
{
|
||||||
$query = $management ? InvestmentZone::query() : $this->visible();
|
$query = $management ? InvestmentZone::query() : $this->visible();
|
||||||
@@ -118,7 +119,7 @@ class InvestmentZones
|
|||||||
$zone = InvestmentZone::whereKey($id)->lockForUpdate()->firstOrFail();
|
$zone = InvestmentZone::whereKey($id)->lockForUpdate()->firstOrFail();
|
||||||
abort_if((int) $zone->version_no !== $version, 409, 'Versão alterada. Recarregue antes de aprovar.');
|
abort_if((int) $zone->version_no !== $version, 409, 'Versão alterada. Recarregue antes de aprovar.');
|
||||||
$source = DB::table('investment_legal_sources')->where('id', $zone->legal_source_id)->lockForUpdate()->first();
|
$source = DB::table('investment_legal_sources')->where('id', $zone->legal_source_id)->lockForUpdate()->first();
|
||||||
$evidence = is_array($zone->source_evidence) ? $zone->source_evidence : [];
|
$evidence = $zone->source_evidence ?? [];
|
||||||
$officialEvidence = collect($evidence)->contains(fn ($item) => in_array($item['source_type'] ?? null, ['government', 'institutional'], true)
|
$officialEvidence = collect($evidence)->contains(fn ($item) => in_array($item['source_type'] ?? null, ['government', 'institutional'], true)
|
||||||
&& str_starts_with((string) ($item['url'] ?? ''), 'https://') && trim((string) ($item['supports'] ?? '')) !== '');
|
&& str_starts_with((string) ($item['url'] ?? ''), 'https://') && trim((string) ($item['supports'] ?? '')) !== '');
|
||||||
$promoterEvidence = $zone->category === 'industrial_park' && collect($evidence)->contains(fn ($item) => ($item['source_type'] ?? null) === 'promoter'
|
$promoterEvidence = $zone->category === 'industrial_park' && collect($evidence)->contains(fn ($item) => ($item['source_type'] ?? null) === 'promoter'
|
||||||
@@ -166,7 +167,7 @@ class InvestmentZones
|
|||||||
{
|
{
|
||||||
return DB::transaction(function () use ($id, $version, $actor) {
|
return DB::transaction(function () use ($id, $version, $actor) {
|
||||||
$location = DB::table('investment_zone_locations')->where('id', $id)->lockForUpdate()->first();
|
$location = DB::table('investment_zone_locations')->where('id', $id)->lockForUpdate()->first();
|
||||||
abort_unless($location, 404);
|
abort_unless($location !== null, 404);
|
||||||
abort_if((int) $location->version_no !== $version, 409, 'Version changed.');
|
abort_if((int) $location->version_no !== $version, 409, 'Version changed.');
|
||||||
abort_if((int) $location->editor_id === $actor, 403, 'Independent review required.');
|
abort_if((int) $location->editor_id === $actor, 403, 'Independent review required.');
|
||||||
abort_unless($location->validation_status === 'pending', 422, 'Territorial association already reviewed.');
|
abort_unless($location->validation_status === 'pending', 422, 'Territorial association already reviewed.');
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ final class ArchiveLimitInspector
|
|||||||
$expandedBytes = 0;
|
$expandedBytes = 0;
|
||||||
for ($index = 0; $index < $archive->numFiles; $index++) {
|
for ($index = 0; $index < $archive->numFiles; $index++) {
|
||||||
$entry = $archive->statIndex($index);
|
$entry = $archive->statIndex($index);
|
||||||
if (! is_array($entry) || ! isset($entry['size']) || ! is_int($entry['size']) || $entry['size'] < 0) {
|
if (! is_array($entry) || $entry['size'] < 0) {
|
||||||
return 'archive_inspection_failed';
|
return 'archive_inspection_failed';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ final class ClamDScanner implements MalwareScanner
|
|||||||
}
|
}
|
||||||
$offset += $written;
|
$offset += $written;
|
||||||
$meta = stream_get_meta_data($socket);
|
$meta = stream_get_meta_data($socket);
|
||||||
if ($meta['timed_out'] ?? false) {
|
if ($meta['timed_out']) {
|
||||||
throw new RuntimeException('ClamD scan timed out while sending data.');
|
throw new RuntimeException('ClamD scan timed out while sending data.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -208,19 +208,21 @@ final class ClamDScanner implements MalwareScanner
|
|||||||
{
|
{
|
||||||
$reply = stream_get_line($socket, 65536, "\0");
|
$reply = stream_get_line($socket, 65536, "\0");
|
||||||
$meta = stream_get_meta_data($socket);
|
$meta = stream_get_meta_data($socket);
|
||||||
if ($reply === false || ($meta['timed_out'] ?? false)) {
|
if ($reply === false || $meta['timed_out']) {
|
||||||
throw new RuntimeException(($meta['timed_out'] ?? false) ? 'ClamD scan timed out.' : 'ClamD returned no scan result.');
|
throw new RuntimeException($meta['timed_out'] ? 'ClamD scan timed out.' : 'ClamD returned no scan result.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return trim($reply);
|
return trim($reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return array{available:bool,engine:string,engine_version:?string,signatures_at:?DateTimeImmutable,signature_age_hours:?float,reason_code:?string} */
|
||||||
private function unavailable(string $reason): array
|
private function unavailable(string $reason): array
|
||||||
{
|
{
|
||||||
return ['available' => false, 'engine' => 'ClamAV', 'engine_version' => null, 'signatures_at' => null,
|
return ['available' => false, 'engine' => 'ClamAV', 'engine_version' => null, 'signatures_at' => null,
|
||||||
'signature_age_hours' => null, 'reason_code' => $reason];
|
'signature_age_hours' => null, 'reason_code' => $reason];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return array{result:string,reason_code:?string,engine:string,engine_version:string,signatures_at:?DateTimeImmutable,duration_ms:int,detail:?string} */
|
||||||
private function result(string $result, ?string $reason, int $startedAt, ?string $detail): array
|
private function result(string $result, ?string $reason, int $startedAt, ?string $detail): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ namespace App\Services\Malware;
|
|||||||
|
|
||||||
interface MalwareScanner
|
interface MalwareScanner
|
||||||
{
|
{
|
||||||
/** @return array{result:string,reason_code:?string,engine:string,engine_version:string,signatures_at:\DateTimeImmutable,duration_ms:int,detail:?string} */
|
/** @return array{result:string,reason_code:?string,engine:string,engine_version:string,signatures_at:?\DateTimeImmutable,duration_ms:int,detail:?string} */
|
||||||
public function scan(string $path, int $fileSizeBytes, string $storageRoot): array;
|
public function scan(string $path, int $fileSizeBytes, string $storageRoot): array;
|
||||||
|
|
||||||
/** @return array{available:bool,engine:string,engine_version:?string,signatures_at:?\DateTimeImmutable,signature_age_hours:?float,reason_code:?string} */
|
/** @return array{available:bool,engine:string,engine_version:?string,signatures_at:?\DateTimeImmutable,signature_age_hours:?float,reason_code:?string} */
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use App\Models\SimulationFormDraft;
|
|
||||||
use App\Models\ExistingBusiness;
|
use App\Models\ExistingBusiness;
|
||||||
|
use App\Models\SimulationFormDraft;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Services\Mne\BusinessRepository;
|
use App\Services\Mne\BusinessRepository;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
@@ -164,6 +164,7 @@ final class SimulationFormDrafts
|
|||||||
|
|
||||||
return DB::transaction(function () use ($actorId, $tokenHash): ?SimulationFormDraft {
|
return DB::transaction(function () use ($actorId, $tokenHash): ?SimulationFormDraft {
|
||||||
$this->setContext($actorId, $tokenHash);
|
$this->setContext($actorId, $tokenHash);
|
||||||
|
|
||||||
return $this->ownedQuery($actorId, $tokenHash)->orderByDesc('updated_at')->first();
|
return $this->ownedQuery($actorId, $tokenHash)->orderByDesc('updated_at')->first();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+214
-58
@@ -2,26 +2,33 @@
|
|||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
|
use App\Models\InvestmentSubmission;
|
||||||
|
use App\Models\Investor;
|
||||||
|
use App\Models\InvestorJourney;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Facades\Crypt;
|
use Illuminate\Support\Facades\Crypt;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
|
|
||||||
class VirtualDesk
|
class VirtualDesk
|
||||||
{
|
{
|
||||||
public function installed(): bool
|
public function installed(): bool
|
||||||
{
|
{
|
||||||
return \Illuminate\Support\Facades\Schema::hasTable('desk_cases');
|
return Schema::hasTable('desk_cases') && Schema::hasColumn('desk_events', 'event_order') && Schema::hasColumn('tasks', 'desk_case_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @param array<string,mixed> $data */
|
||||||
public function encode(array $data): string
|
public function encode(array $data): string
|
||||||
{
|
{
|
||||||
return Crypt::encryptString(json_encode($data, JSON_THROW_ON_ERROR));
|
return Crypt::encryptString(json_encode($data, JSON_THROW_ON_ERROR));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return array<string,mixed> */
|
||||||
public function decode(?string $data): array
|
public function decode(?string $data): array
|
||||||
{
|
{
|
||||||
return $data ? json_decode(Crypt::decryptString($data), true, 512, JSON_THROW_ON_ERROR) : [];
|
return $data ? json_decode(Crypt::decryptString($data), true, 512, JSON_THROW_ON_ERROR) : [];
|
||||||
@@ -33,32 +40,36 @@ class VirtualDesk
|
|||||||
->when($write, fn ($q) => $q->whereIn('role', ['admin', 'manager', 'officer']))->exists();
|
->when($write, fn ($q) => $q->whereIn('role', ['admin', 'manager', 'officer']))->exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function owns(User $actor, object $case, bool $write = true): bool
|
public function owns(User $actor, \stdClass $case, bool $write = true): bool
|
||||||
{
|
{
|
||||||
return $case->organization_id ? $this->represents($actor, $case->organization_id, $write) : (int) $case->user_id === $actor->id;
|
return $case->organization_id ? $this->represents($actor, $case->organization_id, $write) : (int) $case->user_id === $actor->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function case(User $actor, string $id, bool $write = false, bool $lock = false): object
|
public function case(User $actor, string $id, bool $write = false, bool $lock = false): \stdClass
|
||||||
{
|
{
|
||||||
$case = DB::table('desk_cases')->where('id', $id)->when($lock, fn ($q) => $q->lockForUpdate())->first();
|
$case = DB::table('desk_cases')->where('id', $id)->when($lock, fn ($q) => $q->lockForUpdate())->first();
|
||||||
abort_unless($case, 404);
|
abort_unless($case !== null, 404);
|
||||||
abort_unless($this->owns($actor, $case, $write) || (! $write && ($actor->can('manage-portal') || DB::table('desk_requests')->where('case_id', $id)->where('analyst_id', $actor->id)->exists())), 403);
|
abort_unless($this->owns($actor, $case, $write) || (! $write && ($actor->can('manage-portal') || DB::table('desk_requests')->where('case_id', $id)->where('analyst_id', $actor->id)->exists())), 403);
|
||||||
|
|
||||||
return $case;
|
return $case;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function request(User $actor, string $id, bool $ownerOnly = false, bool $lock = false): object
|
public function request(User $actor, string $id, bool $ownerOnly = false, bool $lock = false): \stdClass
|
||||||
{
|
{
|
||||||
$request = DB::table('desk_requests')->where('id', $id)->when($lock, fn ($q) => $q->lockForUpdate())->first();
|
$request = DB::table('desk_requests')->where('id', $id)->when($lock, fn ($q) => $q->lockForUpdate())->first();
|
||||||
abort_unless($request, 404);
|
abort_unless($request !== null, 404);
|
||||||
$case = $this->case($actor, $request->case_id, $ownerOnly);
|
$case = $this->case($actor, $request->case_id, $ownerOnly);
|
||||||
abort_unless($this->owns($actor, $case, $ownerOnly) || (! $ownerOnly && ($actor->can('manage-portal') || (int) $request->analyst_id === $actor->id)), 403);
|
abort_unless($this->owns($actor, $case, $ownerOnly) || (! $ownerOnly && ($actor->can('manage-portal') || (int) $request->analyst_id === $actor->id)), 403);
|
||||||
|
|
||||||
return $request;
|
return $request;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createCase(User $actor, array $input): object
|
/** @param array<string,mixed> $input */
|
||||||
|
public function createCase(User $actor, array $input): \stdClass
|
||||||
{
|
{
|
||||||
$data = Validator::make($input, ['title' => 'required|string|max:200', 'client_key' => 'required|uuid', 'reuse_consent' => 'accepted',
|
$data = Validator::make($input, ['title' => 'required|string|max:200', 'client_key' => 'required|uuid', 'reuse_consent' => 'accepted',
|
||||||
'organization_id' => 'nullable|uuid', 'company_id' => 'nullable|uuid', 'submission_id' => 'nullable|uuid', 'simulation_id' => 'nullable|uuid'])->validate();
|
'organization_id' => 'nullable|uuid', 'company_id' => 'nullable|uuid', 'submission_id' => 'nullable|uuid', 'simulation_id' => 'nullable|uuid', 'journey_id' => 'nullable|uuid', 'interest_request_id' => 'nullable|integer|min:1'])->validate();
|
||||||
|
|
||||||
return DB::transaction(function () use ($actor, $data) {
|
return DB::transaction(function () use ($actor, $data) {
|
||||||
DB::table('users')->where('id', $actor->id)->lockForUpdate()->first();
|
DB::table('users')->where('id', $actor->id)->lockForUpdate()->first();
|
||||||
$existing = DB::table('desk_cases')->where('user_id', $actor->id)->where('client_key', $data['client_key'])->first();
|
$existing = DB::table('desk_cases')->where('user_id', $actor->id)->where('client_key', $data['client_key'])->first();
|
||||||
@@ -66,58 +77,132 @@ class VirtualDesk
|
|||||||
if ($existing) {
|
if ($existing) {
|
||||||
abort_unless(($this->decode($existing->payload)['_creation_hash'] ?? '') === $inputHash, 409, 'Chave de criação usada com outro conteúdo.');
|
abort_unless(($this->decode($existing->payload)['_creation_hash'] ?? '') === $inputHash, 409, 'Chave de criação usada com outro conteúdo.');
|
||||||
abort_unless($this->owns($actor, $existing), 403);
|
abort_unless($this->owns($actor, $existing), 403);
|
||||||
|
|
||||||
return $existing;
|
return $existing;
|
||||||
}
|
}
|
||||||
abort_if(($data['organization_id'] ?? null) && ! $this->represents($actor, $data['organization_id']), 403);
|
abort_if(($data['organization_id'] ?? null) && ! $this->represents($actor, $data['organization_id']), 403);
|
||||||
|
$interest = null;
|
||||||
|
if ($data['interest_request_id'] ?? null) {
|
||||||
|
$interest = DB::table('interest_requests')->where('id', $data['interest_request_id'])->where('metadata->portal_user_id', $actor->id)->whereNull('deleted_at')->firstOrFail();
|
||||||
|
$linkedInterest = DB::table('desk_cases')->where('interest_request_id', $data['interest_request_id'])->where('user_id', $actor->id)->first();
|
||||||
|
if ($linkedInterest) {
|
||||||
|
abort_unless($this->owns($actor, $linkedInterest), 403);
|
||||||
|
foreach (['organization_id', 'submission_id', 'simulation_id', 'company_id', 'journey_id'] as $anchor) {
|
||||||
|
abort_if(($data[$anchor] ?? null) && ($linkedInterest->{$anchor} ?? null) !== $data[$anchor], 409, 'Pedido existente já associado a um dossier; continue nesse contexto.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $linkedInterest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (($data['journey_id'] ?? null) && Schema::hasColumn('desk_cases', 'journey_id')) {
|
||||||
|
InvestorJourney::whereKey($data['journey_id'])->where('user_id', $actor->id)->firstOrFail();
|
||||||
|
$linkedJourney = DB::table('desk_cases')->where('journey_id', $data['journey_id'])->where('user_id', $actor->id)->first();
|
||||||
|
if ($linkedJourney) {
|
||||||
|
abort_unless($this->owns($actor, $linkedJourney), 403);
|
||||||
|
foreach (['organization_id', 'submission_id', 'simulation_id', 'company_id'] as $anchor) {
|
||||||
|
abort_if(($data[$anchor] ?? null) && $linkedJourney->{$anchor} !== $data[$anchor], 409, 'Este percurso já tem um dossier; associe novos elementos no contexto existente.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $linkedJourney;
|
||||||
|
}
|
||||||
|
}
|
||||||
$payload = ['profile' => app(InvestmentWorkspace::class)->account($actor->id)['payload'], 'name' => $actor->name, 'email' => $actor->email, '_creation_hash' => $inputHash, 'reuse_consent' => ['actor_id' => $actor->id, 'date' => now()->toIso8601String()]];
|
$payload = ['profile' => app(InvestmentWorkspace::class)->account($actor->id)['payload'], 'name' => $actor->name, 'email' => $actor->email, '_creation_hash' => $inputHash, 'reuse_consent' => ['actor_id' => $actor->id, 'date' => now()->toIso8601String()]];
|
||||||
if ($data['company_id'] ?? null) {
|
if ($data['company_id'] ?? null) {
|
||||||
$company = DB::table('investment_company_declarations')->where('id', $data['company_id'])->where('user_id', $actor->id)->first();
|
$company = DB::table('investment_company_declarations')->where('id', $data['company_id'])->where('user_id', $actor->id)->first();
|
||||||
abort_unless($company, 404);
|
abort_unless($company !== null, 404);
|
||||||
$payload['company'] = $this->decode($company->payload); $payload['company_version'] = $company->version;
|
$payload['company'] = $this->decode($company->payload);
|
||||||
|
$payload['company_version'] = $company->version;
|
||||||
}
|
}
|
||||||
if ($data['submission_id'] ?? null) {
|
if ($data['submission_id'] ?? null) {
|
||||||
$submission = \App\Models\InvestmentSubmission::where('id', $data['submission_id'])->where('user_id', $actor->id)->firstOrFail();
|
$submission = InvestmentSubmission::where('id', $data['submission_id'])->where('user_id', $actor->id)->firstOrFail();
|
||||||
$payload['investment'] = $submission->payload; $payload['investment_version'] = $submission->version;
|
$payload['investment'] = $submission->payload;
|
||||||
|
$payload['investment_version'] = $submission->version;
|
||||||
|
}
|
||||||
|
if ($data['simulation_id'] ?? null) {
|
||||||
|
app(PartnershipSources::class)->resolve('simulation', $data['simulation_id'], $actor);
|
||||||
}
|
}
|
||||||
if ($data['simulation_id'] ?? null) app(PartnershipSources::class)->resolve('simulation', $data['simulation_id'], $actor);
|
|
||||||
// One case per explicitly reused investment; retries never create parallel dossiers.
|
// One case per explicitly reused investment; retries never create parallel dossiers.
|
||||||
if ($data['submission_id'] ?? null) {
|
if ($data['submission_id'] ?? null) {
|
||||||
$linked = DB::table('desk_cases')->where('submission_id', $data['submission_id'])->where('user_id', $actor->id)->first();
|
$linked = DB::table('desk_cases')->where('submission_id', $data['submission_id'])->where('user_id', $actor->id)->first();
|
||||||
if ($linked) { abort_unless($this->owns($actor, $linked), 403); return $linked; }
|
if ($linked) {
|
||||||
|
abort_unless($this->owns($actor, $linked), 403);
|
||||||
|
foreach (['organization_id', 'simulation_id', 'company_id', 'journey_id'] as $anchor) {
|
||||||
|
abort_if(($data[$anchor] ?? null) && ($linked->{$anchor} ?? null) !== $data[$anchor], 409, 'Contexto já associado a outro dossier; não foi criado um dossier paralelo.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $linked;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($data['simulation_id'] ?? null) {
|
||||||
|
$linked = DB::table('desk_cases')->where('simulation_id', $data['simulation_id'])->where('user_id', $actor->id)->first();
|
||||||
|
if ($linked) {
|
||||||
|
abort_unless($this->owns($actor, $linked), 403);
|
||||||
|
foreach (['organization_id', 'submission_id', 'company_id', 'journey_id'] as $anchor) {
|
||||||
|
abort_if(($data[$anchor] ?? null) && ($linked->{$anchor} ?? null) !== $data[$anchor], 409, 'Contexto já associado a outro dossier; não foi criado um dossier paralelo.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $linked;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$identity = [];
|
||||||
|
if (Schema::hasColumn('desk_cases', 'investor_id')) {
|
||||||
|
$journey = ($data['journey_id'] ?? null) ? InvestorJourney::whereKey($data['journey_id'])->where('user_id', $actor->id)->firstOrFail() : null;
|
||||||
|
$account = DB::table('investor_accounts')->where('user_id', $actor->id)->first();
|
||||||
|
if (! $account) {
|
||||||
|
$investor = ($interest->investor_id ?? null) ? Investor::whereKey($interest->investor_id)->firstOrFail() : Investor::create(['legal_name' => $actor->name, 'investor_type' => 'individual', 'status' => 'prospect', 'source_system' => 'portal-account', 'data_classification' => 'confidential']);
|
||||||
|
DB::table('investor_accounts')->insert(['user_id' => $actor->id, 'investor_id' => $investor->id, 'created_at' => now(), 'updated_at' => now()]);
|
||||||
|
$account = DB::table('investor_accounts')->where('user_id', $actor->id)->first();
|
||||||
|
}
|
||||||
|
$dossierId = $journey->dossier_id ?? ($submission->dossier_id ?? null);
|
||||||
|
$projectId = $dossierId ? DB::table('investment_dossiers')->where('id', $dossierId)->whereNull('deleted_at')->value('project_id') : null;
|
||||||
|
$identity = ['investor_id' => $account->investor_id, 'journey_id' => $journey?->id, 'project_id' => $projectId, 'interest_request_id' => $data['interest_request_id'] ?? null];
|
||||||
}
|
}
|
||||||
$id = (string) Str::uuid();
|
$id = (string) Str::uuid();
|
||||||
DB::table('desk_cases')->insert(['id' => $id, 'user_id' => $actor->id, 'organization_id' => $data['organization_id'] ?? null, 'company_id' => $data['company_id'] ?? null,
|
DB::table('desk_cases')->insert(['id' => $id, 'user_id' => $actor->id, 'organization_id' => $data['organization_id'] ?? null, 'company_id' => $data['company_id'] ?? null,
|
||||||
'submission_id' => $data['submission_id'] ?? null, 'simulation_id' => $data['simulation_id'] ?? null, 'title' => $data['title'], 'client_key' => $data['client_key'],
|
'submission_id' => $data['submission_id'] ?? null, 'simulation_id' => $data['simulation_id'] ?? null, 'title' => $data['title'], 'client_key' => $data['client_key'],
|
||||||
'payload' => $this->encode($payload), 'workflow' => json_encode(array_map(fn ($s) => [...$s, 'status' => 'not_started', 'evidence' => null], config('virtual-desk.steps'))), 'created_at' => now(), 'updated_at' => now()]);
|
'payload' => $this->encode($payload), 'workflow' => json_encode(array_map(fn ($s) => [...$s, 'status' => 'not_started', 'evidence' => null], config('virtual-desk.steps'))), 'created_at' => now(), 'updated_at' => now(), ...$identity]);
|
||||||
$case = DB::table('desk_cases')->where('id', $id)->first();
|
$case = DB::table('desk_cases')->where('id', $id)->firstOrFail();
|
||||||
$this->event($case, $actor, 'case_created', ['reuse_consent' => true]);
|
$this->event($case, $actor, 'case_created', ['reuse_consent' => true]);
|
||||||
|
|
||||||
return $case;
|
return $case;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createRequest(User $actor, string $caseId, string $serviceId, string $clientKey): object
|
public function createRequest(User $actor, string $caseId, string $serviceId, string $clientKey): \stdClass
|
||||||
{
|
{
|
||||||
abort_unless(Str::isUuid($serviceId) && Str::isUuid($clientKey), 422);
|
abort_unless(Str::isUuid($serviceId) && Str::isUuid($clientKey), 422);
|
||||||
|
|
||||||
return DB::transaction(function () use ($actor, $caseId, $serviceId, $clientKey) {
|
return DB::transaction(function () use ($actor, $caseId, $serviceId, $clientKey) {
|
||||||
$case = $this->case($actor, $caseId, true, true);
|
$case = $this->case($actor, $caseId, true, true);
|
||||||
abort_if($case->closed_at, 409, 'Dossier encerrado.');
|
abort_if($case->closed_at, 409, 'Dossier encerrado.');
|
||||||
$service = DB::table('desk_service_versions')->where('id', $serviceId)->where('status', 'published')->first();
|
$service = DB::table('desk_service_versions')->where('id', $serviceId)->where('status', 'published')->first();
|
||||||
abort_unless($service, 422, 'Versão do serviço indisponível para novos pedidos.');
|
abort_unless($service !== null, 422, 'Versão do serviço indisponível para novos pedidos.');
|
||||||
$existing = DB::table('desk_requests')->where('case_id', $caseId)->where('client_key', $clientKey)->first();
|
$existing = DB::table('desk_requests')->where('case_id', $caseId)->where('client_key', $clientKey)->first();
|
||||||
if ($existing) { abort_unless($existing->service_version_id === $serviceId, 409); return $existing; }
|
if ($existing) {
|
||||||
$id = (string) Str::uuid(); $base = $this->decode($case->payload);
|
abort_unless($existing->service_version_id === $serviceId, 409);
|
||||||
|
|
||||||
|
return $existing;
|
||||||
|
}
|
||||||
|
$id = (string) Str::uuid();
|
||||||
|
$base = $this->decode($case->payload);
|
||||||
$payload = ['title' => $case->title, 'description' => $base['investment']['objective'] ?? '', 'regime' => 'unknown'];
|
$payload = ['title' => $case->title, 'description' => $base['investment']['objective'] ?? '', 'regime' => 'unknown'];
|
||||||
DB::table('desk_requests')->insert(['id' => $id, 'case_id' => $caseId, 'service_version_id' => $serviceId, 'client_key' => $clientKey, 'payload' => $this->encode($payload), 'created_at' => now(), 'updated_at' => now()]);
|
DB::table('desk_requests')->insert(['id' => $id, 'case_id' => $caseId, 'service_version_id' => $serviceId, 'client_key' => $clientKey, 'payload' => $this->encode($payload), 'created_at' => now(), 'updated_at' => now()]);
|
||||||
$request = DB::table('desk_requests')->where('id', $id)->first(); $this->event($case, $actor, 'draft_created', [], $request);
|
$request = DB::table('desk_requests')->where('id', $id)->firstOrFail();
|
||||||
|
$this->event($case, $actor, 'draft_created', [], $request);
|
||||||
|
|
||||||
return $request;
|
return $request;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function definition(object $request): array
|
/** @return array<string,mixed> */
|
||||||
|
public function definition(\stdClass $request): array
|
||||||
{
|
{
|
||||||
return json_decode(DB::table('desk_service_versions')->where('id', $request->service_version_id)->value('definition'), true, 512, JSON_THROW_ON_ERROR);
|
return json_decode(DB::table('desk_service_versions')->where('id', $request->service_version_id)->value('definition'), true, 512, JSON_THROW_ON_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @param array<string,mixed> $payload
|
||||||
|
* @param array<string,mixed> $definition
|
||||||
|
* @return array<string,mixed> */
|
||||||
public function validateFields(array $payload, array $definition, bool $submitting): array
|
public function validateFields(array $payload, array $definition, bool $submitting): array
|
||||||
{
|
{
|
||||||
$rules = ['payload' => ['required', 'array:'.implode(',', array_keys($definition['fields']))]];
|
$rules = ['payload' => ['required', 'array:'.implode(',', array_keys($definition['fields']))]];
|
||||||
@@ -126,8 +211,8 @@ class VirtualDesk
|
|||||||
$required = $submitting && ($field['required'] ?? false) && $active;
|
$required = $submitting && ($field['required'] ?? false) && $active;
|
||||||
$rule = [$required ? 'required' : 'nullable'];
|
$rule = [$required ? 'required' : 'nullable'];
|
||||||
$rule = [...$rule, ...match ($field['type']) {
|
$rule = [...$rule, ...match ($field['type']) {
|
||||||
'number' => ['numeric', 'min:'.($field['min'] ?? 0), 'max:999999999999'], 'date' => ['date_format:Y-m-d'],
|
'number' => ['numeric', 'decimal:0,2', 'min:'.($field['min'] ?? 0), 'max:999999999999'], 'date' => ['date_format:Y-m-d'],
|
||||||
'select' => [\Illuminate\Validation\Rule::in(array_keys($field['options']))], 'territory' => ['uuid'],
|
'select' => [Rule::in(array_keys($field['options']))], 'territory' => ['uuid'],
|
||||||
default => ['string', 'max:'.($field['type'] === 'textarea' ? 15000 : 1000)],
|
default => ['string', 'max:'.($field['type'] === 'textarea' ? 15000 : 1000)],
|
||||||
}];
|
}];
|
||||||
$rules['payload.'.$key] = $rule;
|
$rules['payload.'.$key] = $rule;
|
||||||
@@ -135,83 +220,127 @@ class VirtualDesk
|
|||||||
$validated = Validator::make(['payload' => $payload], $rules)->validate()['payload'];
|
$validated = Validator::make(['payload' => $payload], $rules)->validate()['payload'];
|
||||||
if ($validated['territory_id'] ?? null) {
|
if ($validated['territory_id'] ?? null) {
|
||||||
abort_unless(app(InvestmentGeography::class)->publicReferences()->where('id', $validated['territory_id'])->exists(), 422, 'Localização indisponível.');
|
abort_unless(app(InvestmentGeography::class)->publicReferences()->where('id', $validated['territory_id'])->exists(), 422, 'Localização indisponível.');
|
||||||
if ($submitting && trim($validated['location_source'] ?? '') === '') throw ValidationException::withMessages(['payload.location_source' => 'Indique a fonte da localização.']);
|
if ($submitting && trim($validated['location_source'] ?? '') === '') {
|
||||||
|
throw ValidationException::withMessages(['payload.location_source' => 'Indique a fonte da localização.']);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $validated;
|
return $validated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @param array<string,mixed> $payload
|
||||||
|
* @return list<array<string,mixed>> */
|
||||||
public function findings(array $payload): array
|
public function findings(array $payload): array
|
||||||
{
|
{
|
||||||
$findings = [];
|
$findings = [];
|
||||||
if (isset($payload['investment_amount'], $payload['own_finance'], $payload['other_finance']) && abs((float) $payload['investment_amount'] - (float) $payload['own_finance'] - (float) $payload['other_finance']) > 0.01) {
|
$amounts = array_map(function ($key) use ($payload) {
|
||||||
|
$value = (string) ($payload[$key] ?? '');
|
||||||
|
if (! preg_match('/^\d{1,12}(?:\.\d{1,2})?$/', $value)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
[$whole, $fraction] = array_pad(explode('.', $value), 2, '');
|
||||||
|
|
||||||
|
return (int) $whole * 100 + (int) str_pad($fraction, 2, '0');
|
||||||
|
}, ['investment_amount', 'own_finance', 'other_finance']);
|
||||||
|
if (! in_array(null, $amounts, true) && $amounts[0] !== $amounts[1] + $amounts[2]) {
|
||||||
$findings[] = ['code' => 'finance_difference', 'severity' => 'error', 'field' => 'investment_amount', 'explanation' => 'A soma do financiamento difere do valor do investimento.', 'recommendation' => 'Confirme valores e moeda.', 'method' => 'deterministic', 'confidence' => null];
|
$findings[] = ['code' => 'finance_difference', 'severity' => 'error', 'field' => 'investment_amount', 'explanation' => 'A soma do financiamento difere do valor do investimento.', 'recommendation' => 'Confirme valores e moeda.', 'method' => 'deterministic', 'confidence' => null];
|
||||||
}
|
}
|
||||||
if (! ($payload['territory_id'] ?? null)) $findings[] = ['code' => 'location_unknown', 'severity' => 'warning', 'field' => 'territory_id', 'explanation' => 'Localização ainda não documentada.', 'recommendation' => 'Complete quando houver fonte.', 'method' => 'deterministic', 'confidence' => null];
|
if (in_array(null, $amounts, true)) {
|
||||||
|
$findings[] = ['code' => 'finance_unknown', 'severity' => 'warning', 'field' => 'investment_amount', 'explanation' => 'A coerência do financiamento permanece indeterminada sem os três valores válidos na mesma moeda.', 'recommendation' => 'Complete as fontes de financiamento; valores ausentes não são zero.', 'method' => 'deterministic', 'confidence' => null];
|
||||||
|
}
|
||||||
|
if (! ($payload['territory_id'] ?? null)) {
|
||||||
|
$findings[] = ['code' => 'location_unknown', 'severity' => 'warning', 'field' => 'territory_id', 'explanation' => 'Localização ainda não documentada.', 'recommendation' => 'Complete quando houver fonte.', 'method' => 'deterministic', 'confidence' => null];
|
||||||
|
}
|
||||||
$findings[] = ['code' => 'official_form_pending', 'severity' => 'warning', 'field' => null, 'explanation' => 'Adaptação digital do plano; não foi identificada uma versão oficial homologada do formulário APIEX no acervo.', 'recommendation' => 'A preparação e análise interna continuam disponíveis; confirme a versão exigida pela entidade para o ato oficial.', 'method' => 'documentary', 'confidence' => null];
|
$findings[] = ['code' => 'official_form_pending', 'severity' => 'warning', 'field' => null, 'explanation' => 'Adaptação digital do plano; não foi identificada uma versão oficial homologada do formulário APIEX no acervo.', 'recommendation' => 'A preparação e análise interna continuam disponíveis; confirme a versão exigida pela entidade para o ato oficial.', 'method' => 'documentary', 'confidence' => null];
|
||||||
|
|
||||||
return $findings;
|
return $findings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function save(User $actor, string $id, array $input, bool $submit = false): object
|
/** @param array<string,mixed> $input */
|
||||||
|
public function save(User $actor, string $id, array $input, bool $submit = false): \stdClass
|
||||||
{
|
{
|
||||||
$data = Validator::make($input, ['version' => 'required|integer|min:1', 'payload' => 'required|array', 'consent' => $submit ? 'accepted' : 'nullable|boolean', 'reason' => 'nullable|string|max:3000'])->validate();
|
$data = Validator::make($input, ['version' => 'required|integer|min:1', 'payload' => 'required|array', 'consent' => $submit ? 'accepted' : 'nullable|boolean', 'reason' => 'nullable|string|max:3000'])->validate();
|
||||||
|
|
||||||
return DB::transaction(function () use ($actor, $id, $data, $submit) {
|
return DB::transaction(function () use ($actor, $id, $data, $submit) {
|
||||||
$request = $this->request($actor, $id, true, true);
|
$request = $this->request($actor, $id, true, true);
|
||||||
if ($submit && $request->status === 'submitted' && $request->version === (int) $data['version'] + 1 && hash_equals(hash('sha256', json_encode(Arr::sortRecursive($this->decode($request->payload)))), hash('sha256', json_encode(Arr::sortRecursive($data['payload']))))) return $request;
|
if ($submit && $request->status === 'submitted' && $request->version === (int) $data['version'] + 1 && hash_equals(hash('sha256', json_encode(Arr::sortRecursive($this->decode($request->payload)), JSON_THROW_ON_ERROR)), hash('sha256', json_encode(Arr::sortRecursive($this->validateFields($data['payload'], $this->definition($request), false)), JSON_THROW_ON_ERROR)))) {
|
||||||
|
return $request;
|
||||||
|
}
|
||||||
abort_unless(in_array($request->status, ['draft', 'returned'], true) && $request->version === (int) $data['version'], 409, 'Pedido alterado ou já submetido.');
|
abort_unless(in_array($request->status, ['draft', 'returned'], true) && $request->version === (int) $data['version'], 409, 'Pedido alterado ou já submetido.');
|
||||||
$payload = $this->validateFields($data['payload'], $this->definition($request), $submit);
|
$payload = $this->validateFields($data['payload'], $this->definition($request), $submit);
|
||||||
if ($request->status === 'returned') {
|
if ($request->status === 'returned') {
|
||||||
$editable = json_decode($request->editable_fields ?? '[]', true); $previous = $this->decode($request->payload);
|
$editable = json_decode($request->editable_fields ?? '[]', true);
|
||||||
|
$previous = $this->decode($request->payload);
|
||||||
foreach (array_unique([...array_keys($previous), ...array_keys($payload)]) as $key) {
|
foreach (array_unique([...array_keys($previous), ...array_keys($payload)]) as $key) {
|
||||||
if (! in_array($key, $editable, true) && ($previous[$key] ?? null) !== ($payload[$key] ?? null)) throw ValidationException::withMessages(['payload.'.$key => 'Campo não autorizado para esta correção.']);
|
if (! in_array($key, $editable, true) && ($previous[$key] ?? null) !== ($payload[$key] ?? null)) {
|
||||||
|
throw ValidationException::withMessages(['payload.'.$key => 'Campo não autorizado para esta correção.']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
abort_if($submit && trim($data['reason'] ?? '') === '', 422, 'Justifique a correção.');
|
abort_if($submit && trim($data['reason'] ?? '') === '', 422, 'Justifique a correção.');
|
||||||
}
|
}
|
||||||
$findings = $this->findings($payload);
|
$findings = $this->findings($payload);
|
||||||
if ($submit && array_filter($findings, fn ($f) => $f['severity'] === 'error')) throw ValidationException::withMessages(['payload.investment_amount' => $findings[0]['explanation']]);
|
if ($submit && array_filter($findings, fn ($f) => $f['severity'] === 'error')) {
|
||||||
|
throw ValidationException::withMessages(['payload.investment_amount' => $findings[0]['explanation']]);
|
||||||
|
}
|
||||||
$case = $this->case($actor, $request->case_id, true);
|
$case = $this->case($actor, $request->case_id, true);
|
||||||
$snapshot = ['payload' => $payload, 'service_version_id' => $request->service_version_id, 'documents' => DB::table('desk_documents as link')->join('documents as d', 'd.id', '=', 'link.document_id')->where('link.case_id', $case->id)->where(fn ($q) => $q->whereNull('link.request_id')->orWhere('link.request_id', $id))->get(['link.document_id', 'd.sha256', 'd.version_no', 'link.source_reference'])->all(), 'findings' => $findings, 'consent' => $submit, 'source' => config('virtual-desk.source')];
|
$snapshot = ['payload' => $payload, 'service_version_id' => $request->service_version_id, 'documents' => DB::table('desk_documents as link')->join('documents as d', 'd.id', '=', 'link.document_id')->where('link.case_id', $case->id)->where(fn ($q) => $q->whereNull('link.request_id')->orWhere('link.request_id', $id))->get(['link.document_id', 'd.sha256', 'd.version_no', 'link.source_reference'])->all(), 'findings' => $findings, 'consent' => $submit, 'source' => config('virtual-desk.source')];
|
||||||
DB::table('desk_revisions')->insert(['request_id' => $id, 'version' => $request->version, 'snapshot' => $this->encode(['payload' => $this->decode($request->payload), 'status' => $request->status, 'submitted_snapshot' => $request->submitted_snapshot ? $this->decode($request->submitted_snapshot) : null])]);
|
DB::table('desk_revisions')->insert(['request_id' => $id, 'version' => $request->version, 'snapshot' => $this->encode(['payload' => $this->decode($request->payload), 'status' => $request->status, 'submitted_snapshot' => $request->submitted_snapshot ? $this->decode($request->submitted_snapshot) : null])]);
|
||||||
$updates = ['payload' => $this->encode($payload), 'version' => $request->version + 1, 'updated_at' => now()];
|
$updates = ['payload' => $this->encode($payload), 'version' => $request->version + 1, 'updated_at' => now()];
|
||||||
if ($submit) $updates = [...$updates, 'status' => 'submitted', 'protocol' => $request->protocol ?? 'BV-'.date('Y').'-'.strtoupper(str_replace('-', '', $id)), 'submitted_at' => now(), 'submitted_snapshot' => $this->encode($snapshot)];
|
if ($submit) {
|
||||||
DB::table('desk_requests')->where('id', $id)->update($updates); $request = DB::table('desk_requests')->where('id', $id)->first();
|
$updates = [...$updates, 'status' => 'submitted', 'protocol' => $request->protocol ?? 'BV-'.date('Y').'-'.strtoupper(str_replace('-', '', $id)), 'submitted_at' => now(), 'submitted_snapshot' => $this->encode($snapshot)];
|
||||||
|
}
|
||||||
|
DB::table('desk_requests')->where('id', $id)->update($updates);
|
||||||
|
$request = DB::table('desk_requests')->where('id', $id)->firstOrFail();
|
||||||
$this->event($case, $actor, $submit ? 'submitted' : 'draft_saved', ['reason' => $data['reason'] ?? '', 'findings' => $findings], $request);
|
$this->event($case, $actor, $submit ? 'submitted' : 'draft_saved', ['reason' => $data['reason'] ?? '', 'findings' => $findings], $request);
|
||||||
|
|
||||||
return $request;
|
return $request;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function transition(User $actor, string $id, array $data): object
|
/** @param array<string,mixed> $data */
|
||||||
|
public function transition(User $actor, string $id, array $data): \stdClass
|
||||||
{
|
{
|
||||||
$data = Validator::make($data, ['version' => 'required|integer|min:1', 'status' => ['required', \Illuminate\Validation\Rule::in(array_keys(config('virtual-desk.request_states')))], 'reason' => 'required|string|min:3|max:5000', 'editable_fields' => 'nullable|array', 'editable_fields.*' => 'string|max:100'])->validate();
|
$data = Validator::make($data, ['version' => 'required|integer|min:1', 'status' => ['required', Rule::in(array_keys(config('virtual-desk.request_states')))], 'reason' => 'required|string|min:3|max:5000', 'editable_fields' => 'nullable|array', 'editable_fields.*' => 'string|max:100'])->validate();
|
||||||
|
|
||||||
return DB::transaction(function () use ($actor, $id, $data) {
|
return DB::transaction(function () use ($actor, $id, $data) {
|
||||||
$request = $this->request($actor, $id, false, true); $case = $this->case($actor, $request->case_id);
|
$request = $this->request($actor, $id, false, true);
|
||||||
|
$case = $this->case($actor, $request->case_id);
|
||||||
abort_unless($request->version === (int) $data['version'], 409);
|
abort_unless($request->version === (int) $data['version'], 409);
|
||||||
$cancel = $data['status'] === 'cancelled';
|
$cancel = $data['status'] === 'cancelled';
|
||||||
if ($cancel) { abort_unless($this->owns($actor, $case) && in_array($request->status, ['draft', 'returned'], true), 403); }
|
if ($cancel) {
|
||||||
else {
|
abort_unless($this->owns($actor, $case) && in_array($request->status, ['draft', 'returned'], true), 403);
|
||||||
|
} else {
|
||||||
abort_if($this->owns($actor, $case, false), 403, 'O proponente não pode analisar ou decidir o seu próprio pedido.');
|
abort_if($this->owns($actor, $case, false), 403, 'O proponente não pode analisar ou decidir o seu próprio pedido.');
|
||||||
abort_unless($actor->can('manage-portal') || (int) $request->analyst_id === $actor->id, 403);
|
abort_unless($actor->can('manage-portal') || (int) $request->analyst_id === $actor->id, 403);
|
||||||
if (in_array($data['status'], ['accepted', 'rejected', 'closed'], true)) abort_unless($actor->can('manage-portal'), 403);
|
if (in_array($data['status'], ['accepted', 'rejected', 'closed'], true)) {
|
||||||
|
abort_unless($actor->can('manage-portal'), 403);
|
||||||
|
}
|
||||||
abort_unless(in_array($data['status'], config('virtual-desk.transitions.'.$request->status, []), true), 409, 'Transição inválida.');
|
abort_unless(in_array($data['status'], config('virtual-desk.transitions.'.$request->status, []), true), 409, 'Transição inválida.');
|
||||||
}
|
}
|
||||||
$editable = $data['editable_fields'] ?? [];
|
$editable = $data['editable_fields'] ?? [];
|
||||||
abort_if($data['status'] === 'returned' && ! $editable, 422, 'Indique os campos autorizados para correção.');
|
abort_if($data['status'] === 'returned' && ! $editable, 422, 'Indique os campos autorizados para correção.');
|
||||||
abort_if(array_diff($editable, array_keys($this->definition($request)['fields'])), 422);
|
abort_if(array_diff($editable, array_keys($this->definition($request)['fields'])) !== [], 422);
|
||||||
DB::table('desk_requests')->where('id', $id)->update(['status' => $data['status'], 'version' => $request->version + 1, 'editable_fields' => json_encode($editable), 'closed_at' => in_array($data['status'], ['closed', 'cancelled'], true) ? now() : null, 'updated_at' => now()]);
|
DB::table('desk_requests')->where('id', $id)->update(['status' => $data['status'], 'version' => $request->version + 1, 'editable_fields' => json_encode($editable), 'closed_at' => in_array($data['status'], ['closed', 'cancelled'], true) ? now() : null, 'updated_at' => now()]);
|
||||||
$request = DB::table('desk_requests')->where('id', $id)->first(); $this->event($case, $actor, 'request_'.$data['status'], ['reason' => $data['reason'], 'editable_fields' => $editable], $request);
|
$request = DB::table('desk_requests')->where('id', $id)->firstOrFail();
|
||||||
|
$this->event($case, $actor, 'request_'.$data['status'], ['reason' => $data['reason'], 'editable_fields' => $editable], $request);
|
||||||
|
|
||||||
return $request;
|
return $request;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stage(User $actor, string $id, array $data): object
|
/** @param array<string,mixed> $data */
|
||||||
|
public function stage(User $actor, string $id, array $data): \stdClass
|
||||||
{
|
{
|
||||||
$data = Validator::make($data, ['version' => 'required|integer|min:1', 'stage' => ['required', \Illuminate\Validation\Rule::in(array_keys(config('virtual-desk.steps')))],
|
$data = Validator::make($data, ['version' => 'required|integer|min:1', 'stage' => ['required', Rule::in(array_keys(config('virtual-desk.steps')))],
|
||||||
'status' => ['required', \Illuminate\Validation\Rule::in(array_keys(config('virtual-desk.step_states')))], 'reason' => 'required|string|min:3|max:3000',
|
'status' => ['required', Rule::in(array_keys(config('virtual-desk.step_states')))], 'reason' => 'required|string|min:3|max:3000',
|
||||||
'evidence' => 'nullable|string|max:5000', 'document_id' => 'nullable|uuid', 'valid_until' => 'nullable|date_format:Y-m-d', 'exception' => 'nullable|boolean'])->validate();
|
'evidence' => 'nullable|string|max:5000', 'document_id' => 'nullable|uuid', 'valid_until' => 'nullable|date_format:Y-m-d', 'exception' => 'nullable|boolean'])->validate();
|
||||||
|
|
||||||
return DB::transaction(function () use ($actor, $id, $data) {
|
return DB::transaction(function () use ($actor, $id, $data) {
|
||||||
$case = $this->case($actor, $id, false, true);
|
$case = $this->case($actor, $id, false, true);
|
||||||
abort_unless($this->owns($actor, $case) || $actor->can('manage-portal'), 403);
|
abort_unless($this->owns($actor, $case) || $actor->can('manage-portal'), 403);
|
||||||
abort_unless((int) $case->version === (int) $data['version'], 409);
|
abort_unless((int) $case->version === (int) $data['version'], 409);
|
||||||
$workflow = json_decode($case->workflow, true, 512, JSON_THROW_ON_ERROR); $current = $workflow[$data['stage']];
|
$workflow = json_decode($case->workflow, true, 512, JSON_THROW_ON_ERROR);
|
||||||
|
$current = $workflow[$data['stage']];
|
||||||
$decision = in_array($data['status'], ['completed', 'not_applicable'], true);
|
$decision = in_array($data['status'], ['completed', 'not_applicable'], true);
|
||||||
if ($decision) {
|
if ($decision) {
|
||||||
abort_unless($actor->can('manage-portal') && ! $this->owns($actor, $case, false), 403, 'Conclusão documental exige revisão interna por outra pessoa autorizada.');
|
abort_unless($actor->can('manage-portal') && ! $this->owns($actor, $case, false), 403, 'Conclusão documental exige revisão interna por outra pessoa autorizada.');
|
||||||
@@ -219,36 +348,63 @@ class VirtualDesk
|
|||||||
foreach ($current['dependencies'] as $dependency) {
|
foreach ($current['dependencies'] as $dependency) {
|
||||||
abort_unless(in_array($workflow[$dependency]['status'], ['completed', 'not_applicable'], true) || (($data['exception'] ?? false) && ($data['document_id'] ?? null)), 422, 'Dependência '.$dependency.' pendente; uma exceção exige evidência própria.');
|
abort_unless(in_array($workflow[$dependency]['status'], ['completed', 'not_applicable'], true) || (($data['exception'] ?? false) && ($data['document_id'] ?? null)), 422, 'Dependência '.$dependency.' pendente; uma exceção exige evidência própria.');
|
||||||
}
|
}
|
||||||
if ($data['stage'] !== 'E0') abort_unless($data['document_id'] ?? null, 422, 'Ligue o documento de suporte ou de não aplicabilidade.');
|
if ($data['stage'] !== 'E0') {
|
||||||
|
abort_unless($data['document_id'] ?? null, 422, 'Ligue o documento de suporte ou de não aplicabilidade.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($data['document_id'] ?? null) {
|
if ($data['document_id'] ?? null) {
|
||||||
$document = DB::table('desk_documents as l')->join('documents as d', 'd.id', '=', 'l.document_id')->where('l.case_id', $id)->where('d.id', $data['document_id'])->whereNull('d.deleted_at')->first(['d.status', 'd.malware_scan_status', 'd.sha256', 'd.malware_scanned_sha256', 'l.valid_until']);
|
$document = DB::table('desk_documents as l')->join('documents as d', 'd.id', '=', 'l.document_id')->where('l.case_id', $id)->where('d.id', $data['document_id'])->whereNull('d.deleted_at')->first(['d.status', 'd.malware_scan_status', 'd.sha256', 'd.malware_scanned_sha256', 'l.valid_until']);
|
||||||
abort_unless($document, 422);
|
abort_unless($document !== null, 422);
|
||||||
if ($decision) abort_unless($document->status === 'active' && $document->malware_scan_status === 'clean' && trim($document->sha256) === $document->malware_scanned_sha256 && (! $document->valid_until || $document->valid_until >= now()->toDateString()), 422, 'Documento ainda não consultável ou expirado.');
|
if ($decision) {
|
||||||
|
abort_unless($document->status === 'active' && $document->malware_scan_status === 'clean' && trim($document->sha256) === $document->malware_scanned_sha256 && (! $document->valid_until || $document->valid_until >= now()->toDateString()), 422, 'Documento ainda não consultável ou expirado.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (in_array($data['status'], ['referred', 'waiting'], true)) {
|
||||||
|
abort_unless(trim($data['evidence'] ?? '') !== '', 422, 'Registe referência e canal do encaminhamento.');
|
||||||
}
|
}
|
||||||
if (in_array($data['status'], ['referred', 'waiting'], true)) abort_unless(trim($data['evidence'] ?? '') !== '', 422, 'Registe referência e canal do encaminhamento.');
|
|
||||||
// Reopening an upstream step must never leave dependent conclusions falsely valid.
|
// Reopening an upstream step must never leave dependent conclusions falsely valid.
|
||||||
if (! in_array($data['status'], ['completed', 'not_applicable'], true)) {
|
if (! in_array($data['status'], ['completed', 'not_applicable'], true)) {
|
||||||
$affected = [$data['stage']];
|
$affected = [$data['stage']];
|
||||||
do { $changed = false; foreach ($workflow as $code => &$step) { if (! in_array($code, $affected, true) && array_intersect($step['dependencies'], $affected)) { $affected[] = $code; $changed = true; if ($step['status'] === 'completed') $step['status'] = 'pending'; } } unset($step); } while ($changed);
|
do {
|
||||||
|
$changed = false;
|
||||||
|
foreach ($workflow as $code => &$step) {
|
||||||
|
if (! in_array($code, $affected, true) && array_intersect($step['dependencies'], $affected)) {
|
||||||
|
$affected[] = $code;
|
||||||
|
$changed = true;
|
||||||
|
if (in_array($step['status'], ['completed', 'not_applicable'], true)) {
|
||||||
|
$step['status'] = 'pending';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} unset($step);
|
||||||
|
} while ($changed);
|
||||||
}
|
}
|
||||||
$workflow[$data['stage']] = [...$current, 'status' => $data['status'], 'evidence' => $data['evidence'] ?? null, 'document_id' => $data['document_id'] ?? null,
|
$workflow[$data['stage']] = [...$current, 'status' => $data['status'], 'evidence' => $data['evidence'] ?? null, 'document_id' => $data['document_id'] ?? null,
|
||||||
'valid_until' => $data['valid_until'] ?? null, 'reason' => $data['reason'], 'reviewed_by' => $actor->id, 'updated_at' => now()->toIso8601String()];
|
'valid_until' => $data['valid_until'] ?? null, 'reason' => $data['reason'], 'reviewed_by' => $actor->id, 'updated_at' => now()->toIso8601String()];
|
||||||
DB::table('desk_cases')->where('id', $id)->update(['workflow' => json_encode($workflow), 'version' => $case->version + 1, 'updated_at' => now()]);
|
DB::table('desk_cases')->where('id', $id)->update(['workflow' => json_encode($workflow), 'version' => $case->version + 1, 'updated_at' => now()]);
|
||||||
$case = DB::table('desk_cases')->where('id', $id)->first(); $this->event($case, $actor, 'stage_updated', $data);
|
$case = DB::table('desk_cases')->where('id', $id)->firstOrFail();
|
||||||
|
$this->event($case, $actor, 'stage_updated', $data);
|
||||||
|
|
||||||
return $case;
|
return $case;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function event(object $case, User $actor, string $action, array $payload, ?object $request = null): void
|
/** @param array<string,mixed> $payload */
|
||||||
|
public function event(\stdClass $case, User $actor, string $action, array $payload, ?\stdClass $request = null): void
|
||||||
{
|
{
|
||||||
$id = (string) Str::uuid(); $version = $request->version ?? $case->version;
|
$id = (string) Str::uuid();
|
||||||
|
$version = $request->version ?? $case->version;
|
||||||
DB::table('desk_events')->insert(['id' => $id, 'case_id' => $case->id, 'request_id' => $request->id ?? null, 'actor_id' => $actor->id, 'action' => $action, 'version' => $version, 'payload' => $this->encode($payload)]);
|
DB::table('desk_events')->insert(['id' => $id, 'case_id' => $case->id, 'request_id' => $request->id ?? null, 'actor_id' => $actor->id, 'action' => $action, 'version' => $version, 'payload' => $this->encode($payload)]);
|
||||||
DB::table('audit_events')->insert(['source_system' => 'virtual-desk', 'entity_type' => $request ? 'desk_requests' : 'desk_cases', 'entity_id' => $request->id ?? $case->id, 'actor_user_id' => $actor->id, 'action' => $action,
|
DB::table('audit_events')->insert(['source_system' => 'virtual-desk', 'entity_type' => $request ? 'desk_requests' : 'desk_cases', 'entity_id' => $request->id ?? $case->id, 'actor_user_id' => $actor->id, 'action' => $action,
|
||||||
'after_data' => json_encode(['event_id' => $id, 'event_version' => 1, 'version' => $version, 'case_id' => $case->id, 'source_hash' => config('virtual-desk.source.sha256')])]);
|
'after_data' => json_encode(['event_id' => $id, 'event_version' => 1, 'version' => $version, 'case_id' => $case->id, 'source_hash' => config('virtual-desk.source.sha256')])]);
|
||||||
$recipients = [(int) $case->user_id];
|
$recipients = [(int) $case->user_id];
|
||||||
if ($case->organization_id) $recipients = [...$recipients, ...DB::table('memberships')->where('organization_id', $case->organization_id)->whereNull('deleted_at')->pluck('user_id')->all()];
|
if ($case->organization_id) {
|
||||||
if ($request?->analyst_id) $recipients[] = (int) $request->analyst_id;
|
$recipients = [...DB::table('memberships')->where('organization_id', $case->organization_id)->whereNull('deleted_at')->pluck('user_id')->all()];
|
||||||
foreach (array_unique($recipients) as $user) DB::table('desk_notifications')->insert(['event_id' => $id, 'user_id' => $user, 'title' => config('virtual-desk.request_states.'.$request?->status, 'Dossier atualizado'), 'href' => $request ? '/balcao-virtual/pedidos/'.$request->id : '/balcao-virtual/dossiers/'.$case->id]);
|
}
|
||||||
|
if ($request?->analyst_id) {
|
||||||
|
$recipients[] = (int) $request->analyst_id;
|
||||||
|
}
|
||||||
|
foreach (array_unique($recipients) as $user) {
|
||||||
|
DB::table('desk_notifications')->insert(['event_id' => $id, 'user_id' => $user, 'title' => config('virtual-desk.request_states.'.$request?->status, 'Dossier atualizado'), 'href' => $request ? '/balcao-virtual/pedidos/'.$request->id : '/balcao-virtual/dossiers/'.$case->id]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,102 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Services\Malware\MalwareScanner;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class VirtualDeskInstallation
|
||||||
|
{
|
||||||
|
public const MIGRATIONS = ['2026_10_07_190000_create_internal_virtual_desk', '2026_10_08_120000_extend_desk_investor_guidance'];
|
||||||
|
|
||||||
|
public function fingerprint(): string
|
||||||
|
{
|
||||||
|
$files = [...(glob(app_path('Services/Ai/InvestorGuidance*.php')) ?: []), app_path('Services/VirtualDesk.php'), __FILE__,
|
||||||
|
app_path('Http/Controllers/VirtualDeskController.php'), app_path('Http/Controllers/VirtualDeskOperationsController.php'), app_path('Http/Controllers/InvestorGuidanceController.php'),
|
||||||
|
app_path('Http/Controllers/VirtualDeskInstallationController.php'), app_path('Http/Middleware/VirtualDeskInstalled.php'), app_path('Services/InstitutionalLinkMonitor.php'),
|
||||||
|
app_path('Services/Ai/EvidenceRepository.php'), base_path('routes/virtual-desk.php'), config_path('virtual-desk.php'), app_path('Http/Controllers/PortalServicesController.php'), app_path('Http/Middleware/HandleInertiaRequests.php'), resource_path('js/app.tsx'),
|
||||||
|
resource_path('js/lib/business-financial-plan.ts'), resource_path('js/lib/financial-calculators.ts'), resource_path('js/lib/project-dossier.ts'),
|
||||||
|
...array_map(fn ($name) => database_path('migrations/'.$name.'.php'), self::MIGRATIONS),
|
||||||
|
...(glob(resource_path('js/pages/desk/*.tsx')) ?: []), resource_path('js/components/investor-guidance.tsx'), resource_path('js/components/journey-companion.tsx'), resource_path('js/components/desk-internal-operations.tsx'), resource_path('js/layouts/portal-navigation.tsx'), resource_path('js/layouts/app/app-sidebar-layout.tsx'), resource_path('js/pages/investment/shared.tsx'), resource_path('js/lib/investor-guidance-finance.ts')];
|
||||||
|
sort($files);
|
||||||
|
|
||||||
|
return hash('sha256', json_encode(array_map(fn ($file) => hash_file('sha256', $file), $files), JSON_THROW_ON_ERROR));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return array<string,mixed> */
|
||||||
|
public function preview(): array
|
||||||
|
{
|
||||||
|
$identity = DB::selectOne('select current_database() as database, inet_server_port() as port');
|
||||||
|
$directory = config('virtual-desk.proof_directory', storage_path('app/private/virtual-desk'));
|
||||||
|
$read = function ($file) use ($directory) {
|
||||||
|
if (! is_file($directory.'/'.$file)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$contents = file_get_contents($directory.'/'.$file);
|
||||||
|
abort_unless(is_string($contents), 503, 'Evidência privada indisponível.');
|
||||||
|
|
||||||
|
return json_decode($contents, true, 512, JSON_THROW_ON_ERROR);
|
||||||
|
};
|
||||||
|
$backup = $read('backup-proof.json');
|
||||||
|
$qa = $read('guidance-qa-evidence.json');
|
||||||
|
$compatibility = $read('activation-compatibility.json');
|
||||||
|
$code = $this->fingerprint();
|
||||||
|
$backupVerified = ($backup['restore_verified'] ?? false) && ($backup['target']['database'] ?? null) === $identity->database
|
||||||
|
&& (int) ($backup['target']['port'] ?? 0) === (int) $identity->port && is_file($backup['dump_path'] ?? '')
|
||||||
|
&& hash_file('sha256', $backup['dump_path']) === ($backup['sha256'] ?? null)
|
||||||
|
&& ($backup['files_verified'] ?? false) && is_file($backup['files_path'] ?? '')
|
||||||
|
&& hash_file('sha256', $backup['files_path']) === ($backup['files_sha256'] ?? null)
|
||||||
|
&& strtotime($backup['verified_at'] ?? '') >= time() - 86400;
|
||||||
|
$qaVerified = ($qa['passed'] ?? false) && ($qa['code_hash'] ?? null) === $code && str_ends_with($qa['database'] ?? '', '_test') && (int) ($qa['port'] ?? 0) === 55441;
|
||||||
|
$compatibilityVerified = $backupVerified && ($compatibility['passed'] ?? false) && ($compatibility['code_hash'] ?? null) === $code
|
||||||
|
&& ($compatibility['dump_sha256'] ?? null) === ($backup['sha256'] ?? null)
|
||||||
|
&& ($compatibility['empty_rollback_verified'] ?? false) && (int) ($compatibility['port'] ?? 0) === 55441;
|
||||||
|
$counts = [];
|
||||||
|
foreach (['desk_cases', 'desk_requests', 'desk_documents', 'desk_messages', 'tasks', 'investor_accounts', 'investment_submissions'] as $table) {
|
||||||
|
$counts[$table] = Schema::hasTable($table) ? DB::table($table)->count() : null;
|
||||||
|
}
|
||||||
|
$installed = app(VirtualDesk::class)->installed();
|
||||||
|
$privileges = DB::selectOne("select has_schema_privilege(current_user, 'public', 'CREATE') as can_create,
|
||||||
|
pg_has_role(current_user, (select tableowner from pg_tables where schemaname='public' and tablename='tasks'), 'USAGE') as can_alter_tasks");
|
||||||
|
$databaseReady = (bool) ($privileges->can_create && $privileges->can_alter_tasks);
|
||||||
|
|
||||||
|
return ['hash' => hash('sha256', json_encode([$identity, $code, $counts, $backupVerified, $qaVerified, $compatibilityVerified, $databaseReady], JSON_THROW_ON_ERROR)), 'code_hash' => $code,
|
||||||
|
'installed' => $installed, 'target' => $identity, 'counts' => $counts, 'backupVerified' => $backupVerified, 'qaVerified' => $qaVerified,
|
||||||
|
'compatibilityVerified' => $compatibilityVerified, 'backupDate' => $backup['verified_at'] ?? null,
|
||||||
|
'databaseReady' => $databaseReady,
|
||||||
|
'scanner' => app(MalwareScanner::class)->health(),
|
||||||
|
'pendingMigrations' => array_values(array_filter(self::MIGRATIONS, fn ($name) => ! DB::table('migrations')->where('migration', $name)->exists())),
|
||||||
|
'rollback' => 'Reversão vazia ensaiada em cópia isolada. Com dados novos, preservar/exportar pedidos e tarefas; o down recusa eliminar dados. Restauro integral só numa janela autorizada, após reconciliar alterações posteriores ao backup.',
|
||||||
|
'changes' => ['Completar o Balcão Virtual existente, preservando pedidos anteriores.', 'Acrescentar associações opcionais ao investidor, projecto e percurso existentes.',
|
||||||
|
'Reutilizar tasks do CRM para acções expressamente assumidas; sem envio externo.', 'Nenhuma publicação de serviço, documento ou candidatura automática.']];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function apply(string $hash, User $actor): void
|
||||||
|
{
|
||||||
|
abort_unless($actor->can('manage-portal'), 403);
|
||||||
|
DB::transaction(function () use ($hash, $actor) {
|
||||||
|
DB::select('select pg_advisory_xact_lock(261008, 1)');
|
||||||
|
$preview = $this->preview();
|
||||||
|
abort_unless(hash_equals($preview['hash'], $hash), 409, 'Pré-visualização alterada.');
|
||||||
|
if ($preview['installed']) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
abort_unless($preview['backupVerified'] && $preview['qaVerified'] && $preview['compatibilityVerified'] && $preview['databaseReady'], 422, 'Backup/restauro atualizado, compatibilidade/reversão, permissões da base e QA desta versão continuam necessários.');
|
||||||
|
config(['virtual-desk.installation_authorized' => true]);
|
||||||
|
try {
|
||||||
|
foreach (self::MIGRATIONS as $name) {
|
||||||
|
if (! DB::table('migrations')->where('migration', $name)->exists()) {
|
||||||
|
(require database_path('migrations/'.$name.'.php'))->up();
|
||||||
|
DB::table('migrations')->insert(['migration' => $name, 'batch' => (DB::table('migrations')->max('batch') ?? 0) + 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
config(['virtual-desk.installation_authorized' => false]);
|
||||||
|
}
|
||||||
|
DB::table('audit_events')->insert(['source_system' => 'virtual-desk', 'entity_type' => 'desk_cases', 'actor_user_id' => $actor->id,
|
||||||
|
'action' => 'desk_installed', 'after_data' => json_encode(['preview_hash' => $hash, 'code_hash' => $preview['code_hash'], 'prior_counts' => $preview['counts']])]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-4
@@ -1,14 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Http\Middleware\EnsureSimulationRecoveryCookie;
|
||||||
use App\Http\Middleware\HandleAppearance;
|
use App\Http\Middleware\HandleAppearance;
|
||||||
use App\Http\Middleware\HandleInertiaRequests;
|
use App\Http\Middleware\HandleInertiaRequests;
|
||||||
use App\Http\Middleware\PreserveFormFeedback;
|
use App\Http\Middleware\PreserveFormFeedback;
|
||||||
use App\Http\Middleware\EnsureSimulationRecoveryCookie;
|
use Illuminate\Database\QueryException;
|
||||||
use Illuminate\Foundation\Application;
|
use Illuminate\Foundation\Application;
|
||||||
use Illuminate\Foundation\Configuration\Exceptions;
|
use Illuminate\Foundation\Configuration\Exceptions;
|
||||||
use Illuminate\Foundation\Configuration\Middleware;
|
use Illuminate\Foundation\Configuration\Middleware;
|
||||||
use Illuminate\Database\QueryException;
|
|
||||||
use Illuminate\Database\ConnectionException;
|
|
||||||
use Illuminate\Http\Middleware\AddLinkHeadersForPreloadedAssets;
|
use Illuminate\Http\Middleware\AddLinkHeadersForPreloadedAssets;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
@@ -44,7 +43,7 @@ return Application::configure(basePath: dirname(__DIR__))
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($exception instanceof QueryException || $exception instanceof ConnectionException || $exception instanceof \PDOException)
|
if (($exception instanceof QueryException || $exception instanceof PDOException)
|
||||||
&& ! $request->is('api/v1/simulation-drafts*')) {
|
&& ! $request->is('api/v1/simulation-drafts*')) {
|
||||||
$reference = (string) ($response->headers->get('X-Correlation-ID')
|
$reference = (string) ($response->headers->get('X-Correlation-ID')
|
||||||
?? $request->attributes->get('correlation_id')
|
?? $request->attributes->get('correlation_id')
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
'operator_name' => env('PORTAL_OPERATOR_NAME'),
|
||||||
'support' => [
|
'support' => [
|
||||||
'email' => env('PORTAL_SUPPORT_EMAIL'),
|
'email' => env('PORTAL_SUPPORT_EMAIL'),
|
||||||
'phone' => env('PORTAL_SUPPORT_PHONE'),
|
'phone' => env('PORTAL_SUPPORT_PHONE'),
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
$source = ['identifier' => 'Plano de Incorporação e Optimização do Módulo Balcão Virtual — Portal do Investidor',
|
$source = ['identifier' => 'Plano de Incorporação e Optimização do Módulo Balcão Virtual — Portal do Investidor',
|
||||||
'sha256' => 'f167d9156c2572c0253949a6f0ed88aafc28450cce902e8f445e3d979119aa37', 'edition' => 'Plano fornecido em 7 outubro 2026',
|
'sha256' => 'f167d9156c2572c0253949a6f0ed88aafc28450cce902e8f445e3d979119aa37', 'edition' => 'Plano fornecido em 7 outubro 2026',
|
||||||
'legal_status' => 'not_a_legal_instrument', 'form_status' => 'digital_preparation', 'rule_use' => 'internal_workflow_only'];
|
'legal_status' => 'not_a_legal_instrument', 'form_status' => 'digital_preparation', 'rule_use' => 'internal_workflow_only',
|
||||||
|
'legal_claims_status' => 'source_assertions_not_independently_verified', 'official_rates_deadlines_eligibility' => 'indeterminate'];
|
||||||
$steps = [
|
$steps = [
|
||||||
'E0' => ['Perfil e preparação', [], 'Portal do Investidor', 'Dados mínimos do promotor e do projeto; reutilização consentida.'],
|
'E0' => ['Perfil e preparação', [], 'Portal do Investidor', 'Dados mínimos do promotor e do projeto; reutilização consentida.'],
|
||||||
'E1' => ['Reserva do nome', ['E0'], 'SARN', 'Nome aprovado, identificação do pedido, comprovativo e validade.'],
|
'E1' => ['Reserva do nome', ['E0'], 'SARN', 'Nome aprovado, identificação do pedido, comprovativo e validade.'],
|
||||||
@@ -21,6 +22,7 @@ $field = fn ($label, $type = 'text', $required = false, $extra = []) => ['label'
|
|||||||
$common = ['title' => $field('Nome do projeto', 'text', true), 'description' => $field('Descrição e objetivo', 'textarea', true),
|
$common = ['title' => $field('Nome do projeto', 'text', true), 'description' => $field('Descrição e objetivo', 'textarea', true),
|
||||||
'territory_id' => $field('Localização documentada', 'territory'), 'location_source' => $field('Fonte da localização'),
|
'territory_id' => $field('Localização documentada', 'territory'), 'location_source' => $field('Fonte da localização'),
|
||||||
'regime' => $field('Regime declarado', 'select', false, ['options' => ['unknown' => 'Por determinar', 'registration' => 'Mero registo declarado', 'authorization' => 'Autorização declarada', 'special' => 'Regime especial declarado']])];
|
'regime' => $field('Regime declarado', 'select', false, ['options' => ['unknown' => 'Por determinar', 'registration' => 'Mero registo declarado', 'authorization' => 'Autorização declarada', 'special' => 'Regime especial declarado']])];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'installation_authorized' => false,
|
'installation_authorized' => false,
|
||||||
'source' => $source,
|
'source' => $source,
|
||||||
|
|||||||
@@ -5,14 +5,287 @@
|
|||||||
"source_document_note": "Documento do utilizador reconciliado com fontes institucionais e primárias acessíveis. Alegações promocionais não são tratadas como actividade autorizada, operação ou disponibilidade.",
|
"source_document_note": "Documento do utilizador reconciliado com fontes institucionais e primárias acessíveis. Alegações promocionais não são tratadas como actividade autorizada, operação ou disponibilidade.",
|
||||||
"consulted_at": "2026-10-04",
|
"consulted_at": "2026-10-04",
|
||||||
"records": [
|
"records": [
|
||||||
{"code":"MOZ-TOPUITO-PARK","name":"Parque Industrial de Topuito","category":"industrial_park","physical_category":"industrial_park","legal_regime":"pending","development_status":"in_development","availability_status":"reported_unverified","territory_note":"The source names Topuito in Larde; the master dataset has no district row for Larde. This candidate is linked only at Nampula province until the territorial mapping is reviewed.","territories":[{"name":"NAMPULA","type":"province","scope_type":"administrative"}],"source":{"title":"Construction begins on SME Village at Topuito Industrial Park","url":"https://mozparks.co.mz/construction-begins-on-sme-village-at-topuito-industrial-park/","source_type":"promoter","supports":"Project and development activity, not operational availability."},"areas":[{"type":"total","value":215,"unit":"ha","status":"disputed","source_reference":"MozParks brochure 2023, source scope to review"},{"type":"total","value":200,"unit":"ha","status":"disputed","source_reference":"MozParks brochure 2025, source scope to review"},{"type":"developed","value":30,"unit":"ha","status":"reported","source_reference":"MozParks brochure 2025; not a land availability statement"}]},
|
{
|
||||||
{"code":"MOZ-TOPUITO-ZFI","name":"Zona Franca Industrial de Topuito","category":"zfi","physical_category":"industrial_free_zone","legal_regime":"zfi","development_status":"planned","availability_status":"not_informed","territory_note":"The decree names Topuito in Larde; the master dataset has no district row for Larde. This candidate is linked only at Nampula province until the territorial mapping is reviewed.","territories":[{"name":"NAMPULA","type":"province","scope_type":"administrative"}],"source":{"title":"Decreto n.º 57/2023 — criação da ZFI de Topuito","url":"https://www.inm.gov.mz/pt-br/content/conselho-de-ministros-br-n%C2%BA-190-de-031023-boletim-da-rep%C3%BAblica-i-s%C3%A9rie-p%C3%A1g-2349","source_type":"government","supports":"Legal creation and reported legal area; primary review remains required."},"areas":[{"type":"legal","value":65,"unit":"ha","status":"reported","source_reference":"Decreto n.º 57/2023, artigo 1.º — confirm against retained official text"}]},
|
"code": "MOZ-TOPUITO-PARK",
|
||||||
{"code":"MOZ-MUNHAVA-PARK","name":"Parque Industrial e Logístico de Munhava","category":"industrial_park","physical_category":"industrial_logistics_park","legal_regime":"pending","development_status":"in_development","availability_status":"not_informed","territories":[{"name":"CIDADE DA BEIRA","type":"district","scope_type":"administrative"}],"source":{"title":"Parque Industrial e Logístico — SDUBeira","url":"https://sdubeira.co.mz/project/parque-industrial-logistico/","source_type":"promoter","supports":"Project existence, location and reported development status."},"areas":[{"type":"total","value":900,"unit":"ha","status":"disputed","source_reference":"SDUBeira project page, total area scope needs confirmation"},{"type":"total","value":990,"unit":"ha","status":"disputed","source_reference":"SDUBeira project headline, conflicts with page summary"},{"type":"pilot","value":50,"unit":"ha","status":"reported","source_reference":"SDUBeira project page; not available-land confirmation"}]},
|
"name": "Parque Industrial de Topuito",
|
||||||
{"code":"MOZ-CDP-MONTEPUEZ","name":"Parque Industrial de Montepuez","category":"industrial_park","physical_category":"industrial_park","legal_regime":"pending","development_status":"planned","availability_status":"not_informed","territories":[{"name":"MONTEPUEZ","type":"district","scope_type":"administrative"}],"source":{"title":"MozParks — Cabo Delgado parks initiative","url":"https://mozparks.co.mz/mozparks-launches-cabo-delgado-parks/","source_type":"promoter","supports":"District association within a provincial parks initiative; not an operating facility claim."},"areas":[]},
|
"category": "industrial_park",
|
||||||
{"code":"MOZ-CDP-BALAMA","name":"Parque Industrial de Balama","category":"industrial_park","physical_category":"industrial_park","legal_regime":"pending","development_status":"planned","availability_status":"not_informed","territories":[{"name":"BALAMA","type":"district","scope_type":"administrative"}],"source":{"title":"MozParks — Cabo Delgado parks initiative","url":"https://mozparks.co.mz/mozparks-launches-cabo-delgado-parks/","source_type":"promoter","supports":"District association within a provincial parks initiative; not an operating facility claim."},"areas":[]},
|
"physical_category": "industrial_park",
|
||||||
{"code":"MOZ-CDP-ANCUABE","name":"Parque Industrial de Ancuabe","category":"industrial_park","physical_category":"industrial_park","legal_regime":"pending","development_status":"planned","availability_status":"not_informed","territories":[{"name":"ANCUABE","type":"district","scope_type":"administrative"}],"source":{"title":"MozParks — Cabo Delgado parks initiative","url":"https://mozparks.co.mz/mozparks-launches-cabo-delgado-parks/","source_type":"promoter","supports":"District association within a provincial parks initiative; not an operating facility claim."},"areas":[]},
|
"legal_regime": "pending",
|
||||||
{"code":"MOZ-CDP-PALMA","name":"Parque Industrial de Palma","category":"industrial_park","physical_category":"industrial_park","legal_regime":"pending","development_status":"planned","availability_status":"not_informed","territories":[{"name":"PALMA","type":"district","scope_type":"administrative"}],"source":{"title":"MozParks — Cabo Delgado parks initiative","url":"https://mozparks.co.mz/mozparks-launches-cabo-delgado-parks/","source_type":"promoter","supports":"District association within a provincial parks initiative; not an operating facility claim."},"areas":[]},
|
"development_status": "in_development",
|
||||||
{"code":"MOZ-REVUBUE-ZFI","name":"Zona Franca Industrial de Revúbuè","category":"zfi","physical_category":"industrial_free_zone","legal_regime":"zfi","development_status":"planned","availability_status":"not_informed","territories":[{"name":"CHIUTA","type":"district","scope_type":"legal_scope"},{"name":"MOATIZE","type":"district","scope_type":"legal_scope"}],"source":{"title":"Revúbuè Free Industrial Zone — APIEX","url":"https://apiex.gov.mz/revubue-free-industrial-zone/","source_type":"institutional","supports":"APIEX-reported identity, district scope and area; primary legal text pending."},"areas":[{"type":"legal","value":4456,"unit":"ha","status":"reported","source_reference":"APIEX page; confirm perimeter against Decreto 41/2016"}]},
|
"availability_status": "reported_unverified",
|
||||||
{"code":"MOZ-MINHEWENE-ZFI","name":"Zona Franca Industrial de Minhewene","category":"zfi","physical_category":"industrial_free_zone","legal_regime":"zfi","development_status":"planned","availability_status":"not_informed","territories":[{"name":"NAMPULA","type":"province","scope_type":"administrative"}],"source":{"title":"Zona Franca Industrial de Minhewene — APIEX","url":"https://apiex.gov.mz/zona-franca-industrial-de-minhewene/","source_type":"institutional","supports":"APIEX-reported identity, province and area; primary legal text and site precision pending."},"areas":[{"type":"legal","value":350,"unit":"ha","status":"reported","source_reference":"APIEX page; confirm perimeter against Decreto 51/2011"}]}
|
"territory_note": "The source names Topuito in Larde; the master dataset has no district row for Larde. This candidate is linked only at Nampula province until the territorial mapping is reviewed.",
|
||||||
|
"territories": [
|
||||||
|
{
|
||||||
|
"name": "NAMPULA",
|
||||||
|
"type": "province",
|
||||||
|
"scope_type": "administrative"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"title": "Construction begins on SME Village at Topuito Industrial Park",
|
||||||
|
"url": "https://mozparks.co.mz/construction-begins-on-sme-village-at-topuito-industrial-park/",
|
||||||
|
"source_type": "promoter",
|
||||||
|
"supports": "Project and development activity, not operational availability."
|
||||||
|
},
|
||||||
|
"areas": [
|
||||||
|
{
|
||||||
|
"type": "total",
|
||||||
|
"value": 215,
|
||||||
|
"unit": "ha",
|
||||||
|
"status": "disputed",
|
||||||
|
"source_reference": "MozParks brochure 2023, source scope to review"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "total",
|
||||||
|
"value": 200,
|
||||||
|
"unit": "ha",
|
||||||
|
"status": "disputed",
|
||||||
|
"source_reference": "MozParks brochure 2025, source scope to review"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "developed",
|
||||||
|
"value": 30,
|
||||||
|
"unit": "ha",
|
||||||
|
"status": "reported",
|
||||||
|
"source_reference": "MozParks brochure 2025; not a land availability statement"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "MOZ-TOPUITO-ZFI",
|
||||||
|
"name": "Zona Franca Industrial de Topuito",
|
||||||
|
"category": "zfi",
|
||||||
|
"physical_category": "industrial_free_zone",
|
||||||
|
"legal_regime": "zfi",
|
||||||
|
"development_status": "planned",
|
||||||
|
"availability_status": "not_informed",
|
||||||
|
"territory_note": "The decree names Topuito in Larde; the master dataset has no district row for Larde. This candidate is linked only at Nampula province until the territorial mapping is reviewed.",
|
||||||
|
"territories": [
|
||||||
|
{
|
||||||
|
"name": "NAMPULA",
|
||||||
|
"type": "province",
|
||||||
|
"scope_type": "administrative"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"title": "Decreto n.º 57/2023 — criação da ZFI de Topuito",
|
||||||
|
"url": "https://www.inm.gov.mz/pt-br/content/conselho-de-ministros-br-n%C2%BA-190-de-031023-boletim-da-rep%C3%BAblica-i-s%C3%A9rie-p%C3%A1g-2349",
|
||||||
|
"source_type": "government",
|
||||||
|
"supports": "Legal creation and reported legal area; primary review remains required."
|
||||||
|
},
|
||||||
|
"areas": [
|
||||||
|
{
|
||||||
|
"type": "legal",
|
||||||
|
"value": 65,
|
||||||
|
"unit": "ha",
|
||||||
|
"status": "reported",
|
||||||
|
"source_reference": "Decreto n.º 57/2023, artigo 1.º — confirm against retained official text"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "MOZ-MUNHAVA-PARK",
|
||||||
|
"name": "Parque Industrial e Logístico de Munhava",
|
||||||
|
"category": "industrial_park",
|
||||||
|
"physical_category": "industrial_logistics_park",
|
||||||
|
"legal_regime": "pending",
|
||||||
|
"development_status": "in_development",
|
||||||
|
"availability_status": "not_informed",
|
||||||
|
"territories": [
|
||||||
|
{
|
||||||
|
"name": "CIDADE DA BEIRA",
|
||||||
|
"type": "district",
|
||||||
|
"scope_type": "administrative"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"title": "Parque Industrial e Logístico — SDUBeira",
|
||||||
|
"url": "https://sdubeira.co.mz/project/parque-industrial-logistico/",
|
||||||
|
"source_type": "promoter",
|
||||||
|
"supports": "Project existence, location and reported development status."
|
||||||
|
},
|
||||||
|
"areas": [
|
||||||
|
{
|
||||||
|
"type": "total",
|
||||||
|
"value": 900,
|
||||||
|
"unit": "ha",
|
||||||
|
"status": "disputed",
|
||||||
|
"source_reference": "SDUBeira project page, total area scope needs confirmation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "total",
|
||||||
|
"value": 990,
|
||||||
|
"unit": "ha",
|
||||||
|
"status": "disputed",
|
||||||
|
"source_reference": "SDUBeira project headline, conflicts with page summary"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "pilot",
|
||||||
|
"value": 50,
|
||||||
|
"unit": "ha",
|
||||||
|
"status": "reported",
|
||||||
|
"source_reference": "SDUBeira project page; not available-land confirmation"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "MOZ-CDP-MONTEPUEZ",
|
||||||
|
"name": "Parque Industrial de Montepuez",
|
||||||
|
"category": "industrial_park",
|
||||||
|
"physical_category": "industrial_park",
|
||||||
|
"legal_regime": "pending",
|
||||||
|
"development_status": "planned",
|
||||||
|
"availability_status": "not_informed",
|
||||||
|
"territories": [
|
||||||
|
{
|
||||||
|
"name": "MONTEPUEZ",
|
||||||
|
"type": "district",
|
||||||
|
"scope_type": "administrative"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"title": "MozParks — Cabo Delgado parks initiative",
|
||||||
|
"url": "https://mozparks.co.mz/mozparks-launches-cabo-delgado-parks/",
|
||||||
|
"source_type": "promoter",
|
||||||
|
"supports": "District association within a provincial parks initiative; not an operating facility claim."
|
||||||
|
},
|
||||||
|
"areas": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "MOZ-CDP-BALAMA",
|
||||||
|
"name": "Parque Industrial de Balama",
|
||||||
|
"category": "industrial_park",
|
||||||
|
"physical_category": "industrial_park",
|
||||||
|
"legal_regime": "pending",
|
||||||
|
"development_status": "planned",
|
||||||
|
"availability_status": "not_informed",
|
||||||
|
"territories": [
|
||||||
|
{
|
||||||
|
"name": "BALAMA",
|
||||||
|
"type": "district",
|
||||||
|
"scope_type": "administrative"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"title": "MozParks — Cabo Delgado parks initiative",
|
||||||
|
"url": "https://mozparks.co.mz/mozparks-launches-cabo-delgado-parks/",
|
||||||
|
"source_type": "promoter",
|
||||||
|
"supports": "District association within a provincial parks initiative; not an operating facility claim."
|
||||||
|
},
|
||||||
|
"areas": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "MOZ-CDP-ANCUABE",
|
||||||
|
"name": "Parque Industrial de Ancuabe",
|
||||||
|
"category": "industrial_park",
|
||||||
|
"physical_category": "industrial_park",
|
||||||
|
"legal_regime": "pending",
|
||||||
|
"development_status": "planned",
|
||||||
|
"availability_status": "not_informed",
|
||||||
|
"territories": [
|
||||||
|
{
|
||||||
|
"name": "ANCUABE",
|
||||||
|
"type": "district",
|
||||||
|
"scope_type": "administrative"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"title": "MozParks — Cabo Delgado parks initiative",
|
||||||
|
"url": "https://mozparks.co.mz/mozparks-launches-cabo-delgado-parks/",
|
||||||
|
"source_type": "promoter",
|
||||||
|
"supports": "District association within a provincial parks initiative; not an operating facility claim."
|
||||||
|
},
|
||||||
|
"areas": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "MOZ-CDP-PALMA",
|
||||||
|
"name": "Parque Industrial de Palma",
|
||||||
|
"category": "industrial_park",
|
||||||
|
"physical_category": "industrial_park",
|
||||||
|
"legal_regime": "pending",
|
||||||
|
"development_status": "planned",
|
||||||
|
"availability_status": "not_informed",
|
||||||
|
"territories": [
|
||||||
|
{
|
||||||
|
"name": "PALMA",
|
||||||
|
"type": "district",
|
||||||
|
"scope_type": "administrative"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"title": "MozParks — Cabo Delgado parks initiative",
|
||||||
|
"url": "https://mozparks.co.mz/mozparks-launches-cabo-delgado-parks/",
|
||||||
|
"source_type": "promoter",
|
||||||
|
"supports": "District association within a provincial parks initiative; not an operating facility claim."
|
||||||
|
},
|
||||||
|
"areas": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "MOZ-REVUBUE-ZFI",
|
||||||
|
"name": "Zona Franca Industrial de Revúbuè",
|
||||||
|
"category": "zfi",
|
||||||
|
"physical_category": "industrial_free_zone",
|
||||||
|
"legal_regime": "zfi",
|
||||||
|
"development_status": "planned",
|
||||||
|
"availability_status": "not_informed",
|
||||||
|
"territories": [
|
||||||
|
{
|
||||||
|
"name": "CHIUTA",
|
||||||
|
"type": "district",
|
||||||
|
"scope_type": "legal_scope"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "MOATIZE",
|
||||||
|
"type": "district",
|
||||||
|
"scope_type": "legal_scope"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"title": "Revúbuè Free Industrial Zone — APIEX",
|
||||||
|
"url": "https://apiex.gov.mz/revubue-free-industrial-zone/",
|
||||||
|
"source_type": "institutional",
|
||||||
|
"supports": "APIEX-reported identity, district scope and area; primary legal text pending."
|
||||||
|
},
|
||||||
|
"areas": [
|
||||||
|
{
|
||||||
|
"type": "legal",
|
||||||
|
"value": 4456,
|
||||||
|
"unit": "ha",
|
||||||
|
"status": "reported",
|
||||||
|
"source_reference": "APIEX page; confirm perimeter against Decreto 41/2016"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "MOZ-MINHEWENE-ZFI",
|
||||||
|
"name": "Zona Franca Industrial de Minhewene",
|
||||||
|
"category": "zfi",
|
||||||
|
"physical_category": "industrial_free_zone",
|
||||||
|
"legal_regime": "zfi",
|
||||||
|
"development_status": "planned",
|
||||||
|
"availability_status": "not_informed",
|
||||||
|
"territories": [
|
||||||
|
{
|
||||||
|
"name": "NAMPULA",
|
||||||
|
"type": "province",
|
||||||
|
"scope_type": "administrative"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"title": "Zona Franca Industrial de Minhewene — APIEX",
|
||||||
|
"url": "https://apiex.gov.mz/zona-franca-industrial-de-minhewene/",
|
||||||
|
"source_type": "institutional",
|
||||||
|
"supports": "APIEX-reported identity, province and area; primary legal text and site precision pending."
|
||||||
|
},
|
||||||
|
"areas": [
|
||||||
|
{
|
||||||
|
"type": "legal",
|
||||||
|
"value": 350,
|
||||||
|
"unit": "ha",
|
||||||
|
"status": "reported",
|
||||||
|
"source_reference": "APIEX page; confirm perimeter against Decreto 51/2011"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,10 +11,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Beluluane",
|
"name": "Beluluane",
|
||||||
"outcome": "reconcile_existing",
|
"outcome": "reconcile_existing",
|
||||||
"prepared_codes": [
|
"prepared_codes": ["MOZ-BELULUANE-PARK", "MOZ-BELULUANE-ZFI"],
|
||||||
"MOZ-BELULUANE-PARK",
|
|
||||||
"MOZ-BELULUANE-ZFI"
|
|
||||||
],
|
|
||||||
"source": "https://apiex.gov.mz/beluluane-industrial-park-free-zone/",
|
"source": "https://apiex.gov.mz/beluluane-industrial-park-free-zone/",
|
||||||
"known": "MozParks apresenta 700 ha prontos para arrendamento; APIEX apresenta complexo de cerca de 780 ha: parque 600 ha, Mozal 180 ha e ZFI 55 ha. So mbitos que no podem ser somados nem equiparados a disponibilidade.",
|
"known": "MozParks apresenta 700 ha prontos para arrendamento; APIEX apresenta complexo de cerca de 780 ha: parque 600 ha, Mozal 180 ha e ZFI 55 ha. So mbitos que no podem ser somados nem equiparados a disponibilidade.",
|
||||||
"pending": "Confirmar limites e sobreposio cartogrfica/documental, sobretudo relao entre 700 ha e parque de 600 ha. No publicar actividades como autorizadas nem declarar lotes disponveis.",
|
"pending": "Confirmar limites e sobreposio cartogrfica/documental, sobretudo relao entre 700 ha e parque de 600 ha. No publicar actividades como autorizadas nem declarar lotes disponveis.",
|
||||||
@@ -32,10 +29,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Topuito",
|
"name": "Topuito",
|
||||||
"outcome": "prepare_separate_park_and_zfi",
|
"outcome": "prepare_separate_park_and_zfi",
|
||||||
"prepared_codes": [
|
"prepared_codes": ["MOZ-TOPUITO-PARK", "MOZ-TOPUITO-ZFI"],
|
||||||
"MOZ-TOPUITO-PARK",
|
|
||||||
"MOZ-TOPUITO-ZFI"
|
|
||||||
],
|
|
||||||
"source": "https://www.inm.gov.mz/pt-br/content/conselho-de-ministros-br-n%C2%BA-190-de-031023-boletim-da-rep%C3%BAblica-i-s%C3%A9rie-p%C3%A1g-2349",
|
"source": "https://www.inm.gov.mz/pt-br/content/conselho-de-ministros-br-n%C2%BA-190-de-031023-boletim-da-rep%C3%BAblica-i-s%C3%A9rie-p%C3%A1g-2349",
|
||||||
"known": "MozParks apresenta Topuito como parque e oferta de 215 ha; notcia de Agosto de 2026 confirma incio da construo do SME Village. Decreto 57/2023 cria separadamente ZFI com rea legal de 65 ha.",
|
"known": "MozParks apresenta Topuito como parque e oferta de 215 ha; notcia de Agosto de 2026 confirma incio da construo do SME Village. Decreto 57/2023 cria separadamente ZFI com rea legal de 65 ha.",
|
||||||
"pending": "O parque, a obra do SME Village e a ZFI so escopos distintos. Verificar limites, operao e disponibilidade actual. Base territorial no contm distrito Larde; manter associao apenas provincial at reviso.",
|
"pending": "O parque, a obra do SME Village e a ZFI so escopos distintos. Verificar limites, operao e disponibilidade actual. Base territorial no contm distrito Larde; manter associao apenas provincial at reviso.",
|
||||||
@@ -53,9 +47,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Munhava",
|
"name": "Munhava",
|
||||||
"outcome": "prepare_informational_candidate",
|
"outcome": "prepare_informational_candidate",
|
||||||
"prepared_codes": [
|
"prepared_codes": ["MOZ-MUNHAVA-PARK"],
|
||||||
"MOZ-MUNHAVA-PARK"
|
|
||||||
],
|
|
||||||
"source": "https://sdubeira.co.mz/project/parque-industrial-logistico/",
|
"source": "https://sdubeira.co.mz/project/parque-industrial-logistico/",
|
||||||
"known": "SDUBeira descreve o projecto em fases, rea total de 900 ha no resumo e piloto de 50 ha; o destaque de 990 ha na mesma pgina cria divergncia.",
|
"known": "SDUBeira descreve o projecto em fases, rea total de 900 ha no resumo e piloto de 50 ha; o destaque de 990 ha na mesma pgina cria divergncia.",
|
||||||
"pending": "Documento de entrada acrescenta faixa aproximada de 44-60 ha para piloto; no corresponde a metragem confirmada. Obter permetro/plano primrio e no declarar terreno disponvel.",
|
"pending": "Documento de entrada acrescenta faixa aproximada de 44-60 ha para piloto; no corresponde a metragem confirmada. Obter permetro/plano primrio e no declarar terreno disponvel.",
|
||||||
@@ -73,9 +65,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Montepuez",
|
"name": "Montepuez",
|
||||||
"outcome": "prepare_district_candidate",
|
"outcome": "prepare_district_candidate",
|
||||||
"prepared_codes": [
|
"prepared_codes": ["MOZ-CDP-MONTEPUEZ"],
|
||||||
"MOZ-CDP-MONTEPUEZ"
|
|
||||||
],
|
|
||||||
"source": "https://mozparks.co.mz/mozparks-launches-cabo-delgado-parks/",
|
"source": "https://mozparks.co.mz/mozparks-launches-cabo-delgado-parks/",
|
||||||
"known": "A iniciativa MozParks menciona parque/rede de Cabo Delgado no distrito de Montepuez. MozParks confirma a rede/parques em desenvolvimento; actividades do documento so apenas enfoque promocional.",
|
"known": "A iniciativa MozParks menciona parque/rede de Cabo Delgado no distrito de Montepuez. MozParks confirma a rede/parques em desenvolvimento; actividades do documento so apenas enfoque promocional.",
|
||||||
"pending": "Regime jurdico, reas, actividades efectivamente autorizadas/instaladas e disponibilidade permanecem por confirmar.",
|
"pending": "Regime jurdico, reas, actividades efectivamente autorizadas/instaladas e disponibilidade permanecem por confirmar.",
|
||||||
@@ -93,9 +83,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Balama",
|
"name": "Balama",
|
||||||
"outcome": "prepare_district_candidate",
|
"outcome": "prepare_district_candidate",
|
||||||
"prepared_codes": [
|
"prepared_codes": ["MOZ-CDP-BALAMA"],
|
||||||
"MOZ-CDP-BALAMA"
|
|
||||||
],
|
|
||||||
"source": "https://mozparks.co.mz/mozparks-launches-cabo-delgado-parks/",
|
"source": "https://mozparks.co.mz/mozparks-launches-cabo-delgado-parks/",
|
||||||
"known": "A iniciativa MozParks menciona parque/rede de Cabo Delgado no distrito de Balama. MozParks confirma a rede/parques em desenvolvimento; actividades do documento so apenas enfoque promocional.",
|
"known": "A iniciativa MozParks menciona parque/rede de Cabo Delgado no distrito de Balama. MozParks confirma a rede/parques em desenvolvimento; actividades do documento so apenas enfoque promocional.",
|
||||||
"pending": "Regime jurdico, reas, actividades efectivamente autorizadas/instaladas e disponibilidade permanecem por confirmar.",
|
"pending": "Regime jurdico, reas, actividades efectivamente autorizadas/instaladas e disponibilidade permanecem por confirmar.",
|
||||||
@@ -113,9 +101,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Ancuabe",
|
"name": "Ancuabe",
|
||||||
"outcome": "prepare_district_candidate",
|
"outcome": "prepare_district_candidate",
|
||||||
"prepared_codes": [
|
"prepared_codes": ["MOZ-CDP-ANCUABE"],
|
||||||
"MOZ-CDP-ANCUABE"
|
|
||||||
],
|
|
||||||
"source": "https://mozparks.co.mz/mozparks-launches-cabo-delgado-parks/",
|
"source": "https://mozparks.co.mz/mozparks-launches-cabo-delgado-parks/",
|
||||||
"known": "A iniciativa MozParks menciona parque/rede de Cabo Delgado no distrito de Ancuabe. MozParks confirma a rede/parques em desenvolvimento; actividades do documento so apenas enfoque promocional.",
|
"known": "A iniciativa MozParks menciona parque/rede de Cabo Delgado no distrito de Ancuabe. MozParks confirma a rede/parques em desenvolvimento; actividades do documento so apenas enfoque promocional.",
|
||||||
"pending": "Regime jurdico, reas, actividades efectivamente autorizadas/instaladas e disponibilidade permanecem por confirmar.",
|
"pending": "Regime jurdico, reas, actividades efectivamente autorizadas/instaladas e disponibilidade permanecem por confirmar.",
|
||||||
@@ -133,9 +119,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Palma",
|
"name": "Palma",
|
||||||
"outcome": "prepare_district_candidate",
|
"outcome": "prepare_district_candidate",
|
||||||
"prepared_codes": [
|
"prepared_codes": ["MOZ-CDP-PALMA"],
|
||||||
"MOZ-CDP-PALMA"
|
|
||||||
],
|
|
||||||
"source": "https://mozparks.co.mz/mozparks-launches-cabo-delgado-parks/",
|
"source": "https://mozparks.co.mz/mozparks-launches-cabo-delgado-parks/",
|
||||||
"known": "A iniciativa MozParks menciona parque/rede de Cabo Delgado no distrito de Palma. MozParks confirma a rede/parques em desenvolvimento; actividades do documento so apenas enfoque promocional.",
|
"known": "A iniciativa MozParks menciona parque/rede de Cabo Delgado no distrito de Palma. MozParks confirma a rede/parques em desenvolvimento; actividades do documento so apenas enfoque promocional.",
|
||||||
"pending": "Regime jurdico, reas, actividades efectivamente autorizadas/instaladas e disponibilidade permanecem por confirmar.",
|
"pending": "Regime jurdico, reas, actividades efectivamente autorizadas/instaladas e disponibilidade permanecem por confirmar.",
|
||||||
@@ -171,10 +155,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Mocuba ZFI",
|
"name": "Mocuba ZFI",
|
||||||
"outcome": "reconcile_existing",
|
"outcome": "reconcile_existing",
|
||||||
"prepared_codes": [
|
"prepared_codes": ["MOZ-MOCUBA-ZFI", "MOZ-MOCUBA-ZEE"],
|
||||||
"MOZ-MOCUBA-ZFI",
|
|
||||||
"MOZ-MOCUBA-ZEE"
|
|
||||||
],
|
|
||||||
"source": "https://apiex.gov.mz/zif/mocuba-free-industrial-zone/",
|
"source": "https://apiex.gov.mz/zif/mocuba-free-industrial-zone/",
|
||||||
"known": "APIEX confirma a ZFI de 50,58 ha e fase de mobilizao de recursos e operador. A lista de actividades do documento enfoque declarado, no autorizao.",
|
"known": "APIEX confirma a ZFI de 50,58 ha e fase de mobilizao de recursos e operador. A lista de actividades do documento enfoque declarado, no autorizao.",
|
||||||
"pending": "Confirmar diploma primrio, limites e actividades; manter ZFI e ZEE de Mocuba separadas.",
|
"pending": "Confirmar diploma primrio, limites e actividades; manter ZFI e ZEE de Mocuba separadas.",
|
||||||
@@ -193,9 +174,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Revúbuè ZFI",
|
"name": "Revúbuè ZFI",
|
||||||
"outcome": "prepare_one_record_two_districts",
|
"outcome": "prepare_one_record_two_districts",
|
||||||
"prepared_codes": [
|
"prepared_codes": ["MOZ-REVUBUE-ZFI"],
|
||||||
"MOZ-REVUBUE-ZFI"
|
|
||||||
],
|
|
||||||
"source": "https://apiex.gov.mz/revubue-free-industrial-zone/",
|
"source": "https://apiex.gov.mz/revubue-free-industrial-zone/",
|
||||||
"known": "APIEX reporta a ZFI abrangendo Chiuta e Moatize, 4.456 ha, sem operador identificado.",
|
"known": "APIEX reporta a ZFI abrangendo Chiuta e Moatize, 4.456 ha, sem operador identificado.",
|
||||||
"pending": "Obter e validar texto primário do Decreto 41/2016 e as relações territoriais. Um único registo, duas localizações.",
|
"pending": "Obter e validar texto primário do Decreto 41/2016 e as relações territoriais. Um único registo, duas localizações.",
|
||||||
@@ -214,9 +193,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Minhewene ZFI",
|
"name": "Minhewene ZFI",
|
||||||
"outcome": "prepare_province_precision_candidate",
|
"outcome": "prepare_province_precision_candidate",
|
||||||
"prepared_codes": [
|
"prepared_codes": ["MOZ-MINHEWENE-ZFI"],
|
||||||
"MOZ-MINHEWENE-ZFI"
|
|
||||||
],
|
|
||||||
"source": "https://apiex.gov.mz/zona-franca-industrial-de-minhewene/",
|
"source": "https://apiex.gov.mz/zona-franca-industrial-de-minhewene/",
|
||||||
"known": "Pgina APIEX actualmente acessvel reporta Decreto 51/2011, Nampula/Cidade de Nacala, 350 ha e mobilizao de recursos/operador. O documento fornecido diz que a ficha no estava acessvel; esta afirmao diverge da consulta actual.",
|
"known": "Pgina APIEX actualmente acessvel reporta Decreto 51/2011, Nampula/Cidade de Nacala, 350 ha e mobilizao de recursos/operador. O documento fornecido diz que a ficha no estava acessvel; esta afirmao diverge da consulta actual.",
|
||||||
"pending": "Validar Decreto 51/2011 e localizao cadastral exacta; pgina institucional no substitui fonte legal primria nem comprova operacionalizao actual.",
|
"pending": "Validar Decreto 51/2011 e localizao cadastral exacta; pgina institucional no substitui fonte legal primria nem comprova operacionalizao actual.",
|
||||||
|
|||||||
@@ -1,16 +1,125 @@
|
|||||||
{
|
{
|
||||||
"need_category": {"labour_required":"Mão de obra necessária","labour_available":"Mão de obra disponível","infrastructure_existing":"Infraestruturas existentes","infrastructure_required":"Infraestruturas necessárias","education":"Educação e formação","support":"Apoios"},
|
"need_category": {
|
||||||
"infrastructure": {"energy":"Energia","water":"Água","sanitation":"Saneamento","telecom":"Telecomunicações","internet":"Internet","road":"Estrada","rail":"Ferrovia","port":"Porto","airport":"Aeroporto","storage":"Armazenagem","cold_chain":"Cadeia de frio","housing":"Habitação","health":"Saúde","education":"Educação","security":"Segurança","industrial":"Instalações industriais","office":"Escritórios","land":"Terrenos","logistics":"Serviços logísticos"},
|
"labour_required": "Mão de obra necessária",
|
||||||
"education": {"preschool":"Educação pré-escolar","primary":"Ensino primário","secondary":"Ensino secundário","vocational":"Formação técnico-profissional","higher":"Ensino superior","research":"Investigação","innovation":"Centros de inovação","incubation":"Incubadoras","laboratory":"Laboratórios","edtech":"Tecnologia educativa","digital":"Plataformas digitais","connectivity":"Conectividade","buildings":"Infraestruturas escolares","equipment":"Equipamentos","library":"Bibliotecas","residence":"Alojamento","meals":"Alimentação escolar","transport":"Transporte","content":"Produção de conteúdos","teachers":"Formação de professores","skills":"Desenvolvimento de competências","continuing":"Formação contínua"},
|
"labour_available": "Mão de obra disponível",
|
||||||
"labour": {"technical":"Pessoal técnico","professional":"Profissionais especializados","operational":"Pessoal operacional","management":"Gestão","training":"Formadores"},
|
"infrastructure_existing": "Infraestruturas existentes",
|
||||||
"qualification": {"primary":"Ensino primário","secondary":"Ensino secundário","technical":"Qualificação técnica","higher":"Ensino superior","postgraduate":"Pós-graduação"},
|
"infrastructure_required": "Infraestruturas necessárias",
|
||||||
"support": {"licence":"Licenças","incentives":"Incentivos","finance":"Financiamento","land":"Terra","logistics":"Logística","partners":"Parceiros","suppliers":"Fornecedores","recruitment":"Contratação","imports":"Importação","exports":"Exportação","installation":"Instalação","utilities":"Ligação a serviços públicos"},
|
"education": "Educação e formação",
|
||||||
|
"support": "Apoios"
|
||||||
|
},
|
||||||
|
"infrastructure": {
|
||||||
|
"energy": "Energia",
|
||||||
|
"water": "Água",
|
||||||
|
"sanitation": "Saneamento",
|
||||||
|
"telecom": "Telecomunicações",
|
||||||
|
"internet": "Internet",
|
||||||
|
"road": "Estrada",
|
||||||
|
"rail": "Ferrovia",
|
||||||
|
"port": "Porto",
|
||||||
|
"airport": "Aeroporto",
|
||||||
|
"storage": "Armazenagem",
|
||||||
|
"cold_chain": "Cadeia de frio",
|
||||||
|
"housing": "Habitação",
|
||||||
|
"health": "Saúde",
|
||||||
|
"education": "Educação",
|
||||||
|
"security": "Segurança",
|
||||||
|
"industrial": "Instalações industriais",
|
||||||
|
"office": "Escritórios",
|
||||||
|
"land": "Terrenos",
|
||||||
|
"logistics": "Serviços logísticos"
|
||||||
|
},
|
||||||
|
"education": {
|
||||||
|
"preschool": "Educação pré-escolar",
|
||||||
|
"primary": "Ensino primário",
|
||||||
|
"secondary": "Ensino secundário",
|
||||||
|
"vocational": "Formação técnico-profissional",
|
||||||
|
"higher": "Ensino superior",
|
||||||
|
"research": "Investigação",
|
||||||
|
"innovation": "Centros de inovação",
|
||||||
|
"incubation": "Incubadoras",
|
||||||
|
"laboratory": "Laboratórios",
|
||||||
|
"edtech": "Tecnologia educativa",
|
||||||
|
"digital": "Plataformas digitais",
|
||||||
|
"connectivity": "Conectividade",
|
||||||
|
"buildings": "Infraestruturas escolares",
|
||||||
|
"equipment": "Equipamentos",
|
||||||
|
"library": "Bibliotecas",
|
||||||
|
"residence": "Alojamento",
|
||||||
|
"meals": "Alimentação escolar",
|
||||||
|
"transport": "Transporte",
|
||||||
|
"content": "Produção de conteúdos",
|
||||||
|
"teachers": "Formação de professores",
|
||||||
|
"skills": "Desenvolvimento de competências",
|
||||||
|
"continuing": "Formação contínua"
|
||||||
|
},
|
||||||
|
"labour": {
|
||||||
|
"technical": "Pessoal técnico",
|
||||||
|
"professional": "Profissionais especializados",
|
||||||
|
"operational": "Pessoal operacional",
|
||||||
|
"management": "Gestão",
|
||||||
|
"training": "Formadores"
|
||||||
|
},
|
||||||
|
"qualification": {
|
||||||
|
"primary": "Ensino primário",
|
||||||
|
"secondary": "Ensino secundário",
|
||||||
|
"technical": "Qualificação técnica",
|
||||||
|
"higher": "Ensino superior",
|
||||||
|
"postgraduate": "Pós-graduação"
|
||||||
|
},
|
||||||
|
"support": {
|
||||||
|
"licence": "Licenças",
|
||||||
|
"incentives": "Incentivos",
|
||||||
|
"finance": "Financiamento",
|
||||||
|
"land": "Terra",
|
||||||
|
"logistics": "Logística",
|
||||||
|
"partners": "Parceiros",
|
||||||
|
"suppliers": "Fornecedores",
|
||||||
|
"recruitment": "Contratação",
|
||||||
|
"imports": "Importação",
|
||||||
|
"exports": "Exportação",
|
||||||
|
"installation": "Instalação",
|
||||||
|
"utilities": "Ligação a serviços públicos"
|
||||||
|
},
|
||||||
"priority": { "low": "Baixa", "normal": "Normal", "high": "Alta" },
|
"priority": { "low": "Baixa", "normal": "Normal", "high": "Alta" },
|
||||||
"unit": {"people":"Pessoas","units":"Unidades","mw":"MW","m3_day":"m³/dia","km":"km","hectares":"Hectares"},
|
"unit": {
|
||||||
"participation": {"invest":"Investir","finance":"Financiar","supply":"Fornecer","operate":"Operar","partner":"Estabelecer parceria"},
|
"people": "Pessoas",
|
||||||
"partnership": {"direct":"Investimento directo","joint_venture":"Joint venture","ppp":"Parceria público-privada","supply":"Fornecimento","technical":"Cooperação técnica"},
|
"units": "Unidades",
|
||||||
"investor_profile": {"individual":"Individual","company":"Empresa","fund":"Fundo","public":"Entidade pública"},
|
"mw": "MW",
|
||||||
"impact": {"employment":"Emprego","training":"Competências","local_supply":"Fornecimento local","environment":"Ambiente","exports":"Exportações"},
|
"m3_day": "m³/dia",
|
||||||
|
"km": "km",
|
||||||
|
"hectares": "Hectares"
|
||||||
|
},
|
||||||
|
"participation": {
|
||||||
|
"invest": "Investir",
|
||||||
|
"finance": "Financiar",
|
||||||
|
"supply": "Fornecer",
|
||||||
|
"operate": "Operar",
|
||||||
|
"partner": "Estabelecer parceria"
|
||||||
|
},
|
||||||
|
"partnership": {
|
||||||
|
"direct": "Investimento directo",
|
||||||
|
"joint_venture": "Joint venture",
|
||||||
|
"ppp": "Parceria público-privada",
|
||||||
|
"supply": "Fornecimento",
|
||||||
|
"technical": "Cooperação técnica"
|
||||||
|
},
|
||||||
|
"investor_profile": {
|
||||||
|
"individual": "Individual",
|
||||||
|
"company": "Empresa",
|
||||||
|
"fund": "Fundo",
|
||||||
|
"public": "Entidade pública"
|
||||||
|
},
|
||||||
|
"impact": {
|
||||||
|
"employment": "Emprego",
|
||||||
|
"training": "Competências",
|
||||||
|
"local_supply": "Fornecimento local",
|
||||||
|
"environment": "Ambiente",
|
||||||
|
"exports": "Exportações"
|
||||||
|
},
|
||||||
"subsector": {},
|
"subsector": {},
|
||||||
"need_status": {"declared":"Declarada","available":"Disponível segundo declaração","required":"Necessária"}
|
"need_status": {
|
||||||
|
"declared": "Declarada",
|
||||||
|
"available": "Disponível segundo declaração",
|
||||||
|
"required": "Necessária"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,19 +13,72 @@
|
|||||||
"area_value": null,
|
"area_value": null,
|
||||||
"area_unit": null,
|
"area_unit": null,
|
||||||
"area_components": [
|
"area_components": [
|
||||||
{"type":"total","value":780,"unit":"ha","status":"disputed","source_reference":"https://apiex.gov.mz/beluluane-industrial-park-free-zone/ — APIEX reports the complex; scope and overlap need confirmation","source_date":null},
|
{
|
||||||
{"type":"total","value":700,"unit":"ha","status":"disputed","source_reference":"Document cited in the integration prompt was not attached; claim retained as unresolved, not imported as verified data","source_date":null},
|
"type": "total",
|
||||||
{"type":"developed","value":600,"unit":"ha","status":"reported","source_reference":"https://apiex.gov.mz/beluluane-industrial-park-free-zone/ — APIEX describes the industrial park component","source_date":null},
|
"value": 780,
|
||||||
{"type":"developed","value":180,"unit":"ha","status":"reported","source_reference":"https://apiex.gov.mz/beluluane-industrial-park-free-zone/ — APIEX describes the Mozal site component; do not add as available land","source_date":null},
|
"unit": "ha",
|
||||||
{"type":"legal","value":55,"unit":"ha","status":"reported","source_reference":"https://apiex.gov.mz/beluluane-industrial-park-free-zone/ — separate ZFI component; do not merge with park","source_date":null}
|
"status": "disputed",
|
||||||
|
"source_reference": "https://apiex.gov.mz/beluluane-industrial-park-free-zone/ — APIEX reports the complex; scope and overlap need confirmation",
|
||||||
|
"source_date": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "total",
|
||||||
|
"value": 700,
|
||||||
|
"unit": "ha",
|
||||||
|
"status": "disputed",
|
||||||
|
"source_reference": "Document cited in the integration prompt was not attached; claim retained as unresolved, not imported as verified data",
|
||||||
|
"source_date": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "developed",
|
||||||
|
"value": 600,
|
||||||
|
"unit": "ha",
|
||||||
|
"status": "reported",
|
||||||
|
"source_reference": "https://apiex.gov.mz/beluluane-industrial-park-free-zone/ — APIEX describes the industrial park component",
|
||||||
|
"source_date": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "developed",
|
||||||
|
"value": 180,
|
||||||
|
"unit": "ha",
|
||||||
|
"status": "reported",
|
||||||
|
"source_reference": "https://apiex.gov.mz/beluluane-industrial-park-free-zone/ — APIEX describes the Mozal site component; do not add as available land",
|
||||||
|
"source_date": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "legal",
|
||||||
|
"value": 55,
|
||||||
|
"unit": "ha",
|
||||||
|
"status": "reported",
|
||||||
|
"source_reference": "https://apiex.gov.mz/beluluane-industrial-park-free-zone/ — separate ZFI component; do not merge with park",
|
||||||
|
"source_date": null
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"description": "A APIEX apresenta aproximadamente 780 ha para o conjunto referido como Parque Industrial de Beluluane–Zona Franca, incluindo componentes com perímetros distintos. O valor não representa área livre ou disponível. A fonte identifica historicamente Matola-Rio, Boane, Província de Maputo. Situação operacional e área disponível não confirmadas por esta referência.",
|
"description": "A APIEX apresenta aproximadamente 780 ha para o conjunto referido como Parque Industrial de Beluluane–Zona Franca, incluindo componentes com perímetros distintos. O valor não representa área livre ou disponível. A fonte identifica historicamente Matola-Rio, Boane, Província de Maputo. Situação operacional e área disponível não confirmadas por esta referência.",
|
||||||
"description_en": "APIEX reports approximately 780 ha for the Beluluane Industrial Park–Free Zone complex, including distinct components. This is not an available-land figure. The source historically identifies Matola-Rio, Boane, Maputo Province. Operational status and available area are not confirmed by this reference.",
|
"description_en": "APIEX reports approximately 780 ha for the Beluluane Industrial Park–Free Zone complex, including distinct components. This is not an available-land figure. The source historically identifies Matola-Rio, Boane, Maputo Province. Operational status and available area are not confirmed by this reference.",
|
||||||
"aliases": ["PIB-ZF", "Parque Industrial de Beluluane–Zona Franca"],
|
"aliases": ["PIB-ZF", "Parque Industrial de Beluluane–Zona Franca"],
|
||||||
"activities": [],
|
"activities": [],
|
||||||
"historical_territory": {"name": "Matola-Rio", "district": "Boane", "province": "Maputo", "source_reference": "APIEX page; current territorial equivalence requires review"},
|
"historical_territory": {
|
||||||
"source": {"title": "Beluluane Industrial Park – Free Zone", "url": "https://apiex.gov.mz/beluluane-industrial-park-free-zone/", "diploma": "Resolução Interna do Conselho de Ministros n.º 15/99, de 12 de Outubro", "article": "Act of creation; article and current legal effect pending review", "valid_from": "1999-10-12", "competent_entity": "Conselho de Ministros / APIEX source page"},
|
"name": "Matola-Rio",
|
||||||
"territories": [{"name": "MATOLA RIO", "type": "admin_post", "scope_type": "administrative"}]
|
"district": "Boane",
|
||||||
|
"province": "Maputo",
|
||||||
|
"source_reference": "APIEX page; current territorial equivalence requires review"
|
||||||
|
},
|
||||||
|
"source": {
|
||||||
|
"title": "Beluluane Industrial Park – Free Zone",
|
||||||
|
"url": "https://apiex.gov.mz/beluluane-industrial-park-free-zone/",
|
||||||
|
"diploma": "Resolução Interna do Conselho de Ministros n.º 15/99, de 12 de Outubro",
|
||||||
|
"article": "Act of creation; article and current legal effect pending review",
|
||||||
|
"valid_from": "1999-10-12",
|
||||||
|
"competent_entity": "Conselho de Ministros / APIEX source page"
|
||||||
|
},
|
||||||
|
"territories": [
|
||||||
|
{
|
||||||
|
"name": "MATOLA RIO",
|
||||||
|
"type": "admin_post",
|
||||||
|
"scope_type": "administrative"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"code": "MOZ-BELULUANE-ZFI",
|
"code": "MOZ-BELULUANE-ZFI",
|
||||||
@@ -42,9 +95,27 @@
|
|||||||
"aliases": ["Beluluane IFZ"],
|
"aliases": ["Beluluane IFZ"],
|
||||||
"activities": [],
|
"activities": [],
|
||||||
"parent_code": "MOZ-BELULUANE-PARK",
|
"parent_code": "MOZ-BELULUANE-PARK",
|
||||||
"historical_territory": {"name": "Matola-Rio", "district": "Boane", "province": "Maputo", "source_reference": "APIEX page; current territorial equivalence requires review"},
|
"historical_territory": {
|
||||||
"source": {"title": "Beluluane Industrial Park – Free Zone", "url": "https://apiex.gov.mz/beluluane-industrial-park-free-zone/", "diploma": "Resolução Interna do Conselho de Ministros n.º 15/99, de 12 de Outubro", "article": "Act of creation; article and current legal effect pending review", "valid_from": "1999-10-12", "competent_entity": "Conselho de Ministros / APIEX source page"},
|
"name": "Matola-Rio",
|
||||||
"territories": [{"name": "MATOLA RIO", "type": "admin_post", "scope_type": "administrative"}]
|
"district": "Boane",
|
||||||
|
"province": "Maputo",
|
||||||
|
"source_reference": "APIEX page; current territorial equivalence requires review"
|
||||||
|
},
|
||||||
|
"source": {
|
||||||
|
"title": "Beluluane Industrial Park – Free Zone",
|
||||||
|
"url": "https://apiex.gov.mz/beluluane-industrial-park-free-zone/",
|
||||||
|
"diploma": "Resolução Interna do Conselho de Ministros n.º 15/99, de 12 de Outubro",
|
||||||
|
"article": "Act of creation; article and current legal effect pending review",
|
||||||
|
"valid_from": "1999-10-12",
|
||||||
|
"competent_entity": "Conselho de Ministros / APIEX source page"
|
||||||
|
},
|
||||||
|
"territories": [
|
||||||
|
{
|
||||||
|
"name": "MATOLA RIO",
|
||||||
|
"type": "admin_post",
|
||||||
|
"scope_type": "administrative"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"code": "MOZ-CRUSSE-JAMALI-ZEE",
|
"code": "MOZ-CRUSSE-JAMALI-ZEE",
|
||||||
@@ -59,9 +130,28 @@
|
|||||||
"description": "Criada em regime de ZEE pelo Decreto n.º 47/2013, de 30 de Agosto. A fonte oficial indica 1.750 ha no Posto Administrativo de Matibane, Distrito de Mossuril, Nampula. A criação da zona não confirma que infra-estruturas ou oportunidades previstas estejam actualmente disponíveis.",
|
"description": "Criada em regime de ZEE pelo Decreto n.º 47/2013, de 30 de Agosto. A fonte oficial indica 1.750 ha no Posto Administrativo de Matibane, Distrito de Mossuril, Nampula. A criação da zona não confirma que infra-estruturas ou oportunidades previstas estejam actualmente disponíveis.",
|
||||||
"description_en": "Created under the SEZ regime by Decree no. 47/2013 of 30 August. The official source states 1,750 ha in Matibane Administrative Post, Mossuril District, Nampula. Establishment of the zone does not confirm that planned infrastructure or opportunities are currently available.",
|
"description_en": "Created under the SEZ regime by Decree no. 47/2013 of 30 August. The official source states 1,750 ha in Matibane Administrative Post, Mossuril District, Nampula. Establishment of the zone does not confirm that planned infrastructure or opportunities are currently available.",
|
||||||
"aliases": ["Crusse-Jamali", "Crusse & Jamali"],
|
"aliases": ["Crusse-Jamali", "Crusse & Jamali"],
|
||||||
"activities": [{"name": "Turismo integrado", "status": "potential", "source_reference": "Decreto n.º 47/2013; tourism scope in the creation description"}],
|
"activities": [
|
||||||
"source": {"title": "Conselho de Ministros — BR n.º 70 de 30.08.13", "url": "https://www.inm.gov.mz/pt-br/content/conselho-de-ministros-br-n%C2%BA-70-de-300813-boletim-da-rep%C3%BAblica-i-serie-p%C3%A1g-571", "diploma": "Decreto n.º 47/2013, de 30 de Agosto", "article": "Act of creation; article reference pending review", "valid_from": "2013-08-30", "competent_entity": "Conselho de Ministros / Imprensa Nacional de Moçambique"},
|
{
|
||||||
"territories": [{"name": "MATIBANE", "type": "admin_post", "scope_type": "legal_scope"}]
|
"name": "Turismo integrado",
|
||||||
|
"status": "potential",
|
||||||
|
"source_reference": "Decreto n.º 47/2013; tourism scope in the creation description"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": {
|
||||||
|
"title": "Conselho de Ministros — BR n.º 70 de 30.08.13",
|
||||||
|
"url": "https://www.inm.gov.mz/pt-br/content/conselho-de-ministros-br-n%C2%BA-70-de-300813-boletim-da-rep%C3%BAblica-i-serie-p%C3%A1g-571",
|
||||||
|
"diploma": "Decreto n.º 47/2013, de 30 de Agosto",
|
||||||
|
"article": "Act of creation; article reference pending review",
|
||||||
|
"valid_from": "2013-08-30",
|
||||||
|
"competent_entity": "Conselho de Ministros / Imprensa Nacional de Moçambique"
|
||||||
|
},
|
||||||
|
"territories": [
|
||||||
|
{
|
||||||
|
"name": "MATIBANE",
|
||||||
|
"type": "admin_post",
|
||||||
|
"scope_type": "legal_scope"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"code": "MOZ-MANGA-MUNGASSA-ZEE",
|
"code": "MOZ-MANGA-MUNGASSA-ZEE",
|
||||||
@@ -77,12 +167,37 @@
|
|||||||
"description_en": "APIEX reports establishment by Decree no. 22/2012 of 6 June, location in Beira City, Sofala, and an area of 217 ha. Sectors described as investment potential are not treated as authorized activities or registered opportunities.",
|
"description_en": "APIEX reports establishment by Decree no. 22/2012 of 6 June, location in Beira City, Sofala, and an area of 217 ha. Sectors described as investment potential are not treated as authorized activities or registered opportunities.",
|
||||||
"aliases": ["Manga Mungassa ZEE"],
|
"aliases": ["Manga Mungassa ZEE"],
|
||||||
"activities": [
|
"activities": [
|
||||||
{"name": "Indústria", "status": "potential", "source_reference": "APIEX Manga-Mungassa page; potential sectors"},
|
{
|
||||||
{"name": "Logística e transporte", "status": "potential", "source_reference": "APIEX Manga-Mungassa page; potential sectors"},
|
"name": "Indústria",
|
||||||
{"name": "Hotelaria e serviços", "status": "potential", "source_reference": "APIEX Manga-Mungassa page; potential sectors"}
|
"status": "potential",
|
||||||
|
"source_reference": "APIEX Manga-Mungassa page; potential sectors"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Logística e transporte",
|
||||||
|
"status": "potential",
|
||||||
|
"source_reference": "APIEX Manga-Mungassa page; potential sectors"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Hotelaria e serviços",
|
||||||
|
"status": "potential",
|
||||||
|
"source_reference": "APIEX Manga-Mungassa page; potential sectors"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"source": {"title": "Manga-Mungassa Special Economic Zone – APIEX", "url": "https://apiex.gov.mz/zee/manga-mungassa-special-economic-zone/", "diploma": "Decreto n.º 22/2012, de 6 de Junho", "article": "Act of creation; article reference pending review", "valid_from": "2012-06-06", "competent_entity": "Conselho de Ministros / APIEX"},
|
"source": {
|
||||||
"territories": [{"name": "CIDADE DA BEIRA", "type": "district", "scope_type": "administrative"}]
|
"title": "Manga-Mungassa Special Economic Zone – APIEX",
|
||||||
|
"url": "https://apiex.gov.mz/zee/manga-mungassa-special-economic-zone/",
|
||||||
|
"diploma": "Decreto n.º 22/2012, de 6 de Junho",
|
||||||
|
"article": "Act of creation; article reference pending review",
|
||||||
|
"valid_from": "2012-06-06",
|
||||||
|
"competent_entity": "Conselho de Ministros / APIEX"
|
||||||
|
},
|
||||||
|
"territories": [
|
||||||
|
{
|
||||||
|
"name": "CIDADE DA BEIRA",
|
||||||
|
"type": "district",
|
||||||
|
"scope_type": "administrative"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"code": "MOZ-MOCUBA-ZEE",
|
"code": "MOZ-MOCUBA-ZEE",
|
||||||
@@ -98,12 +213,31 @@
|
|||||||
"description_en": "Created by Decree no. 28/2014 of 6 June. INM and APIEX state that it covers all of Mocuba District and Munhamade Administrative Post in Lugela District, Zambézia. APIEX reports 10,727 km²; the unit and scope are preserved without reducing it to Mocuba City.",
|
"description_en": "Created by Decree no. 28/2014 of 6 June. INM and APIEX state that it covers all of Mocuba District and Munhamade Administrative Post in Lugela District, Zambézia. APIEX reports 10,727 km²; the unit and scope are preserved without reducing it to Mocuba City.",
|
||||||
"aliases": ["Mocuba ZEE"],
|
"aliases": ["Mocuba ZEE"],
|
||||||
"activities": [
|
"activities": [
|
||||||
{"name": "Produção agrícola, pecuária, florestal e processamento", "status": "potential", "source_reference": "APIEX Mocuba SEZ page; stated attraction objectives"}
|
{
|
||||||
|
"name": "Produção agrícola, pecuária, florestal e processamento",
|
||||||
|
"status": "potential",
|
||||||
|
"source_reference": "APIEX Mocuba SEZ page; stated attraction objectives"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"source": {"title": "BR n.º 46 de 06.06.14 — Decreto n.º 28/2014", "url": "https://www.inm.gov.mz/pt-br/content/conselho-de-ministros-br-n%C2%BA-46-de-060614-boletim-da-rep%C3%BAblica-i-serie-p%C3%A1g-1259", "diploma": "Decreto n.º 28/2014, de 6 de Junho", "article": "Act of creation; article reference pending review", "valid_from": "2014-06-06", "competent_entity": "Conselho de Ministros / Imprensa Nacional de Moçambique"},
|
"source": {
|
||||||
|
"title": "BR n.º 46 de 06.06.14 — Decreto n.º 28/2014",
|
||||||
|
"url": "https://www.inm.gov.mz/pt-br/content/conselho-de-ministros-br-n%C2%BA-46-de-060614-boletim-da-rep%C3%BAblica-i-serie-p%C3%A1g-1259",
|
||||||
|
"diploma": "Decreto n.º 28/2014, de 6 de Junho",
|
||||||
|
"article": "Act of creation; article reference pending review",
|
||||||
|
"valid_from": "2014-06-06",
|
||||||
|
"competent_entity": "Conselho de Ministros / Imprensa Nacional de Moçambique"
|
||||||
|
},
|
||||||
"territories": [
|
"territories": [
|
||||||
{"name": "MOCUBA", "type": "district", "scope_type": "legal_scope"},
|
{
|
||||||
{"name": "MUNHAMADE", "type": "admin_post", "scope_type": "legal_scope"}
|
"name": "MOCUBA",
|
||||||
|
"type": "district",
|
||||||
|
"scope_type": "legal_scope"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "MUNHAMADE",
|
||||||
|
"type": "admin_post",
|
||||||
|
"scope_type": "legal_scope"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -120,8 +254,21 @@
|
|||||||
"description_en": "Created by Decree no. 29/2014 of 6 June and located in Mocuba City. APIEX describes this IFZ as mobilizing resources and an operator. It is distinct from Mocuba SEZ and does not imply tax eligibility for companies.",
|
"description_en": "Created by Decree no. 29/2014 of 6 June and located in Mocuba City. APIEX describes this IFZ as mobilizing resources and an operator. It is distinct from Mocuba SEZ and does not imply tax eligibility for companies.",
|
||||||
"aliases": ["Mocuba IFZ", "ZFI de Mocuba"],
|
"aliases": ["Mocuba IFZ", "ZFI de Mocuba"],
|
||||||
"activities": [],
|
"activities": [],
|
||||||
"source": {"title": "Mocuba IFZ – APIEX", "url": "https://apiex.gov.mz/zif/mocuba-free-industrial-zone/", "diploma": "Decreto n.º 29/2014, de 6 de Junho", "article": "Act of creation; article reference pending review", "valid_from": "2014-06-06", "competent_entity": "Conselho de Ministros / APIEX"},
|
"source": {
|
||||||
"territories": [{"name": "CIDADE DE MOCUBA", "type": "admin_post", "scope_type": "administrative"}]
|
"title": "Mocuba IFZ – APIEX",
|
||||||
|
"url": "https://apiex.gov.mz/zif/mocuba-free-industrial-zone/",
|
||||||
|
"diploma": "Decreto n.º 29/2014, de 6 de Junho",
|
||||||
|
"article": "Act of creation; article reference pending review",
|
||||||
|
"valid_from": "2014-06-06",
|
||||||
|
"competent_entity": "Conselho de Ministros / APIEX"
|
||||||
|
},
|
||||||
|
"territories": [
|
||||||
|
{
|
||||||
|
"name": "CIDADE DE MOCUBA",
|
||||||
|
"type": "admin_post",
|
||||||
|
"scope_type": "administrative"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"code": "MOZ-NACALA-ZEE",
|
"code": "MOZ-NACALA-ZEE",
|
||||||
@@ -137,13 +284,37 @@
|
|||||||
"description_en": "APIEX reports establishment by Decree no. 76/2007 of 18 December, covering Nacala and Nacala-à-Velha districts, with an area of 1,539 km². It is distinct from the Nacala Corridor, port, and other free zones. Project and employment counts on the page are not imported as current because their reference date is not confirmed.",
|
"description_en": "APIEX reports establishment by Decree no. 76/2007 of 18 December, covering Nacala and Nacala-à-Velha districts, with an area of 1,539 km². It is distinct from the Nacala Corridor, port, and other free zones. Project and employment counts on the page are not imported as current because their reference date is not confirmed.",
|
||||||
"aliases": ["ZEEN", "Nacala SEZ"],
|
"aliases": ["ZEEN", "Nacala SEZ"],
|
||||||
"activities": [
|
"activities": [
|
||||||
{"name": "Logística e indústria", "status": "potential", "source_reference": "APIEX Nacala SEZ page; sectors identified as potential"},
|
{
|
||||||
{"name": "Agro-processamento e indústria química", "status": "potential", "source_reference": "APIEX Nacala SEZ page; sectors identified as potential"}
|
"name": "Logística e indústria",
|
||||||
|
"status": "potential",
|
||||||
|
"source_reference": "APIEX Nacala SEZ page; sectors identified as potential"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Agro-processamento e indústria química",
|
||||||
|
"status": "potential",
|
||||||
|
"source_reference": "APIEX Nacala SEZ page; sectors identified as potential"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"source": {"title": "Nacala Special Economic Zone – APIEX", "url": "https://apiex.gov.mz/nacala-special-economic-zone/", "diploma": "Decreto n.º 76/2007, de 18 de Dezembro", "article": "Act of creation; article reference pending review", "valid_from": "2007-12-18", "competent_entity": "Conselho de Ministros / APIEX"},
|
"source": {
|
||||||
|
"title": "Nacala Special Economic Zone – APIEX",
|
||||||
|
"url": "https://apiex.gov.mz/nacala-special-economic-zone/",
|
||||||
|
"diploma": "Decreto n.º 76/2007, de 18 de Dezembro",
|
||||||
|
"article": "Act of creation; article reference pending review",
|
||||||
|
"valid_from": "2007-12-18",
|
||||||
|
"competent_entity": "Conselho de Ministros / APIEX"
|
||||||
|
},
|
||||||
"territories": [
|
"territories": [
|
||||||
{"name": "NACALA-PORTO", "type": "district", "scope_type": "legal_scope"},
|
{
|
||||||
{"name": "NACALA-VELHA", "source_name": "Nacala-à-Velha", "type": "district", "scope_type": "legal_scope"}
|
"name": "NACALA-PORTO",
|
||||||
|
"type": "district",
|
||||||
|
"scope_type": "legal_scope"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "NACALA-VELHA",
|
||||||
|
"source_name": "Nacala-à-Velha",
|
||||||
|
"type": "district",
|
||||||
|
"scope_type": "legal_scope"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ return new class extends Migration
|
|||||||
]);
|
]);
|
||||||
DB::statement('DROP INDEX IF EXISTS simulation_form_drafts_owner_active_unique');
|
DB::statement('DROP INDEX IF EXISTS simulation_form_drafts_owner_active_unique');
|
||||||
DB::statement('CREATE INDEX simulation_form_drafts_owner_active_idx ON public.simulation_form_drafts(owner_user_id, updated_at DESC) WHERE owner_user_id IS NOT NULL AND deleted_at IS NULL');
|
DB::statement('CREATE INDEX simulation_form_drafts_owner_active_idx ON public.simulation_form_drafts(owner_user_id, updated_at DESC) WHERE owner_user_id IS NOT NULL AND deleted_at IS NULL');
|
||||||
DB::statement("CREATE UNIQUE INDEX simulation_form_drafts_claimed_token_unique ON public.simulation_form_drafts(claimed_token_hash) WHERE claimed_token_hash IS NOT NULL");
|
DB::statement('CREATE UNIQUE INDEX simulation_form_drafts_claimed_token_unique ON public.simulation_form_drafts(claimed_token_hash) WHERE claimed_token_hash IS NOT NULL');
|
||||||
|
|
||||||
Schema::create('simulation_draft_business_links', function ($table): void {
|
Schema::create('simulation_draft_business_links', function ($table): void {
|
||||||
$table->uuid('id')->primary();
|
$table->uuid('id')->primary();
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ return new class extends Migration
|
|||||||
DB::statement("ALTER TABLE investment_zones ADD CONSTRAINT investment_zones_physical_category_check CHECK (physical_category IS NULL OR physical_category IN ('economic_zone','industrial_park','industrial_free_zone','integrated_tourism_area','other','unknown'))");
|
DB::statement("ALTER TABLE investment_zones ADD CONSTRAINT investment_zones_physical_category_check CHECK (physical_category IS NULL OR physical_category IN ('economic_zone','industrial_park','industrial_free_zone','integrated_tourism_area','other','unknown'))");
|
||||||
DB::statement("ALTER TABLE investment_zones ADD CONSTRAINT investment_zones_legal_regime_check CHECK (legal_regime IS NULL OR legal_regime IN ('zee','zfi','general','pending','not_applicable'))");
|
DB::statement("ALTER TABLE investment_zones ADD CONSTRAINT investment_zones_legal_regime_check CHECK (legal_regime IS NULL OR legal_regime IN ('zee','zfi','general','pending','not_applicable'))");
|
||||||
DB::statement("ALTER TABLE investment_zones ADD CONSTRAINT investment_zones_operational_status_check CHECK (operational_status IN ('operational','implementation','planned','suspended','unknown'))");
|
DB::statement("ALTER TABLE investment_zones ADD CONSTRAINT investment_zones_operational_status_check CHECK (operational_status IN ('operational','implementation','planned','suspended','unknown'))");
|
||||||
DB::statement("ALTER TABLE investment_zones ADD CONSTRAINT investment_zones_area_check CHECK (area_value IS NULL OR area_value >= 0)");
|
DB::statement('ALTER TABLE investment_zones ADD CONSTRAINT investment_zones_area_check CHECK (area_value IS NULL OR area_value >= 0)');
|
||||||
|
|
||||||
Schema::create('investment_zone_locations', function (Blueprint $table): void {
|
Schema::create('investment_zone_locations', function (Blueprint $table): void {
|
||||||
$table->uuid('id')->primary();
|
$table->uuid('id')->primary();
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ return new class extends Migration
|
|||||||
DB::statement("ALTER TABLE portal_resource_links ADD CONSTRAINT portal_resource_links_relationship_check CHECK (relationship IN ('applies_to','supports','version_of','translation_of','amends','repeals','implements','cites','related_to'))");
|
DB::statement("ALTER TABLE portal_resource_links ADD CONSTRAINT portal_resource_links_relationship_check CHECK (relationship IN ('applies_to','supports','version_of','translation_of','amends','repeals','implements','cites','related_to'))");
|
||||||
DB::statement("ALTER TABLE portal_resource_links ADD CONSTRAINT portal_resource_links_applicability_check CHECK (applicability IN ('required','conditional','support','optional_template','evidence'))");
|
DB::statement("ALTER TABLE portal_resource_links ADD CONSTRAINT portal_resource_links_applicability_check CHECK (applicability IN ('required','conditional','support','optional_template','evidence'))");
|
||||||
DB::statement("ALTER TABLE portal_resource_links ADD CONSTRAINT portal_resource_links_basis_check CHECK ((applicability NOT IN ('required','conditional') OR length(trim(coalesce(basis_reference,''))) >= 5) AND (applicability <> 'conditional' OR length(trim(coalesce(condition_text,''))) >= 5))");
|
DB::statement("ALTER TABLE portal_resource_links ADD CONSTRAINT portal_resource_links_basis_check CHECK ((applicability NOT IN ('required','conditional') OR length(trim(coalesce(basis_reference,''))) >= 5) AND (applicability <> 'conditional' OR length(trim(coalesce(condition_text,''))) >= 5))");
|
||||||
DB::statement("ALTER TABLE portal_resources ADD CONSTRAINT portal_resources_metadata_version_check CHECK (metadata_version > 0)");
|
DB::statement('ALTER TABLE portal_resources ADD CONSTRAINT portal_resources_metadata_version_check CHECK (metadata_version > 0)');
|
||||||
DB::statement("ALTER TABLE portal_resource_revisions ADD CONSTRAINT portal_resource_revisions_change_type_check CHECK (change_type IN ('created','metadata_updated','published','unpublished'))");
|
DB::statement("ALTER TABLE portal_resource_revisions ADD CONSTRAINT portal_resource_revisions_change_type_check CHECK (change_type IN ('created','metadata_updated','published','unpublished'))");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
return new class extends Migration
|
return new class extends Migration
|
||||||
{
|
{
|
||||||
public function up(): void
|
public function up(): void
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ return new class extends Migration
|
|||||||
Schema::table('portal_resource_links', function (Blueprint $table): void {
|
Schema::table('portal_resource_links', function (Blueprint $table): void {
|
||||||
$table->string('review_status', 16)->default('pending');
|
$table->string('review_status', 16)->default('pending');
|
||||||
});
|
});
|
||||||
DB::statement("ALTER TABLE portal_resource_links DROP CONSTRAINT portal_resource_links_target_type_check");
|
DB::statement('ALTER TABLE portal_resource_links DROP CONSTRAINT portal_resource_links_target_type_check');
|
||||||
DB::statement("ALTER TABLE portal_resource_links ADD CONSTRAINT portal_resource_links_target_type_check CHECK (target_type IN ('theme','module','activity','stage','procedure','entity','territory','document','investment_type','legal_source','requirement'))");
|
DB::statement("ALTER TABLE portal_resource_links ADD CONSTRAINT portal_resource_links_target_type_check CHECK (target_type IN ('theme','module','activity','stage','procedure','entity','territory','document','investment_type','legal_source','requirement'))");
|
||||||
DB::statement("ALTER TABLE portal_resource_links ADD CONSTRAINT portal_resource_links_review_status_check CHECK (review_status IN ('pending','confirmed'))");
|
DB::statement("ALTER TABLE portal_resource_links ADD CONSTRAINT portal_resource_links_review_status_check CHECK (review_status IN ('pending','confirmed'))");
|
||||||
DB::statement('ALTER TABLE portal_resource_revisions DROP CONSTRAINT portal_resource_revisions_change_type_check');
|
DB::statement('ALTER TABLE portal_resource_revisions DROP CONSTRAINT portal_resource_revisions_change_type_check');
|
||||||
|
|||||||
@@ -19,60 +19,128 @@ return new class extends Migration
|
|||||||
{
|
{
|
||||||
$this->guard(true);
|
$this->guard(true);
|
||||||
Schema::create('desk_service_versions', function (Blueprint $t) {
|
Schema::create('desk_service_versions', function (Blueprint $t) {
|
||||||
$t->uuid('id')->primary(); $t->string('code'); $t->unsignedInteger('version'); $t->string('status')->default('draft');
|
$t->uuid('id')->primary();
|
||||||
$t->jsonb('definition'); $t->jsonb('source'); $t->foreignId('author_id')->constrained('users')->restrictOnDelete();
|
$t->string('code');
|
||||||
$t->foreignId('published_by')->nullable()->constrained('users')->restrictOnDelete(); $t->timestampTz('published_at')->nullable(); $t->timestampsTz(); $t->unique(['code', 'version']);
|
$t->unsignedInteger('version');
|
||||||
|
$t->string('status')->default('draft');
|
||||||
|
$t->jsonb('definition');
|
||||||
|
$t->jsonb('source');
|
||||||
|
$t->foreignId('author_id')->constrained('users')->restrictOnDelete();
|
||||||
|
$t->foreignId('published_by')->nullable()->constrained('users')->restrictOnDelete();
|
||||||
|
$t->timestampTz('published_at')->nullable();
|
||||||
|
$t->timestampsTz();
|
||||||
|
$t->unique(['code', 'version']);
|
||||||
});
|
});
|
||||||
Schema::create('desk_cases', function (Blueprint $t) {
|
Schema::create('desk_cases', function (Blueprint $t) {
|
||||||
$t->uuid('id')->primary(); $t->foreignId('user_id')->constrained('users')->restrictOnDelete();
|
$t->uuid('id')->primary();
|
||||||
|
$t->foreignId('user_id')->constrained('users')->restrictOnDelete();
|
||||||
$t->foreignUuid('organization_id')->nullable()->constrained('organizations')->restrictOnDelete();
|
$t->foreignUuid('organization_id')->nullable()->constrained('organizations')->restrictOnDelete();
|
||||||
$t->foreignUuid('company_id')->nullable()->constrained('investment_company_declarations')->restrictOnDelete();
|
$t->foreignUuid('company_id')->nullable()->constrained('investment_company_declarations')->restrictOnDelete();
|
||||||
$t->foreignUuid('submission_id')->nullable()->constrained('investment_submissions')->restrictOnDelete();
|
$t->foreignUuid('submission_id')->nullable()->constrained('investment_submissions')->restrictOnDelete();
|
||||||
$t->uuid('simulation_id')->nullable(); $t->string('title'); $t->uuid('client_key'); $t->unsignedInteger('version')->default(1);
|
$t->uuid('simulation_id')->nullable();
|
||||||
$t->text('payload'); $t->jsonb('workflow'); $t->timestampTz('closed_at')->nullable(); $t->timestampsTz(); $t->unique(['user_id', 'client_key']);
|
$t->string('title');
|
||||||
|
$t->uuid('client_key');
|
||||||
|
$t->unsignedInteger('version')->default(1);
|
||||||
|
$t->text('payload');
|
||||||
|
$t->jsonb('workflow');
|
||||||
|
$t->timestampTz('closed_at')->nullable();
|
||||||
|
$t->timestampsTz();
|
||||||
|
$t->unique(['user_id', 'client_key']);
|
||||||
});
|
});
|
||||||
Schema::create('desk_requests', function (Blueprint $t) {
|
Schema::create('desk_requests', function (Blueprint $t) {
|
||||||
$t->uuid('id')->primary(); $t->foreignUuid('case_id')->constrained('desk_cases')->restrictOnDelete();
|
$t->uuid('id')->primary();
|
||||||
|
$t->foreignUuid('case_id')->constrained('desk_cases')->restrictOnDelete();
|
||||||
$t->foreignUuid('service_version_id')->constrained('desk_service_versions')->restrictOnDelete();
|
$t->foreignUuid('service_version_id')->constrained('desk_service_versions')->restrictOnDelete();
|
||||||
$t->foreignId('analyst_id')->nullable()->constrained('users')->restrictOnDelete(); $t->string('status')->default('draft');
|
$t->foreignId('analyst_id')->nullable()->constrained('users')->restrictOnDelete();
|
||||||
$t->unsignedInteger('version')->default(1); $t->uuid('client_key'); $t->text('payload'); $t->string('protocol')->nullable()->unique();
|
$t->string('status')->default('draft');
|
||||||
$t->text('submitted_snapshot')->nullable(); $t->jsonb('editable_fields')->nullable(); $t->timestampTz('submitted_at')->nullable();
|
$t->unsignedInteger('version')->default(1);
|
||||||
$t->timestampTz('due_at')->nullable(); $t->timestampTz('closed_at')->nullable(); $t->timestampsTz(); $t->unique(['case_id', 'client_key']);
|
$t->uuid('client_key');
|
||||||
|
$t->text('payload');
|
||||||
|
$t->string('protocol')->nullable()->unique();
|
||||||
|
$t->text('submitted_snapshot')->nullable();
|
||||||
|
$t->jsonb('editable_fields')->nullable();
|
||||||
|
$t->timestampTz('submitted_at')->nullable();
|
||||||
|
$t->timestampTz('due_at')->nullable();
|
||||||
|
$t->timestampTz('closed_at')->nullable();
|
||||||
|
$t->timestampsTz();
|
||||||
|
$t->unique(['case_id', 'client_key']);
|
||||||
});
|
});
|
||||||
Schema::create('desk_documents', function (Blueprint $t) {
|
Schema::create('desk_documents', function (Blueprint $t) {
|
||||||
$t->uuid('id')->primary(); $t->foreignUuid('case_id')->constrained('desk_cases')->restrictOnDelete();
|
$t->uuid('id')->primary();
|
||||||
$t->foreignUuid('document_id')->constrained('documents')->restrictOnDelete(); $t->foreignUuid('request_id')->nullable()->constrained('desk_requests')->restrictOnDelete();
|
$t->foreignUuid('case_id')->constrained('desk_cases')->restrictOnDelete();
|
||||||
$t->string('category'); $t->string('stage')->nullable(); $t->date('valid_until')->nullable(); $t->text('source_reference');
|
$t->foreignUuid('document_id')->constrained('documents')->restrictOnDelete();
|
||||||
$t->foreignId('linked_by')->constrained('users')->restrictOnDelete(); $t->timestampTz('created_at')->useCurrent(); $t->unique(['case_id', 'document_id']);
|
$t->foreignUuid('request_id')->nullable()->constrained('desk_requests')->restrictOnDelete();
|
||||||
|
$t->string('category');
|
||||||
|
$t->string('stage')->nullable();
|
||||||
|
$t->date('valid_until')->nullable();
|
||||||
|
$t->text('source_reference');
|
||||||
|
$t->foreignId('linked_by')->constrained('users')->restrictOnDelete();
|
||||||
|
$t->timestampTz('created_at')->useCurrent();
|
||||||
|
$t->unique(['case_id', 'document_id']);
|
||||||
});
|
});
|
||||||
Schema::create('desk_events', function (Blueprint $t) {
|
Schema::create('desk_events', function (Blueprint $t) {
|
||||||
$t->uuid('id')->primary(); $t->foreignUuid('case_id')->constrained('desk_cases')->restrictOnDelete();
|
$t->uuid('id')->primary();
|
||||||
$t->foreignUuid('request_id')->nullable()->constrained('desk_requests')->restrictOnDelete(); $t->foreignId('actor_id')->constrained('users')->restrictOnDelete();
|
$t->foreignUuid('case_id')->constrained('desk_cases')->restrictOnDelete();
|
||||||
$t->string('action'); $t->unsignedInteger('version'); $t->text('payload'); $t->timestampTz('created_at')->useCurrent();
|
$t->foreignUuid('request_id')->nullable()->constrained('desk_requests')->restrictOnDelete();
|
||||||
|
$t->foreignId('actor_id')->constrained('users')->restrictOnDelete();
|
||||||
|
$t->string('action');
|
||||||
|
$t->unsignedInteger('version');
|
||||||
|
$t->text('payload');
|
||||||
|
$t->timestampTz('created_at')->useCurrent();
|
||||||
});
|
});
|
||||||
Schema::create('desk_revisions', function (Blueprint $t) {
|
Schema::create('desk_revisions', function (Blueprint $t) {
|
||||||
$t->id(); $t->foreignUuid('request_id')->constrained('desk_requests')->restrictOnDelete(); $t->unsignedInteger('version');
|
$t->id();
|
||||||
$t->text('snapshot'); $t->timestampTz('created_at')->useCurrent(); $t->unique(['request_id', 'version']);
|
$t->foreignUuid('request_id')->constrained('desk_requests')->restrictOnDelete();
|
||||||
|
$t->unsignedInteger('version');
|
||||||
|
$t->text('snapshot');
|
||||||
|
$t->timestampTz('created_at')->useCurrent();
|
||||||
|
$t->unique(['request_id', 'version']);
|
||||||
});
|
});
|
||||||
Schema::create('desk_messages', function (Blueprint $t) {
|
Schema::create('desk_messages', function (Blueprint $t) {
|
||||||
$t->uuid('id')->primary(); $t->foreignUuid('request_id')->constrained('desk_requests')->restrictOnDelete();
|
$t->uuid('id')->primary();
|
||||||
$t->foreignId('actor_id')->constrained('users')->restrictOnDelete(); $t->uuid('client_key'); $t->text('body'); $t->timestampTz('created_at')->useCurrent();
|
$t->foreignUuid('request_id')->constrained('desk_requests')->restrictOnDelete();
|
||||||
|
$t->foreignId('actor_id')->constrained('users')->restrictOnDelete();
|
||||||
|
$t->uuid('client_key');
|
||||||
|
$t->text('body');
|
||||||
|
$t->timestampTz('created_at')->useCurrent();
|
||||||
$t->unique(['request_id', 'actor_id', 'client_key']);
|
$t->unique(['request_id', 'actor_id', 'client_key']);
|
||||||
});
|
});
|
||||||
Schema::create('desk_notifications', function (Blueprint $t) {
|
Schema::create('desk_notifications', function (Blueprint $t) {
|
||||||
$t->id(); $t->foreignUuid('event_id')->constrained('desk_events')->restrictOnDelete(); $t->foreignId('user_id')->constrained('users')->restrictOnDelete();
|
$t->id();
|
||||||
$t->string('title'); $t->string('href'); $t->timestampTz('read_at')->nullable(); $t->unique(['event_id', 'user_id']);
|
$t->foreignUuid('event_id')->constrained('desk_events')->restrictOnDelete();
|
||||||
|
$t->foreignId('user_id')->constrained('users')->restrictOnDelete();
|
||||||
|
$t->string('title');
|
||||||
|
$t->string('href');
|
||||||
|
$t->timestampTz('read_at')->nullable();
|
||||||
|
$t->unique(['event_id', 'user_id']);
|
||||||
});
|
});
|
||||||
Schema::create('desk_institutional_links', function (Blueprint $t) {
|
Schema::create('desk_institutional_links', function (Blueprint $t) {
|
||||||
$t->uuid('id')->primary(); $t->string('stage'); $t->string('entity'); $t->string('purpose'); $t->text('url'); $t->string('contact')->nullable();
|
$t->uuid('id')->primary();
|
||||||
$t->string('status')->default('pending'); $t->unsignedInteger('version')->default(1); $t->text('source_reference');
|
$t->string('stage');
|
||||||
$t->timestampTz('verified_at')->nullable(); $t->foreignId('verified_by')->nullable()->constrained('users')->restrictOnDelete(); $t->timestampsTz();
|
$t->string('entity');
|
||||||
|
$t->string('purpose');
|
||||||
|
$t->text('url');
|
||||||
|
$t->string('contact')->nullable();
|
||||||
|
$t->string('status')->default('pending');
|
||||||
|
$t->unsignedInteger('version')->default(1);
|
||||||
|
$t->text('source_reference');
|
||||||
|
$t->timestampTz('verified_at')->nullable();
|
||||||
|
$t->foreignId('verified_by')->nullable()->constrained('users')->restrictOnDelete();
|
||||||
|
$t->timestampsTz();
|
||||||
});
|
});
|
||||||
Schema::create('desk_payments', function (Blueprint $t) {
|
Schema::create('desk_payments', function (Blueprint $t) {
|
||||||
$t->uuid('id')->primary(); $t->foreignUuid('request_id')->constrained('desk_requests')->restrictOnDelete();
|
$t->uuid('id')->primary();
|
||||||
$t->string('reference')->unique(); $t->decimal('amount', 18, 2); $t->string('currency', 3); $t->text('source_reference');
|
$t->foreignUuid('request_id')->constrained('desk_requests')->restrictOnDelete();
|
||||||
$t->string('status')->default('pending'); $t->foreignUuid('document_id')->nullable()->constrained('documents')->restrictOnDelete();
|
$t->string('reference')->unique();
|
||||||
$t->foreignId('verified_by')->nullable()->constrained('users')->restrictOnDelete(); $t->text('reason')->nullable(); $t->unsignedInteger('version')->default(1); $t->timestampsTz();
|
$t->decimal('amount', 18, 2);
|
||||||
|
$t->string('currency', 3);
|
||||||
|
$t->text('source_reference');
|
||||||
|
$t->string('status')->default('pending');
|
||||||
|
$t->foreignUuid('document_id')->nullable()->constrained('documents')->restrictOnDelete();
|
||||||
|
$t->foreignId('verified_by')->nullable()->constrained('users')->restrictOnDelete();
|
||||||
|
$t->text('reason')->nullable();
|
||||||
|
$t->unsignedInteger('version')->default(1);
|
||||||
|
$t->timestampsTz();
|
||||||
});
|
});
|
||||||
DB::statement("ALTER TABLE desk_requests ADD CONSTRAINT desk_request_status CHECK (status IN ('draft','submitted','reviewing','returned','opinion','accepted','rejected','closed','cancelled'))");
|
DB::statement("ALTER TABLE desk_requests ADD CONSTRAINT desk_request_status CHECK (status IN ('draft','submitted','reviewing','returned','opinion','accepted','rejected','closed','cancelled'))");
|
||||||
DB::statement("ALTER TABLE desk_requests ADD CONSTRAINT desk_request_receipt CHECK (status IN ('draft','cancelled') OR (protocol IS NOT NULL AND submitted_snapshot IS NOT NULL AND submitted_at IS NOT NULL))");
|
DB::statement("ALTER TABLE desk_requests ADD CONSTRAINT desk_request_receipt CHECK (status IN ('draft','cancelled') OR (protocol IS NOT NULL AND submitted_snapshot IS NOT NULL AND submitted_at IS NOT NULL))");
|
||||||
@@ -83,8 +151,12 @@ return new class extends Migration
|
|||||||
{
|
{
|
||||||
$this->guard();
|
$this->guard();
|
||||||
foreach (['desk_cases', 'desk_service_versions', 'desk_institutional_links'] as $table) {
|
foreach (['desk_cases', 'desk_service_versions', 'desk_institutional_links'] as $table) {
|
||||||
if (DB::table($table)->exists()) throw new RuntimeException('Preserve virtual desk data before rollback.');
|
if (DB::table($table)->exists()) {
|
||||||
|
throw new RuntimeException('Preserve virtual desk data before rollback.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (['desk_payments', 'desk_institutional_links', 'desk_notifications', 'desk_messages', 'desk_revisions', 'desk_events', 'desk_documents', 'desk_requests', 'desk_cases', 'desk_service_versions'] as $table) {
|
||||||
|
Schema::drop($table);
|
||||||
}
|
}
|
||||||
foreach (['desk_payments', 'desk_institutional_links', 'desk_notifications', 'desk_messages', 'desk_revisions', 'desk_events', 'desk_documents', 'desk_requests', 'desk_cases', 'desk_service_versions'] as $table) Schema::drop($table);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
private function guard(): void
|
||||||
|
{
|
||||||
|
$identity = DB::selectOne('select current_database() as database, inet_server_port() as port');
|
||||||
|
if (! (app()->environment('testing') && str_ends_with($identity->database, '_test') && (int) $identity->port === 55441)
|
||||||
|
&& ! config('virtual-desk.installation_authorized')) {
|
||||||
|
throw new RuntimeException('Guidance requires isolated QA or authenticated installation with verified restore.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
$this->guard();
|
||||||
|
DB::statement('ALTER TABLE desk_events ADD COLUMN event_order bigint GENERATED ALWAYS AS IDENTITY');
|
||||||
|
DB::statement('CREATE UNIQUE INDEX desk_event_order_unique ON desk_events(event_order)');
|
||||||
|
Schema::table('desk_cases', function (Blueprint $t) {
|
||||||
|
$t->foreignUuid('investor_id')->nullable()->constrained('investors')->restrictOnDelete();
|
||||||
|
$t->foreignUuid('project_id')->nullable()->constrained('projects')->restrictOnDelete();
|
||||||
|
$t->foreignUuid('journey_id')->nullable()->constrained('investor_journeys')->restrictOnDelete();
|
||||||
|
$t->foreignId('interest_request_id')->nullable()->constrained('interest_requests')->restrictOnDelete();
|
||||||
|
});
|
||||||
|
Schema::table('tasks', function (Blueprint $t) {
|
||||||
|
$t->foreignUuid('desk_case_id')->nullable()->constrained('desk_cases')->restrictOnDelete();
|
||||||
|
$t->foreignUuid('desk_request_id')->nullable()->constrained('desk_requests')->restrictOnDelete();
|
||||||
|
$t->string('guidance_key', 100)->nullable();
|
||||||
|
$t->foreignId('accepted_by')->nullable()->constrained('users')->restrictOnDelete();
|
||||||
|
$t->timestampTz('accepted_at')->nullable();
|
||||||
|
$t->string('external_sync_status')->nullable();
|
||||||
|
$t->unique(['desk_case_id', 'guidance_key']);
|
||||||
|
});
|
||||||
|
DB::statement("ALTER TABLE tasks ADD CONSTRAINT guidance_task_acceptance CHECK (desk_case_id IS NULL OR (accepted_by IS NOT NULL AND accepted_at IS NOT NULL AND guidance_key IS NOT NULL AND data_classification = 'confidential' AND external_sync_status = 'pending_authorization'))");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
$this->guard();
|
||||||
|
if (DB::table('tasks')->whereNotNull('desk_case_id')->exists() || DB::table('desk_cases')->whereNotNull('investor_id')->exists()) {
|
||||||
|
throw new RuntimeException('Preserve guidance associations and accepted tasks before rollback.');
|
||||||
|
}
|
||||||
|
DB::statement('ALTER TABLE tasks DROP CONSTRAINT guidance_task_acceptance');
|
||||||
|
DB::statement('ALTER TABLE desk_events DROP COLUMN event_order');
|
||||||
|
Schema::table('tasks', function (Blueprint $t) {
|
||||||
|
$t->dropUnique(['desk_case_id', 'guidance_key']);
|
||||||
|
foreach (['desk_case_id', 'desk_request_id', 'accepted_by'] as $column) {
|
||||||
|
$t->dropConstrainedForeignId($column);
|
||||||
|
}
|
||||||
|
$t->dropColumn(['guidance_key', 'accepted_at', 'external_sync_status']);
|
||||||
|
});
|
||||||
|
Schema::table('desk_cases', function (Blueprint $t) {
|
||||||
|
foreach (['investor_id', 'project_id', 'journey_id', 'interest_request_id'] as $column) {
|
||||||
|
$t->dropConstrainedForeignId($column);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -89,7 +89,11 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- database:/var/lib/postgresql/data
|
- database:/var/lib/postgresql/data
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ['CMD-SHELL', 'pg_isready -U investmoz -d investmoz_development']
|
test:
|
||||||
|
[
|
||||||
|
'CMD-SHELL',
|
||||||
|
'pg_isready -U investmoz -d investmoz_development',
|
||||||
|
]
|
||||||
interval: 5s
|
interval: 5s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 10
|
retries: 10
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ O repositório já tinha alterações funcionais locais no início da auditoria:
|
|||||||
## Stack e versões confirmadas
|
## Stack e versões confirmadas
|
||||||
|
|
||||||
| Componente | Baseline observado | Evidência |
|
| Componente | Baseline observado | Evidência |
|
||||||
| --- | --- | --- |
|
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
|
||||||
| Backend | Laravel 13.30.1 (`composer.lock`); `composer.json` exige PHP `^8.3` e Laravel `^13.17` | `composer.lock`, `composer.json` |
|
| Backend | Laravel 13.30.1 (`composer.lock`); `composer.json` exige PHP `^8.3` e Laravel `^13.17` | `composer.lock`, `composer.json` |
|
||||||
| PHP CLI | PHP 8.5.11; `php.ini` em `C:\Users\macbook\.config\investmoz\php-8.5.11\php.ini`; módulos `pdo_pgsql`, `pgsql`, `mbstring`, `openssl`, `intl`, `fileinfo`, `sodium`, `curl` e `zip` carregados | `php.exe -v`, `--ini`, `-m` |
|
| PHP CLI | PHP 8.5.11; `php.ini` em `C:\Users\macbook\.config\investmoz\php-8.5.11\php.ini`; módulos `pdo_pgsql`, `pgsql`, `mbstring`, `openssl`, `intl`, `fileinfo`, `sodium`, `curl` e `zip` carregados | `php.exe -v`, `--ini`, `-m` |
|
||||||
| Composer | Composer 2.8.12; `composer.json` validado com o PHP 8.5.11 explícito | `composer.phar validate --no-check-publish` |
|
| Composer | Composer 2.8.12; `composer.json` validado com o PHP 8.5.11 explícito | `composer.phar validate --no-check-publish` |
|
||||||
@@ -80,7 +80,7 @@ Inventário local: 36 ficheiros de testes Feature e 5 Unit, mais testes Node. `p
|
|||||||
**Gate executado nesta auditoria:**
|
**Gate executado nesta auditoria:**
|
||||||
|
|
||||||
| Comando | Resultado |
|
| Comando | Resultado |
|
||||||
| --- | --- |
|
| ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| PHP 8.5.11 `-v`, `--ini`, `-m` | Aprovado; caminho/configuração e extensões verificados |
|
| PHP 8.5.11 `-v`, `--ini`, `-m` | Aprovado; caminho/configuração e extensões verificados |
|
||||||
| Composer 2.8.12 `validate --no-check-publish`, invocado pelo PHP 8.5.11 | Aprovado: `composer.json is valid` |
|
| Composer 2.8.12 `validate --no-check-publish`, invocado pelo PHP 8.5.11 | Aprovado: `composer.json is valid` |
|
||||||
| `artisan migrate:status --database=pgsql` no banco de teste 55441 | Aprovado: 52 Ran, zero pendentes nessa base |
|
| `artisan migrate:status --database=pgsql` no banco de teste 55441 | Aprovado: 52 Ran, zero pendentes nessa base |
|
||||||
@@ -93,7 +93,7 @@ As pastas/ficheiros listados pelo Vite Plus incluem código e documentos de dive
|
|||||||
## Matriz de bloqueadores
|
## Matriz de bloqueadores
|
||||||
|
|
||||||
| Severidade | Bloqueador e evidência | Responsável por função | Condição de desbloqueio |
|
| Severidade | Bloqueador e evidência | Responsável por função | Condição de desbloqueio |
|
||||||
| --- | --- | --- | --- |
|
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| Crítica — gate actual | `npm.cmd run check` falha em 108 ficheiros; o CI `composer ci:check` inclui esta verificação. | Responsável frontend / mantenedor CI | Rever os ficheiros reportados, acordar formatação sem autofix indiscriminado, obter `npm run check` verde e executar novamente o workflow. |
|
| Crítica — gate actual | `npm.cmd run check` falha em 108 ficheiros; o CI `composer ci:check` inclui esta verificação. | Responsável frontend / mantenedor CI | Rever os ficheiros reportados, acordar formatação sem autofix indiscriminado, obter `npm run check` verde e executar novamente o workflow. |
|
||||||
| Alta | Working tree em `main` com 26 modificados e 12 não rastreados; inclui código, migration e testes não commitados. | Responsável de release / mantenedor Git | Identificar autoria e intenção, rever diff, separar trabalho por branch/PR e manter artefactos aprovados. |
|
| Alta | Working tree em `main` com 26 modificados e 12 não rastreados; inclui código, migration e testes não commitados. | Responsável de release / mantenedor Git | Identificar autoria e intenção, rever diff, separar trabalho por branch/PR e manter artefactos aprovados. |
|
||||||
| Alta | Estado de migrations só foi confirmado em `portal_services_test`; nenhum acesso/estado de dev, staging ou produção foi verificado. | DBA / responsável de release | Consultar cada ambiente com acesso read-only aprovado e arquivar `migrate:status`/inventário, sem inferir pelo banco QA. |
|
| Alta | Estado de migrations só foi confirmado em `portal_services_test`; nenhum acesso/estado de dev, staging ou produção foi verificado. | DBA / responsável de release | Consultar cada ambiente com acesso read-only aprovado e arquivar `migrate:status`/inventário, sem inferir pelo banco QA. |
|
||||||
@@ -203,6 +203,7 @@ Não há nomes de autoridades sem fonte oficial aprovada; o endpoint informa cat
|
|||||||
Rollback: executar `php artisan migrate:rollback --step=1` apenas num ambiente onde esta migration seja a última aplicada e após exportar/publicar nenhum conteúdo de catálogo; o `down()` protege-se contra remoção de dados de autoridade/actividade. Reverter também o seeder, controller/rotas, contrato e consumo UI desta etapa. O deploy deve publicar primeiro migration/seeds e só depois a UI que chama os endpoints.
|
Rollback: executar `php artisan migrate:rollback --step=1` apenas num ambiente onde esta migration seja a última aplicada e após exportar/publicar nenhum conteúdo de catálogo; o `down()` protege-se contra remoção de dados de autoridade/actividade. Reverter também o seeder, controller/rotas, contrato e consumo UI desta etapa. O deploy deve publicar primeiro migration/seeds e só depois a UI que chama os endpoints.
|
||||||
|
|
||||||
**Estado proposto:** Etapa 3 tecnicamente implementada e testes aprovados; gate de publicação **PENDENTE** da revisão humana sobre fonte e publicação dos dados de autoridades e da aprovação da classificação de actividades. Não iniciar a etapa seguinte sem fechar esse gate.
|
**Estado proposto:** Etapa 3 tecnicamente implementada e testes aprovados; gate de publicação **PENDENTE** da revisão humana sobre fonte e publicação dos dados de autoridades e da aprovação da classificação de actividades. Não iniciar a etapa seguinte sem fechar esse gate.
|
||||||
|
|
||||||
## Gate da Etapa 6 — Simulações, jobs, relatórios e segurança — 2026-10-01
|
## Gate da Etapa 6 — Simulações, jobs, relatórios e segurança — 2026-10-01
|
||||||
|
|
||||||
**Resultado: BLOQUEADO antes de alterações funcionais.** A inspecção confirmou Laravel 13.30.1, PHP CLI 8.5.11, React 19 com Inertia, PostgreSQL 17.11/PostGIS 3.6.2 e CI com PostgreSQL/PostGIS 17. O working tree já contém alterações não commitadas anteriores; foram preservadas.
|
**Resultado: BLOQUEADO antes de alterações funcionais.** A inspecção confirmou Laravel 13.30.1, PHP CLI 8.5.11, React 19 com Inertia, PostgreSQL 17.11/PostGIS 3.6.2 e CI com PostgreSQL/PostGIS 17. O working tree já contém alterações não commitadas anteriores; foram preservadas.
|
||||||
@@ -223,6 +224,7 @@ Após aprovação do modelo de parâmetros e das matrizes IAM/RLS, inspeccionar
|
|||||||
**Condição para desbloquear:** aprovar o esquema de parâmetros e snapshots; fornecer matriz actor × recurso × operação e tenant/contexto; aprovar papéis PostgreSQL separados, grants, comportamento de jobs e estratégia de conexão/pool; definir escopo/retensão de idempotência, política de soft delete e ciclo de vida do token anónimo; fixar retries/reconciliação por job.
|
**Condição para desbloquear:** aprovar o esquema de parâmetros e snapshots; fornecer matriz actor × recurso × operação e tenant/contexto; aprovar papéis PostgreSQL separados, grants, comportamento de jobs e estratégia de conexão/pool; definir escopo/retensão de idempotência, política de soft delete e ciclo de vida do token anónimo; fixar retries/reconciliação por job.
|
||||||
|
|
||||||
**Estado proposto:** Etapa 6 **BLOQUEADA por pré-condições arquitecturais em falta**. Alteração desta tentativa: somente esta secção documental. Rollback: remover esta secção de `baseline.md`; não há alteração de código, migration, dado ou ambiente a reverter.
|
**Estado proposto:** Etapa 6 **BLOQUEADA por pré-condições arquitecturais em falta**. Alteração desta tentativa: somente esta secção documental. Rollback: remover esta secção de `baseline.md`; não há alteração de código, migration, dado ou ambiente a reverter.
|
||||||
|
|
||||||
## Execução da Etapa 6 — Simulações, jobs, relatórios e segurança — 2026-10-01
|
## Execução da Etapa 6 — Simulações, jobs, relatórios e segurança — 2026-10-01
|
||||||
|
|
||||||
O utilizador instruiu assumir todas as aprovações anteriores. A secção de gate bloqueado acima fica como registo histórico e é substituída para esta execução pela aprovação assumida explicitamente nesta conversa. A inspecção confirmou Laravel 13.30.1, PHP 8.5.11, React 19/Inertia, PostgreSQL 17.11/PostGIS 3.6.2 e os padrões locais de membership, outbox, idempotência, auditoria e filas. Não foram alteradas migrations anteriores nem `.env`.
|
O utilizador instruiu assumir todas as aprovações anteriores. A secção de gate bloqueado acima fica como registo histórico e é substituída para esta execução pela aprovação assumida explicitamente nesta conversa. A inspecção confirmou Laravel 13.30.1, PHP 8.5.11, React 19/Inertia, PostgreSQL 17.11/PostGIS 3.6.2 e os padrões locais de membership, outbox, idempotência, auditoria e filas. Não foram alteradas migrations anteriores nem `.env`.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
Esta governação define o MVP fiscal sem substituir funcionalidades existentes do Portal do Investidor. O âmbito funcional do Simulador Fiscal fica limitado ao que está aprovado nesta especificação; não declara homologação, publicação de regras, integração operacional ou cobertura fiscal que não tenha evidência.
|
Esta governação define o MVP fiscal sem substituir funcionalidades existentes do Portal do Investidor. O âmbito funcional do Simulador Fiscal fica limitado ao que está aprovado nesta especificação; não declara homologação, publicação de regras, integração operacional ou cobertura fiscal que não tenha evidência.
|
||||||
|
|
||||||
| Tratamento | Âmbito aprovado para o MVP |
|
| Tratamento | Âmbito aprovado para o MVP |
|
||||||
| --- | --- |
|
| ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| Calcular | IRPC; IRPS sobre remunerações; IVA; ISPC; retenções na fonte; INSS; valor aduaneiro; direitos aduaneiros; ICE; IVA na importação; obrigações fiscais/cambiais; cenários; relatórios PDF e JSON. |
|
| Calcular | IRPC; IRPS sobre remunerações; IVA; ISPC; retenções na fonte; INSS; valor aduaneiro; direitos aduaneiros; ICE; IVA na importação; obrigações fiscais/cambiais; cenários; relatórios PDF e JSON. |
|
||||||
| Identificar e orientar, sem cálculo automático | Imposto do selo; impostos autárquicos; mais-valias; preços de transferência; convenções completas de dupla tributação; benefícios complexos ZEE/ZFI; regimes sectoriais. |
|
| Identificar e orientar, sem cálculo automático | Imposto do selo; impostos autárquicos; mais-valias; preços de transferência; convenções completas de dupla tributação; benefícios complexos ZEE/ZFI; regimes sectoriais. |
|
||||||
| Fora desta release | Manifestações formais; oportunidades de negócio; conversões para projecto/oportunidade; CRM completo; conta avançada do investidor; assistente inteligente. |
|
| Fora desta release | Manifestações formais; oportunidades de negócio; conversões para projecto/oportunidade; CRM completo; conta avançada do investidor; assistente inteligente. |
|
||||||
@@ -31,7 +31,7 @@ Decisão de escopo registada em 2026-10-01: a especificação limita o MVP fisca
|
|||||||
## Matriz de conformidade e rastreabilidade
|
## Matriz de conformidade e rastreabilidade
|
||||||
|
|
||||||
| Requisito/fase | Evidência actual | Estado | Lacuna ou divergência | Ficheiros/áreas de referência | Próximo gate |
|
| Requisito/fase | Evidência actual | Estado | Lacuna ou divergência | Ficheiros/áreas de referência | Próximo gate |
|
||||||
| --- | --- | --- | --- | --- | --- |
|
| ----------------------------------------- | ---------------------------------------------------------------------------------------------------- | --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
|
||||||
| Fase 0 — governação | Baseline, decisões e ADRs; este documento acrescenta escopo, RACI funcional, riscos, backlog e gates | CONFORME PARA INICIAR A FASE 1 | Responsáveis nominais e aprovações fiscal/jurídica/segurança/ops continuam necessários antes dos gates que delas dependem | `docs/implementation/baseline.md`, `docs/implementation/adr/`, este ficheiro | Gate da Fase 1 |
|
| Fase 0 — governação | Baseline, decisões e ADRs; este documento acrescenta escopo, RACI funcional, riscos, backlog e gates | CONFORME PARA INICIAR A FASE 1 | Responsáveis nominais e aprovações fiscal/jurídica/segurança/ops continuam necessários antes dos gates que delas dependem | `docs/implementation/baseline.md`, `docs/implementation/adr/`, este ficheiro | Gate da Fase 1 |
|
||||||
| Fase 1 — fundação e contratos executáveis | Migrations, mapa SQL/OpenAPI, contratos por domínio e teste de ciclo de schema | PARCIAL | Contratos fragmentados em 3.0.3/3.1.0; validação integral e reconciliação de todos os caminhos/colunas não demonstradas neste gate | `database/migrations/`, `docs/implementation/sql-openapi-map.csv`, `docs/investmoz/*/openapi.json` | Inventário aprovado, validação OpenAPI integral e testes seguros em DB descartável |
|
| Fase 1 — fundação e contratos executáveis | Migrations, mapa SQL/OpenAPI, contratos por domínio e teste de ciclo de schema | PARCIAL | Contratos fragmentados em 3.0.3/3.1.0; validação integral e reconciliação de todos os caminhos/colunas não demonstradas neste gate | `database/migrations/`, `docs/implementation/sql-openapi-map.csv`, `docs/investmoz/*/openapi.json` | Inventário aprovado, validação OpenAPI integral e testes seguros em DB descartável |
|
||||||
| Fase 2 — repositório legislativo | Existe rota de consulta de fontes legislativas e registos jurídicos noutros domínios | PARCIAL | Não há evidência suficiente de repositório fiscal versionado com disposições, vigência, hashes, relações, ingestão e pesquisa integral | `app/Http/Controllers/Api/V1/LegislationSourceController.php`, migrations, `routes/api.php` | Contrato e fontes oficiais aprovadas; verificar CRUD/importação e integridade |
|
| Fase 2 — repositório legislativo | Existe rota de consulta de fontes legislativas e registos jurídicos noutros domínios | PARCIAL | Não há evidência suficiente de repositório fiscal versionado com disposições, vigência, hashes, relações, ingestão e pesquisa integral | `app/Http/Controllers/Api/V1/LegislationSourceController.php`, migrations, `routes/api.php` | Contrato e fontes oficiais aprovadas; verificar CRUD/importação e integridade |
|
||||||
@@ -55,7 +55,7 @@ Decisão de escopo registada em 2026-10-01: a especificação limita o MVP fisca
|
|||||||
Não foram atribuídos nomes. A nomeação de responsáveis e a aprovação desta matriz são pendências do gate.
|
Não foram atribuídos nomes. A nomeação de responsáveis e a aprovação desta matriz são pendências do gate.
|
||||||
|
|
||||||
| Actividade | Responsável (R) | Accountable (A) | Consultados (C) | Informados (I) |
|
| Actividade | Responsável (R) | Accountable (A) | Consultados (C) | Informados (I) |
|
||||||
| --- | --- | --- | --- | --- |
|
| ---------------------------------------------- | ------------------------------ | ------------------------- | ---------------------------- | ------------------- |
|
||||||
| Aprovar fonte, regra, vigência e casos fiscais | Especialista fiscal | Dono de produto fiscal | Jurídico, dados, engenharia | QA, operações |
|
| Aprovar fonte, regra, vigência e casos fiscais | Especialista fiscal | Dono de produto fiscal | Jurídico, dados, engenharia | QA, operações |
|
||||||
| Publicar regra versionada | Engenharia fiscal | Dono de produto fiscal | Fiscal, jurídico, segurança | QA, operações |
|
| Publicar regra versionada | Engenharia fiscal | Dono de produto fiscal | Fiscal, jurídico, segurança | QA, operações |
|
||||||
| Aprovar privacidade e fluxo anónimo | Privacidade/protecção de dados | Dono de produto | Jurídico, segurança, fiscal | Engenharia, QA |
|
| Aprovar privacidade e fluxo anónimo | Privacidade/protecção de dados | Dono de produto | Jurídico, segurança, fiscal | Engenharia, QA |
|
||||||
@@ -68,7 +68,7 @@ RACI é uma proposta de funções e não atribui autoridade a pessoas. Gate bloq
|
|||||||
## Backlog e gates de aceitação
|
## Backlog e gates de aceitação
|
||||||
|
|
||||||
| Prioridade | Item | Dependência | Critério de conclusão |
|
| Prioridade | Item | Dependência | Critério de conclusão |
|
||||||
| --- | --- | --- | --- |
|
| ---------- | --------------------------------------------------------------------------- | ------------------------------------- | ----------------------------------------------------------------------------------- |
|
||||||
| P0 | Resolver divergência do modo anónimo, PII e funcionalidades fora da release | Decisão de produto e privacidade | Formulário e contrato aprovados sem recolha anónima vedada; decisão registada |
|
| P0 | Resolver divergência do modo anónimo, PII e funcionalidades fora da release | Decisão de produto e privacidade | Formulário e contrato aprovados sem recolha anónima vedada; decisão registada |
|
||||||
| P0 | Aprovar fontes, regras, vigência e arredondamento de cada cálculo | Autoridade fiscal e jurídico | Fonte oficial/hash, regra versionada, casos dourados e dupla revisão registados |
|
| P0 | Aprovar fontes, regras, vigência e arredondamento de cada cálculo | Autoridade fiscal e jurídico | Fonte oficial/hash, regra versionada, casos dourados e dupla revisão registados |
|
||||||
| P0 | Aprovar matriz IAM/RLS e papéis SQL | Segurança/DBA | Testes actor×recurso×operação com papel runtime sem bypass e contexto limpo |
|
| P0 | Aprovar matriz IAM/RLS e papéis SQL | Segurança/DBA | Testes actor×recurso×operação com papel runtime sem bypass e contexto limpo |
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
Base `/api/v1/ai`. Autenticação por sessão Laravel, email verificado, `manage-portal`, feature flag e CSRF do middleware web. Não é API OAuth/OIDC para terceiros. Enviar `Accept: application/json`; o React usa as rotas equivalentes `/management/ai` via Inertia.
|
Base `/api/v1/ai`. Autenticação por sessão Laravel, email verificado, `manage-portal`, feature flag e CSRF do middleware web. Não é API OAuth/OIDC para terceiros. Enviar `Accept: application/json`; o React usa as rotas equivalentes `/management/ai` via Inertia.
|
||||||
|
|
||||||
| Método / recurso | Entrada | Resultado |
|
| Método / recurso | Entrada | Resultado |
|
||||||
| --- | --- | --- |
|
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
|
||||||
| POST `/runs` | capability, purpose, language; query para assistant/search; source_id para summary; interest_id para classify; sector_id/province/maturity_level opcionais para recommend; source_id/nature opcionais para search | 201 com UUID; finalidade verificada também pelo gateway |
|
| POST `/runs` | capability, purpose, language; query para assistant/search; source_id para summary; interest_id para classify; sector_id/province/maturity_level opcionais para recommend; source_id/nature opcionais para search | 201 com UUID; finalidade verificada também pelo gateway |
|
||||||
| GET `/runs/{uuid}` | UUID | Metadados e resultado, ou resultado nulo quando fonte/consentimento revogados ou capacidade suspensa |
|
| GET `/runs/{uuid}` | UUID | Metadados e resultado, ou resultado nulo quando fonte/consentimento revogados ou capacidade suspensa |
|
||||||
| POST `/runs/{uuid}/feedback` | rating: helpful/unhelpful/unsafe; review_requested boolean | Feedback idempotente por utilizador/resultado; unsafe suspende a capacidade |
|
| POST `/runs/{uuid}/feedback` | rating: helpful/unhelpful/unsafe; review_requested boolean | Feedback idempotente por utilizador/resultado; unsafe suspende a capacidade |
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ O React apenas comunica com Laravel. A primeira interface é interna, para gesto
|
|||||||
## 3. Linha de base dos sete casos
|
## 3. Linha de base dos sete casos
|
||||||
|
|
||||||
| Caso | Execução inicial | Limite explícito |
|
| Caso | Execução inicial | Limite explícito |
|
||||||
| --- | --- | --- |
|
| --------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
|
||||||
| UC-IA-001 | Recuperar excertos autorizados com fonte, data, natureza e recusa sem resultados | Sem resposta generativa ou aconselhamento jurídico/financeiro |
|
| UC-IA-001 | Recuperar excertos autorizados com fonte, data, natureza e recusa sem resultados | Sem resposta generativa ou aconselhamento jurídico/financeiro |
|
||||||
| UC-IA-002 | Full-text search PT/EN, filtros de fontes e acesso antes da recuperação | Híbrido/embeddings/reranker exigem infraestrutura e benchmark |
|
| UC-IA-002 | Full-text search PT/EN, filtros de fontes e acesso antes da recuperação | Híbrido/embeddings/reranker exigem infraestrutura e benchmark |
|
||||||
| UC-IA-003 | Correspondência estruturada com oportunidades publicadas, factores, lacunas de informação e regras versionadas | Sem previsão de retorno, pontuação financeira ou inferência sensível |
|
| UC-IA-003 | Correspondência estruturada com oportunidades publicadas, factores, lacunas de informação e regras versionadas | Sem previsão de retorno, pontuação financeira ou inferência sensível |
|
||||||
|
|||||||
@@ -7,15 +7,76 @@
|
|||||||
"cases": 8,
|
"cases": 8,
|
||||||
"repetitions_per_case": 5,
|
"repetitions_per_case": 5,
|
||||||
"measurements": [
|
"measurements": [
|
||||||
{"language":"pt","query":"formação técnica","expected_match":true,"passed":true,"p50_ms":1.604,"max_ms":8.87},
|
{
|
||||||
{"language":"pt","query":"cadeia logística","expected_match":true,"passed":true,"p50_ms":1.228,"max_ms":1.551},
|
"language": "pt",
|
||||||
{"language":"pt","query":"energia solar","expected_match":true,"passed":true,"p50_ms":1.207,"max_ms":1.724},
|
"query": "formação técnica",
|
||||||
{"language":"pt","query":"taxa oficial","expected_match":false,"passed":true,"p50_ms":1.091,"max_ms":1.457},
|
"expected_match": true,
|
||||||
{"language":"en","query":"vocational training","expected_match":true,"passed":true,"p50_ms":1.237,"max_ms":1.518},
|
"passed": true,
|
||||||
{"language":"en","query":"logistics corridor","expected_match":true,"passed":true,"p50_ms":1.233,"max_ms":1.3},
|
"p50_ms": 1.604,
|
||||||
{"language":"en","query":"solar energy","expected_match":true,"passed":true,"p50_ms":1.23,"max_ms":1.426},
|
"max_ms": 8.87
|
||||||
{"language":"en","query":"official tax","expected_match":false,"passed":true,"p50_ms":1.167,"max_ms":1.337}
|
},
|
||||||
|
{
|
||||||
|
"language": "pt",
|
||||||
|
"query": "cadeia logística",
|
||||||
|
"expected_match": true,
|
||||||
|
"passed": true,
|
||||||
|
"p50_ms": 1.228,
|
||||||
|
"max_ms": 1.551
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"language": "pt",
|
||||||
|
"query": "energia solar",
|
||||||
|
"expected_match": true,
|
||||||
|
"passed": true,
|
||||||
|
"p50_ms": 1.207,
|
||||||
|
"max_ms": 1.724
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"language": "pt",
|
||||||
|
"query": "taxa oficial",
|
||||||
|
"expected_match": false,
|
||||||
|
"passed": true,
|
||||||
|
"p50_ms": 1.091,
|
||||||
|
"max_ms": 1.457
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"language": "en",
|
||||||
|
"query": "vocational training",
|
||||||
|
"expected_match": true,
|
||||||
|
"passed": true,
|
||||||
|
"p50_ms": 1.237,
|
||||||
|
"max_ms": 1.518
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"language": "en",
|
||||||
|
"query": "logistics corridor",
|
||||||
|
"expected_match": true,
|
||||||
|
"passed": true,
|
||||||
|
"p50_ms": 1.233,
|
||||||
|
"max_ms": 1.3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"language": "en",
|
||||||
|
"query": "solar energy",
|
||||||
|
"expected_match": true,
|
||||||
|
"passed": true,
|
||||||
|
"p50_ms": 1.23,
|
||||||
|
"max_ms": 1.426
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"language": "en",
|
||||||
|
"query": "official tax",
|
||||||
|
"expected_match": false,
|
||||||
|
"passed": true,
|
||||||
|
"p50_ms": 1.167,
|
||||||
|
"max_ms": 1.337
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"generative_benchmark": "not_executed_no_runtime_or_model",
|
"generative_benchmark": "not_executed_no_runtime_or_model",
|
||||||
"limitations": ["small_single_source_cases", "not_a_representative_benchmark", "not_human_validated_PT_MZ", "no_concurrency_or_load_test"]
|
"limitations": [
|
||||||
|
"small_single_source_cases",
|
||||||
|
"not_a_representative_benchmark",
|
||||||
|
"not_human_validated_PT_MZ",
|
||||||
|
"no_concurrency_or_load_test"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
## Casos do pedido
|
## Casos do pedido
|
||||||
|
|
||||||
| Caso | Implementado nesta etapa | Pendente |
|
| Caso | Implementado nesta etapa | Pendente |
|
||||||
| --- | --- | --- |
|
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| UC-IA-001 | Excertos citados de fontes elegíveis, data/natureza, recusa sem evidência e pedido de revisão | Respostas generativas fundamentadas, corpus oficial, assistência pública |
|
| UC-IA-001 | Excertos citados de fontes elegíveis, data/natureza, recusa sem evidência e pedido de revisão | Respostas generativas fundamentadas, corpus oficial, assistência pública |
|
||||||
| UC-IA-002 | FTS PT/EN, idioma, fonte, natureza e acesso antes da recuperação; fusão RRF unitariamente testada | Embeddings, índice pgvector, reranker e filtros territoriais/multidimensionais completos; RRF ainda não ligado a vectores reais |
|
| UC-IA-002 | FTS PT/EN, idioma, fonte, natureza e acesso antes da recuperação; fusão RRF unitariamente testada | Embeddings, índice pgvector, reranker e filtros territoriais/multidimensionais completos; RRF ainda não ligado a vectores reais |
|
||||||
| UC-IA-003 | Filtros eliminatórios de publicação/sector/província/maturidade, factores e dados em falta; apenas oportunidades canónicas publicadas | Perfil completo, regras institucionais aprovadas, similitude semântica, clusters/corredores/instrumentos/parceiros; pontuação actual conta filtros, não é ponderação financeira |
|
| UC-IA-003 | Filtros eliminatórios de publicação/sector/província/maturidade, factores e dados em falta; apenas oportunidades canónicas publicadas | Perfil completo, regras institucionais aprovadas, similitude semântica, clusters/corredores/instrumentos/parceiros; pontuação actual conta filtros, não é ponderação financeira |
|
||||||
@@ -17,7 +17,7 @@ Nenhum caso é declarado integralmente concluído. A aceitação da revisão ape
|
|||||||
## Pipeline RAG de 17 passos
|
## Pipeline RAG de 17 passos
|
||||||
|
|
||||||
| Passos | Situação |
|
| Passos | Situação |
|
||||||
| --- | --- |
|
| --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| 1–2: recepção e segurança | Cadastro canónico, upload apenas texto UTF-8, limite de tamanho, confirmação de autorização, rejeição de fontes confidenciais/restritas; formatos complexos/OCR/antivírus pendentes |
|
| 1–2: recepção e segurança | Cadastro canónico, upload apenas texto UTF-8, limite de tamanho, confirmação de autorização, rejeição de fontes confidenciais/restritas; formatos complexos/OCR/antivírus pendentes |
|
||||||
| 3–6: extracção, versão, acesso e fragmentação | Texto simples, versão/checksum do documento, metadados de fonte, revisão independente, fragmentos com ID/checksum/posição; divisão por caracteres não substitui tokenização do modelo |
|
| 3–6: extracção, versão, acesso e fragmentação | Texto simples, versão/checksum do documento, metadados de fonte, revisão independente, fragmentos com ID/checksum/posição; divisão por caracteres não substitui tokenização do modelo |
|
||||||
| 7–8: embeddings e pgvector | Não executados. Extensão/runtime ausentes. Esquema proposto separado, sem tocar na base partilhada |
|
| 7–8: embeddings e pgvector | Não executados. Extensão/runtime ausentes. Esquema proposto separado, sem tocar na base partilhada |
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
Consulta de fontes primárias em 26/09/2026. São candidatos identificados, não alegações de versões mais recentes nem selecção final. Licença do modelo não elimina obrigações de proveniência dos dados nem valida juridicamente o uso em Moçambique.
|
Consulta de fontes primárias em 26/09/2026. São candidatos identificados, não alegações de versões mais recentes nem selecção final. Licença do modelo não elimina obrigações de proveniência dos dados nem valida juridicamente o uso em Moçambique.
|
||||||
|
|
||||||
| Candidato fixado para avaliação | Licença declarada | Recursos e decisão |
|
| Candidato fixado para avaliação | Licença declarada | Recursos e decisão |
|
||||||
| --- | --- | --- |
|
| --------------------------------------------- | ----------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| mistralai/Mistral-Small-3.2-24B-Instruct-2506 | Apache-2.0 | A ficha indica cerca de 55 GB GPU em BF16/FP16. Incompatível com a GPU virtual disponível. Quantização precisa de benchmark próprio. |
|
| mistralai/Mistral-Small-3.2-24B-Instruct-2506 | Apache-2.0 | A ficha indica cerca de 55 GB GPU em BF16/FP16. Incompatível com a GPU virtual disponível. Quantização precisa de benchmark próprio. |
|
||||||
| Qwen/Qwen3-4B-Instruct-2507 | Apache-2.0 | Estimativa aritmética de pesos: cerca de 8 GB a 16 bits ou 2 GB a 4 bits, antes de KV cache, runtime e metadados. Candidato menor para benchmark, não aprovado. |
|
| Qwen/Qwen3-4B-Instruct-2507 | Apache-2.0 | Estimativa aritmética de pesos: cerca de 8 GB a 16 bits ou 2 GB a 4 bits, antes de KV cache, runtime e metadados. Candidato menor para benchmark, não aprovado. |
|
||||||
| BAAI/bge-m3 | MIT | Embeddings de 1024 dimensões, contexto máximo indicado de 8192 tokens; memória e latência locais não medidas. |
|
| BAAI/bge-m3 | MIT | Embeddings de 1024 dimensões, contexto máximo indicado de 8192 tokens; memória e latência locais não medidas. |
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ QA de aceitação: pesquisa por um projecto documental publicado deve devolvê-l
|
|||||||
## Avaliação transversal
|
## Avaliação transversal
|
||||||
|
|
||||||
| Área | Evidência e conclusão |
|
| Área | Evidência e conclusão |
|
||||||
| --- | --- |
|
| ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| Arquitectura | Laravel centraliza autorização e persistência; serviços de IA separados de controllers. R1 e R4 mostram necessidade de versões explícitas entre edição, cadastro e publicação. |
|
| Arquitectura | Laravel centraliza autorização e persistência; serviços de IA separados de controllers. R1 e R4 mostram necessidade de versões explícitas entre edição, cadastro e publicação. |
|
||||||
| Dados | Importação transaccional/idempotente, códigos documentais e relações preservados. Valores indicativos continuam em texto. R3 impede reconstituição completa do histórico editorial. |
|
| Dados | Importação transaccional/idempotente, códigos documentais e relações preservados. Valores indicativos continuam em texto. R3 impede reconstituição completa do histórico editorial. |
|
||||||
| Segurança | Rotas de gestão exigem autenticação, email verificado e `manage-portal`; resultados IA encriptados e fontes documentais revalidadas. R2 deixa uma lacuna equivalente nas dependências estruturadas. |
|
| Segurança | Rotas de gestão exigem autenticação, email verificado e `manage-portal`; resultados IA encriptados e fontes documentais revalidadas. R2 deixa uma lacuna equivalente nas dependências estruturadas. |
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ O SQL recebido foi convertido numa migração incremental para PostgreSQL/PostGI
|
|||||||
## Correspondências
|
## Correspondências
|
||||||
|
|
||||||
| SQL recebido | Modelo actual |
|
| SQL recebido | Modelo actual |
|
||||||
| --- | --- |
|
| --------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `business.parties` | Contas autenticadas em `users`; proponentes institucionais em `organizations`; perfis de investimento em `investors` e `investor_accounts`. Não é criada uma segunda tabela de identidade. |
|
| `business.parties` | Contas autenticadas em `users`; proponentes institucionais em `organizations`; perfis de investimento em `investors` e `investor_accounts`. Não é criada uma segunda tabela de identidade. |
|
||||||
| `business.opportunities` | `existing_businesses`: `tracking_code` usa `code`; proponente/criador usa `owner_user_id`; proprietário institucional usa `organization_id`; sector usa `sector_id`; versão usa `version_no`. |
|
| `business.opportunities` | `existing_businesses`: `tracking_code` usa `code`; proponente/criador usa `owner_user_id`; proprietário institucional usa `organization_id`; sector usa `sector_id`; versão usa `version_no`. |
|
||||||
| `business.opportunity_locations` | Nova tabela de relações `existing_business_locations`, ligada a `geo_locations` por UUID e com validação da hierarquia e geometria PostGIS. |
|
| `business.opportunity_locations` | Nova tabela de relações `existing_business_locations`, ligada a `geo_locations` por UUID e com validação da hierarquia e geometria PostGIS. |
|
||||||
@@ -38,7 +38,7 @@ Esta entrega altera o esquema e a serialização do modelo. Os endpoints/formul
|
|||||||
A implementação da proposta reutiliza os serviços e modelos que já existem, sem introduzir `Opportunity`, `Interest`, `Party` ou `OutboxMessage` paralelos:
|
A implementação da proposta reutiliza os serviços e modelos que já existem, sem introduzir `Opportunity`, `Interest`, `Party` ou `OutboxMessage` paralelos:
|
||||||
|
|
||||||
| Responsabilidade proposta | Implementação no portal |
|
| Responsabilidade proposta | Implementação no portal |
|
||||||
| --- | --- |
|
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| Criar e actualizar rascunhos | `ExistingBusinessDrafts`, usado pela API autenticada `api/v1/existing-business/listings`. |
|
| Criar e actualizar rascunhos | `ExistingBusinessDrafts`, usado pela API autenticada `api/v1/existing-business/listings`. |
|
||||||
| Submeter e rever anúncios | `ExistingBusinessIntake`, com autorização via `ExistingBusinessPolicy`, controlo de versão e histórico cifrado. |
|
| Submeter e rever anúncios | `ExistingBusinessIntake`, com autorização via `ExistingBusinessPolicy`, controlo de versão e histórico cifrado. |
|
||||||
| Pedidos de interesse idempotentes | `InterestRequestController` e `InterestSubmission`; eventos são gravados na outbox existente. |
|
| Pedidos de interesse idempotentes | `InterestRequestController` e `InterestSubmission`; eventos são gravados na outbox existente. |
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ Data: 04/10/2026. Revisão feita por leitura da base activa e do código de impo
|
|||||||
Todas as linhas abaixo têm `source_system=upgrade-v4`, `validation_status=pending`, `association_type=potential`, `source_reference=NULL`, `evidence_reference=NULL`, `valid_from=NULL`, `valid_until=NULL`, `editor_id=NULL` e `validator_id=NULL`. A correspondência está registada na matriz de importação da secção 4.3.4 do documento de programação indicado pelo seeder; não há citação individual de página/documento oficial ou evidência que permita elevar o tipo para `official`.
|
Todas as linhas abaixo têm `source_system=upgrade-v4`, `validation_status=pending`, `association_type=potential`, `source_reference=NULL`, `evidence_reference=NULL`, `valid_from=NULL`, `valid_until=NULL`, `editor_id=NULL` e `validator_id=NULL`. A correspondência está registada na matriz de importação da secção 4.3.4 do documento de programação indicado pelo seeder; não há citação individual de página/documento oficial ou evidência que permita elevar o tipo para `official`.
|
||||||
|
|
||||||
| Corredor | Cluster | Resultado da revisão |
|
| Corredor | Cluster | Resultado da revisão |
|
||||||
|---|---|---|
|
| --------------------------------------------- | ------------------------------------------- | ------------------------------------------------------------------- |
|
||||||
| COR-02 Corredor da Beira e Centro | CLU-01 Agro-indústria e segurança alimentar | Mapeamento de planeamento registado; relação factual por confirmar. |
|
| COR-02 Corredor da Beira e Centro | CLU-01 Agro-indústria e segurança alimentar | Mapeamento de planeamento registado; relação factual por confirmar. |
|
||||||
| COR-02 Corredor da Beira e Centro | CLU-02 Energia e industrialização | Mapeamento de planeamento registado; relação factual por confirmar. |
|
| COR-02 Corredor da Beira e Centro | CLU-02 Energia e industrialização | Mapeamento de planeamento registado; relação factual por confirmar. |
|
||||||
| COR-02 Corredor da Beira e Centro | CLU-03 Logística, corredores e exportação | Mapeamento de planeamento registado; relação factual por confirmar. |
|
| COR-02 Corredor da Beira e Centro | CLU-03 Logística, corredores e exportação | Mapeamento de planeamento registado; relação factual por confirmar. |
|
||||||
@@ -42,7 +42,7 @@ Os outros 30 vínculos (`cluster_projects`: 13; `corridor_projects`: 17) têm os
|
|||||||
## Projectos âncora — estado documental observado
|
## Projectos âncora — estado documental observado
|
||||||
|
|
||||||
| Código | Projecto | Estado de execução | Orçamento/calendário | Fonte e decisão |
|
| Código | Projecto | Estado de execução | Orçamento/calendário | Fonte e decisão |
|
||||||
|---|---|---|---|---|
|
| ------ | -------------------------------------------------------------- | ------------------ | -------------------- | ------------------------------------------------------------------------------------------------- |
|
||||||
| A01 | MozParks – 20 Parques Industriais | draft | vazio | Fonte genérica do documento de programação, secções 6.1/6.6; situação operacional não confirmada. |
|
| A01 | MozParks – 20 Parques Industriais | draft | vazio | Fonte genérica do documento de programação, secções 6.1/6.6; situação operacional não confirmada. |
|
||||||
| A02 | Linha Ferroviária Norte–Sul | draft | vazio | Idem; fonte primária individual por confirmar. |
|
| A02 | Linha Ferroviária Norte–Sul | draft | vazio | Idem; fonte primária individual por confirmar. |
|
||||||
| A03 | Programa de Desenvolvimento Integrado do Corredor de Nacala | draft | vazio | Idem; financiamento, calendário e execução por confirmar. |
|
| A03 | Programa de Desenvolvimento Integrado do Corredor de Nacala | draft | vazio | Idem; financiamento, calendário e execução por confirmar. |
|
||||||
@@ -72,4 +72,3 @@ Os outros 30 vínculos (`cluster_projects`: 13; `corridor_projects`: 17) têm os
|
|||||||
2. Fonte primária e estado actual para cada um dos 15 projectos âncora; decisão humana de publicação/actualização após confronto documental. Nenhum estado de concurso é inferido.
|
2. Fonte primária e estado actual para cada um dos 15 projectos âncora; decisão humana de publicação/actualização após confronto documental. Nenhum estado de concurso é inferido.
|
||||||
3. Para zonas, fornecer fonte legal validada e registo real autorizado para ensaio visual de ponta a ponta. O fluxo sintético prova implementação técnica, não conteúdo real.
|
3. Para zonas, fornecer fonte legal validada e registo real autorizado para ensaio visual de ponta a ponta. O fluxo sintético prova implementação técnica, não conteúdo real.
|
||||||
4. Para investimentos, substituir ou validar os seis registos de seed; fornecer ao menos uma oportunidade e um anúncio de negócio autorizados, com fonte e data, antes de ensaiar uma pretensão real. O fluxo de submissão foi coberto por fixtures na suite, sem criar dados reais.
|
4. Para investimentos, substituir ou validar os seis registos de seed; fornecer ao menos uma oportunidade e um anúncio de negócio autorizados, com fonte e data, antes de ensaiar uma pretensão real. O fluxo de submissão foi coberto por fixtures na suite, sem criar dados reais.
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,9 @@
|
|||||||
"paths": {
|
"paths": {
|
||||||
"/authorities": { "$ref": "#/components/pathItems/Authorities" },
|
"/authorities": { "$ref": "#/components/pathItems/Authorities" },
|
||||||
"/jurisdictions": { "$ref": "#/components/pathItems/Jurisdictions" },
|
"/jurisdictions": { "$ref": "#/components/pathItems/Jurisdictions" },
|
||||||
"/economic-activities": { "$ref": "#/components/pathItems/EconomicActivities" }
|
"/economic-activities": {
|
||||||
|
"$ref": "#/components/pathItems/EconomicActivities"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"components": {
|
"components": {
|
||||||
"pathItems": {
|
"pathItems": {
|
||||||
@@ -18,43 +20,111 @@
|
|||||||
"get": {
|
"get": {
|
||||||
"summary": "Search the published authorities catalogue",
|
"summary": "Search the published authorities catalogue",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{ "$ref": "#/components/parameters/q" }, { "$ref": "#/components/parameters/version" },
|
{ "$ref": "#/components/parameters/q" },
|
||||||
{ "$ref": "#/components/parameters/page" }, { "$ref": "#/components/parameters/per_page" },
|
{ "$ref": "#/components/parameters/version" },
|
||||||
{ "name": "jurisdiction_id", "in": "query", "schema": { "type": "string", "format": "uuid" } }
|
{ "$ref": "#/components/parameters/page" },
|
||||||
|
{ "$ref": "#/components/parameters/per_page" },
|
||||||
|
{
|
||||||
|
"name": "jurisdiction_id",
|
||||||
|
"in": "query",
|
||||||
|
"schema": { "type": "string", "format": "uuid" }
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"responses": { "200": { "$ref": "#/components/responses/CatalogPage" }, "429": { "description": "Rate limit exceeded" } }
|
"responses": {
|
||||||
|
"200": { "$ref": "#/components/responses/CatalogPage" },
|
||||||
|
"429": { "description": "Rate limit exceeded" }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Jurisdictions": {
|
"Jurisdictions": {
|
||||||
"get": {
|
"get": {
|
||||||
"summary": "List territorial reference options for dependent dropdowns",
|
"summary": "List territorial reference options for dependent dropdowns",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{ "$ref": "#/components/parameters/q" }, { "$ref": "#/components/parameters/version" },
|
{ "$ref": "#/components/parameters/q" },
|
||||||
{ "$ref": "#/components/parameters/page" }, { "$ref": "#/components/parameters/per_page" },
|
{ "$ref": "#/components/parameters/version" },
|
||||||
{ "name": "type", "in": "query", "required": true, "schema": { "type": "string", "enum": ["country", "province", "district", "admin_post", "locality"] } },
|
{ "$ref": "#/components/parameters/page" },
|
||||||
{ "name": "parent_id", "in": "query", "schema": { "type": "string", "format": "uuid" }, "description": "Required for district, admin_post and locality; the parent must be of the immediately preceding level." }
|
{ "$ref": "#/components/parameters/per_page" },
|
||||||
|
{
|
||||||
|
"name": "type",
|
||||||
|
"in": "query",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"country",
|
||||||
|
"province",
|
||||||
|
"district",
|
||||||
|
"admin_post",
|
||||||
|
"locality"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "parent_id",
|
||||||
|
"in": "query",
|
||||||
|
"schema": { "type": "string", "format": "uuid" },
|
||||||
|
"description": "Required for district, admin_post and locality; the parent must be of the immediately preceding level."
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"responses": { "200": { "$ref": "#/components/responses/CatalogPage" }, "422": { "description": "Invalid or missing parent selection" }, "429": { "description": "Rate limit exceeded" } }
|
"responses": {
|
||||||
|
"200": { "$ref": "#/components/responses/CatalogPage" },
|
||||||
|
"422": {
|
||||||
|
"description": "Invalid or missing parent selection"
|
||||||
|
},
|
||||||
|
"429": { "description": "Rate limit exceeded" }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"EconomicActivities": {
|
"EconomicActivities": {
|
||||||
"get": {
|
"get": {
|
||||||
"summary": "Search the portal-curated economic activity groupings",
|
"summary": "Search the portal-curated economic activity groupings",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{ "$ref": "#/components/parameters/q" }, { "$ref": "#/components/parameters/version" },
|
{ "$ref": "#/components/parameters/q" },
|
||||||
{ "$ref": "#/components/parameters/page" }, { "$ref": "#/components/parameters/per_page" },
|
{ "$ref": "#/components/parameters/version" },
|
||||||
{ "name": "parent_id", "in": "query", "schema": { "type": "string", "format": "uuid" }, "description": "Optional parent activity for hierarchical catalog browsing." },
|
{ "$ref": "#/components/parameters/page" },
|
||||||
{ "name": "sector_id", "in": "query", "schema": { "type": "integer", "minimum": 1 }, "description": "Optional sector filter for the dependent activity dropdown." }
|
{ "$ref": "#/components/parameters/per_page" },
|
||||||
|
{
|
||||||
|
"name": "parent_id",
|
||||||
|
"in": "query",
|
||||||
|
"schema": { "type": "string", "format": "uuid" },
|
||||||
|
"description": "Optional parent activity for hierarchical catalog browsing."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sector_id",
|
||||||
|
"in": "query",
|
||||||
|
"schema": { "type": "integer", "minimum": 1 },
|
||||||
|
"description": "Optional sector filter for the dependent activity dropdown."
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"responses": { "200": { "$ref": "#/components/responses/CatalogPage" }, "429": { "description": "Rate limit exceeded" } }
|
"responses": {
|
||||||
|
"200": { "$ref": "#/components/responses/CatalogPage" },
|
||||||
|
"429": { "description": "Rate limit exceeded" }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"q": { "name": "q", "in": "query", "schema": { "type": "string", "maxLength": 100 } },
|
"q": {
|
||||||
"version": { "name": "version", "in": "query", "schema": { "type": "integer", "minimum": 1 }, "description": "A published immutable version; omitted selects the current effective version." },
|
"name": "q",
|
||||||
"page": { "name": "page", "in": "query", "schema": { "type": "integer", "minimum": 1 } },
|
"in": "query",
|
||||||
"per_page": { "name": "per_page", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 100 } }
|
"schema": { "type": "string", "maxLength": 100 }
|
||||||
|
},
|
||||||
|
"version": {
|
||||||
|
"name": "version",
|
||||||
|
"in": "query",
|
||||||
|
"schema": { "type": "integer", "minimum": 1 },
|
||||||
|
"description": "A published immutable version; omitted selects the current effective version."
|
||||||
|
},
|
||||||
|
"page": {
|
||||||
|
"name": "page",
|
||||||
|
"in": "query",
|
||||||
|
"schema": { "type": "integer", "minimum": 1 }
|
||||||
|
},
|
||||||
|
"per_page": {
|
||||||
|
"name": "per_page",
|
||||||
|
"in": "query",
|
||||||
|
"schema": { "type": "integer", "minimum": 1, "maximum": 100 }
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"responses": {
|
"responses": {
|
||||||
"CatalogPage": {
|
"CatalogPage": {
|
||||||
@@ -67,17 +137,42 @@
|
|||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": ["data", "links", "meta", "next_page_url", "prev_page_url", "current_page", "per_page", "total", "last_page"],
|
"required": [
|
||||||
|
"data",
|
||||||
|
"links",
|
||||||
|
"meta",
|
||||||
|
"next_page_url",
|
||||||
|
"prev_page_url",
|
||||||
|
"current_page",
|
||||||
|
"per_page",
|
||||||
|
"total",
|
||||||
|
"last_page"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"data": { "type": "array", "items": { "$ref": "#/components/schemas/CatalogEntry" } },
|
"data": {
|
||||||
"links": { "type": "object", "properties": { "next": { "type": ["string", "null"] }, "previous": { "type": ["string", "null"] } } },
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/CatalogEntry"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"links": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"next": { "type": ["string", "null"] },
|
||||||
|
"previous": {
|
||||||
|
"type": ["string", "null"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"next_page_url": { "type": ["string", "null"] },
|
"next_page_url": { "type": ["string", "null"] },
|
||||||
"prev_page_url": { "type": ["string", "null"] },
|
"prev_page_url": { "type": ["string", "null"] },
|
||||||
"current_page": { "type": "integer" },
|
"current_page": { "type": "integer" },
|
||||||
"per_page": { "type": "integer" },
|
"per_page": { "type": "integer" },
|
||||||
"total": { "type": "integer" },
|
"total": { "type": "integer" },
|
||||||
"last_page": { "type": "integer" },
|
"last_page": { "type": "integer" },
|
||||||
"meta": { "$ref": "#/components/schemas/CatalogMetadata" }
|
"meta": {
|
||||||
|
"$ref": "#/components/schemas/CatalogMetadata"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,33 +185,66 @@
|
|||||||
"required": ["id", "value", "code", "name", "label", "locale"],
|
"required": ["id", "value", "code", "name", "label", "locale"],
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": { "type": "string", "format": "uuid" },
|
"id": { "type": "string", "format": "uuid" },
|
||||||
"value": { "type": "string", "description": "Stable API value; never the translated label." },
|
"value": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Stable API value; never the translated label."
|
||||||
|
},
|
||||||
"code": { "type": "string" },
|
"code": { "type": "string" },
|
||||||
"name": { "type": "string" },
|
"name": { "type": "string" },
|
||||||
"label": { "type": "string", "description": "Presentation label in pt-MZ." },
|
"label": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Presentation label in pt-MZ."
|
||||||
|
},
|
||||||
"locale": { "const": "pt-MZ" },
|
"locale": { "const": "pt-MZ" },
|
||||||
"parent_id": { "type": ["string", "null"], "format": "uuid" },
|
"parent_id": {
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"format": "uuid"
|
||||||
|
},
|
||||||
"type": { "type": "string" },
|
"type": { "type": "string" },
|
||||||
"version_no": { "type": "integer", "minimum": 1 },
|
"version_no": { "type": "integer", "minimum": 1 },
|
||||||
"sector_id": { "type": "integer" },
|
"sector_id": { "type": "integer" },
|
||||||
"source_code": { "type": ["string", "null"] },
|
"source_code": { "type": ["string", "null"] },
|
||||||
"authority_type": { "type": "string" },
|
"authority_type": { "type": "string" },
|
||||||
"organization_id": { "type": "string", "format": "uuid" },
|
"organization_id": { "type": "string", "format": "uuid" },
|
||||||
"jurisdiction_id": { "type": ["string", "null"], "format": "uuid" },
|
"jurisdiction_id": {
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"format": "uuid"
|
||||||
|
},
|
||||||
"jurisdiction_name": { "type": ["string", "null"] }
|
"jurisdiction_name": { "type": ["string", "null"] }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"CatalogMetadata": {
|
"CatalogMetadata": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": ["catalog", "version", "locale", "current_page", "per_page", "total", "last_page"],
|
"required": [
|
||||||
|
"catalog",
|
||||||
|
"version",
|
||||||
|
"locale",
|
||||||
|
"current_page",
|
||||||
|
"per_page",
|
||||||
|
"total",
|
||||||
|
"last_page"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"catalog": { "type": "string", "enum": ["authorities", "jurisdictions", "economic-activities"] },
|
"catalog": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"authorities",
|
||||||
|
"jurisdictions",
|
||||||
|
"economic-activities"
|
||||||
|
]
|
||||||
|
},
|
||||||
"version": { "type": ["integer", "null"] },
|
"version": { "type": ["integer", "null"] },
|
||||||
"locale": { "const": "pt-MZ" },
|
"locale": { "const": "pt-MZ" },
|
||||||
"status": { "type": "string", "enum": ["not_published"] },
|
"status": { "type": "string", "enum": ["not_published"] },
|
||||||
"source_version": { "type": ["string", "null"] },
|
"source_version": { "type": ["string", "null"] },
|
||||||
"valid_from": { "type": ["string", "null"], "format": "date" },
|
"valid_from": {
|
||||||
"valid_to": { "type": ["string", "null"], "format": "date" },
|
"type": ["string", "null"],
|
||||||
|
"format": "date"
|
||||||
|
},
|
||||||
|
"valid_to": {
|
||||||
|
"type": ["string", "null"],
|
||||||
|
"format": "date"
|
||||||
|
},
|
||||||
"current_page": { "type": "integer" },
|
"current_page": { "type": "integer" },
|
||||||
"per_page": { "type": "integer" },
|
"per_page": { "type": "integer" },
|
||||||
"total": { "type": "integer" },
|
"total": { "type": "integer" },
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ Este relatório é um índice de estado actual; prevalece sobre afirmações his
|
|||||||
## Reconciliação por grupos de pedidos
|
## Reconciliação por grupos de pedidos
|
||||||
|
|
||||||
| Grupo | Estado técnico actual | Pendência que impede conclusão |
|
| Grupo | Estado técnico actual | Pendência que impede conclusão |
|
||||||
| --- | --- | --- |
|
| ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| Diagnóstico integral da aplicação e inventário de funcionalidades | Parcial; documentação/matriz consolidada existe | Rever manualmente todas as páginas e validar com perfis reais. Integrações e comportamentos não comprovados pelo código continuam “a validar”. |
|
| Diagnóstico integral da aplicação e inventário de funcionalidades | Parcial; documentação/matriz consolidada existe | Rever manualmente todas as páginas e validar com perfis reais. Integrações e comportamentos não comprovados pelo código continuam “a validar”. |
|
||||||
| Migrações, PostgreSQL/PostGIS, segurança e QA | Parcial/concluído tecnicamente em componentes | Suite foi repetida em cluster descartável; o incidente histórico em `investmoz_test:5432` carece de comparação/restauro validado por DBA. Não executar operações destrutivas nessa base. |
|
| Migrações, PostgreSQL/PostGIS, segurança e QA | Parcial/concluído tecnicamente em componentes | Suite foi repetida em cluster descartável; o incidente histórico em `investmoz_test:5432` carece de comparação/restauro validado por DBA. Não executar operações destrutivas nessa base. |
|
||||||
| Geografia e formulários de investimento/oportunidades | Implementação extensa e testes presentes | Confirmar catálogo territorial e conteúdo com fonte de negócio, percorrer browser/dispositivos e validar permissões operacionais. |
|
| Geografia e formulários de investimento/oportunidades | Implementação extensa e testes presentes | Confirmar catálogo territorial e conteúdo com fonte de negócio, percorrer browser/dispositivos e validar permissões operacionais. |
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Data: 2026-10-03. Âmbito: prompt master recebido em `Pasted text.txt`, document
|
|||||||
## Estado inicial e ambiente
|
## Estado inicial e ambiente
|
||||||
|
|
||||||
| Item | Evidência observada |
|
| Item | Evidência observada |
|
||||||
| --- | --- |
|
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| Branch / commit | `main` / `4f35313d06ccd597a4ebf9ed043964d898c95813` |
|
| Branch / commit | `main` / `4f35313d06ccd597a4ebf9ed043964d898c95813` |
|
||||||
| Árvore de trabalho | 50 ficheiros rastreados modificados, muitos não rastreados; cerca de 7.748 inserções e 1.053 remoções rastreadas. Estado anterior preservado, sem reset ou limpeza. |
|
| Árvore de trabalho | 50 ficheiros rastreados modificados, muitos não rastreados; cerca de 7.748 inserções e 1.053 remoções rastreadas. Estado anterior preservado, sem reset ou limpeza. |
|
||||||
| Runtime | PHP 8.5.11, Composer 2.8.12, Node 24.20.0, npm 11.19.0. Laravel 13.30.1, Inertia Laravel 3.3.3, React 19.2.8, TypeScript 5.9.3, Vite 8.2.2, PHPUnit 12.5.34. |
|
| Runtime | PHP 8.5.11, Composer 2.8.12, Node 24.20.0, npm 11.19.0. Laravel 13.30.1, Inertia Laravel 3.3.3, React 19.2.8, TypeScript 5.9.3, Vite 8.2.2, PHPUnit 12.5.34. |
|
||||||
@@ -18,7 +18,7 @@ Data: 2026-10-03. Âmbito: prompt master recebido em `Pasted text.txt`, document
|
|||||||
Estados: **implementado e verificado**, **parcial**, **não implementado**, **não verificado**, **bloqueado**, **substituído por decisão documentada**.
|
Estados: **implementado e verificado**, **parcial**, **não implementado**, **não verificado**, **bloqueado**, **substituído por decisão documentada**.
|
||||||
|
|
||||||
| ID / origem | Requisito e aceite verificável | Implementação / evidência actual | Estado / lacuna | Dependências / prioridade | Próxima alteração ou teste / validação pendente |
|
| ID / origem | Requisito e aceite verificável | Implementação / evidência actual | Estado / lacuna | Dependências / prioridade | Próxima alteração ou teste / validação pendente |
|
||||||
| --- | --- | --- | --- | --- | --- |
|
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| M-01 §1–3, master | Preservar autorização, tecnologia, trabalho existente e limites de publicação/dados. | Branch e commit registados; Laravel 13 + React/Inertia/TS + PostgreSQL/PostGIS confirmados; diff preexistente mantido. | Implementado e verificado no procedimento desta revisão. | Transversal / crítica. | Continuar a executar mudanças reversíveis; nenhuma publicação ou integração real sem configuração e autorização específicas. |
|
| M-01 §1–3, master | Preservar autorização, tecnologia, trabalho existente e limites de publicação/dados. | Branch e commit registados; Laravel 13 + React/Inertia/TS + PostgreSQL/PostGIS confirmados; diff preexistente mantido. | Implementado e verificado no procedimento desta revisão. | Transversal / crítica. | Continuar a executar mudanças reversíveis; nenhuma publicação ou integração real sem configuração e autorização específicas. |
|
||||||
| M-02 §2, master | Reconciliar documentos e caminhos sem inferir ausência funcional. | Prompt master, directórios `Formularios`/`por executar`, relatório PII e docs internos localizados. Revisão consolidada Markdown e protótipo HTML não localizados no caminho pesquisado. | Parcial. | Inventário documental / alta. | Extrair conteúdo/hash dos DOCX relevantes por lote e mapear requisitos aos IDs; confirmar se os dois artefactos ausentes existem noutra pasta. |
|
| M-02 §2, master | Reconciliar documentos e caminhos sem inferir ausência funcional. | Prompt master, directórios `Formularios`/`por executar`, relatório PII e docs internos localizados. Revisão consolidada Markdown e protótipo HTML não localizados no caminho pesquisado. | Parcial. | Inventário documental / alta. | Extrair conteúdo/hash dos DOCX relevantes por lote e mapear requisitos aos IDs; confirmar se os dois artefactos ausentes existem noutra pasta. |
|
||||||
| M-03 §4 e §13, master | Inventariar e manter matriz completa, sequencial e persistente. | Esta matriz e o ledger `simulator-evolution-progress.md`; rotas, testes, migrations, CI e OpenAPI localizados. | Parcial. | Todas as etapas / crítica. | Expandir matriz com requisitos atómicos e referências de parágrafo/tabela dos DOCX; actualizar estado após cada etapa. |
|
| M-03 §4 e §13, master | Inventariar e manter matriz completa, sequencial e persistente. | Esta matriz e o ledger `simulator-evolution-progress.md`; rotas, testes, migrations, CI e OpenAPI localizados. | Parcial. | Todas as etapas / crítica. | Expandir matriz com requisitos atómicos e referências de parágrafo/tabela dos DOCX; actualizar estado após cada etapa. |
|
||||||
@@ -46,7 +46,7 @@ Estados: **implementado e verificado**, **parcial**, **não implementado**, **n
|
|||||||
## Reconciliação de versões e conflitos
|
## Reconciliação de versões e conflitos
|
||||||
|
|
||||||
| Conflito | Decisão baseada no pedido e evidência actual | Consequência |
|
| Conflito | Decisão baseada no pedido e evidência actual | Consequência |
|
||||||
| --- | --- | --- |
|
| -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
|
||||||
| Coordenada obrigatória vs localização por validar | Não inventar coordenada; lista continua disponível. | Publicação no mapa requer evidência geográfica validada. |
|
| Coordenada obrigatória vs localização por validar | Não inventar coordenada; lista continua disponível. | Publicação no mapa requer evidência geográfica validada. |
|
||||||
| CRM vs SuiteCRM | CRM interno é domínio próprio; SuiteCRM é integração por mecanismo suportado. | Sem escrita directa na BD SuiteCRM; manter integração desligada até configuração e teste. |
|
| CRM vs SuiteCRM | CRM interno é domínio próprio; SuiteCRM é integração por mecanismo suportado. | Sem escrita directa na BD SuiteCRM; manter integração desligada até configuração e teste. |
|
||||||
| Projecto previsto vs oportunidade disponível | São entidades e estados editoriais distintos. | Investimento do PII não entra automaticamente no catálogo público. |
|
| Projecto previsto vs oportunidade disponível | São entidades e estados editoriais distintos. | Investimento do PII não entra automaticamente no catálogo público. |
|
||||||
@@ -56,7 +56,7 @@ Estados: **implementado e verificado**, **parcial**, **não implementado**, **n
|
|||||||
## Linha de base e evidências
|
## Linha de base e evidências
|
||||||
|
|
||||||
| Comando executado | Resultado |
|
| Comando executado | Resultado |
|
||||||
| --- | --- |
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `git branch --show-current; git rev-parse HEAD; git status --short` | `main`, commit acima; diff preexistente preservado. |
|
| `git branch --show-current; git rev-parse HEAD; git status --short` | `main`, commit acima; diff preexistente preservado. |
|
||||||
| `php artisan route:list --json` com PHP 8.5.11 | Sucesso; rotas públicas, autenticadas e management listadas. |
|
| `php artisan route:list --json` com PHP 8.5.11 | Sucesso; rotas públicas, autenticadas e management listadas. |
|
||||||
| `composer show --no-interaction --direct` | Sucesso; versões do backend confirmadas. |
|
| `composer show --no-interaction --direct` | Sucesso; versões do backend confirmadas. |
|
||||||
@@ -66,7 +66,7 @@ Estados: **implementado e verificado**, **parcial**, **não implementado**, **n
|
|||||||
| `composer run types:check --no-interaction` | Passou, PHPStan: 0 erros. |
|
| `composer run types:check --no-interaction` | Passou, PHPStan: 0 erros. |
|
||||||
| `composer run lint:check --no-interaction` | Falhou em cinco ficheiros: migration territorial de 28/09, `routes/investment-zones.php`, `routes/web.php`, `tests/Feature/ApiContractTest.php`, `tools/test-mne-integrity.php`. Não alterados nesta tranche. |
|
| `composer run lint:check --no-interaction` | Falhou em cinco ficheiros: migration territorial de 28/09, `routes/investment-zones.php`, `routes/web.php`, `tests/Feature/ApiContractTest.php`, `tools/test-mne-integrity.php`. Não alterados nesta tranche. |
|
||||||
| `npm.cmd run check` | Falhou antes da análise porque `docs/investmoz/simulator-evolution-progress.md` não pode ser lido pelo formatador (ficheiro binário/inacessível). Nenhuma opção `--fix` executada. |
|
| `npm.cmd run check` | Falhou antes da análise porque `docs/investmoz/simulator-evolution-progress.md` não pode ser lido pelo formatador (ficheiro binário/inacessível). Nenhuma opção `--fix` executada. |
|
||||||
| `php vendor/bin/phpunit --configuration=phpunit.xml --filter PortalServicesTest --do-not-cache-result` | 5/5 testes, 191 assertions; passou na base QA `investmoz_browser_e2e_test`, porta 55441.
|
| `php vendor/bin/phpunit --configuration=phpunit.xml --filter PortalServicesTest --do-not-cache-result` | 5/5 testes, 191 assertions; passou na base QA `investmoz_browser_e2e_test`, porta 55441. |
|
||||||
| `php vendor/bin/phpunit --configuration=phpunit.xml --do-not-cache-result` | 231/231 testes, 2.299 assertions; passou em 71,593 s na mesma base QA isolada. |
|
| `php vendor/bin/phpunit --configuration=phpunit.xml --do-not-cache-result` | 231/231 testes, 2.299 assertions; passou em 71,593 s na mesma base QA isolada. |
|
||||||
| Build Vite | 2.388 módulos compilados com sucesso nesta revisão. |
|
| Build Vite | 2.388 módulos compilados com sucesso nesta revisão. |
|
||||||
| `npm.cmd run build` | Passou nesta revisão; 2.388 módulos. Aviso não bloqueante: dependência opcional `fontaine`. |
|
| `npm.cmd run build` | Passou nesta revisão; 2.388 módulos. Aviso não bloqueante: dependência opcional `fontaine`. |
|
||||||
@@ -153,7 +153,7 @@ The three investment structure junction tables now support association type, sou
|
|||||||
Esta adenda prevalece sobre estados e caminhos pesquisados em 2026-10-03, sem apagar o registo historico. A matriz continua sendo o indice consolidado; `simulator-evolution-progress.md` e o diario de execucao, nao uma segunda matriz.
|
Esta adenda prevalece sobre estados e caminhos pesquisados em 2026-10-03, sem apagar o registo historico. A matriz continua sendo o indice consolidado; `simulator-evolution-progress.md` e o diario de execucao, nao uma segunda matriz.
|
||||||
|
|
||||||
| ID | Requisito | Evidencia actual conferida | Estado actual e accao | Teste/gate |
|
| ID | Requisito | Evidencia actual conferida | Estado actual e accao | Teste/gate |
|
||||||
| --- | --- | --- | --- | --- |
|
| ----------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| M-02 | Reconciliar prompts, fontes e pastas indicadas, sem inferir ausencia a partir de um caminho errado. | A pasta `C:\Mac\Home\Documents\TEMPO\Portal Tempo\Servicos Tempo\prompt` e acessivel; existe conjunto de DOCX, incluindo prompts do simulador e formulários. A pasta `Legislacao` tem codigos e alteracoes fiscais antes registados como nao disponiveis. Foi localizado `Informacao Publica\Legislacao - resumos\Reforma fiscal de 2026.docx`. | Corrigida a afirmacao de indisponibilidade do resumo fiscal. A coleccao foi inventariada e documentos relevantes foram extraidos selectivamente; nao se declara leitura/reconciliacao integral de todos os DOCX. `DUAT.docx` permanece bloqueado por uso do ficheiro e nao foi alterado. | Continuar leitura por dominio e actualizar esta matriz; scans exigem OCR/cotejo visual. |
|
| M-02 | Reconciliar prompts, fontes e pastas indicadas, sem inferir ausencia a partir de um caminho errado. | A pasta `C:\Mac\Home\Documents\TEMPO\Portal Tempo\Servicos Tempo\prompt` e acessivel; existe conjunto de DOCX, incluindo prompts do simulador e formulários. A pasta `Legislacao` tem codigos e alteracoes fiscais antes registados como nao disponiveis. Foi localizado `Informacao Publica\Legislacao - resumos\Reforma fiscal de 2026.docx`. | Corrigida a afirmacao de indisponibilidade do resumo fiscal. A coleccao foi inventariada e documentos relevantes foram extraidos selectivamente; nao se declara leitura/reconciliacao integral de todos os DOCX. `DUAT.docx` permanece bloqueado por uso do ficheiro e nao foi alterado. | Continuar leitura por dominio e actualizar esta matriz; scans exigem OCR/cotejo visual. |
|
||||||
| D-05 / V-04 | Motor fiscal reproduzivel, por periodo, com fontes, formulas, pressupostos e resultado indeterminado quando faltar dado. | `SimulationTaxRuleExpression` implementa DSL allowlist/DAG/BigRational; `SimulationTaxParameterResolver` trata periodo, `scope_key`, contexto e fonte; endpoint publico projecta parametros; interface apresenta estado/fonte. `RunSimulation` nao invoca o avaliador e continua aritmetica geral/custom. | **Parcial; nenhum motor de apuramento fiscal integrado.** Testes de DSL/resolucao existem, mas sem casos dourados externos ligados a resultados independentes. Nao chamar o fluxo genericamente estimativo de calculo legal. | Executar os testes unitarios tecnicos; gate por componente requer texto legivel/autenticado, regra ligada, snapshot/explicabilidade e resultado de referencia confirmado. |
|
| D-05 / V-04 | Motor fiscal reproduzivel, por periodo, com fontes, formulas, pressupostos e resultado indeterminado quando faltar dado. | `SimulationTaxRuleExpression` implementa DSL allowlist/DAG/BigRational; `SimulationTaxParameterResolver` trata periodo, `scope_key`, contexto e fonte; endpoint publico projecta parametros; interface apresenta estado/fonte. `RunSimulation` nao invoca o avaliador e continua aritmetica geral/custom. | **Parcial; nenhum motor de apuramento fiscal integrado.** Testes de DSL/resolucao existem, mas sem casos dourados externos ligados a resultados independentes. Nao chamar o fluxo genericamente estimativo de calculo legal. | Executar os testes unitarios tecnicos; gate por componente requer texto legivel/autenticado, regra ligada, snapshot/explicabilidade e resultado de referencia confirmado. |
|
||||||
| D-05 / M-04 | Consolidar CIVA sem somar texto substituido e respeitar vigencia. | O acervo tem Lei 13/2016 (32 paginas, sem camada de texto), PDF denominado rectificado (15 paginas, sem camada de texto), Lei 22/2022 (26 paginas, camada de texto) e alteracao CIVA 2023 (18 paginas, texto extraivel). Ha fontes oficiais INM/Parlamento ja citadas em `official-source-register.md`. | Localizacao confirmada; OCR util nao obtido nesta execucao para scans. Aplicar Lei 13/2016 como base metodologica, reconciliar diplomas anteriores e aplicar posteriores apenas por artigo/vigencia. Anexos rectificados continuam pendentes de cotejo legivel. | Sem activar isencoes/taxas afectadas ate cotejo de fonte/autenticidade e testes antes/depois da vigencia. |
|
| D-05 / M-04 | Consolidar CIVA sem somar texto substituido e respeitar vigencia. | O acervo tem Lei 13/2016 (32 paginas, sem camada de texto), PDF denominado rectificado (15 paginas, sem camada de texto), Lei 22/2022 (26 paginas, camada de texto) e alteracao CIVA 2023 (18 paginas, texto extraivel). Ha fontes oficiais INM/Parlamento ja citadas em `official-source-register.md`. | Localizacao confirmada; OCR util nao obtido nesta execucao para scans. Aplicar Lei 13/2016 como base metodologica, reconciliar diplomas anteriores e aplicar posteriores apenas por artigo/vigencia. Anexos rectificados continuam pendentes de cotejo legivel. | Sem activar isencoes/taxas afectadas ate cotejo de fonte/autenticidade e testes antes/depois da vigencia. |
|
||||||
@@ -166,7 +166,7 @@ Esta adenda prevalece sobre estados e caminhos pesquisados em 2026-10-03, sem ap
|
|||||||
Documento lido: `Informacao Publica/Legislacao - resumos/Reforma fiscal de 2026.docx`, SHA-256 `36666904ADB982AD578145E7B70244146C6414299B18F086042A5B4A6C2385B6`. Referencia primaria consultada no BR 248 previamente arquivado e no sumario oficial INM. Uma segunda copia local tem texto extraivel, mas hash e paginação diferem do exemplar arquivado.
|
Documento lido: `Informacao Publica/Legislacao - resumos/Reforma fiscal de 2026.docx`, SHA-256 `36666904ADB982AD578145E7B70244146C6414299B18F086042A5B4A6C2385B6`. Referencia primaria consultada no BR 248 previamente arquivado e no sumario oficial INM. Uma segunda copia local tem texto extraivel, mas hash e paginação diferem do exemplar arquivado.
|
||||||
|
|
||||||
| Tema | Alegacao secundária | Dispositivo primário cotejado | Resultado / estado |
|
| Tema | Alegacao secundária | Dispositivo primário cotejado | Resultado / estado |
|
||||||
| --- | --- | --- | --- |
|
| ---------------------------------------- | --------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| IVA vs ISPC | Revogacao dos regimes simplificados de IVA pode ser lida como eliminacao do ISPC. | Lei 9/2025 cria/actualiza ISPC; Lei 10/2025, arts. 3 e 53, altera/revoga disposicoes do CIVA e regula transicao do IVA. | Regimes distintos; divergencia resolvida. ISPC permanece sujeito a elegibilidade propria, nao basta limite de volume. |
|
| IVA vs ISPC | Revogacao dos regimes simplificados de IVA pode ser lida como eliminacao do ISPC. | Lei 9/2025 cria/actualiza ISPC; Lei 10/2025, arts. 3 e 53, altera/revoga disposicoes do CIVA e regula transicao do IVA. | Regimes distintos; divergencia resolvida. ISPC permanece sujeito a elegibilidade propria, nao basta limite de volume. |
|
||||||
| Reembolso IVA | 150 dias e prescricao de 10 anos. | Lei 10/2025, art. 21, n.os 10 e 15 no texto extraido. | Correspondencia textual encontrada. Nao confundir credito/pedido com reconhecimento ou recebimento; regulamento/procedimento e estados de tesouraria continuam por validar. |
|
| Reembolso IVA | 150 dias e prescricao de 10 anos. | Lei 10/2025, art. 21, n.os 10 e 15 no texto extraido. | Correspondencia textual encontrada. Nao confundir credito/pedido com reconhecimento ou recebimento; regulamento/procedimento e estados de tesouraria continuam por validar. |
|
||||||
| Dedutibilidade | Proporcao em casos de base reduzida e exclusoes. | Lei 10/2025, art. 18(6) e art. 19(2), este referente a operacoes do art. 17-A. | Confirmado apenas no escopo dos dispositivos citados; nao generalizar a todas as operacoes. |
|
| Dedutibilidade | Proporcao em casos de base reduzida e exclusoes. | Lei 10/2025, art. 18(6) e art. 19(2), este referente a operacoes do art. 17-A. | Confirmado apenas no escopo dos dispositivos citados; nao generalizar a todas as operacoes. |
|
||||||
@@ -178,7 +178,7 @@ Documento lido: `Informacao Publica/Legislacao - resumos/Reforma fiscal de 2026.
|
|||||||
### Inventario de fontes fiscais localizadas nesta revisao
|
### Inventario de fontes fiscais localizadas nesta revisao
|
||||||
|
|
||||||
| Ficheiro (fora do repositorio) | Tamanho / SHA-256 | Leitura nesta execucao |
|
| Ficheiro (fora do repositorio) | Tamanho / SHA-256 | Leitura nesta execucao |
|
||||||
| --- | --- | --- |
|
| ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
|
||||||
| `Legislacao/Lei 13_2016_Reimpressao Codigo do IVA.pdf` | 2.127.554 bytes / `b90dc7c14ece2a2e3784c62e8e5a47d54a5644c457baeb8b8053b92fd2a5710b` | 32 paginas, sem camada de texto; OCR nao produziu texto utilizavel. |
|
| `Legislacao/Lei 13_2016_Reimpressao Codigo do IVA.pdf` | 2.127.554 bytes / `b90dc7c14ece2a2e3784c62e8e5a47d54a5644c457baeb8b8053b92fd2a5710b` | 32 paginas, sem camada de texto; OCR nao produziu texto utilizavel. |
|
||||||
| `Legislacao/RectificaçãoLei.13.2016_Republicação.Codigo.IVA.pdf` | 19.539.751 bytes / `ad675fef757016b730e859c834ab1a1602576260510912dda6f9d320393d415c` | 15 paginas, sem camada de texto; OCR nao produziu texto utilizavel. |
|
| `Legislacao/RectificaçãoLei.13.2016_Republicação.Codigo.IVA.pdf` | 19.539.751 bytes / `ad675fef757016b730e859c834ab1a1602576260510912dda6f9d320393d415c` | 15 paginas, sem camada de texto; OCR nao produziu texto utilizavel. |
|
||||||
| `Legislacao/alteracao CIVA 2023.pdf` | 708.707 bytes / `0c13f4b03dadea7f2dfe30694650078fa7b9de00ef84cb47389422d23a5271cd` | 18 paginas; texto extraivel, ainda nao reconciliado artigo a artigo. |
|
| `Legislacao/alteracao CIVA 2023.pdf` | 708.707 bytes / `0c13f4b03dadea7f2dfe30694650078fa7b9de00ef84cb47389422d23a5271cd` | 18 paginas; texto extraivel, ainda nao reconciliado artigo a artigo. |
|
||||||
@@ -192,7 +192,7 @@ O PDF de compromisso OCAM foi lido apenas para estabelecer o seu escopo (Modelo
|
|||||||
## REC001-REC016 - connected journey tranche (2026-10-04)
|
## REC001-REC016 - connected journey tranche (2026-10-04)
|
||||||
|
|
||||||
| REC | Current evidence and decision | State after this tranche | Next concrete work |
|
| REC | Current evidence and decision | State after this tranche | Next concrete work |
|
||||||
| --- | --- | --- | --- |
|
| ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
|
||||||
| REC001 | `SimulationFormDraft` already encrypts snapshots; `SimulationBusinessPlan` stores a versioned plan snapshot. Adapt existing draft rather than add a second dossier. | Partial: exploratory small-business draft now contains idea and plan stages; not yet one persistent canonical project linked to all modules. | Define canonical project relationship and cross-module ownership before linking records. |
|
| REC001 | `SimulationFormDraft` already encrypts snapshots; `SimulationBusinessPlan` stores a versioned plan snapshot. Adapt existing draft rather than add a second dossier. | Partial: exploratory small-business draft now contains idea and plan stages; not yet one persistent canonical project linked to all modules. | Define canonical project relationship and cross-module ownership before linking records. |
|
||||||
| REC002 | Guided sections already exist in `simulation-form.ts`. | Partial: the small-business exploratory path captures problem, customers, value proposition, sector/activity, location and declared market assumptions in the existing resumable draft. | Add structured market evidence and reusable operational detail. |
|
| REC002 | Guided sections already exist in `simulation-form.ts`. | Partial: the small-business exploratory path captures problem, customers, value proposition, sector/activity, location and declared market assumptions in the existing resumable draft. | Add structured market evidence and reusable operational detail. |
|
||||||
| REC003 | Business plan and cashflow tools have independent tests and versioned snapshots. | Partial: financial plan is available in exploratory small-business path; fiscal rules remain separate and may be indeterminate. | Test full plan-to-simulator reconciliation and scenario history. |
|
| REC003 | Business plan and cashflow tools have independent tests and versioned snapshots. | Partial: financial plan is available in exploratory small-business path; fiscal rules remain separate and may be indeterminate. | Test full plan-to-simulator reconciliation and scenario history. |
|
||||||
@@ -215,7 +215,7 @@ Pilot: synthetic, unseeded small-business idea using the public `/Simulador` pat
|
|||||||
### REC001–REC016 follow-up — 2026-10-04
|
### REC001–REC016 follow-up — 2026-10-04
|
||||||
|
|
||||||
| Area | Delivered in this tranche | Remaining gate |
|
| Area | Delivered in this tranche | Remaining gate |
|
||||||
| --- | --- | --- |
|
| ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||||
| Dossier, idea and finance | Reused encrypted `SimulationFormDraft` and existing versioned business-plan snapshot; added dossier CSV with market claim/source, location, finance assumptions, declared needs, team and execution rows. | Cross-module canonical project identity and plan snapshot reconciliation remain future work. |
|
| Dossier, idea and finance | Reused encrypted `SimulationFormDraft` and existing versioned business-plan snapshot; added dossier CSV with market claim/source, location, finance assumptions, declared needs, team and execution rows. | Cross-module canonical project identity and plan snapshot reconciliation remain future work. |
|
||||||
| Team and execution | New structured planner rows capture competency, availability/gap, planned response, estimated cost/date, milestone status and planned/actual amounts. Server enforces JSON shape, state whitelist, 100-row limit and nonnegative amounts. | Matching to education providers/certified skills and reconciling realized amounts to accounting/plan remain pending. |
|
| Team and execution | New structured planner rows capture competency, availability/gap, planned response, estimated cost/date, milestone status and planned/actual amounts. Server enforces JSON shape, state whitelist, 100-row limit and nonnegative amounts. | Matching to education providers/certified skills and reconciling realized amounts to accounting/plan remain pending. |
|
||||||
| Market origin and indicators | UI and dossier explicitly say “Informação declarada, não verificada”; source/date optional. Exports distinguish declared assumptions and estimates from selected territorial catalogue values. | Official indicator catalogue with source, period, geography, unit and coverage is not present as a complete connected dataset. |
|
| Market origin and indicators | UI and dossier explicitly say “Informação declarada, não verificada”; source/date optional. Exports distinguish declared assumptions and estimates from selected territorial catalogue values. | Official indicator catalogue with source, period, geography, unit and coverage is not present as a complete connected dataset. |
|
||||||
@@ -238,7 +238,7 @@ Esta secção é a reconciliação corrente desta matriz para Documentos e Formu
|
|||||||
### Documentos — quatro recursos, revisão separada por dimensão
|
### Documentos — quatro recursos, revisão separada por dimensão
|
||||||
|
|
||||||
| ID recurso / ID documento | Título e URL de gestão | Origem efectivamente identificada | Autenticidade | Vigência/actualidade | Direitos de divulgação / autorização | Bloqueio e proposta individual |
|
| ID recurso / ID documento | Título e URL de gestão | Origem efectivamente identificada | Autenticidade | Vigência/actualidade | Direitos de divulgação / autorização | Bloqueio e proposta individual |
|
||||||
|---|---|---|---|---|---|---|
|
| -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `1` / `5c860c48-e8cb-4d8d-ab9b-2e3ea7036ce2` | Lei n.º 22/2022, alteração ao CIVA (republicação). `http://localhost:8000/management/portal-services` — localizar recurso 1. | [INM](https://www.inm.gov.mz/pt-br/content/assembleia-da-rep%C3%BAblica-suplemento-n%C2%BA-2-de-281222-pag-2252-25-42-br-n%C2%BA-250-boletim-da); catálogo/WebDAV oficial AT; tamanho e SHA-256 coincidem com a cópia oficial registada. | Confirmada para a edição e bytes. | Marcada `amended`; art. 17(1) foi localizado, mas não é consolidação integral actual. Não bloqueia publicação como documento histórico se assim rotulado; bloqueia tratá-la como texto actual consolidado. | Documento e recurso `rights_status=unconfirmed`, classificação `internal`; autorização para redistribuir esta cópia PDF/fac-símile não documentada. | **Não pronta.** Gestor regista base de reutilização/divulgação, depois classifica explicitamente como pública e publica. Proposta: Lei 22/2022 histórica, com aviso de alterações posteriores, nunca como CIVA consolidado. Fonte e malware passam; direitos bloqueiam publicação. |
|
| `1` / `5c860c48-e8cb-4d8d-ab9b-2e3ea7036ce2` | Lei n.º 22/2022, alteração ao CIVA (republicação). `http://localhost:8000/management/portal-services` — localizar recurso 1. | [INM](https://www.inm.gov.mz/pt-br/content/assembleia-da-rep%C3%BAblica-suplemento-n%C2%BA-2-de-281222-pag-2252-25-42-br-n%C2%BA-250-boletim-da); catálogo/WebDAV oficial AT; tamanho e SHA-256 coincidem com a cópia oficial registada. | Confirmada para a edição e bytes. | Marcada `amended`; art. 17(1) foi localizado, mas não é consolidação integral actual. Não bloqueia publicação como documento histórico se assim rotulado; bloqueia tratá-la como texto actual consolidado. | Documento e recurso `rights_status=unconfirmed`, classificação `internal`; autorização para redistribuir esta cópia PDF/fac-símile não documentada. | **Não pronta.** Gestor regista base de reutilização/divulgação, depois classifica explicitamente como pública e publica. Proposta: Lei 22/2022 histórica, com aviso de alterações posteriores, nunca como CIVA consolidado. Fonte e malware passam; direitos bloqueiam publicação. |
|
||||||
| `2` / `64c46765-96b9-4f43-afc6-f5b730c010c4` | BR n.º 248/2025, Suplemento n.º 1. `http://localhost:8000/management/portal-services` — localizar recurso 2. | [Ficha INM](https://inm.gov.mz/pt-br/content/suplemento-n%C2%BA-1-de-291225-pag-2180-1-20-br-n%C2%BA-248-boletim-da-rep%C3%BAblica-i-serie); WebDAV oficial AT; 440.018 bytes e SHA-256 coincidem com a edição oficial registada. | Confirmada para a edição e bytes. | Contém seis diplomas distintos (Leis 7–12/2025); situação `unknown`. Citações/artigos localizados no PDF, mas não há uma vigência única para o boletim. | Direitos do ficheiro composto `unconfirmed`, classificação `internal`; autorização de redistribuição integral não registada. | **Não pronta.** Gestor documenta direitos do boletim composto. Proposta: publicar como edição oficial do BR com aviso de que os seis diplomas não são uma regra única ou consolidação. Não activar cálculos pela associação temática. |
|
| `2` / `64c46765-96b9-4f43-afc6-f5b730c010c4` | BR n.º 248/2025, Suplemento n.º 1. `http://localhost:8000/management/portal-services` — localizar recurso 2. | [Ficha INM](https://inm.gov.mz/pt-br/content/suplemento-n%C2%BA-1-de-291225-pag-2180-1-20-br-n%C2%BA-248-boletim-da-rep%C3%BAblica-i-serie); WebDAV oficial AT; 440.018 bytes e SHA-256 coincidem com a edição oficial registada. | Confirmada para a edição e bytes. | Contém seis diplomas distintos (Leis 7–12/2025); situação `unknown`. Citações/artigos localizados no PDF, mas não há uma vigência única para o boletim. | Direitos do ficheiro composto `unconfirmed`, classificação `internal`; autorização de redistribuição integral não registada. | **Não pronta.** Gestor documenta direitos do boletim composto. Proposta: publicar como edição oficial do BR com aviso de que os seis diplomas não são uma regra única ou consolidação. Não activar cálculos pela associação temática. |
|
||||||
| `3` / `58abf343-e1f5-446d-a9cb-3255f376ece9` | BR n.º 89/2017, I Série — aviso de rectificação da Lei 13/2016. `http://localhost:8000/management/portal-services` — localizar recurso 3. | [Ficha INM](https://www.inm.gov.mz/pt-br/content/assembleia-da-rep%C3%BAblica-br-n%C2%BA-89-de-080617-boletim-da-rep%C3%BAblica-i-serie-p%C3%A1g-569) identifica o aviso na p. 569. A página respondeu HTTP 200, mas não expõe ligação para PDF integral; só a ficha geral do BR. | **Binário local não autenticado:** hash local conhecido, sem comparação a exemplar oficial. Texto local refere alteração do art. 6(5), eliminação do art. 14(2)(c) e rectificação dos anexos I–III do art. 9; não autentica o PDF. | Efeito temporal e anexos rectificados não foram cotejados com cópia autêntica; `legal_status=unknown`. | Direitos `unconfirmed`, classificação `internal`. | **Não pronta.** Necessária cópia oficial dos bytes e anexos, comparação/hash e decisão sobre divulgação do fac-símile. A busca confirmou a ficha, não encontrou o binário. Depois, gestor decide direitos/publicação. |
|
| `3` / `58abf343-e1f5-446d-a9cb-3255f376ece9` | BR n.º 89/2017, I Série — aviso de rectificação da Lei 13/2016. `http://localhost:8000/management/portal-services` — localizar recurso 3. | [Ficha INM](https://www.inm.gov.mz/pt-br/content/assembleia-da-rep%C3%BAblica-br-n%C2%BA-89-de-080617-boletim-da-rep%C3%BAblica-i-serie-p%C3%A1g-569) identifica o aviso na p. 569. A página respondeu HTTP 200, mas não expõe ligação para PDF integral; só a ficha geral do BR. | **Binário local não autenticado:** hash local conhecido, sem comparação a exemplar oficial. Texto local refere alteração do art. 6(5), eliminação do art. 14(2)(c) e rectificação dos anexos I–III do art. 9; não autentica o PDF. | Efeito temporal e anexos rectificados não foram cotejados com cópia autêntica; `legal_status=unknown`. | Direitos `unconfirmed`, classificação `internal`. | **Não pronta.** Necessária cópia oficial dos bytes e anexos, comparação/hash e decisão sobre divulgação do fac-símile. A busca confirmou a ficha, não encontrou o binário. Depois, gestor decide direitos/publicação. |
|
||||||
@@ -249,7 +249,7 @@ Estado técnico comum dos quatro: ficheiros `active`, ClamAV 1.5.4 `clean`, hash
|
|||||||
### Negócios existentes — dois rascunhos privados
|
### Negócios existentes — dois rascunhos privados
|
||||||
|
|
||||||
| ID | Título armazenado / modalidade | URL de gestão e de proprietário | Origem, conteúdo conhecido e faltas | Bloqueio/regra; decisão proposta |
|
| ID | Título armazenado / modalidade | URL de gestão e de proprietário | Origem, conteúdo conhecido e faltas | Bloqueio/regra; decisão proposta |
|
||||||
|---|---|---|---|---|
|
| -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `7208ef2b-0693-49ba-b0e2-9e52938b1a99` | Título privado guardado: “privado”; modalidade `mining_license`; `public_title=NULL`; estado `draft`; classificação `confidential`. | Gestão: `http://localhost:8000/management/negocios` (fila; rascunho não aparece). Não há GET administrativo individual. Ficha privada do proprietário: `http://localhost:8000/investidor/negocios/7208ef2b-0693-49ba-b0e2-9e52938b1a99`. | `source_system` e `legacy_id` nulos; payload só tem título e versão/etapa do assistente. Não há fonte, requerente/proponente, descrição de licença, localização, entidade emissora, referência/licença, actividade, validade ou autorização de divulgação. | Não é publicável como oportunidade: o registo é rascunho confidencial e não há conteúdo suficiente para descrever uma licença ou provar a autorização do proponente. Não há bloqueio por falta de operador de uma zona; trata-se de outra categoria. **Decisão do proprietário necessária:** identificar o que “privado” designa e fornecer fonte/autorização antes de submeter. Nenhuma publicação proposta agora. |
|
| `7208ef2b-0693-49ba-b0e2-9e52938b1a99` | Título privado guardado: “privado”; modalidade `mining_license`; `public_title=NULL`; estado `draft`; classificação `confidential`. | Gestão: `http://localhost:8000/management/negocios` (fila; rascunho não aparece). Não há GET administrativo individual. Ficha privada do proprietário: `http://localhost:8000/investidor/negocios/7208ef2b-0693-49ba-b0e2-9e52938b1a99`. | `source_system` e `legacy_id` nulos; payload só tem título e versão/etapa do assistente. Não há fonte, requerente/proponente, descrição de licença, localização, entidade emissora, referência/licença, actividade, validade ou autorização de divulgação. | Não é publicável como oportunidade: o registo é rascunho confidencial e não há conteúdo suficiente para descrever uma licença ou provar a autorização do proponente. Não há bloqueio por falta de operador de uma zona; trata-se de outra categoria. **Decisão do proprietário necessária:** identificar o que “privado” designa e fornecer fonte/autorização antes de submeter. Nenhuma publicação proposta agora. |
|
||||||
| `f65c1d9d-5820-4030-8dc1-fe7ff3de0cd2` | Título privado guardado: “venda de empresa”; modalidade `company_sale`; `public_title=NULL`; estado `draft`; classificação `confidential`. | Gestão: `http://localhost:8000/management/negocios` (fila; rascunho não aparece). Não há GET administrativo individual. Ficha privada do proprietário: `http://localhost:8000/investidor/negocios/f65c1d9d-5820-4030-8dc1-fe7ff3de0cd2`. | `source_system` e `legacy_id` nulos; payload só contém título e versão/etapa. Sem empresa identificada, descrição, proponente, mandato quando aplicável, origem da informação, localização, modalidade da transacção, valor/moeda e autorização específica para divulgar. | O estado privado e o fluxo de revisão são controlos existentes. **Decisão do proprietário necessária:** completar a ficha e declarar a autoridade para divulgar. Só depois da submissão entram na fila e nas etapas de revisão. Não publicar agora. |
|
| `f65c1d9d-5820-4030-8dc1-fe7ff3de0cd2` | Título privado guardado: “venda de empresa”; modalidade `company_sale`; `public_title=NULL`; estado `draft`; classificação `confidential`. | Gestão: `http://localhost:8000/management/negocios` (fila; rascunho não aparece). Não há GET administrativo individual. Ficha privada do proprietário: `http://localhost:8000/investidor/negocios/f65c1d9d-5820-4030-8dc1-fe7ff3de0cd2`. | `source_system` e `legacy_id` nulos; payload só contém título e versão/etapa. Sem empresa identificada, descrição, proponente, mandato quando aplicável, origem da informação, localização, modalidade da transacção, valor/moeda e autorização específica para divulgar. | O estado privado e o fluxo de revisão são controlos existentes. **Decisão do proprietário necessária:** completar a ficha e declarar a autoridade para divulgar. Só depois da submissão entram na fila e nas etapas de revisão. Não publicar agora. |
|
||||||
|
|
||||||
@@ -258,7 +258,7 @@ Estado técnico comum dos quatro: ficheiros `active`, ClamAV 1.5.4 `clean`, hash
|
|||||||
Todos os seis registos correspondem exactamente ao conjunto fixo de `database/seeders/OpportunitySeeder.php`: títulos, referências, províncias, valores e impactos coincidem; todos usam `promoter_name="Promotor em validação"`, a mesma data de criação/publicação `2026-09-24 19:02:25`, `last_validated_at=NULL` e `geography_scope=unspecified`. A tabela `opportunities` não guarda `source_system`, actor de importação, documento de origem nem autorização do proponente. Assim, **a origem do conteúdo é um conjunto de demonstração definido no seeder; não é possível provar pela base qual processo executou/importou cada linha**. Não foram removidos nem alterados.
|
Todos os seis registos correspondem exactamente ao conjunto fixo de `database/seeders/OpportunitySeeder.php`: títulos, referências, províncias, valores e impactos coincidem; todos usam `promoter_name="Promotor em validação"`, a mesma data de criação/publicação `2026-09-24 19:02:25`, `last_validated_at=NULL` e `geography_scope=unspecified`. A tabela `opportunities` não guarda `source_system`, actor de importação, documento de origem nem autorização do proponente. Assim, **a origem do conteúdo é um conjunto de demonstração definido no seeder; não é possível provar pela base qual processo executou/importou cada linha**. Não foram removidos nem alterados.
|
||||||
|
|
||||||
| ID / referência | Título | URL de gestão existente | Informação presente; falta individual | Estado e acção proposta |
|
| ID / referência | Título | URL de gestão existente | Informação presente; falta individual | Estado e acção proposta |
|
||||||
|---|---|---|---|---|
|
| ----------------------- | --------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `1` / `INV-MZ-AGR-001` | Unidade de processamento agrícola em Nampula | `http://localhost:8000/management/opportunities/1/context` (edita só contexto; não é gestão editorial/publicação da oportunidade) | Sector agro-negócio, Nampula, USD 2.500.000, impacto textual e maturidade 4; falta fonte comercial, promotor/autorização, data de validação e localização abaixo da província. | Já pública; não há proposta de republicação. Decisão humana: confirmar que deve permanecer como exemplo visível ou entregar evidência de uma proposta real autorizada. |
|
| `1` / `INV-MZ-AGR-001` | Unidade de processamento agrícola em Nampula | `http://localhost:8000/management/opportunities/1/context` (edita só contexto; não é gestão editorial/publicação da oportunidade) | Sector agro-negócio, Nampula, USD 2.500.000, impacto textual e maturidade 4; falta fonte comercial, promotor/autorização, data de validação e localização abaixo da província. | Já pública; não há proposta de republicação. Decisão humana: confirmar que deve permanecer como exemplo visível ou entregar evidência de uma proposta real autorizada. |
|
||||||
| `2` / `INV-MZ-ENE-002` | Mini-rede solar para polo produtivo | `http://localhost:8000/management/opportunities/2/context` (só contexto) | Sector energia, Zambézia, USD 1.200.000 e impacto textual; faltam fonte, proponente/consentimento, validação e localização exacta. | Já pública; mesma decisão individual: demonstrar como exemplo, ou fornecer origem real autorizada. |
|
| `2` / `INV-MZ-ENE-002` | Mini-rede solar para polo produtivo | `http://localhost:8000/management/opportunities/2/context` (só contexto) | Sector energia, Zambézia, USD 1.200.000 e impacto textual; faltam fonte, proponente/consentimento, validação e localização exacta. | Já pública; mesma decisão individual: demonstrar como exemplo, ou fornecer origem real autorizada. |
|
||||||
| `3` / `INV-MZ-TUR-003` | Eco-lodge costeiro com integração comunitária | `http://localhost:8000/management/opportunities/3/context` (só contexto) | Turismo, Inhambane, USD 1.800.000 e impacto textual; faltam fonte, proponente/consentimento, validação e localização exacta. | Já pública; mesma decisão individual. |
|
| `3` / `INV-MZ-TUR-003` | Eco-lodge costeiro com integração comunitária | `http://localhost:8000/management/opportunities/3/context` (só contexto) | Turismo, Inhambane, USD 1.800.000 e impacto textual; faltam fonte, proponente/consentimento, validação e localização exacta. | Já pública; mesma decisão individual. |
|
||||||
@@ -273,7 +273,7 @@ O status `published` já está activo, mas “Promotor em validação” e a dat
|
|||||||
Situação comum observada: `publication_status=draft`, `validation_status=validated`, `reviewer_id=NULL`. Existem 19 relações territoriais adicionais, todas `pending`. As localizações primárias abaixo correspondem a registos públicos do mestre territorial, mas a localização jurídica adicional não entra em pesquisa pública enquanto a relação estiver pendente. Para ZEE/ZFI, seis referências legais existentes estão `pending` e três registos não têm referência legal estruturada. Para parques, existe fonte HTTPS em `source_evidence`; a fonte pode ser promocional/institucional e os claims têm de ficar limitados ao que a página sustenta. O código permite a revisão administrativa por gestor diferente do autor; não exige operador nem certificador externo.
|
Situação comum observada: `publication_status=draft`, `validation_status=validated`, `reviewer_id=NULL`. Existem 19 relações territoriais adicionais, todas `pending`. As localizações primárias abaixo correspondem a registos públicos do mestre territorial, mas a localização jurídica adicional não entra em pesquisa pública enquanto a relação estiver pendente. Para ZEE/ZFI, seis referências legais existentes estão `pending` e três registos não têm referência legal estruturada. Para parques, existe fonte HTTPS em `source_evidence`; a fonte pode ser promocional/institucional e os claims têm de ficar limitados ao que a página sustenta. O código permite a revisão administrativa por gestor diferente do autor; não exige operador nem certificador externo.
|
||||||
|
|
||||||
| ID / código | Título, localização e URL de gestão | Origem e alcance efectivamente registado | Falta exacta; bloqueio; proposta individual |
|
| ID / código | Título, localização e URL de gestão | Origem e alcance efectivamente registado | Falta exacta; bloqueio; proposta individual |
|
||||||
|---|---|---|---|
|
| ----------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `1b57649a-f522-4cd5-8e97-32e82b6e1b37` / `MOZ-BELULUANE-PARK` | Parque Industrial de Beluluane — Matola Rio, Boane. `http://localhost:8000/management/investment/zones/1b57649a-f522-4cd5-8e97-32e82b6e1b37` | [APIEX — Beluluane](https://apiex.gov.mz/beluluane-industrial-park-free-zone/); referência institucional, não comprova regime, incentivos ou disponibilidade. Reconciliação local distingue complexo ~780 ha, parque 600 ha, Mozal 180 ha e 55 ha de ZFI; [MozParks](https://mozparks.co.mz/) também reporta área para arrendamento com âmbito diferente. | Relação Matola Rio pendente; perímetros e relação das áreas não reconciliados; não há confirmação de lotes disponíveis. Sem revisor. **Proposta:** pode ser considerado para publicação informativa depois de o gestor confirmar existência/escopo e publicar sem declarar área disponível; manter sem operador se desconhecido. |
|
| `1b57649a-f522-4cd5-8e97-32e82b6e1b37` / `MOZ-BELULUANE-PARK` | Parque Industrial de Beluluane — Matola Rio, Boane. `http://localhost:8000/management/investment/zones/1b57649a-f522-4cd5-8e97-32e82b6e1b37` | [APIEX — Beluluane](https://apiex.gov.mz/beluluane-industrial-park-free-zone/); referência institucional, não comprova regime, incentivos ou disponibilidade. Reconciliação local distingue complexo ~780 ha, parque 600 ha, Mozal 180 ha e 55 ha de ZFI; [MozParks](https://mozparks.co.mz/) também reporta área para arrendamento com âmbito diferente. | Relação Matola Rio pendente; perímetros e relação das áreas não reconciliados; não há confirmação de lotes disponíveis. Sem revisor. **Proposta:** pode ser considerado para publicação informativa depois de o gestor confirmar existência/escopo e publicar sem declarar área disponível; manter sem operador se desconhecido. |
|
||||||
| `d25d4eb1-744a-42e1-943a-47d33019c31c` / `MOZ-BELULUANE-ZFI` | Zona Franca Industrial de Beluluane — Matola Rio, Boane. `http://localhost:8000/management/investment/zones/d25d4eb1-744a-42e1-943a-47d33019c31c` | [APIEX — Beluluane](https://apiex.gov.mz/beluluane-industrial-park-free-zone/); referência à Resolução Interna do Conselho de Ministros n.º 15/99, 12-10-1999. | Artigo/efeito legal actual e fonte oficial primária ainda pendentes; `investment_legal_sources.validation_status=pending`; relação territorial pendente; sem revisor. **Não pronta.** Revisor confirma texto e vigência, valida território e só então gestor decide publicação. |
|
| `d25d4eb1-744a-42e1-943a-47d33019c31c` / `MOZ-BELULUANE-ZFI` | Zona Franca Industrial de Beluluane — Matola Rio, Boane. `http://localhost:8000/management/investment/zones/d25d4eb1-744a-42e1-943a-47d33019c31c` | [APIEX — Beluluane](https://apiex.gov.mz/beluluane-industrial-park-free-zone/); referência à Resolução Interna do Conselho de Ministros n.º 15/99, 12-10-1999. | Artigo/efeito legal actual e fonte oficial primária ainda pendentes; `investment_legal_sources.validation_status=pending`; relação territorial pendente; sem revisor. **Não pronta.** Revisor confirma texto e vigência, valida território e só então gestor decide publicação. |
|
||||||
| `0d216b6d-598c-4672-be2a-294e5e924da5` / `MOZ-CDP-ANCUABE` | Parque Industrial de Ancuabe — distrito Ancuabe, Cabo Delgado. `http://localhost:8000/management/investment/zones/0d216b6d-598c-4672-be2a-294e5e924da5` | [MozParks — iniciativa de Cabo Delgado](https://mozparks.co.mz/mozparks-launches-cabo-delgado-parks/); suporta associação distrital na iniciativa provincial, não instalação operacional independente. | Fonte de promotor, não primária oficial; relação Ancuabe pendente; estado planeado, sem área/operação/disponibilidade confirmadas; sem revisor. **Não pronta** segundo o requisito de fonte oficial. Decisão: obter fonte oficial adequada ou manter rascunho; se publicar no futuro, rotular “planeado/iniciativa”, não parque operacional. |
|
| `0d216b6d-598c-4672-be2a-294e5e924da5` / `MOZ-CDP-ANCUABE` | Parque Industrial de Ancuabe — distrito Ancuabe, Cabo Delgado. `http://localhost:8000/management/investment/zones/0d216b6d-598c-4672-be2a-294e5e924da5` | [MozParks — iniciativa de Cabo Delgado](https://mozparks.co.mz/mozparks-launches-cabo-delgado-parks/); suporta associação distrital na iniciativa provincial, não instalação operacional independente. | Fonte de promotor, não primária oficial; relação Ancuabe pendente; estado planeado, sem área/operação/disponibilidade confirmadas; sem revisor. **Não pronta** segundo o requisito de fonte oficial. Decisão: obter fonte oficial adequada ou manter rascunho; se publicar no futuro, rotular “planeado/iniciativa”, não parque operacional. |
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ Backup/restauro verificado antes desta correcção: `storage/app/private/zones-b
|
|||||||
## Trabalho que continua por terminar
|
## Trabalho que continua por terminar
|
||||||
|
|
||||||
| Área | Lacuna confirmada nos relatórios/código | Trabalho necessário |
|
| Área | Lacuna confirmada nos relatórios/código | Trabalho necessário |
|
||||||
| --- | --- | --- |
|
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| GIS completo | Limites geográficos versionados, transformação/validação de geometrias, endpoints resolve/near/bbox e cobertura espacial não entregues integralmente | Implementar serviços e contratos; carregar geometrias apenas quando fornecidas, sem inventar coordenadas |
|
| GIS completo | Limites geográficos versionados, transformação/validação de geometrias, endpoints resolve/near/bbox e cobertura espacial não entregues integralmente | Implementar serviços e contratos; carregar geometrias apenas quando fornecidas, sem inventar coordenadas |
|
||||||
| Integração territorial transversal | A nova associação é principal; os consumidores educativos, organizações e restantes formulários não usam ainda todos o mesmo selector; relações múltiplas legadas continuam separadas | Consolidar consumidores e testar cada jornada, incluindo históricos e remoção de referências |
|
| Integração territorial transversal | A nova associação é principal; os consumidores educativos, organizações e restantes formulários não usam ainda todos o mesmo selector; relações múltiplas legadas continuam separadas | Consolidar consumidores e testar cada jornada, incluindo históricos e remoção de referências |
|
||||||
| Importação territorial | CSV auditado, mas não existe ainda o workflow integral de batches/rejeições/aprovação/carga; PDF histórico tem colunas ambíguas | Terminar pipeline, excepções documentadas e reconciliação dos códigos; não tratar aprovação como reparação automática de dados contraditórios |
|
| Importação territorial | CSV auditado, mas não existe ainda o workflow integral de batches/rejeições/aprovação/carga; PDF histórico tem colunas ambíguas | Terminar pipeline, excepções documentadas e reconciliação dos códigos; não tratar aprovação como reparação automática de dados contraditórios |
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Data: 06-10-2026. Inventário limitado aos anexos enumerados no manifesto local
|
|||||||
## Reconciliação quantitativa
|
## Reconciliação quantitativa
|
||||||
|
|
||||||
| Medida | Resultado desta revisão |
|
| Medida | Resultado desta revisão |
|
||||||
|---|---:|
|
| -------------------------------------------------------------- | --------------------------------------------------------------------------------------------: |
|
||||||
| Anexos enumerados no manifesto | 52 ficheiros `.txt` |
|
| Anexos enumerados no manifesto | 52 ficheiros `.txt` |
|
||||||
| Conteúdos de anexo únicos por SHA-256 | 50 |
|
| Conteúdos de anexo únicos por SHA-256 | 50 |
|
||||||
| Pares de anexos exactamente duplicados | 2 pares: `1b36f6f0…` / `27922f5b…` e `11c236f7…` / `f003a1f1…` |
|
| Pares de anexos exactamente duplicados | 2 pares: `1b36f6f0…` / `27922f5b…` e `11c236f7…` / `f003a1f1…` |
|
||||||
@@ -29,7 +29,7 @@ Os 10 itens inacessíveis são as sete fontes antigas referidas por caminho rela
|
|||||||
O lote real de quatro fontes foi previamente importado para a biblioteca activa, com cópia privada, hash e análise antimalware. A pré-visualização repetida de `php artisan documents:import-legal-source-archive` nesta execução encontrou os quatro hashes já registados e devolveu `reused/reconciled` para cada um; terminou com “Preview only; no files or database rows were changed.” Não criou cópias nem alterou a base activa.
|
O lote real de quatro fontes foi previamente importado para a biblioteca activa, com cópia privada, hash e análise antimalware. A pré-visualização repetida de `php artisan documents:import-legal-source-archive` nesta execução encontrou os quatro hashes já registados e devolveu `reused/reconciled` para cada um; terminou com “Preview only; no files or database rows were changed.” Não criou cópias nem alterou a base activa.
|
||||||
|
|
||||||
| Recurso | Disponibilidade | Situação documental | Uso fiscal |
|
| Recurso | Disponibilidade | Situação documental | Uso fiscal |
|
||||||
|---:|---|---|---|
|
| -----------------------------------------: | --------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
|
||||||
| 1 — Lei n.º 22/2022, CIVA republicado | Privado; consulta pública pendente da acção autenticada de disponibilização | Fonte oficial e bytes confirmados; diploma alterador; edição/data visíveis; não equivale a consolidação integral actual | Art. 17(1) citado como evidência documental; não activa taxa nem cálculo |
|
| 1 — Lei n.º 22/2022, CIVA republicado | Privado; consulta pública pendente da acção autenticada de disponibilização | Fonte oficial e bytes confirmados; diploma alterador; edição/data visíveis; não equivale a consolidação integral actual | Art. 17(1) citado como evidência documental; não activa taxa nem cálculo |
|
||||||
| 2 — BR n.º 248/2025, Suplemento n.º 1 | Privado; consulta pública pendente da mesma acção autenticada | Edição oficial confirmada; contém seis diplomas distintos; vigência deve ser tratada por diploma/dispositivo | Citações ligadas às chaves técnicas como evidência; sem activação de regras |
|
| 2 — BR n.º 248/2025, Suplemento n.º 1 | Privado; consulta pública pendente da mesma acção autenticada | Edição oficial confirmada; contém seis diplomas distintos; vigência deve ser tratada por diploma/dispositivo | Citações ligadas às chaves técnicas como evidência; sem activação de regras |
|
||||||
| 3 — BR n.º 89/2017, aviso de rectificação | Privado; autorização anterior permite disponibilizar como cópia fornecida | A ficha INM identifica o aviso, mas os bytes/anexos da cópia não foram comparados com exemplar oficial; autenticidade da cópia não confirmada | Associação ao CIVA fica pendente; não é fundamento confirmado |
|
| 3 — BR n.º 89/2017, aviso de rectificação | Privado; autorização anterior permite disponibilizar como cópia fornecida | A ficha INM identifica o aviso, mas os bytes/anexos da cópia não foram comparados com exemplar oficial; autenticidade da cópia não confirmada | Associação ao CIVA fica pendente; não é fundamento confirmado |
|
||||||
@@ -52,7 +52,7 @@ As 25 referências cobrem: catálogos da AT e INSS; cadeia do CIVA (Leis 3/2012,
|
|||||||
Fontes primárias presentes no acervo activo: Lei 22/2022, BR 248/2025 e BR 89/2017. O código de importação/revisão identifica a Lei 22/2022, art. 17(1), e as Leis 7–12/2025 no BR 248; as relações activas à data desta leitura são somente tags gerais pendentes, não relações persistidas a requisitos `fiscal.*`. A associação candidata do BR 89/2017 também permanece pendente. A identificação de artigos é evidência documental, não validação da incidência, vigência integral ou fórmula.
|
Fontes primárias presentes no acervo activo: Lei 22/2022, BR 248/2025 e BR 89/2017. O código de importação/revisão identifica a Lei 22/2022, art. 17(1), e as Leis 7–12/2025 no BR 248; as relações activas à data desta leitura são somente tags gerais pendentes, não relações persistidas a requisitos `fiscal.*`. A associação candidata do BR 89/2017 também permanece pendente. A identificação de artigos é evidência documental, não validação da incidência, vigência integral ou fórmula.
|
||||||
|
|
||||||
| Componente | Fonte localizada/ligada | Lacuna documental ou de regra | Estado de uso |
|
| Componente | Fonte localizada/ligada | Lacuna documental ou de regra | Estado de uso |
|
||||||
|---|---|---|---|
|
| --------------------- | ------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
|
||||||
| IVA | Lei 22/2022 art. 17(1); Lei 10/2025 e Lei 3/2025 dentro do BR 248; cadeia de 2016/2017 descrita no registo oficial | O PDF da republicação integral Lei 13/2016 e cópia legível/autêntica dos anexos rectificados continuam inacessíveis; faltam os binários/efeitos consolidados das alterações 2020 e regulamentos publicados/anunciados em 2026 | Um ponto textual de 16% está identificado no documento; sem cálculo fiscal integrado |
|
| IVA | Lei 22/2022 art. 17(1); Lei 10/2025 e Lei 3/2025 dentro do BR 248; cadeia de 2016/2017 descrita no registo oficial | O PDF da republicação integral Lei 13/2016 e cópia legível/autêntica dos anexos rectificados continuam inacessíveis; faltam os binários/efeitos consolidados das alterações 2020 e regulamentos publicados/anunciados em 2026 | Um ponto textual de 16% está identificado no documento; sem cálculo fiscal integrado |
|
||||||
| IRPC | Lei 12/2025, arts. e dispositivos indicados na revisão do BR 248 | Código-base consolidado, regulamentos 2026, retenções, mais-valias digitais/estabelecimento estável por contexto e casos dourados completos não estão arquivados neste lote | Sem regra activada |
|
| IRPC | Lei 12/2025, arts. e dispositivos indicados na revisão do BR 248 | Código-base consolidado, regulamentos 2026, retenções, mais-valias digitais/estabelecimento estável por contexto e casos dourados completos não estão arquivados neste lote | Sem regra activada |
|
||||||
| ISPC | Lei 9/2025 e republicação anexa da Lei 5/2009 no BR 248 | Diploma-base/regulamento integral legível e alterações regulamentares de 2026; elegibilidade e exclusões por operação ainda carecem de consolidação | Sem regra activada; não confundir com regimes simplificados de IVA/IRPS |
|
| ISPC | Lei 9/2025 e republicação anexa da Lei 5/2009 no BR 248 | Diploma-base/regulamento integral legível e alterações regulamentares de 2026; elegibilidade e exclusões por operação ainda carecem de consolidação | Sem regra activada; não confundir com regimes simplificados de IVA/IRPS |
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ Foram importados quatro documentos para armazenamento privado. Todos permanecem
|
|||||||
## Inventário e decisões pendentes por documento
|
## Inventário e decisões pendentes por documento
|
||||||
|
|
||||||
| Documento | Proveniência e estado | Relações | Decisão pendente antes de publicar |
|
| Documento | Proveniência e estado | Relações | Decisão pendente antes de publicar |
|
||||||
|---|---|---|---|
|
| --------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| Lei n.º 22/2022, republicação do Código do IVA | PDF comparado byte a byte com o exemplar da AT; origem oficial confirmada. Estado jurídico registado como alterado, não como consolidação integral actual. | Evidência documental do simulador fiscal. | Gestor deve rever a possibilidade de divulgação da composição PDF e confirmar a versão/alcance editorial. Direitos: `unconfirmed`; classificação: `internal`. |
|
| Lei n.º 22/2022, republicação do Código do IVA | PDF comparado byte a byte com o exemplar da AT; origem oficial confirmada. Estado jurídico registado como alterado, não como consolidação integral actual. | Evidência documental do simulador fiscal. | Gestor deve rever a possibilidade de divulgação da composição PDF e confirmar a versão/alcance editorial. Direitos: `unconfirmed`; classificação: `internal`. |
|
||||||
| BR n.º 248/2025, Suplemento n.º 1 | PDF comparado byte a byte com endpoint oficial da AT. Reúne vários diplomas; estado jurídico agregado desconhecido. | Evidência documental fiscal, sem afirmar que cada tema cria obrigação ou regra activa. | Avaliar direitos da composição e identificar os diplomas e vigências individualmente antes de apresentar como referência consolidada. |
|
| BR n.º 248/2025, Suplemento n.º 1 | PDF comparado byte a byte com endpoint oficial da AT. Reúne vários diplomas; estado jurídico agregado desconhecido. | Evidência documental fiscal, sem afirmar que cada tema cria obrigação ou regra activa. | Avaliar direitos da composição e identificar os diplomas e vigências individualmente antes de apresentar como referência consolidada. |
|
||||||
| BR n.º 89, I Série, de 08/06/2017 | A ficha do INM identifica o aviso de rectificação da Lei n.º 13/2016 na p. 569; o binário local não foi comparado com um download oficial. Proveniência apenas identificada. | Evidência fiscal; efeito temporal continua por confirmar. | Obter o PDF/binário oficial, comparar hash e confirmar autenticidade, anexos e efeito da rectificação. Direitos continuam por confirmar. |
|
| BR n.º 89, I Série, de 08/06/2017 | A ficha do INM identifica o aviso de rectificação da Lei n.º 13/2016 na p. 569; o binário local não foi comparado com um download oficial. Proveniência apenas identificada. | Evidência fiscal; efeito temporal continua por confirmar. | Obter o PDF/binário oficial, comparar hash e confirmar autenticidade, anexos e efeito da rectificação. Direitos continuam por confirmar. |
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ Uma consulta apenas de leitura à base configurada como `investemoz`, juntando `
|
|||||||
Os três ficheiros abaixo estão em `docs/investmoz/simulations/source-archive/`. O inventário registou nome, tamanho e hash; esta tarefa **não confirmou o texto integral, fonte oficial, vigência, idioma, direitos de reprodução, âmbito ou aptidão para publicação**. Permanecem no arquivo original e não foram importados para o catálogo.
|
Os três ficheiros abaixo estão em `docs/investmoz/simulations/source-archive/`. O inventário registou nome, tamanho e hash; esta tarefa **não confirmou o texto integral, fonte oficial, vigência, idioma, direitos de reprodução, âmbito ou aptidão para publicação**. Permanecem no arquivo original e não foram importados para o catálogo.
|
||||||
|
|
||||||
| Ficheiro | Bytes | SHA-256 | Situação para a biblioteca |
|
| Ficheiro | Bytes | SHA-256 | Situação para a biblioteca |
|
||||||
|---|---:|---|---|
|
| ----------------------------------------------------- | --------: | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------- |
|
||||||
| `Lei-22-2022-IVA-republicada-BR-250-2-suplemento.pdf` | 1.834.284 | `EA1B0DC6F5CF6E595F6D9A19E7042F398999E0087CAEF1785F6E8FAC571B5F53` | Candidato a legislação; fonte canónica, artigos, vigência consolidada e direitos por rever. |
|
| `Lei-22-2022-IVA-republicada-BR-250-2-suplemento.pdf` | 1.834.284 | `EA1B0DC6F5CF6E595F6D9A19E7042F398999E0087CAEF1785F6E8FAC571B5F53` | Candidato a legislação; fonte canónica, artigos, vigência consolidada e direitos por rever. |
|
||||||
| `BR-89-I-Serie-2017-06-08.pdf` | 9.456.358 | `11F0CAB15EB6E51010952203FFA24FDC533A24FD642E19525FE4F46B17A1F5E5` | Boletim da República; acto/artigos e relação com diplomas por identificar. |
|
| `BR-89-I-Serie-2017-06-08.pdf` | 9.456.358 | `11F0CAB15EB6E51010952203FFA24FDC533A24FD642E19525FE4F46B17A1F5E5` | Boletim da República; acto/artigos e relação com diplomas por identificar. |
|
||||||
| `BR-248-I-Suplemento-1-2025.pdf` | 440.018 | `CCF2A8DEECA820F2DD076B4B2141B1EFE3F6A806568C3A587CA59A8E92F4C251` | Boletim da República; acto/artigos e relação com diplomas por identificar. |
|
| `BR-248-I-Suplemento-1-2025.pdf` | 440.018 | `CCF2A8DEECA820F2DD076B4B2141B1EFE3F6A806568C3A587CA59A8E92F4C251` | Boletim da República; acto/artigos e relação com diplomas por identificar. |
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ A migração aditiva `2026_10_06_200000_add_document_requirement_evidence_links`
|
|||||||
O PDF de 21 páginas foi descarregado do catálogo/WebDAV oficial da Autoridade Tributária e comparado com a cópia arquivada: 440.018 bytes e SHA-256 `CCF2A8DEECA820F2DD076B4B2141B1EFE3F6A806568C3A587CA59A8E92F4C251`. A ficha da Imprensa Nacional identifica a edição. A leitura directa foi feita no texto extraído do próprio PDF, com localização por página. O número do boletim, isoladamente, não é usado como referência de requisito.
|
O PDF de 21 páginas foi descarregado do catálogo/WebDAV oficial da Autoridade Tributária e comparado com a cópia arquivada: 440.018 bytes e SHA-256 `CCF2A8DEECA820F2DD076B4B2141B1EFE3F6A806568C3A587CA59A8E92F4C251`. A ficha da Imprensa Nacional identifica a edição. A leitura directa foi feita no texto extraído do próprio PDF, com localização por página. O número do boletim, isoladamente, não é usado como referência de requisito.
|
||||||
|
|
||||||
| Chave técnica | Diploma identificado dentro do BR | Dispositivos citados no texto primário | Páginas PDF | Estado da associação |
|
| Chave técnica | Diploma identificado dentro do BR | Dispositivos citados no texto primário | Páginas PDF | Estado da associação |
|
||||||
|---|---|---|---:|---|
|
| --------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------: | ----------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `fiscal.ice.lei_7_2025` | Lei n.º 7/2025, de 29 de Dezembro, alteração ao Código do ICE | Lei, arts. 1–5 e tabela anexa; art. 1 prorroga a aplicação das taxas até 2027 e art. 5 indica entrada em vigor em 01/01/2026 | 1–2 | Citação localizada; vigência consolidada, regulamentação, alcance da tabela e aprovação fiscal pendentes |
|
| `fiscal.ice.lei_7_2025` | Lei n.º 7/2025, de 29 de Dezembro, alteração ao Código do ICE | Lei, arts. 1–5 e tabela anexa; art. 1 prorroga a aplicação das taxas até 2027 e art. 5 indica entrada em vigor em 01/01/2026 | 1–2 | Citação localizada; vigência consolidada, regulamentação, alcance da tabela e aprovação fiscal pendentes |
|
||||||
| `fiscal.customs.lei_8_2025` | Lei n.º 8/2025, de 29 de Dezembro, alteração à Pauta Aduaneira e Instruções Preliminares | Lei, art. 1 altera os arts. 21(2), 22 e 27 das Instruções Preliminares; Lei, arts. 2–5 e tabela anexa | 2–7 | Citação localizada; classificação por código/origem, preferências, regulamentação e aplicação a operações concretas pendentes |
|
| `fiscal.customs.lei_8_2025` | Lei n.º 8/2025, de 29 de Dezembro, alteração à Pauta Aduaneira e Instruções Preliminares | Lei, art. 1 altera os arts. 21(2), 22 e 27 das Instruções Preliminares; Lei, arts. 2–5 e tabela anexa | 2–7 | Citação localizada; classificação por código/origem, preferências, regulamentação e aplicação a operações concretas pendentes |
|
||||||
| `fiscal.ispc.lei_9_2025` | Lei n.º 9/2025, de 29 de Dezembro, alteração ao ISPC | Lei, arts. 1–7 e republicação anexa da Lei n.º 5/2009 | 8–11 | Citação localizada; interpretação, regulamento, elegibilidade e aprovação fiscal pendentes |
|
| `fiscal.ispc.lei_9_2025` | Lei n.º 9/2025, de 29 de Dezembro, alteração ao ISPC | Lei, arts. 1–7 e republicação anexa da Lei n.º 5/2009 | 8–11 | Citação localizada; interpretação, regulamento, elegibilidade e aprovação fiscal pendentes |
|
||||||
@@ -28,7 +28,7 @@ Também existe a chave `fiscal.iva.lei_22_2022` para a Lei n.º 22/2022, art. 17
|
|||||||
## Quatro ficheiros: origem e pendências por tipo
|
## Quatro ficheiros: origem e pendências por tipo
|
||||||
|
|
||||||
| Ficheiro e título | Diploma/conteúdo e origem | Autenticidade | Vigência/actualidade | Possibilidade de divulgação |
|
| Ficheiro e título | Diploma/conteúdo e origem | Autenticidade | Vigência/actualidade | Possibilidade de divulgação |
|
||||||
|---|---|---|---|---|
|
| -------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||||
| `Lei-22-2022-IVA-republicada-BR-250-2-suplemento.pdf` — Lei n.º 22/2022, alteração ao CIVA | [INM — 2.º Suplemento do BR n.º 250](https://www.inm.gov.mz/pt-br/content/assembleia-da-rep%C3%BAblica-suplemento-n%C2%BA-2-de-281222-pag-2252-25-42-br-n%C2%BA-250-boletim-da); cópia também comparada byte a byte com o endpoint oficial AT | Confirmada ao nível da origem e bytes (1.834.284 bytes; hash no registo de migração) | Documento alterador de 2022, marcado `amended`; não é consolidação integral actual. Art. 17(1) conferido, mas período e alterações posteriores devem acompanhar a consulta | A lei é texto oficial. Falta decisão administrativa documentada sobre divulgação desta composição/fac-símile PDF e confirmação de direitos de reutilização do artefacto. O registo continua `internal`, direitos `unconfirmed` |
|
| `Lei-22-2022-IVA-republicada-BR-250-2-suplemento.pdf` — Lei n.º 22/2022, alteração ao CIVA | [INM — 2.º Suplemento do BR n.º 250](https://www.inm.gov.mz/pt-br/content/assembleia-da-rep%C3%BAblica-suplemento-n%C2%BA-2-de-281222-pag-2252-25-42-br-n%C2%BA-250-boletim-da); cópia também comparada byte a byte com o endpoint oficial AT | Confirmada ao nível da origem e bytes (1.834.284 bytes; hash no registo de migração) | Documento alterador de 2022, marcado `amended`; não é consolidação integral actual. Art. 17(1) conferido, mas período e alterações posteriores devem acompanhar a consulta | A lei é texto oficial. Falta decisão administrativa documentada sobre divulgação desta composição/fac-símile PDF e confirmação de direitos de reutilização do artefacto. O registo continua `internal`, direitos `unconfirmed` |
|
||||||
| `BR-248-I-Suplemento-1-2025.pdf` — BR n.º 248/2025, Suplemento n.º 1 | [INM — ficha da edição](https://inm.gov.mz/pt-br/content/suplemento-n%C2%BA-1-de-291225-pag-2180-1-20-br-n%C2%BA-248-boletim-da-rep%C3%BAblica-i-serie); PDF comparado byte a byte com WebDAV oficial AT | Confirmada ao nível da edição, origem oficial e bytes (440.018 bytes) | Edição contém seis diplomas distintos (Leis 7–12/2025). Não há um único estado de vigência para o boletim; revisão deve ser por lei/artigo e regulamento | Falta documentar a autorização aplicável à divulgação do ficheiro composto, incluindo a apresentação integral do boletim. Permanece privado com direitos `unconfirmed` |
|
| `BR-248-I-Suplemento-1-2025.pdf` — BR n.º 248/2025, Suplemento n.º 1 | [INM — ficha da edição](https://inm.gov.mz/pt-br/content/suplemento-n%C2%BA-1-de-291225-pag-2180-1-20-br-n%C2%BA-248-boletim-da-rep%C3%BAblica-i-serie); PDF comparado byte a byte com WebDAV oficial AT | Confirmada ao nível da edição, origem oficial e bytes (440.018 bytes) | Edição contém seis diplomas distintos (Leis 7–12/2025). Não há um único estado de vigência para o boletim; revisão deve ser por lei/artigo e regulamento | Falta documentar a autorização aplicável à divulgação do ficheiro composto, incluindo a apresentação integral do boletim. Permanece privado com direitos `unconfirmed` |
|
||||||
| `BR-89-I-Serie-2017-06-08.pdf` — BR n.º 89/2017, aviso de rectificação da Lei n.º 13/2016 | [INM — ficha do BR 89, p. 569](https://www.inm.gov.mz/pt-br/content/assembleia-da-rep%C3%BAblica-br-n%C2%BA-89-de-080617-boletim-da-rep%C3%BAblica-i-serie-p%C3%A1g-569) | A ficha oficial confirma a existência do aviso; o PDF local não foi comparado com exemplar oficial descarregado e a cadeia de custódia não está demonstrada | O aviso altera o CIVA e manda rectificar anexos I–III. Os anexos substitutivos e o efeito temporal ainda não foram cotejados com cópia autêntica; não serve como consolidação | Falta autenticar o binário e esclarecer a divulgação do fac-símile. Mantido privado; associação candidata pendente, não exibida como fundamento confirmado |
|
| `BR-89-I-Serie-2017-06-08.pdf` — BR n.º 89/2017, aviso de rectificação da Lei n.º 13/2016 | [INM — ficha do BR 89, p. 569](https://www.inm.gov.mz/pt-br/content/assembleia-da-rep%C3%BAblica-br-n%C2%BA-89-de-080617-boletim-da-rep%C3%BAblica-i-serie-p%C3%A1g-569) | A ficha oficial confirma a existência do aviso; o PDF local não foi comparado com exemplar oficial descarregado e a cadeia de custódia não está demonstrada | O aviso altera o CIVA e manda rectificar anexos I–III. Os anexos substitutivos e o efeito temporal ainda não foram cotejados com cópia autêntica; não serve como consolidação | Falta autenticar o binário e esclarecer a divulgação do fac-símile. Mantido privado; associação candidata pendente, não exibida como fundamento confirmado |
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Estado: **validado tecnicamente para desenvolvimento local**, por revisão do re
|
|||||||
## Decisões adoptadas
|
## Decisões adoptadas
|
||||||
|
|
||||||
| ID | Decisão e fundamento confirmado | Execução e limites |
|
| ID | Decisão e fundamento confirmado | Execução e limites |
|
||||||
| --- | --- | --- |
|
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||||
| D-EDU-01 / B02 | O catálogo público usa `opportunities.id` bigint; os domínios novos usam UUID. Preservar ambos, com uma associação explícita, sem converter IDs existentes. | `education_investment_proposals` tem UUID e referências a `labour_demands` e `opportunities`. Uma ficha inicial por procura; restrições únicas e bloqueio transaccional evitam duplicação. `education_opportunities` conserva a semântica de oferta calendarizada. |
|
| D-EDU-01 / B02 | O catálogo público usa `opportunities.id` bigint; os domínios novos usam UUID. Preservar ambos, com uma associação explícita, sem converter IDs existentes. | `education_investment_proposals` tem UUID e referências a `labour_demands` e `opportunities`. Uma ficha inicial por procura; restrições únicas e bloqueio transaccional evitam duplicação. `education_opportunities` conserva a semântica de oferta calendarizada. |
|
||||||
| D-EDU-02 / B03 | Reutilizar sessão, email verificado e `manage-portal` para preparação interna. O registo público não concede acesso. | As rotas novas estão no grupo de gestão, atrás de `EducationEnabled`. Não criar perfis institucionais ou OAuth/OIDC sem mandatos/issuer reais. A revisão por outro gestor continua distinta de validação oficial. |
|
| D-EDU-02 / B03 | Reutilizar sessão, email verificado e `manage-portal` para preparação interna. O registo público não concede acesso. | As rotas novas estão no grupo de gestão, atrás de `EducationEnabled`. Não criar perfis institucionais ou OAuth/OIDC sem mandatos/issuer reais. A revisão por outro gestor continua distinta de validação oficial. |
|
||||||
| D-EDU-03 / B06 | Vagas formativas não equivalem a trabalhadores disponíveis. Fontes desconhecidas não equivalem a zero. A versão revista da procura é requisito para preparar uma proposta. | Comparação existente preservada; proposta referencia a versão revista e vigente. Alteração de versão produz conflito na criação e aviso na consulta da ficha anterior. Nenhuma soma de vagas é apresentada como défice laboral. |
|
| D-EDU-03 / B06 | Vagas formativas não equivalem a trabalhadores disponíveis. Fontes desconhecidas não equivalem a zero. A versão revista da procura é requisito para preparar uma proposta. | Comparação existente preservada; proposta referencia a versão revista e vigente. Alteração de versão produz conflito na criação e aviso na consulta da ficha anterior. Nenhuma soma de vagas é apresentada como défice laboral. |
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ As rotas continuam internas, sob `/management/education`, com sessão, verifica
|
|||||||
“Parcial” significa código existente com limitações concretas; nenhum RF abaixo foi declarado integralmente cumprido. Os critérios completos mantêm-se em `requirements.csv`.
|
“Parcial” significa código existente com limitações concretas; nenhum RF abaixo foi declarado integralmente cumprido. Os critérios completos mantêm-se em `requirements.csv`.
|
||||||
|
|
||||||
| RF-EDU | Estado funcional | Evidência e trabalho por concluir |
|
| RF-EDU | Estado funcional | Evidência e trabalho por concluir |
|
||||||
| --- | --- | --- |
|
| ------ | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| 001 | Parcial | Cadastro de código/nome; faltam taxonomia, sinónimos, níveis, fontes e revisão de versões. B01/B06. |
|
| 001 | Parcial | Cadastro de código/nome; faltam taxonomia, sinónimos, níveis, fontes e revisão de versões. B01/B06. |
|
||||||
| 002 | Parcial | Procura por projecto, ocupação, competência principal, território e período; faltam múltiplas competências, contexto produtivo completo e mandatos. B01/B03. |
|
| 002 | Parcial | Procura por projecto, ocupação, competência principal, território e período; faltam múltiplas competências, contexto produtivo completo e mandatos. B01/B03. |
|
||||||
| 003 | Parcial | Instituições, cursos e capacidade declarada; faltam cobertura, documentação e vínculo institucional verificado. B01/B03. |
|
| 003 | Parcial | Instituições, cursos e capacidade declarada; faltam cobertura, documentação e vínculo institucional verificado. B01/B03. |
|
||||||
@@ -64,7 +64,7 @@ As rotas continuam internas, sob `/management/education`, com sessão, verifica
|
|||||||
Ambiente de teste novo e isolado: PostgreSQL/PostGIS local, porta 55440, base `investmoz_education_test`; PHP 8.5.11 com driver PostgreSQL. Não foi usada a base da aplicação para migrations ou testes. Não foram inseridos dados institucionais reais.
|
Ambiente de teste novo e isolado: PostgreSQL/PostGIS local, porta 55440, base `investmoz_education_test`; PHP 8.5.11 com driver PostgreSQL. Não foi usada a base da aplicação para migrations ou testes. Não foram inseridos dados institucionais reais.
|
||||||
|
|
||||||
| Verificação | Evidência |
|
| Verificação | Evidência |
|
||||||
| --- | --- |
|
| ---------------------------------- | ------------------------------------------------------------------------------- |
|
||||||
| Migrations | Aplicadas com sucesso na base temporária inicialmente vazia. |
|
| Migrations | Aplicadas com sucesso na base temporária inicialmente vazia. |
|
||||||
| PHPUnit | 107 testes, 884 verificações, todos aprovados. Inclui 9 testes Education. |
|
| PHPUnit | 107 testes, 884 verificações, todos aprovados. Inclui 9 testes Education. |
|
||||||
| Exemplos e consistência documental | 11 testes Node aprovados; não equivalem a conformidade funcional integral. |
|
| Exemplos e consistência documental | 11 testes Node aprovados; não equivalem a conformidade funcional integral. |
|
||||||
@@ -79,7 +79,7 @@ Os testes Education usam transacções revertidas e verificam que o destino term
|
|||||||
## 4. Decisões necessárias para concluir o MVP
|
## 4. Decisões necessárias para concluir o MVP
|
||||||
|
|
||||||
| Decisão concreta | Proposta para revisão | Responsável | Condição de avanço |
|
| Decisão concreta | Proposta para revisão | Responsável | Condição de avanço |
|
||||||
| --- | --- | --- | --- |
|
| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------- | ---------------------------------------------------------------------------------------- |
|
||||||
| Identidade da oportunidade educativa | Estender o domínio canónico de oportunidades, mantendo a oferta calendarizada separada; preservar IDs e contratos existentes. | Produto e Arquitectura | Aprovar mapeamento de identidade, campos, vínculo CRM e compatibilidade. B02. |
|
| Identidade da oportunidade educativa | Estender o domínio canónico de oportunidades, mantendo a oferta calendarizada separada; preservar IDs e contratos existentes. | Produto e Arquitectura | Aprovar mapeamento de identidade, campos, vínculo CRM e compatibilidade. B02. |
|
||||||
| Autoridade e permissões | Gestão interna não concede mandato institucional. Vincular validação a organização, âmbito e validade do mandato; manter autor diferente do revisor. | Segurança e entidades competentes | Aprovar matriz e comprovar OAuth/OIDC antes de API institucional. B03. |
|
| Autoridade e permissões | Gestão interna não concede mandato institucional. Vincular validação a organização, âmbito e validade do mandato; manter autor diferente do revisor. | Segurança e entidades competentes | Aprovar matriz e comprovar OAuth/OIDC antes de API institucional. B03. |
|
||||||
| Dados e metodologia | Comparar pessoas disponíveis com procura; capacidade formativa é uma resposta potencial, sujeita a calendário, conclusão e recursos partilhados. | Secretariado e entidades competentes | Validar fontes, taxonomia, unidade, cobertura, actualidade e regra de alocação. B01/B06. |
|
| Dados e metodologia | Comparar pessoas disponíveis com procura; capacidade formativa é uma resposta potencial, sujeita a calendário, conclusão e recursos partilhados. | Secretariado e entidades competentes | Validar fontes, taxonomia, unidade, cobertura, actualidade e regra de alocação. B01/B06. |
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ Executado o anexo de tabelas recebido em 30/09/2026, adaptado aos mestres existe
|
|||||||
As seguintes tabelas são extensões com **PK também FK obrigatória** para o mestre. Não geram um segundo identificador da entidade. Nomes/códigos e outros campos indicados continuam a ser lidos no mestre; não foram copiados.
|
As seguintes tabelas são extensões com **PK também FK obrigatória** para o mestre. Não geram um segundo identificador da entidade. Nomes/códigos e outros campos indicados continuam a ser lidos no mestre; não foram copiados.
|
||||||
|
|
||||||
| Extensão em skills_edu | Mestre em public | Informação mantida no mestre |
|
| Extensão em skills_edu | Mestre em public | Informação mantida no mestre |
|
||||||
|---|---|---|
|
| ------------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------ |
|
||||||
| skill_details | skills | UUID, código e nome PT |
|
| skill_details | skills | UUID, código e nome PT |
|
||||||
| occupation_details | occupations | UUID, código e nome PT |
|
| occupation_details | occupations | UUID, código e nome PT |
|
||||||
| program_details | courses | UUID, código, título PT, instituição/provider e estado |
|
| program_details | courses | UUID, código, título PT, instituição/provider e estado |
|
||||||
@@ -30,8 +30,8 @@ Os estados destas entidades seguem o mestre existente: por exemplo, consentiment
|
|||||||
O consentimento deve ter `public.consents.subject_ref` igual ao UUID do perfil. O trigger da extensão valida esta ligação e que a expiração é posterior à concessão. Não converte consentimento de outra finalidade nem muda o mestre.
|
O consentimento deve ter `public.consents.subject_ref` igual ao UUID do perfil. O trigger da extensão valida esta ligação e que a expiração é posterior à concessão. Não converte consentimento de outra finalidade nem muda o mestre.
|
||||||
|
|
||||||
| Referência do anexo | Mestre e tipo confirmados |
|
| Referência do anexo | Mestre e tipo confirmados |
|
||||||
|---|---|
|
| -------------------------------------------------- | -------------------------------------- |
|
||||||
| user_master_id e campos de actores *_by/*_user_id | public.users.id — bigint |
|
| user_master_id e campos de actores _\_by/__user_id | public.users.id — bigint |
|
||||||
| sector_master_id | public.sectors.id — bigint |
|
| sector_master_id | public.sectors.id — bigint |
|
||||||
| company_master_id / organisation_master_id | public.organizations.id — UUID |
|
| company_master_id / organisation_master_id | public.organizations.id — UUID |
|
||||||
| institution_master_id | public.training_providers.id — UUID |
|
| institution_master_id | public.training_providers.id — UUID |
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ A autorização do utilizador para executar está registada na conversa. Não se
|
|||||||
## Conservar–Melhorar–Substituir–Descontinuar
|
## Conservar–Melhorar–Substituir–Descontinuar
|
||||||
|
|
||||||
| Decisão | Componentes | Justificação |
|
| Decisão | Componentes | Justificação |
|
||||||
|---|---|---|
|
| ------------ | ------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------- |
|
||||||
| Conservar | users, organizations, sectors, projects, economic_clusters, development_corridors, investment_zones, geo_locations | Identidades mestre; não converter bigint em UUID nem duplicar taxonomias. |
|
| Conservar | users, organizations, sectors, projects, economic_clusters, development_corridors, investment_zones, geo_locations | Identidades mestre; não converter bigint em UUID nem duplicar taxonomias. |
|
||||||
| Conservar | skills, occupations, courses, training_providers, consents, documents e extensões skills_edu | Reutilizar PK/FK e estados do mestre; novos dados por migrations aditivas. |
|
| Conservar | skills, occupations, courses, training_providers, consents, documents e extensões skills_edu | Reutilizar PK/FK e estados do mestre; novos dados por migrations aditivas. |
|
||||||
| Conservar | Fluxos internos, revisão independente, cálculo de lacunas e oportunidade canónica | Compatibilidade; capacidade de formação não equivale a oferta laboral. |
|
| Conservar | Fluxos internos, revisão independente, cálculo de lacunas e oportunidade canónica | Compatibilidade; capacidade de formação não equivale a oferta laboral. |
|
||||||
@@ -34,7 +34,7 @@ A autorização do utilizador para executar está registada na conversa. Não se
|
|||||||
## Plano por ficheiro — proposto, ainda não executado
|
## Plano por ficheiro — proposto, ainda não executado
|
||||||
|
|
||||||
| Ordem | Caminhos | Alteração e verificação necessária |
|
| Ordem | Caminhos | Alteração e verificação necessária |
|
||||||
|---|---|---|
|
| ----- | --------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| 1 | `docs/investmoz/education/requirements.csv`, nova matriz funcional | Relacionar RF-CAN, CA/CT, RF-EDU/CRM/EII/GEO e A.31 com entidades, APIs, ecrãs, evidências e responsáveis. Não atribuir IDs normativos sem conferir a fonte. |
|
| 1 | `docs/investmoz/education/requirements.csv`, nova matriz funcional | Relacionar RF-CAN, CA/CT, RF-EDU/CRM/EII/GEO e A.31 com entidades, APIs, ecrãs, evidências e responsáveis. Não atribuir IDs normativos sem conferir a fonte. |
|
||||||
| 2 | `config/education.php`, `app/Http/Middleware/EducationEnabled.php` | Flags independentes; desligar sem apagar dados. Testar acesso negado e contratos actuais. |
|
| 2 | `config/education.php`, `app/Http/Middleware/EducationEnabled.php` | Flags independentes; desligar sem apagar dados. Testar acesso negado e contratos actuais. |
|
||||||
| 3 | Nova migration Laravel posterior a `100600` | Evoluir rascunho/arquivo, concorrência e escopos conforme desenho aprovado; não reescrever SQL aplicado. Testar ida/volta em base isolada e recusa de perda de dados. |
|
| 3 | Nova migration Laravel posterior a `100600` | Evoluir rascunho/arquivo, concorrência e escopos conforme desenho aprovado; não reescrever SQL aplicado. Testar ida/volta em base isolada e recusa de perda de dados. |
|
||||||
@@ -58,7 +58,7 @@ Sem mudança da ligação principal de dados nesta etapa. Antes de futuras migra
|
|||||||
**Não concluído. Não iniciar desenvolvimento funcional sob este prompt até resolver os bloqueadores materiais expressamente definidos nele.**
|
**Não concluído. Não iniciar desenvolvimento funcional sob este prompt até resolver os bloqueadores materiais expressamente definidos nele.**
|
||||||
|
|
||||||
| Elemento | Evidência disponível / falta concreta |
|
| Elemento | Evidência disponível / falta concreta |
|
||||||
|---|---|
|
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||||
| Autorização para executar | Recebida; não precisa de repetição. |
|
| Autorização para executar | Recebida; não precisa de repetição. |
|
||||||
| Rastreabilidade | Há `requirements.csv`, `requirements-audit.csv` e especificação anterior. Há referências a A.31, mas não foi identificada nesta pesquisa a secção normativa integral com versão e correspondência ao novo anexo. |
|
| Rastreabilidade | Há `requirements.csv`, `requirements-audit.csv` e especificação anterior. Há referências a A.31, mas não foi identificada nesta pesquisa a secção normativa integral com versão e correspondência ao novo anexo. |
|
||||||
| Âmbito | O novo pedido inclui indivíduos, instituições e correspondência; a decisão antiga D-EDU-06 excluía dados individuais. Actualizar formalmente o registo de âmbito com o novo pedido, sem tratar a autorização de desenvolvimento como consentimento dos candidatos. |
|
| Âmbito | O novo pedido inclui indivíduos, instituições e correspondência; a decisão antiga D-EDU-06 excluía dados individuais. Actualizar formalmente o registo de âmbito com o novo pedido, sem tratar a autorização de desenvolvimento como consentimento dos candidatos. |
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ Fase executada: descoberta e enquadramento. Todas as etapas estão autorizadas p
|
|||||||
## Diagnóstico confirmado
|
## Diagnóstico confirmado
|
||||||
|
|
||||||
| Componente | Evidência no repositório | Aplicação ao mercado |
|
| Componente | Evidência no repositório | Aplicação ao mercado |
|
||||||
| --- | --- | --- |
|
| --------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
|
||||||
| Stack | composer.lock: Laravel 13.30.1, Fortify 1.39.0, Inertia Laravel 3.3.3; instalados React 19.2.8, TypeScript 5.9.3, Vite 8.2.2 | Compatível; sem nova dependência |
|
| Stack | composer.lock: Laravel 13.30.1, Fortify 1.39.0, Inertia Laravel 3.3.3; instalados React 19.2.8, TypeScript 5.9.3, Vite 8.2.2 | Compatível; sem nova dependência |
|
||||||
| Runtime e BD | Inventário apenas de leitura: PHP 8.5.11, PostgreSQL 17.11, PostGIS 3.6.2 | Reutilizar; desenvolvimento local não comprova prontidão de produção |
|
| Runtime e BD | Inventário apenas de leitura: PHP 8.5.11, PostgreSQL 17.11, PostGIS 3.6.2 | Reutilizar; desenvolvimento local não comprova prontidão de produção |
|
||||||
| Identidade | users, organizations, memberships; Fortify e manage-portal | Identidade da conta não comprova titularidade nem representação; falta mandato por anúncio |
|
| Identidade | users, organizations, memberships; Fortify e manage-portal | Identidade da conta não comprova titularidade nem representação; falta mandato por anúncio |
|
||||||
@@ -36,7 +36,7 @@ Não se encontrou cadastro dedicado de anúncios MNE, mandatos, titularidades, l
|
|||||||
## Conservar–Melhorar–Substituir–Descontinuar
|
## Conservar–Melhorar–Substituir–Descontinuar
|
||||||
|
|
||||||
| Decisão | Componente | Acção proposta |
|
| Decisão | Componente | Acção proposta |
|
||||||
| --- | --- | --- |
|
| -------------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
|
||||||
| Conservar | Laravel/React/PostGIS, identidade, documentos canónicos, outbox e IDs mestres | Adaptadores versionados; manter contratos existentes |
|
| Conservar | Laravel/React/PostGIS, identidade, documentos canónicos, outbox e IDs mestres | Adaptadores versionados; manter contratos existentes |
|
||||||
| Melhorar | Autorização | Função e atributo por anúncio, mandatário, revisor e aprovador; MFA privilegiado; segregação em dois níveis |
|
| Melhorar | Autorização | Função e atributo por anúncio, mandatário, revisor e aprovador; MFA privilegiado; segregação em dois níveis |
|
||||||
| Melhorar | Documentos e CRM | Quarentena/scanner, grants revogáveis, escopo por anúncio; idempotência e reconciliação MNE |
|
| Melhorar | Documentos e CRM | Quarentena/scanner, grants revogáveis, escopo por anúncio; idempotência e reconciliação MNE |
|
||||||
@@ -60,7 +60,7 @@ Estados solicitados: rascunho, submetido, em triagem, em revisão, pendente de i
|
|||||||
## RACI proposto — atribuições nominais pendentes
|
## RACI proposto — atribuições nominais pendentes
|
||||||
|
|
||||||
| Actividade | Responsável pela execução (R) | Responsável final (A) | Consultados (C) | Informados (I) |
|
| Actividade | Responsável pela execução (R) | Responsável final (A) | Consultados (C) | Informados (I) |
|
||||||
| --- | --- | --- | --- | --- |
|
| ---------------------------------------------- | ----------------------------- | ------------------------------- | ---------------------------------------------- | -------------- |
|
||||||
| Escopo, piloto e política | Produto | Dono do Produto | Jurídico, Dados, Segurança | Operações |
|
| Escopo, piloto e política | Produto | Dono do Produto | Jurídico, Dados, Segurança | Operações |
|
||||||
| Modelo e contratos | Engenharia/Arquitectura | Arquitectura | Dados, CRM, Segurança | Produto |
|
| Modelo e contratos | Engenharia/Arquitectura | Arquitectura | Dados, CRM, Segurança | Produto |
|
||||||
| Legitimidade, direitos, NDA, KYC/AML aplicável | Jurídico/Conformidade | Responsável jurídico designado | Titular, entidade competente quando autorizada | Produto |
|
| Legitimidade, direitos, NDA, KYC/AML aplicável | Jurídico/Conformidade | Responsável jurídico designado | Titular, entidade competente quando autorizada | Produto |
|
||||||
@@ -77,7 +77,7 @@ Papéis propostos não concedem permissões. Ninguém foi nomeado por inferênci
|
|||||||
Esta matriz é de **questões para validação**, não parecer ou afirmação de admissibilidade legal. Não foram inventadas leis, termos de uso ou autoridades competentes. Regra, fonte oficial, versão, entidade, parecer e validade ficam pendentes.
|
Esta matriz é de **questões para validação**, não parecer ou afirmação de admissibilidade legal. Não foram inventadas leis, termos de uso ou autoridades competentes. Regra, fonte oficial, versão, entidade, parecer e validade ficam pendentes.
|
||||||
|
|
||||||
| Grupo de modalidades solicitadas | Objecto a distinguir | Verificação e documento necessário | Responsável proposto / estado |
|
| Grupo de modalidades solicitadas | Objecto a distinguir | Verificação e documento necessário | Responsável proposto / estado |
|
||||||
| --- | --- | --- | --- |
|
| -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------- |
|
||||||
| Venda 100%, parcial, aumento de capital, investidor financeiro, sócio estratégico, comprador | Empresa, participação, mandato e avaliação | Titularidade/representação, encargos, consentimentos e requisitos da operação | Jurídico + titular / pendente |
|
| Venda 100%, parcial, aumento de capital, investidor financeiro, sócio estratégico, comprador | Empresa, participação, mandato e avaliação | Titularidade/representação, encargos, consentimentos e requisitos da operação | Jurídico + titular / pendente |
|
||||||
| Cessão de posição, franchising, joint venture | Contrato, licença de uso, posição contratual | Restrições, consentimentos de terceiros, validade e análise da cessão | Jurídico / pendente |
|
| Cessão de posição, franchising, joint venture | Contrato, licença de uso, posição contratual | Restrições, consentimentos de terceiros, validade e análise da cessão | Jurídico / pendente |
|
||||||
| Venda/arrendamento de activos, transferência de unidade, sucessão | Activo físico, unidade, contratos e obrigações | Cadeia documental, legitimidade, passivos e autorizações | Jurídico + diligência especializada / pendente |
|
| Venda/arrendamento de activos, transferência de unidade, sucessão | Activo físico, unidade, contratos e obrigações | Cadeia documental, legitimidade, passivos e autorizações | Jurídico + diligência especializada / pendente |
|
||||||
@@ -90,7 +90,7 @@ Termos de uso, base de tratamento, consentimento granular, retenção, conflitos
|
|||||||
## Classificação e ameaças
|
## Classificação e ameaças
|
||||||
|
|
||||||
| Dados | Classificação inicial proposta | Controlos e teste de aceitação |
|
| Dados | Classificação inicial proposta | Controlos e teste de aceitação |
|
||||||
| --- | --- | --- |
|
| --------------------------------------------------------------------------------- | ----------------------------------------------- | ---------------------------------------------------------------------------- |
|
||||||
| Teaser aprovado, modalidade, sector, região indicativa, valor rotulado | Público apenas após autorização | Allowlist na API/índice/exportação; teste de reidentificação |
|
| Teaser aprovado, modalidade, sector, região indicativa, valor rotulado | Público apenas após autorização | Allowlist na API/índice/exportação; teste de reidentificação |
|
||||||
| Triagem, tarefas, estados, origens CRM | Interno | Menor privilégio; auditoria sem conteúdo reservado |
|
| Triagem, tarefas, estados, origens CRM | Interno | Menor privilégio; auditoria sem conteúdo reservado |
|
||||||
| Empresa, financeiros, contratos, clientes/fornecedores, propostas | Confidencial | Cifragem, escopo por anúncio, grants temporais; teste de acesso cruzado |
|
| Empresa, financeiros, contratos, clientes/fornecedores, propostas | Confidencial | Cifragem, escopo por anúncio, grants temporais; teste de acesso cruzado |
|
||||||
@@ -99,7 +99,7 @@ Termos de uso, base de tratamento, consentimento granular, retenção, conflitos
|
|||||||
Finalidade, base, dono, retenção, eliminação e divulgação precisam de decisão por categoria; nenhum prazo foi inventado. Cifragem existente depende da chave Laravel e não substitui gestão de chaves, mandatos ou política de retenção.
|
Finalidade, base, dono, retenção, eliminação e divulgação precisam de decisão por categoria; nenhum prazo foi inventado. Cifragem existente depende da chave Laravel e não substitui gestão de chaves, mandatos ou política de retenção.
|
||||||
|
|
||||||
| Ameaça | Controlo planeado | Prova exigida |
|
| Ameaça | Controlo planeado | Prova exigida |
|
||||||
| --- | --- | --- |
|
| --------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
|
||||||
| Anunciante falso/mandato revogado | Verificação separada de conta, identidade, representação e mandato; revalidação | Publicação negada quando ausente/expirado/revogado |
|
| Anunciante falso/mandato revogado | Verificação separada de conta, identidade, representação e mandato; revalidação | Publicação negada quando ausente/expirado/revogado |
|
||||||
| IDOR entre negócios ou data rooms | Autorização por utilizador, negócio, documento, versão e grant | Leitura/download/listagem cruzados negados |
|
| IDOR entre negócios ou data rooms | Autorização por utilizador, negócio, documento, versão e grant | Leitura/download/listagem cruzados negados |
|
||||||
| Auto-publicação e corrida de versões | Dupla aprovação, lock transaccional e versão esperada | Auto-aprovação negada; versão obsoleta 409 |
|
| Auto-publicação e corrida de versões | Dupla aprovação, lock transaccional e versão esperada | Auto-aprovação negada; versão obsoleta 409 |
|
||||||
|
|||||||
@@ -90,9 +90,7 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"max": 500,
|
"max": 500,
|
||||||
"when": {
|
"when": {
|
||||||
"acting_capacity": [
|
"acting_capacity": ["representative"]
|
||||||
"representative"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mandate_document_reference": {
|
"mandate_document_reference": {
|
||||||
@@ -102,9 +100,7 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"max": 500,
|
"max": 500,
|
||||||
"when": {
|
"when": {
|
||||||
"acting_capacity": [
|
"acting_capacity": ["representative"]
|
||||||
"representative"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mandate_valid_until": {
|
"mandate_valid_until": {
|
||||||
@@ -114,9 +110,7 @@
|
|||||||
"type": "date",
|
"type": "date",
|
||||||
"max": 10,
|
"max": 10,
|
||||||
"when": {
|
"when": {
|
||||||
"acting_capacity": [
|
"acting_capacity": ["representative"]
|
||||||
"representative"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"disclosure_scope": {
|
"disclosure_scope": {
|
||||||
@@ -126,9 +120,7 @@
|
|||||||
"type": "textarea",
|
"type": "textarea",
|
||||||
"max": 2000,
|
"max": 2000,
|
||||||
"when": {
|
"when": {
|
||||||
"acting_capacity": [
|
"acting_capacity": ["representative"]
|
||||||
"representative"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"legitimacy_declaration": {
|
"legitimacy_declaration": {
|
||||||
@@ -209,9 +201,7 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"max": 200,
|
"max": 200,
|
||||||
"when": {
|
"when": {
|
||||||
"project_stage": [
|
"project_stage": ["other"]
|
||||||
"other"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"availability": {
|
"availability": {
|
||||||
@@ -233,9 +223,7 @@
|
|||||||
"type": "date",
|
"type": "date",
|
||||||
"max": 10,
|
"max": 10,
|
||||||
"when": {
|
"when": {
|
||||||
"availability": [
|
"availability": ["from_date"]
|
||||||
"from_date"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"valid_until": {
|
"valid_until": {
|
||||||
@@ -252,10 +240,7 @@
|
|||||||
"type": "decimal",
|
"type": "decimal",
|
||||||
"max": 24,
|
"max": 24,
|
||||||
"when": {
|
"when": {
|
||||||
"value_status": [
|
"value_status": ["defined", "indicative"]
|
||||||
"defined",
|
|
||||||
"indicative"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"value_status": {
|
"value_status": {
|
||||||
@@ -283,10 +268,7 @@
|
|||||||
"financing_sought": "Financiamento procurado"
|
"financing_sought": "Financiamento procurado"
|
||||||
},
|
},
|
||||||
"when": {
|
"when": {
|
||||||
"value_status": [
|
"value_status": ["defined", "indicative"]
|
||||||
"defined",
|
|
||||||
"indicative"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"value_nature": {
|
"value_nature": {
|
||||||
@@ -301,10 +283,7 @@
|
|||||||
"appraised": "Avaliado, sujeito a prova"
|
"appraised": "Avaliado, sujeito a prova"
|
||||||
},
|
},
|
||||||
"when": {
|
"when": {
|
||||||
"value_status": [
|
"value_status": ["defined", "indicative"]
|
||||||
"defined",
|
|
||||||
"indicative"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"currency": {
|
"currency": {
|
||||||
@@ -314,10 +293,7 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"max": 3,
|
"max": 3,
|
||||||
"when": {
|
"when": {
|
||||||
"value_status": [
|
"value_status": ["defined", "indicative"]
|
||||||
"defined",
|
|
||||||
"indicative"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"amount_secured": {
|
"amount_secured": {
|
||||||
@@ -327,9 +303,7 @@
|
|||||||
"type": "decimal",
|
"type": "decimal",
|
||||||
"max": 24,
|
"max": 24,
|
||||||
"when": {
|
"when": {
|
||||||
"opportunity_type": [
|
"opportunity_type": ["investment_project"]
|
||||||
"investment_project"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"investment_total": {
|
"investment_total": {
|
||||||
@@ -339,9 +313,7 @@
|
|||||||
"type": "decimal",
|
"type": "decimal",
|
||||||
"max": 24,
|
"max": 24,
|
||||||
"when": {
|
"when": {
|
||||||
"opportunity_type": [
|
"opportunity_type": ["investment_project"]
|
||||||
"investment_project"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"amount_sought": {
|
"amount_sought": {
|
||||||
@@ -351,10 +323,7 @@
|
|||||||
"type": "decimal",
|
"type": "decimal",
|
||||||
"max": 24,
|
"max": 24,
|
||||||
"when": {
|
"when": {
|
||||||
"opportunity_type": [
|
"opportunity_type": ["investment_project", "financing_request"]
|
||||||
"investment_project",
|
|
||||||
"financing_request"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"equity_percentage": {
|
"equity_percentage": {
|
||||||
@@ -383,10 +352,7 @@
|
|||||||
"assets": "Activos"
|
"assets": "Activos"
|
||||||
},
|
},
|
||||||
"when": {
|
"when": {
|
||||||
"opportunity_type": [
|
"opportunity_type": ["company_sale", "asset_sale"]
|
||||||
"company_sale",
|
|
||||||
"asset_sale"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"partnership_contribution": {
|
"partnership_contribution": {
|
||||||
@@ -404,9 +370,7 @@
|
|||||||
"other": "Outra"
|
"other": "Outra"
|
||||||
},
|
},
|
||||||
"when": {
|
"when": {
|
||||||
"opportunity_type": [
|
"opportunity_type": ["business_partnership"]
|
||||||
"business_partnership"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"asset_modality": {
|
"asset_modality": {
|
||||||
@@ -421,9 +385,7 @@
|
|||||||
"other": "Outra"
|
"other": "Outra"
|
||||||
},
|
},
|
||||||
"when": {
|
"when": {
|
||||||
"opportunity_type": [
|
"opportunity_type": ["asset_sale"]
|
||||||
"asset_sale"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"concession_entity": {
|
"concession_entity": {
|
||||||
@@ -433,9 +395,7 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"max": 300,
|
"max": 300,
|
||||||
"when": {
|
"when": {
|
||||||
"opportunity_type": [
|
"opportunity_type": ["concession_opportunity"]
|
||||||
"concession_opportunity"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"concession_reference": {
|
"concession_reference": {
|
||||||
@@ -445,9 +405,7 @@
|
|||||||
"type": "textarea",
|
"type": "textarea",
|
||||||
"max": 2000,
|
"max": 2000,
|
||||||
"when": {
|
"when": {
|
||||||
"opportunity_type": [
|
"opportunity_type": ["concession_opportunity"]
|
||||||
"concession_opportunity"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"supply_description": {
|
"supply_description": {
|
||||||
@@ -457,9 +415,7 @@
|
|||||||
"type": "textarea",
|
"type": "textarea",
|
||||||
"max": 2000,
|
"max": 2000,
|
||||||
"when": {
|
"when": {
|
||||||
"opportunity_type": [
|
"opportunity_type": ["supply_opportunity"]
|
||||||
"supply_opportunity"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"conditions": {
|
"conditions": {
|
||||||
@@ -489,10 +445,7 @@
|
|||||||
"type": "territory",
|
"type": "territory",
|
||||||
"max": 36,
|
"max": 36,
|
||||||
"when": {
|
"when": {
|
||||||
"geography_scope": [
|
"geography_scope": ["specific", "multiple"]
|
||||||
"specific",
|
|
||||||
"multiple"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"district_id": {
|
"district_id": {
|
||||||
@@ -502,10 +455,7 @@
|
|||||||
"type": "territory",
|
"type": "territory",
|
||||||
"max": 36,
|
"max": 36,
|
||||||
"when": {
|
"when": {
|
||||||
"geography_scope": [
|
"geography_scope": ["specific", "multiple"]
|
||||||
"specific",
|
|
||||||
"multiple"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin_post_id": {
|
"admin_post_id": {
|
||||||
@@ -515,10 +465,7 @@
|
|||||||
"type": "territory",
|
"type": "territory",
|
||||||
"max": 36,
|
"max": 36,
|
||||||
"when": {
|
"when": {
|
||||||
"geography_scope": [
|
"geography_scope": ["specific", "multiple"]
|
||||||
"specific",
|
|
||||||
"multiple"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"locality_id": {
|
"locality_id": {
|
||||||
@@ -528,10 +475,7 @@
|
|||||||
"type": "territory",
|
"type": "territory",
|
||||||
"max": 36,
|
"max": 36,
|
||||||
"when": {
|
"when": {
|
||||||
"geography_scope": [
|
"geography_scope": ["specific", "multiple"]
|
||||||
"specific",
|
|
||||||
"multiple"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"location_notes": {
|
"location_notes": {
|
||||||
@@ -552,10 +496,7 @@
|
|||||||
"no": "Não"
|
"no": "Não"
|
||||||
},
|
},
|
||||||
"when": {
|
"when": {
|
||||||
"geography_scope": [
|
"geography_scope": ["specific", "multiple"]
|
||||||
"specific",
|
|
||||||
"multiple"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"disclosure_precision": {
|
"disclosure_precision": {
|
||||||
@@ -570,10 +511,7 @@
|
|||||||
"administrative": "Apenas território administrativo"
|
"administrative": "Apenas território administrativo"
|
||||||
},
|
},
|
||||||
"when": {
|
"when": {
|
||||||
"geography_scope": [
|
"geography_scope": ["specific", "multiple"]
|
||||||
"specific",
|
|
||||||
"multiple"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"asset_notes": {
|
"asset_notes": {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ Não existe publicação neste incremento. A constraint da BD permite apenas `dr
|
|||||||
## Matriz das fases e decisões
|
## Matriz das fases e decisões
|
||||||
|
|
||||||
| Fase | Executado | Lacunas / decisão |
|
| Fase | Executado | Lacunas / decisão |
|
||||||
| --- | --- | --- |
|
| --------------------------- | ---------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| 0 — descoberta | Diagnóstico, ameaças, RACI, matriz jurídica, baseline | Política/base/equipa/piloto não homologados; No-Go institucional mantém-se |
|
| 0 — descoberta | Diagnóstico, ameaças, RACI, matriz jurídica, baseline | Política/base/equipa/piloto não homologados; No-Go institucional mantém-se |
|
||||||
| 1 — modelo | Negócio, objectos tipados separados, mandato pendente, classificação, versões, histórico, rollback | Relações documentais/territoriais detalhadas, titularidade comprovada, revisão de mandatos e retenção homologada pendentes; Go condicionado técnico |
|
| 1 — modelo | Negócio, objectos tipados separados, mandato pendente, classificação, versões, histórico, rollback | Relações documentais/territoriais detalhadas, titularidade comprovada, revisão de mandatos e retenção homologada pendentes; Go condicionado técnico |
|
||||||
| 2 — submissão/administração | UI e API de rascunho, submissão, consentimento, revisão independente, pedido de informação, retirada | Upload/scanner, verificações documentais, dois níveis de aprovação e publicação ainda não implementados; núcleo privado utilizável, fase parcial |
|
| 2 — submissão/administração | UI e API de rascunho, submissão, consentimento, revisão independente, pedido de informação, retirada | Upload/scanner, verificações documentais, dois níveis de aprovação e publicação ainda não implementados; núcleo privado utilizável, fase parcial |
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -21,7 +21,7 @@ erDiagram
|
|||||||
## Dicionário implementado
|
## Dicionário implementado
|
||||||
|
|
||||||
| Tabela | Campos e invariantes |
|
| Tabela | Campos e invariantes |
|
||||||
| --- | --- |
|
| --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| existing_businesses | UUID, code único permanente, source_system/legacy_id conjuntamente nulos ou presentes e únicos, owner_user_id obrigatório, organization_id opcional, investment_item_id opcional e único, modality, status exclusivamente draft, classification internal/confidential/restricted, version_no positivo, payload cifrado, timestamps e deleted_at |
|
| existing_businesses | UUID, code único permanente, source_system/legacy_id conjuntamente nulos ou presentes e únicos, owner_user_id obrigatório, organization_id opcional, investment_item_id opcional e único, modality, status exclusivamente draft, classification internal/confidential/restricted, version_no positivo, payload cifrado, timestamps e deleted_at |
|
||||||
| existing_business_objects | UUID, business_id, kind distinguindo company/participation/asset/property/unit/improvement/agricultural_investment/land_right/contract/license/authorization/encumbrance/valuation/capital_request, classification confidential/restricted, verification_status exclusivamente pending, payload cifrado, timestamps |
|
| existing_business_objects | UUID, business_id, kind distinguindo company/participation/asset/property/unit/improvement/agricultural_investment/land_right/contract/license/authorization/encumbrance/valuation/capital_request, classification confidential/restricted, verification_status exclusivamente pending, payload cifrado, timestamps |
|
||||||
| existing_business_mandates | UUID, business_id, representative_user_id, document_id, valid_from/valid_until coerentes, verification_status exclusivamente pending, payload cifrado, timestamps. Documento anexado não comprova legitimidade. Nenhum acesso é concedido pelo mandato pendente. |
|
| existing_business_mandates | UUID, business_id, representative_user_id, document_id, valid_from/valid_until coerentes, verification_status exclusivamente pending, payload cifrado, timestamps. Documento anexado não comprova legitimidade. Nenhum acesso é concedido pelo mandato pendente. |
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ O prompt não fornece uma sequência numerada RF-MNE; `traceability.csv` usa ide
|
|||||||
## Gate
|
## Gate
|
||||||
|
|
||||||
| Critério obrigatório da Fase 0 | Evidência | Resultado |
|
| Critério obrigatório da Fase 0 | Evidência | Resultado |
|
||||||
| --- | --- | --- |
|
| ---------------------------------------------- | ------------------------------------------------------------ | ------------------------------- |
|
||||||
| Dono do produto/autorização de desenvolvimento | Instrução explícita do utilizador | Confirmado para desenvolvimento |
|
| Dono do produto/autorização de desenvolvimento | Instrução explícita do utilizador | Confirmado para desenvolvimento |
|
||||||
| Política de publicação, termos e base legal | Não fornecidos/validados nesta sessão | Pendente |
|
| Política de publicação, termos e base legal | Não fornecidos/validados nesta sessão | Pendente |
|
||||||
| Equipa e mandatos de revisão | Apenas RACI proposto; sem nomeações | Pendente |
|
| Equipa e mandatos de revisão | Apenas RACI proposto; sem nomeações | Pendente |
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
17. **Go/No-Go:** Go para testar preparação privada local; **No-Go para entrega integral A–C ou Go-Live**. Os fluxos incompletos não foram expostos como funcionais.
|
17. **Go/No-Go:** Go para testar preparação privada local; **No-Go para entrega integral A–C ou Go-Live**. Os fluxos incompletos não foram expostos como funcionais.
|
||||||
|
|
||||||
| Requisito | Implementação actual | Estado |
|
| Requisito | Implementação actual | Estado |
|
||||||
|---|---|---|
|
| --------------------------- | ----------------------------------------------------------------- | ------------------------------------------------- |
|
||||||
| A: proponente/representação | Campos cifrados, mandato condicional, declaração e validação | Parcial; sem verificação de identidade/documentos |
|
| A: proponente/representação | Campos cifrados, mandato condicional, declaração e validação | Parcial; sem verificação de identidade/documentos |
|
||||||
| A: modalidade/sector/valor | Taxonomia existente, FK, limites, moeda e natureza na submissão | Parcial; faltam intervalos e estruturas completas |
|
| A: modalidade/sector/valor | Taxonomia existente, FK, limites, moeda e natureza na submissão | Parcial; faltam intervalos e estruturas completas |
|
||||||
| A: localização/contexto | Descrição privada | Geografia estruturada e ligações pendentes |
|
| A: localização/contexto | Descrição privada | Geografia estruturada e ligações pendentes |
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ O dono do produto autorizou a progressão automática por todas as fases nesta s
|
|||||||
## Estado por fase
|
## Estado por fase
|
||||||
|
|
||||||
| Fase | Estado e recomendação | Evidência / condição |
|
| Fase | Estado e recomendação | Evidência / condição |
|
||||||
| --- | --- | --- |
|
| ------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| 0 — inventário | Parcial; Go condicionado para artefactos preparatórios | Código, índices, mapas e controlos inventariados abaixo. Excel localizado e inspeccionado após indicação do utilizador; documento original A.31 ainda não localizado. |
|
| 0 — inventário | Parcial; Go condicionado para artefactos preparatórios | Código, índices, mapas e controlos inventariados abaixo. Excel localizado e inspeccionado após indicação do utilizador; documento original A.31 ainda não localizado. |
|
||||||
| 1 — modelo e regras | Proposta de reconciliação; Go condicionado | Reutilizar o cadastro existente, sem uma segunda base GIS. Reconciliar a proposta com A.31 antes de fechar o modelo. |
|
| 1 — modelo e regras | Proposta de reconciliação; Go condicionado | Reutilizar o cadastro existente, sem uma segunda base GIS. Reconciliar a proposta com A.31 antes de fechar o modelo. |
|
||||||
| 2 — serviços e importação | Auditor de XLSX implementado; restante pendente | Auditor local sem ligação à BD, com checksum, autorização de inspecção, limites e quarentena. Não é importador. |
|
| 2 — serviços e importação | Auditor de XLSX implementado; restante pendente | Auditor local sem ligação à BD, com checksum, autorização de inspecção, limites e quarentena. Não é importador. |
|
||||||
@@ -59,7 +59,7 @@ Pesquisaram-se nomes de ficheiros DOCX/XLSX/PDF no repositório (incluindo ignor
|
|||||||
Os identificadores TECH abaixo são **provisórios locais**, não transcrição da A.31. Não se criou uma segunda sequência RF-GIS.
|
Os identificadores TECH abaixo são **provisórios locais**, não transcrição da A.31. Não se criou uma segunda sequência RF-GIS.
|
||||||
|
|
||||||
| RF-GEO | TECH provisório | Modelo / serviço previsto | API / evento previsto | Frontend e teste necessário | Estado |
|
| RF-GEO | TECH provisório | Modelo / serviço previsto | API / evento previsto | Frontend e teste necessário | Estado |
|
||||||
| --- | --- | --- | --- | --- | --- |
|
| ------ | -------------------- | --------------------------------------------------------------- | --------------------------------------------------- | ------------------------------------------------------------------- | --------------------------------- |
|
||||||
| 001 | TECH-GEO-CAD | Adaptar geo_locations, proveniência, validade, revisão imutável | locations GET/POST/PATCH; location.revised | Cadastro; códigos duplicados, ciclos e concorrência | Base parcial |
|
| 001 | TECH-GEO-CAD | Adaptar geo_locations, proveniência, validade, revisão imutável | locations GET/POST/PATCH; location.revised | Cadastro; códigos duplicados, ciclos e concorrência | Base parcial |
|
||||||
| 002 | TECH-GEO-REL | Adaptar project_locations, papel, período, natureza | Relações explicitadas no contrato de localização | Vários projectos sem duplicar geometria | Base parcial |
|
| 002 | TECH-GEO-REL | Adaptar project_locations, papel, período, natureza | Relações explicitadas no contrato de localização | Vários projectos sem duplicar geometria | Base parcial |
|
||||||
| 003 | TECH-GEO-MULTI | Localização principal por período; secundárias | Ficha do projecto/localizações | Projecto multiterritorial; unicidade principal | Parcial |
|
| 003 | TECH-GEO-MULTI | Localização principal por período; secundárias | Ficha do projecto/localizações | Projecto multiterritorial; unicidade principal | Parcial |
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ Relatórios indicam ordinal do registo CSV e códigos de erro, sem repetir o con
|
|||||||
Validação executada: suite PHP completa com **168 testes e 1.707 verificações aprovadas** (32,524 s), incluindo seis novos testes unitários de CSV; PHPStan sem erros e Pint aprovado nos ficheiros PHP alterados. A extracção do PDF real terminou com 666 linhas de revisão. Não houve alteração de frontend nem alegação de testes visuais nesta fase.
|
Validação executada: suite PHP completa com **168 testes e 1.707 verificações aprovadas** (32,524 s), incluindo seis novos testes unitários de CSV; PHPStan sem erros e Pint aprovado nos ficheiros PHP alterados. A extracção do PDF real terminou com 666 linhas de revisão. Não houve alteração de frontend nem alegação de testes visuais nesta fase.
|
||||||
|
|
||||||
| Critério | Situação e motivo | Impacto / próxima acção |
|
| Critério | Situação e motivo | Impacto / próxima acção |
|
||||||
| --- | --- | --- |
|
| ------------------------------------------------------- | ----------------- | ------------------------------------------------------------------------------ |
|
||||||
| Original, checksum e revisão reproduzível | Executado | Conservar pacote privado |
|
| Original, checksum e revisão reproduzível | Executado | Conservar pacote privado |
|
||||||
| Auditoria estrutural CSV | Executada | Não substitui carga ou aprovação |
|
| Auditoria estrutural CSV | Executada | Não substitui carga ou aprovação |
|
||||||
| Seed MZ, 11 províncias e capitais em staging | Por implementar | Criar seed idempotente com proveniência, sem localidades fictícias |
|
| Seed MZ, 11 províncias e capitais em staging | Por implementar | Criar seed idempotente com proveniência, sem localidades fictícias |
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ O índice legado de código/tipo é global, mais restritivo que código de prov
|
|||||||
Migration `2026_09_28_150000_territorial_registry.php` acrescenta cinco tabelas:
|
Migration `2026_09_28_150000_territorial_registry.php` acrescenta cinco tabelas:
|
||||||
|
|
||||||
| Tabela | Finalidade e controlos |
|
| Tabela | Finalidade e controlos |
|
||||||
| --- | --- |
|
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| geo_sources | Fonte, entidade, referência, licença, checksum, versão, data, CRS original e estado; checksum/versão únicos; editor/revisor e evidência da decisão |
|
| geo_sources | Fonte, entidade, referência, licença, checksum, versão, data, CRS original e estado; checksum/versão únicos; editor/revisor e evidência da decisão |
|
||||||
| geo_territory_profiles | FK única para geo_locations; fonte, ISO2/ISO3 opcionais únicos, capital por FK, vigência, estado, editor/revisor/publicador |
|
| geo_territory_profiles | FK única para geo_locations; fonte, ISO2/ISO3 opcionais únicos, capital por FK, vigência, estado, editor/revisor/publicador |
|
||||||
| geo_names | Nomes/idiomas por FK; nome normalizado e oficial; unicidade por entidade/idioma/nome e um oficial por idioma |
|
| geo_names | Nomes/idiomas por FK; nome normalizado e oficial; unicidade por entidade/idioma/nome e um oficial por idioma |
|
||||||
|
|||||||
@@ -669,10 +669,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"parent_id": {
|
"parent_id": {
|
||||||
"type": [
|
"type": ["string", "null"],
|
||||||
"string",
|
|
||||||
"null"
|
|
||||||
],
|
|
||||||
"format": "uuid"
|
"format": "uuid"
|
||||||
},
|
},
|
||||||
"source_id": {
|
"source_id": {
|
||||||
@@ -684,10 +681,7 @@
|
|||||||
"format": "date"
|
"format": "date"
|
||||||
},
|
},
|
||||||
"valid_to": {
|
"valid_to": {
|
||||||
"type": [
|
"type": ["string", "null"],
|
||||||
"string",
|
|
||||||
"null"
|
|
||||||
],
|
|
||||||
"format": "date"
|
"format": "date"
|
||||||
},
|
},
|
||||||
"reason": {
|
"reason": {
|
||||||
@@ -784,10 +778,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"parent_id": {
|
"parent_id": {
|
||||||
"type": [
|
"type": ["string", "null"],
|
||||||
"string",
|
|
||||||
"null"
|
|
||||||
],
|
|
||||||
"format": "uuid"
|
"format": "uuid"
|
||||||
},
|
},
|
||||||
"source_id": {
|
"source_id": {
|
||||||
@@ -799,10 +790,7 @@
|
|||||||
"format": "date"
|
"format": "date"
|
||||||
},
|
},
|
||||||
"valid_to": {
|
"valid_to": {
|
||||||
"type": [
|
"type": ["string", "null"],
|
||||||
"string",
|
|
||||||
"null"
|
|
||||||
],
|
|
||||||
"format": "date"
|
"format": "date"
|
||||||
},
|
},
|
||||||
"reason": {
|
"reason": {
|
||||||
@@ -906,11 +894,7 @@
|
|||||||
"minLength": 10
|
"minLength": 10
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": ["action", "version_no", "reason"]
|
||||||
"action",
|
|
||||||
"version_no",
|
|
||||||
"reason"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1100,20 +1084,14 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"action": {
|
"action": {
|
||||||
"enum": [
|
"enum": ["approved", "revoked"]
|
||||||
"approved",
|
|
||||||
"revoked"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"approval_reference": {
|
"approval_reference": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 10
|
"minLength": 10
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": ["action", "approval_reference"]
|
||||||
"action",
|
|
||||||
"approval_reference"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ A página agora oferece os percursos “Tenho um projecto definido” e “Tenho
|
|||||||
- No catálogo real carregado, há seis oportunidades provenientes do `OpportunitySeeder`, todas sem `last_validated_at`, e zero anúncios de negócio. Filtros por Nampula e agronegócio devolveram um cartão cada; o CTA anónimo encaminha para login. A origem seed não prova autorização comercial. O catálogo e detalhe agora avisam quando a data de validação documental não está registada. Evidência: [JSON](pilot/authorized-opportunity-filter-browser-2026-10-04.json).
|
- No catálogo real carregado, há seis oportunidades provenientes do `OpportunitySeeder`, todas sem `last_validated_at`, e zero anúncios de negócio. Filtros por Nampula e agronegócio devolveram um cartão cada; o CTA anónimo encaminha para login. A origem seed não prova autorização comercial. O catálogo e detalhe agora avisam quando a data de validação documental não está registada. Evidência: [JSON](pilot/authorized-opportunity-filter-browser-2026-10-04.json).
|
||||||
- `npm.cmd run types:check`, `npm.cmd run build` e `node --test tests/frontend/*.test.mjs`: passaram (139/139). Avisos de build: dependência opcional `fontaine` ausente e chunk `services` acima de 500 kB.
|
- `npm.cmd run types:check`, `npm.cmd run build` e `node --test tests/frontend/*.test.mjs`: passaram (139/139). Avisos de build: dependência opcional `fontaine` ausente e chunk `services` acima de 500 kB.
|
||||||
- Os resultados e decisões de fonte para as 50 relações, 15 projectos âncora e catálogos constam em [revisão documental](catalogue-review-2026-10-04.md).
|
- Os resultados e decisões de fonte para as 50 relações, 15 projectos âncora e catálogos constam em [revisão documental](catalogue-review-2026-10-04.md).
|
||||||
|
|
||||||
## Pendências e limites
|
## Pendências e limites
|
||||||
|
|
||||||
1. **50 relações candidatas:** falta atribuir revisor interno e registar fonte/evidência individual com vigência. A decisão pendente é a natureza de cada ligação (oficial, influência, proximidade, potencial, histórica) ou remoção. Não se exige certificador externo; relações sem prova ficam fora de pesquisas oficiais. Os catálogos e fichas continuam acessíveis.
|
1. **50 relações candidatas:** falta atribuir revisor interno e registar fonte/evidência individual com vigência. A decisão pendente é a natureza de cada ligação (oficial, influência, proximidade, potencial, histórica) ou remoção. Não se exige certificador externo; relações sem prova ficam fora de pesquisas oficiais. Os catálogos e fichas continuam acessíveis.
|
||||||
@@ -65,6 +66,7 @@ A página agora oferece os percursos “Tenho um projecto definido” e “Tenho
|
|||||||
4. **Negócios e oportunidades:** os seis cartões disponíveis são seeds sem data de validação; o catálogo de negócios tem 0 anúncios. Falta ao menos um registo autorizado com fonte e data para verificar anúncio e pretensão real. O catálogo continua consultável com aviso; não há confirmação de oferta.
|
4. **Negócios e oportunidades:** os seis cartões disponíveis são seeds sem data de validação; o catálogo de negócios tem 0 anúncios. Falta ao menos um registo autorizado com fonte e data para verificar anúncio e pretensão real. O catálogo continua consultável com aviso; não há confirmação de oferta.
|
||||||
5. **ZFE:** a sigla não tem definição/fonte encontrada; pedir a referência original antes de criar categoria.
|
5. **ZFE:** a sigla não tem definição/fonte encontrada; pedir a referência original antes de criar categoria.
|
||||||
6. **Dispositivo físico:** falta ensaio num telemóvel físico; viewport Chromium não substitui compatibilidade real.
|
6. **Dispositivo físico:** falta ensaio num telemóvel físico; viewport Chromium não substitui compatibilidade real.
|
||||||
|
|
||||||
## Diff lógico nesta entrega
|
## Diff lógico nesta entrega
|
||||||
|
|
||||||
- `database/migrations/2026_10_03_180000_govern_investment_structure_relations.php`: migration aditiva pendente executada nas três tabelas; não foi editada.
|
- `database/migrations/2026_10_03_180000_govern_investment_structure_relations.php`: migration aditiva pendente executada nas três tabelas; não foi editada.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ O acervo disponível permite identificar diplomas e pontos de revisão, mas não
|
|||||||
## Matriz de fontes e efeitos
|
## Matriz de fontes e efeitos
|
||||||
|
|
||||||
| Matéria | Diploma ou indicação | Fonte consultada e qualidade | Vigência/estado nesta triagem | Área do produto | Teste/controlo | Aprovação |
|
| Matéria | Diploma ou indicação | Fonte consultada e qualidade | Vigência/estado nesta triagem | Área do produto | Teste/controlo | Aprovação |
|
||||||
| --- | --- | --- | --- | --- | --- | --- |
|
| ----------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------- |
|
||||||
| Lei de Terras | Lei n.º 19/97, de 1 de Outubro; a reprodução consultada contém, entre outros, arts. 12–15 (aquisição, titulação, registo e prova), art. 19 (plano de exploração) e art. 24 (participação comunitária) | PDF “Lei de terra” na página normativa do PDUL, programa governamental. É reprodução útil para localizar dispositivos, ainda sem confronto página a página com o BR | Lei-base histórica identificada. Consolidação/alterações e vigência artigo a artigo por confirmar no BR e com revisão jurídica | Avisos, categorias de pedido, direitos adquiridos por ocupação e formulação de campos | Testar que ausência de título/registo não é tratada pelo portal como inexistência de direito; nenhuma inferência jurídica a partir de mapa | Pendente de confirmação por jurista fundiário |
|
| Lei de Terras | Lei n.º 19/97, de 1 de Outubro; a reprodução consultada contém, entre outros, arts. 12–15 (aquisição, titulação, registo e prova), art. 19 (plano de exploração) e art. 24 (participação comunitária) | PDF “Lei de terra” na página normativa do PDUL, programa governamental. É reprodução útil para localizar dispositivos, ainda sem confronto página a página com o BR | Lei-base histórica identificada. Consolidação/alterações e vigência artigo a artigo por confirmar no BR e com revisão jurídica | Avisos, categorias de pedido, direitos adquiridos por ocupação e formulação de campos | Testar que ausência de título/registo não é tratada pelo portal como inexistência de direito; nenhuma inferência jurídica a partir de mapa | Pendente de confirmação por jurista fundiário |
|
||||||
| Regulamento rural | Decreto n.º 66/98, de 8 de Dezembro | PDF “Regulamento da Lei de Terra” na página normativa do PDUL; reprodução governamental. Fontes secundárias consultadas indicam alterações pelos Decretos n.º 1/2003, 50/2007 e 43/2010; falta conferir os diplomas e artigos no BR | Texto-base identificado; consolidação e vigência por dispositivo pendentes | Checklist por modalidade, consulta comunitária, plano e processo rural | Não tornar campos ou scans em obrigação até completar a matriz artigo→campo→evidência | Pendente |
|
| Regulamento rural | Decreto n.º 66/98, de 8 de Dezembro | PDF “Regulamento da Lei de Terra” na página normativa do PDUL; reprodução governamental. Fontes secundárias consultadas indicam alterações pelos Decretos n.º 1/2003, 50/2007 e 43/2010; falta conferir os diplomas e artigos no BR | Texto-base identificado; consolidação e vigência por dispositivo pendentes | Checklist por modalidade, consulta comunitária, plano e processo rural | Não tornar campos ou scans em obrigação até completar a matriz artigo→campo→evidência | Pendente |
|
||||||
| Solo urbano | Decreto n.º 60/2006, de 26 de Dezembro, Regulamento do Solo Urbano | PDF ligado pela página normativa do PDUL; reprodução governamental | Identificado; relação com actos posteriores, regulamentos locais e reformas de ordenamento a validar por jurisdição | Ramificação urbana distinta; não reutilizar automaticamente procedimentos rurais | Caso de teste urbano não deve herdar checklist rural por omissão | Pendente |
|
| Solo urbano | Decreto n.º 60/2006, de 26 de Dezembro, Regulamento do Solo Urbano | PDF ligado pela página normativa do PDUL; reprodução governamental | Identificado; relação com actos posteriores, regulamentos locais e reformas de ordenamento a validar por jurisdição | Ramificação urbana distinta; não reutilizar automaticamente procedimentos rurais | Caso de teste urbano não deve herdar checklist rural por omissão | Pendente |
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
**Revisão:** 2026-10-03. Esta matriz descreve o código presente no repositório; não certifica a validade jurídica de modelos nem a aprovação da funcionalidade para submissão oficial.
|
**Revisão:** 2026-10-03. Esta matriz descreve o código presente no repositório; não certifica a validade jurídica de modelos nem a aprovação da funcionalidade para submissão oficial.
|
||||||
|
|
||||||
| Requisito do prompt | Fonte disponível/estado | Campo ou percurso | Validação/evidência | Teste/estado |
|
| Requisito do prompt | Fonte disponível/estado | Campo ou percurso | Validação/evidência | Teste/estado |
|
||||||
| --- | --- | --- | --- | --- |
|
| ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| Guia público e limites do InvestMoz | `resources/js/pages/land-assistance/guide.tsx`; não depende de requisito jurídico específico | `/terra-duat` | Aviso de que não atribui DUAT nem confirma disponibilidade ou direitos | `LandAssistanceTest`: guia público 200; coberto |
|
| Guia público e limites do InvestMoz | `resources/js/pages/land-assistance/guide.tsx`; não depende de requisito jurídico específico | `/terra-duat` | Aviso de que não atribui DUAT nem confirma disponibilidade ou direitos | `LandAssistanceTest`: guia público 200; coberto |
|
||||||
| Formulário em branco público | Modelo InvestMoz `land-assistance-v1`; scans oficiais não identificados | `/terra-duat/formulario-em-branco` | Impressão/guardar como PDF; explicitamente não oficial e não preenchível | `LandAssistanceTest`: rota pública 200; coberto como modelo imprimível |
|
| Formulário em branco público | Modelo InvestMoz `land-assistance-v1`; scans oficiais não identificados | `/terra-duat/formulario-em-branco` | Impressão/guardar como PDF; explicitamente não oficial e não preenchível | `LandAssistanceTest`: rota pública 200; coberto como modelo imprimível |
|
||||||
| Formulário progressivo, rascunho, retoma e versão | Modelo interno `land-assistance-v1` | `/investidor/terra-duat/novo`, edição e acompanhamento | Autenticação, cifra do payload, versão optimista, histórico cifrado e eventos sem conteúdo pessoal | Testes de feature cobrem criação, propriedade, concorrência e suporte; sem evidência de ensaio browser DUAT nesta revisão |
|
| Formulário progressivo, rascunho, retoma e versão | Modelo interno `land-assistance-v1` | `/investidor/terra-duat/novo`, edição e acompanhamento | Autenticação, cifra do payload, versão optimista, histórico cifrado e eventos sem conteúdo pessoal | Testes de feature cobrem criação, propriedade, concorrência e suporte; sem evidência de ensaio browser DUAT nesta revisão |
|
||||||
@@ -38,9 +38,11 @@
|
|||||||
## Adenda — contacto telefónico sem email (2026-10-03)
|
## Adenda — contacto telefónico sem email (2026-10-03)
|
||||||
|
|
||||||
A regra anterior desta matriz que marcava o email como obrigatório foi substituída no código: o pedido de apoio aceita email ou telefone. Email ausente é persistido como `NULL`, sem endereço inventado. Uma migration aditiva torna a coluna anulável; o rollback recusa-se a remover essa compatibilidade enquanto existirem pedidos só telefónicos. A conversão CRM para lead continua a exigir confirmação de email. Os testes de feature foram escritos, mas não executados porque a base isolada configurada em `127.0.0.1:55441` estava encerrada; não foi tentada ligação à porta operacional 5432.
|
A regra anterior desta matriz que marcava o email como obrigatório foi substituída no código: o pedido de apoio aceita email ou telefone. Email ausente é persistido como `NULL`, sem endereço inventado. Uma migration aditiva torna a coluna anulável; o rollback recusa-se a remover essa compatibilidade enquanto existirem pedidos só telefónicos. A conversão CRM para lead continua a exigir confirmação de email. Os testes de feature foram escritos, mas não executados porque a base isolada configurada em `127.0.0.1:55441` estava encerrada; não foi tentada ligação à porta operacional 5432.
|
||||||
|
|
||||||
### Evidência posterior — migration e percurso telefónico (2026-10-03)
|
### Evidência posterior — migration e percurso telefónico (2026-10-03)
|
||||||
|
|
||||||
A nota anterior de tentativa bloqueada foi superada numa execução posterior: a nova base PostgreSQL 17 foi criada em pasta temporária exclusiva e usada através da porta QA 55441. `LandAssistanceTest` passou 4/4 (42 asserções) e a suite PHP completa passou 251/251 (2.586 asserções); isto executou a migration aditiva em QA. O cluster foi parado. Nenhuma migration foi executada na base da aplicação e a porta 5432 não foi usada.
|
A nota anterior de tentativa bloqueada foi superada numa execução posterior: a nova base PostgreSQL 17 foi criada em pasta temporária exclusiva e usada através da porta QA 55441. `LandAssistanceTest` passou 4/4 (42 asserções) e a suite PHP completa passou 251/251 (2.586 asserções); isto executou a migration aditiva em QA. O cluster foi parado. Nenhuma migration foi executada na base da aplicação e a porta 5432 não foi usada.
|
||||||
|
|
||||||
### Actualização dos testes de reversibilidade — 2026-10-03
|
### Actualização dos testes de reversibilidade — 2026-10-03
|
||||||
|
|
||||||
`LandAssistanceTest` agora passa 6/6 (46 asserções), incluindo reversão normal da coluna para não nula quando não existem pedidos telefónicos e bloqueio do rollback quando existem. A suite PHP completa após esses testes passou 253/253 (2.590 asserções) no cluster PostgreSQL QA descartável. O cluster foi parado; nenhuma conexão de teste foi aberta na porta 5432. Nenhuma migration foi aplicada à base local ou de produção.
|
`LandAssistanceTest` agora passa 6/6 (46 asserções), incluindo reversão normal da coluna para não nula quando não existem pedidos telefónicos e bloqueio do rollback quando existem. A suite PHP completa após esses testes passou 253/253 (2.590 asserções) no cluster PostgreSQL QA descartável. O cluster foi parado; nenhuma conexão de teste foi aberta na porta 5432. Nenhuma migration foi aplicada à base local ou de produção.
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
Pasta observada: `C:\Mac\Home\Documents\TEMPO\Portal Tempo\Servicos Tempo\Scan\Terras`. A classificação abaixo deriva apenas do nome da subpasta, não da leitura do conteúdo. Os PDFs não apresentam camada de texto detectável nesta verificação; OCR e conferência página a página continuam pendentes. Não foram copiados para `public/` nem usados para criar requisitos automáticos.
|
Pasta observada: `C:\Mac\Home\Documents\TEMPO\Portal Tempo\Servicos Tempo\Scan\Terras`. A classificação abaixo deriva apenas do nome da subpasta, não da leitura do conteúdo. Os PDFs não apresentam camada de texto detectável nesta verificação; OCR e conferência página a página continuam pendentes. Não foram copiados para `public/` nem usados para criar requisitos automáticos.
|
||||||
|
|
||||||
| Categoria provisória | Ficheiro original | Bytes | SHA-256 | Tratamento |
|
| Categoria provisória | Ficheiro original | Bytes | SHA-256 | Tratamento |
|
||||||
| --- | --- | ---: | --- | --- |
|
| ------------------------------ | ------------------------- | -----: | ------------------------------------------------------------------ | ---------------------------------------------- |
|
||||||
| Consulta comunitária/pareceres | `Consulta/scan0001.pdf` | 140871 | `3C1143FD565D92403E0C175ADFBEA293AFC3F187FD6A201BA26E1D45A998D2CA` | Referência reservada; conteúdo por OCR/revisão |
|
| Consulta comunitária/pareceres | `Consulta/scan0001.pdf` | 140871 | `3C1143FD565D92403E0C175ADFBEA293AFC3F187FD6A201BA26E1D45A998D2CA` | Referência reservada; conteúdo por OCR/revisão |
|
||||||
| Consulta comunitária/pareceres | `Consulta/scan0002.pdf` | 88860 | `B6A0CCAC07EEF71294089DDE653F6ED3E600196B75836D69C0E99687E199D6CC` | Referência reservada; conteúdo por OCR/revisão |
|
| Consulta comunitária/pareceres | `Consulta/scan0002.pdf` | 88860 | `B6A0CCAC07EEF71294089DDE653F6ED3E600196B75836D69C0E99687E199D6CC` | Referência reservada; conteúdo por OCR/revisão |
|
||||||
| Consulta comunitária/pareceres | `Consulta/scan.pdf` | 174964 | `732FF341BBD4C0C05E8ACCDB6919FA6151D18E50E0C3ED0CD618A4FD69B9018F` | Referência reservada; conteúdo por OCR/revisão |
|
| Consulta comunitária/pareceres | `Consulta/scan.pdf` | 174964 | `732FF341BBD4C0C05E8ACCDB6919FA6151D18E50E0C3ED0CD618A4FD69B9018F` | Referência reservada; conteúdo por OCR/revisão |
|
||||||
@@ -19,7 +19,7 @@ Também foi localizado `C:\Mac\Home\Documents\TEMPO\Portal Tempo\Servicos Tempo\
|
|||||||
### Fontes normativas digitais localizadas em 2026-10-03
|
### Fontes normativas digitais localizadas em 2026-10-03
|
||||||
|
|
||||||
| Material | Fonte e natureza | Uso permitido nesta fase | Estado |
|
| Material | Fonte e natureza | Uso permitido nesta fase | Estado |
|
||||||
| --- | --- | --- | --- |
|
| ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| Lei n.º 19/97, de 1 de Outubro | [PDUL — Documentos Normativos](https://www.pdul.gov.mz/Anuncios/Documentos-Normativos), ligação “Lei de terra” para PDF; compilação alojada num programa governamental, reprodução digital do diploma | Identificar estrutura/artigos para revisão; não substituir conferência com o Boletim da República | Texto pesquisável obtido; cópia do BR e reconciliação de alterações ainda pendentes |
|
| Lei n.º 19/97, de 1 de Outubro | [PDUL — Documentos Normativos](https://www.pdul.gov.mz/Anuncios/Documentos-Normativos), ligação “Lei de terra” para PDF; compilação alojada num programa governamental, reprodução digital do diploma | Identificar estrutura/artigos para revisão; não substituir conferência com o Boletim da República | Texto pesquisável obtido; cópia do BR e reconciliação de alterações ainda pendentes |
|
||||||
| Decreto n.º 66/98, de 8 de Dezembro | Mesma página PDUL, ligação “Regulamento da Lei de Terra” | Referência de trabalho para revisão do regulamento | Texto digital localizado; verificar alterações em conjunto (Decretos n.º 1/2003, 50/2007 e 43/2010 mencionados nas fontes consultadas) |
|
| Decreto n.º 66/98, de 8 de Dezembro | Mesma página PDUL, ligação “Regulamento da Lei de Terra” | Referência de trabalho para revisão do regulamento | Texto digital localizado; verificar alterações em conjunto (Decretos n.º 1/2003, 50/2007 e 43/2010 mencionados nas fontes consultadas) |
|
||||||
| Decreto n.º 60/2006, de 26 de Dezembro | Mesma página PDUL, ligação “Regulamento do solo urbano” | Identificar percurso urbano separado do rural | PDF localizado; texto extraído pela pesquisa não foi integralmente confrontado com o BR |
|
| Decreto n.º 60/2006, de 26 de Dezembro | Mesma página PDUL, ligação “Regulamento do solo urbano” | Identificar percurso urbano separado do rural | PDF localizado; texto extraído pela pesquisa não foi integralmente confrontado com o BR |
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ Os três ficheiros passaram pelo ClamAV 1.5.4, com assinaturas de 06/10/2026 08:
|
|||||||
## Matriz dos documentos importados
|
## Matriz dos documentos importados
|
||||||
|
|
||||||
| Documento e versão | Módulos e informação sustentada | Estado documental | Revisão/pendências |
|
| Documento e versão | Módulos e informação sustentada | Estado documental | Revisão/pendências |
|
||||||
|---|---|---|---|
|
| ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||||
| Lei n.º 22/2022, republicada no 2.º Suplemento do BR 250 | `simulator` como evidência documental; tema IVA. A revisão documental cita o art. 17(1). | Ficheiro descarregado do catálogo oficial AT e comparado byte a byte com o arquivo: 1.834.284 bytes; SHA-256 `EA1B0DC6F5CF6E595F6D9A19E7042F398999E0087CAEF1785F6E8FAC571B5F53`. Origem oficial confirmada. Situação registada como `amended`; não é apresentado como consolidação integral actual. | Direitos da composição PDF aguardam revisão administrativa; classificação privada e publicação pendente. A taxa ou regra não é activada pelo registo documental. |
|
| Lei n.º 22/2022, republicada no 2.º Suplemento do BR 250 | `simulator` como evidência documental; tema IVA. A revisão documental cita o art. 17(1). | Ficheiro descarregado do catálogo oficial AT e comparado byte a byte com o arquivo: 1.834.284 bytes; SHA-256 `EA1B0DC6F5CF6E595F6D9A19E7042F398999E0087CAEF1785F6E8FAC571B5F53`. Origem oficial confirmada. Situação registada como `amended`; não é apresentado como consolidação integral actual. | Direitos da composição PDF aguardam revisão administrativa; classificação privada e publicação pendente. A taxa ou regra não é activada pelo registo documental. |
|
||||||
| BR n.º 248/2025, Suplemento n.º 1 | `simulator` como evidência; temas ICE, aduaneiro, ISPC, IVA, IRPS e IRPC, sem afirmar uma obrigação por tema. | Ficheiro descarregado do endpoint WebDAV oficial AT e comparado byte a byte com o arquivo: 440.018 bytes; SHA-256 `CCF2A8DEECA820F2DD076B4B2141B1EFE3F6A806568C3A587CA59A8E92F4C251`. Origem oficial confirmada. Situação jurídica registada como `unknown`, pois a edição contém vários diplomas cuja vigência deve ser analisada individualmente. | Direitos da composição PDF aguardam revisão administrativa; classificação privada e publicação pendente. Os artigos e a vigência de cada lei não ficam aprovados pela associação temática. |
|
| BR n.º 248/2025, Suplemento n.º 1 | `simulator` como evidência; temas ICE, aduaneiro, ISPC, IVA, IRPS e IRPC, sem afirmar uma obrigação por tema. | Ficheiro descarregado do endpoint WebDAV oficial AT e comparado byte a byte com o arquivo: 440.018 bytes; SHA-256 `CCF2A8DEECA820F2DD076B4B2141B1EFE3F6A806568C3A587CA59A8E92F4C251`. Origem oficial confirmada. Situação jurídica registada como `unknown`, pois a edição contém vários diplomas cuja vigência deve ser analisada individualmente. | Direitos da composição PDF aguardam revisão administrativa; classificação privada e publicação pendente. Os artigos e a vigência de cada lei não ficam aprovados pela associação temática. |
|
||||||
| BR n.º 89, I Série, 08/06/2017 — aviso de rectificação da Lei n.º 13/2016 | `simulator` como evidência; tema IVA. A ficha INM identifica o aviso na p. 569. | O hash do PDF local é `11F0CAB15EB6E51010952203FFA24FDC533A24FD642E19525FE4F46B17A1F5E5` e coincide com o exemplar arquivado no repositório. A ficha oficial identifica o acto, mas os bytes locais não foram comparados com um download oficial. Origem `identified`; situação jurídica `unknown`. | Cadeia de custódia, autenticidade binária, anexos e efeito temporal por confirmar. Direitos por confirmar; classificação privada e publicação pendente. |
|
| BR n.º 89, I Série, 08/06/2017 — aviso de rectificação da Lei n.º 13/2016 | `simulator` como evidência; tema IVA. A ficha INM identifica o aviso na p. 569. | O hash do PDF local é `11F0CAB15EB6E51010952203FFA24FDC533A24FD642E19525FE4F46B17A1F5E5` e coincide com o exemplar arquivado no repositório. A ficha oficial identifica o acto, mas os bytes locais não foram comparados com um download oficial. Origem `identified`; situação jurídica `unknown`. | Cadeia de custódia, autenticidade binária, anexos e efeito temporal por confirmar. Direitos por confirmar; classificação privada e publicação pendente. |
|
||||||
@@ -25,7 +25,7 @@ As onze associações foram gravadas como evidência (`applicability=evidence`),
|
|||||||
As seis linhas de `investment_legal_sources` são referências URL, todas com `validation_status=pending`; não são binários e não foram convertidas em documentos fictícios:
|
As seis linhas de `investment_legal_sources` são referências URL, todas com `validation_status=pending`; não são binários e não foram convertidas em documentos fictícios:
|
||||||
|
|
||||||
| Referência existente | Situação nesta migração |
|
| Referência existente | Situação nesta migração |
|
||||||
|---|---|
|
| --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
|
||||||
| Beluluane Industrial Park — Free Zone; Resolução Interna do Conselho de Ministros n.º 15/99; página APIEX | URL existente; diploma/efeito actual e ficheiro integral por confirmar. |
|
| Beluluane Industrial Park — Free Zone; Resolução Interna do Conselho de Ministros n.º 15/99; página APIEX | URL existente; diploma/efeito actual e ficheiro integral por confirmar. |
|
||||||
| Conselho de Ministros — BR n.º 70, 30/08/2013; Decreto n.º 47/2013 | Página INM existente; texto integral e artigos aplicáveis por confirmar. |
|
| Conselho de Ministros — BR n.º 70, 30/08/2013; Decreto n.º 47/2013 | Página INM existente; texto integral e artigos aplicáveis por confirmar. |
|
||||||
| Manga-Mungassa Special Economic Zone; Decreto n.º 22/2012 | Página APIEX existente; diploma e efeito actual por confirmar. |
|
| Manga-Mungassa Special Economic Zone; Decreto n.º 22/2012 | Página APIEX existente; diploma e efeito actual por confirmar. |
|
||||||
|
|||||||
@@ -12,9 +12,6 @@
|
|||||||
"bilateralAgreement": true,
|
"bilateralAgreement": true,
|
||||||
"milestoneCompleted": true,
|
"milestoneCompleted": true,
|
||||||
"roomClosed": true,
|
"roomClosed": true,
|
||||||
"viewports": [
|
"viewports": [1440, 390],
|
||||||
1440,
|
|
||||||
390
|
|
||||||
],
|
|
||||||
"errors": []
|
"errors": []
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@ Não existe entrega externa configurada. Os endpoints públicos são `GET /api/v
|
|||||||
As escritas usam a sessão existente, CSRF e autorização por recurso. Os contratos das rotas estão em `routes/partnerships.php`. Alterações enviam `version`; uma versão desatualizada resulta em 409. Criação de rascunho e mensagens usam `client_key` UUID: repetir a mesma operação devolve o resultado existente; reutilizar a chave com outro conteúdo resulta em 409.
|
As escritas usam a sessão existente, CSRF e autorização por recurso. Os contratos das rotas estão em `routes/partnerships.php`. Alterações enviam `version`; uma versão desatualizada resulta em 409. Criação de rascunho e mensagens usam `client_key` UUID: repetir a mesma operação devolve o resultado existente; reutilizar a chave com outro conteúdo resulta em 409.
|
||||||
|
|
||||||
| Agregado | Estados persistidos | Separação |
|
| Agregado | Estados persistidos | Separação |
|
||||||
| --- | --- | --- |
|
| ----------- | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| Publicação | draft, submitted, returned, rejected, published, suspended, archived; pending legado | Renovar recupera o rascunho e exige nova submissão. Editar uma proposta publicada não publica a alteração automaticamente. |
|
| Publicação | draft, submitted, returned, rejected, published, suspended, archived; pending legado | Renovar recupera o rascunho e exige nova submissão. Editar uma proposta publicada não publica a alteração automaticamente. |
|
||||||
| Candidatura | submitted, clarification, shortlisted, rejected, withdrawn, negotiation | Negociação de um candidato não encerra outros. A retirada pertence ao candidato; avaliação e decisão ao titular da proposta. |
|
| Candidatura | submitted, clarification, shortlisted, rejected, withdrawn, negotiation | Negociação de um candidato não encerra outros. A retirada pertence ao candidato; avaliação e decisão ao titular da proposta. |
|
||||||
| Sala/acordo | negotiation, agreement_recorded, agreed, execution, closed, cancelled | Registo de termos não confirma as partes. Só a confirmação de ambas permite acompanhar a execução. Encerramento exige os marcos concluídos. Renovação devolve a negociação sem apagar o histórico dos termos. |
|
| Sala/acordo | negotiation, agreement_recorded, agreed, execution, closed, cancelled | Registo de termos não confirma as partes. Só a confirmação de ambas permite acompanhar a execução. Encerramento exige os marcos concluídos. Renovação devolve a negociação sem apagar o histórico dos termos. |
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
Especificação: «Bolsas de pareceria Bolsa de Parcerias.docx», versão 1.0, 7 outubro 2026, no acervo de Relatórios. Original, hash e inventário permanecem privados em `storage/app/private/partnership-exchange/`. As instruções do responsável prevalecem sobre as dependências externas e a exigência geral de organização verificada do documento.
|
Especificação: «Bolsas de pareceria Bolsa de Parcerias.docx», versão 1.0, 7 outubro 2026, no acervo de Relatórios. Original, hash e inventário permanecem privados em `storage/app/private/partnership-exchange/`. As instruções do responsável prevalecem sobre as dependências externas e a exigência geral de organização verificada do documento.
|
||||||
|
|
||||||
| Requisito | Existente | Alteração necessária | Verificação |
|
| Requisito | Existente | Alteração necessária | Verificação |
|
||||||
| --- | --- | --- | --- |
|
| ---------------------------- | ------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- |
|
||||||
| Identidade e representação | users, organizations, memberships | Reutilizar sessão; escrita pela conta titular ou representante autorizado; rascunho pessoal permitido | Conta alheia, organizações e papéis |
|
| Identidade e representação | users, organizations, memberships | Reutilizar sessão; escrita pela conta titular ou representante autorizado; rascunho pessoal permitido | Conta alheia, organizações e papéis |
|
||||||
| Catálogo e propostas antigas | /parcerias, portal_partnerships, moderação | Estender os registos, manter IDs/autores/estados; pesquisa, detalhe, tipos e filtros | Preservação e paginação |
|
| Catálogo e propostas antigas | /parcerias, portal_partnerships, moderação | Estender os registos, manter IDs/autores/estados; pesquisa, detalhe, tipos e filtros | Preservação e paginação |
|
||||||
| Dados mestres e origens | opportunities, dossiers, projects, economic_clusters, investment_zones, declarações empresariais | Referências por ID; entradas e ligações nos dois sentidos | Origem pública/privada e identidade |
|
| Dados mestres e origens | opportunities, dossiers, projects, economic_clusters, investment_zones, declarações empresariais | Referências por ID; entradas e ligações nos dois sentidos | Origem pública/privada e identidade |
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Data da análise: 2026-10-03. **Este documento é um inventário estrutural e de
|
|||||||
## Proveniência
|
## Proveniência
|
||||||
|
|
||||||
| Campo | Registo |
|
| Campo | Registo |
|
||||||
| --- | --- |
|
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| Ficheiro | `C:\Mac\Home\Documents\TEMPO\Portal Tempo\Servicos Tempo\portal do investidor\MPD_Relatório Final do PII 26-30_2111.docx` |
|
| Ficheiro | `C:\Mac\Home\Documents\TEMPO\Portal Tempo\Servicos Tempo\portal do investidor\MPD_Relatório Final do PII 26-30_2111.docx` |
|
||||||
| Tamanho / data local | 5.456.742 bytes; 2026-09-08 14:34 (metadata do filesystem) |
|
| Tamanho / data local | 5.456.742 bytes; 2026-09-08 14:34 (metadata do filesystem) |
|
||||||
| SHA-256 | `BCBF8EC976100CC5E978AEF54050C3E3E9D959B0D361FA80A788528A8E5049A6` |
|
| SHA-256 | `BCBF8EC976100CC5E978AEF54050C3E3E9D959B0D361FA80A788528A8E5049A6` |
|
||||||
@@ -15,7 +15,7 @@ Data da análise: 2026-10-03. **Este documento é um inventário estrutural e de
|
|||||||
## Inventário e qualidade estrutural
|
## Inventário e qualidade estrutural
|
||||||
|
|
||||||
| Observação | Resultado verificável | Implicação |
|
| Observação | Resultado verificável | Implicação |
|
||||||
| --- | --- | --- |
|
| ------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| Estrutura integral do corpo | 2.520 parágrafos, 30 tabelas e 353 linhas no total. | O ficheiro contém contexto programático além das tabelas de projectos; não importar o DOCX como se fosse uma única tabela. |
|
| Estrutura integral do corpo | 2.520 parágrafos, 30 tabelas e 353 linhas no total. | O ficheiro contém contexto programático além das tabelas de projectos; não importar o DOCX como se fosse uma única tabela. |
|
||||||
| Tabelas com projectos/custos | Tabelas 11–13, 15–21 e 23–25 (13 tabelas), 174 linhas preenchidas. | Cada linha continua a ser uma proposta/estimativa do plano; não se converte automaticamente em anúncio público. |
|
| Tabelas com projectos/custos | Tabelas 11–13, 15–21 e 23–25 (13 tabelas), 174 linhas preenchidas. | Cada linha continua a ser uma proposta/estimativa do plano; não se converte automaticamente em anúncio público. |
|
||||||
| Campos tabulares centrais | Nas 174 linhas, os campos de identificação/nome, localização, custo e horizonte estão preenchidos nas respectivas colunas. | Preenchimento tabular não confirma a exactidão, actualidade nem granularidade geográfica do conteúdo. |
|
| Campos tabulares centrais | Nas 174 linhas, os campos de identificação/nome, localização, custo e horizonte estão preenchidos nas respectivas colunas. | Preenchimento tabular não confirma a exactidão, actualidade nem granularidade geográfica do conteúdo. |
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ Escopo: observar o percurso existente e a continuidade do dossier. O código já
|
|||||||
## Folha de observação (sem PII)
|
## Folha de observação (sem PII)
|
||||||
|
|
||||||
| Sessão | Dispositivo/browser | Tarefa | Resultado (concluída/parou) | Dificuldade ou interpretação | Sugestão literal, sem identificadores | Severidade (bloqueia/atrapalha/menor) |
|
| Sessão | Dispositivo/browser | Tarefa | Resultado (concluída/parou) | Dificuldade ou interpretação | Sugestão literal, sem identificadores | Severidade (bloqueia/atrapalha/menor) |
|
||||||
|---|---|---|---|---|---|---|
|
| ------ | ------------------- | ------ | --------------------------- | ---------------------------- | ------------------------------------- | ------------------------------------- |
|
||||||
| | | | | | | |
|
| | | | | | | |
|
||||||
|
|
||||||
Em cada tarefa, observar primeiro sem ajudar. Registar conclusão autónoma, tempo aproximado, pedidos de ajuda, validações compreendidas à primeira, sucesso de recuperação e duplicações percebidas. Perguntar ao participante o que faria a seguir com o resultado e que dados considera declarados, estimados ou verificados. Não guardar respostas do formulário junto das notas de pesquisa.
|
Em cada tarefa, observar primeiro sem ajudar. Registar conclusão autónoma, tempo aproximado, pedidos de ajuda, validações compreendidas à primeira, sucesso de recuperação e duplicações percebidas. Perguntar ao participante o que faria a seguir com o resultado e que dados considera declarados, estimados ou verificados. Não guardar respostas do formulário junto das notas de pesquisa.
|
||||||
|
|||||||
@@ -47,5 +47,3 @@ O runner configurado em `phpunit.xml` aponta à porta `55441`, onde não havia P
|
|||||||
- Falta ensaio num dispositivo móvel físico.
|
- Falta ensaio num dispositivo móvel físico.
|
||||||
|
|
||||||
Não declarar a cobertura territorial transversal concluída. As rotas e pendências por módulo continuam descritas na [auditoria territorial anterior](../territorial-search-audit-2026-10-04.md).
|
Não declarar a cobertura territorial transversal concluída. As rotas e pendências por módulo continuam descritas na [auditoria territorial anterior](../territorial-search-audit-2026-10-04.md).
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,9 +21,7 @@
|
|||||||
"Unidade de processamento agrícola em Nampula"
|
"Unidade de processamento agrícola em Nampula"
|
||||||
],
|
],
|
||||||
"serverApiMatchesVisibleResults": true,
|
"serverApiMatchesVisibleResults": true,
|
||||||
"mapStatus": [
|
"mapStatus": ["0 investimentos com coordenadas disponíveis."],
|
||||||
"0 investimentos com coordenadas disponíveis."
|
|
||||||
],
|
|
||||||
"mobile": {
|
"mobile": {
|
||||||
"innerWidth": 390,
|
"innerWidth": 390,
|
||||||
"scrollWidth": 390,
|
"scrollWidth": 390,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Implementação local de 27/09/2026, seguindo as sete áreas pedidas pelo propri
|
|||||||
## Páginas e percursos
|
## Páginas e percursos
|
||||||
|
|
||||||
| Área | Caminho e comportamento |
|
| Área | Caminho e comportamento |
|
||||||
| --- | --- |
|
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| Página inicial | `/`: cabeçalho, banner, sectores activos, Como Investir, oportunidades em destaque, documentos essenciais publicados, apoio e rodapé. |
|
| Página inicial | `/`: cabeçalho, banner, sectores activos, Como Investir, oportunidades em destaque, documentos essenciais publicados, apoio e rodapé. |
|
||||||
| Oportunidades | `/oportunidades`: pesquisa, sector, província, estado de preparação/maturidade e dimensão por montante mínimo/máximo e moeda. Valores em moedas diferentes nunca são somados ou comparados automaticamente. Só aparecem oportunidades publicadas. |
|
| Oportunidades | `/oportunidades`: pesquisa, sector, província, estado de preparação/maturidade e dimensão por montante mínimo/máximo e moeda. Valores em moedas diferentes nunca são somados ou comparados automaticamente. Só aparecem oportunidades publicadas. |
|
||||||
| Ficha de oportunidade | `/oportunidades/{slug}`: ficha e manifestação de interesse existentes. |
|
| Ficha de oportunidade | `/oportunidades/{slug}`: ficha e manifestação de interesse existentes. |
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ O total inclui schemas legados e tabelas de extensões. Não significa 237 entid
|
|||||||
As decisões abaixo seleccionam objectos reais. «Estender» não significa que a alteração já foi aplicada. Nenhuma equivalência parcial é declarada cobertura integral.
|
As decisões abaixo seleccionam objectos reais. «Estender» não significa que a alteração já foi aplicada. Nenhuma equivalência parcial é declarada cobertura integral.
|
||||||
|
|
||||||
| Conceito proposto | Objecto existente / evidência no repositório | Cobertura e lacunas | Decisão técnica |
|
| Conceito proposto | Objecto existente / evidência no repositório | Cobertura e lacunas | Decisão técnica |
|
||||||
|---|---|---|---|
|
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| Fontes / data_sources | `public.geo_sources` (migration territorial_registry); `public.investment_legal_sources` (investment_zone_foundation); `public.ai_sources`; `investmoz.fontes_dados`; `mne.source_records` | Há cinco mecanismos especializados, com identidades, validações e consumidores diferentes. A fonte jurídica não é automaticamente autorização para IA nem proveniência cartográfica. Não existe correspondência transversal comprovada. | Mapear por compatibilidade, preservando tipo e schema na identidade. Não criar `data_sources` nem fundir registos por URL apenas. A definição do adaptador e da referência transversal ainda falta. |
|
| Fontes / data_sources | `public.geo_sources` (migration territorial_registry); `public.investment_legal_sources` (investment_zone_foundation); `public.ai_sources`; `investmoz.fontes_dados`; `mne.source_records` | Há cinco mecanismos especializados, com identidades, validações e consumidores diferentes. A fonte jurídica não é automaticamente autorização para IA nem proveniência cartográfica. Não existe correspondência transversal comprovada. | Mapear por compatibilidade, preservando tipo e schema na identidade. Não criar `data_sources` nem fundir registos por URL apenas. A definição do adaptador e da referência transversal ainda falta. |
|
||||||
| Diplomas / legal_instruments | `public.investment_legal_sources`; modelo InvestmentLegalSource; serviço InvestmentZones | Diploma, artigo, entidade competente, URL, vigência, versão, proprietário e revisor já existem. Tipo, número estruturado e publicação não têm colunas próprias. | Estender este mestre com os campos efectivamente necessários; não duplicar diplomas em legal_instruments. Documentos legais do portal conservam a referência ao ficheiro. |
|
| Diplomas / legal_instruments | `public.investment_legal_sources`; modelo InvestmentLegalSource; serviço InvestmentZones | Diploma, artigo, entidade competente, URL, vigência, versão, proprietário e revisor já existem. Tipo, número estruturado e publicação não têm colunas próprias. | Estender este mestre com os campos efectivamente necessários; não duplicar diplomas em legal_instruments. Documentos legais do portal conservam a referência ao ficheiro. |
|
||||||
| Organizações / organisations | `public.organizations`, `memberships`; migration investmoz_identity; `mne.organizations` separado | Mestre público UUID; pertenças existentes. MNE não está integrado como autoridade. Tax identifier, contactos e site não devem ser copiados silenciosamente entre módulos. | Reutilizar public.organizations; mapear MNE apenas por vínculo comprovado. Preservar IDs e contas bigint. |
|
| Organizações / organisations | `public.organizations`, `memberships`; migration investmoz_identity; `mne.organizations` separado | Mestre público UUID; pertenças existentes. MNE não está integrado como autoridade. Tax identifier, contactos e site não devem ser copiados silenciosamente entre módulos. | Reutilizar public.organizations; mapear MNE apenas por vínculo comprovado. Preservar IDs e contas bigint. |
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user