IVA pela actividade: 5% do artigo 17-A para saúde e ensino, 16% para as restantes

Decisão do proprietário de 04/12/2026: o investidor não escolhe a taxa de
IVA; ela decorre da actividade (CAE) do plano. Saúde privada (CAE 86),
ensino privado reconhecido e formação profissional usam a taxa reduzida do
artigo 17-A da Lei 22/2022; as restantes actividades usam a taxa geral.
O IVA mensal das vendas mostra a taxa, a base legal e as condições da lei
para o investidor confirmar.

A taxa reduzida é uma versão governada própria
(IVA-REDUZIDA-17A-BASE-LIQUIDA), com ficha em database/qa, registo QA por
fiscal:qa-register-iva --reduced, pré-visualização QA e ligação por
INVESTMOZ_IVA_REDUCED_RULE_ID/VERSION. Enquanto não estiver publicada, o
IVA das actividades a 5% fica por determinar e nunca usa a taxa geral em
substituição. Os resultados anteriores à taxa geral continuam actuais.

Decisões e pendências da sessão registadas no manual existente.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzJmxFy3izprXr5dSq91jM
This commit is contained in:
Claude
2026-12-05 05:50:56 +02:00
committed by nala
parent 66316f0902
commit 2b9b6c367d
12 changed files with 379 additions and 37 deletions
@@ -28,6 +28,9 @@ class SimulationPublishedFiscalTest extends TestCase
private InvestmentLegalSource $source;
/** @var array<string, User> */
private array $actors = [];
protected function setUp(): void
{
parent::setUp();
@@ -39,6 +42,7 @@ class SimulationPublishedFiscalTest extends TestCase
config(['simulation-tax-governance.'.$role => [$actors[$role]->email]]);
}
$this->publisher = $actors['publishers'];
$this->actors = $actors;
$this->source = InvestmentLegalSource::create([
'title' => 'Synthetic QA fixture, not a homologation publication', 'url' => 'https://www.inm.gov.mz/',
'diploma' => 'Lei 22/2022', 'article' => 'Artigo 17(1)', 'competent_entity' => 'Assembleia da República',
@@ -114,6 +118,35 @@ class SimulationPublishedFiscalTest extends TestCase
self::assertSame(2, Simulation::where('owner_user_id', $this->consumer->id)->count());
}
public function test_reduced_rate_of_article_17a_is_its_own_published_version_and_never_borrows_the_general_rate(): void
{
// Owner decision 04/12/2026: IVA follows the activity; health and education at 5% (Lei 22/2022, artigo 17-A).
$input = $this->monthlyInput(['operation' => 'internal_reduced_17a_net']);
$this->actingAs($this->consumer)->postJson('/api/v1/simulations', $input, ['Idempotency-Key' => (string) Str::uuid()])->assertStatus(503);
$this->getJson('/api/v1/fiscal-consumer')->assertOk()->assertJsonPath('data.reduced_enabled', false);
$source = InvestmentLegalSource::create([...collect($this->source->getAttributes())->only(['title', 'url', 'diploma', 'competent_entity', 'valid_from', 'valid_until', 'validation_status', 'owner_id', 'version_no', 'validator_id', 'validated_at'])->all(), 'article' => 'Artigo 17-A']);
$data = json_decode(file_get_contents(database_path('qa/iva-reduced-17a-net-v1.json')), true, flags: JSON_THROW_ON_ERROR);
$data['legal_source_id'] = $source->id;
$gov = app(SimulationTaxRuleGovernance::class);
$rule = $gov->create($this->actors['editors'], $data);
foreach (['submit' => 'editors', 'review' => 'reviewers', 'approve' => 'approvers', 'publish' => 'publishers'] as $action => $role) {
$rule = $gov->transition($this->actors[$role], $rule->id, $rule->version_no, $action, 'Synthetic isolated QA fixture for the reduced rate consumer.');
}
config(['simulation-fiscal-consumer.reduced_rule_id' => $rule->id, 'simulation-fiscal-consumer.reduced_rule_version' => 1]);
$this->getJson('/api/v1/fiscal-consumer')->assertOk()->assertJsonPath('data.reduced_enabled', true);
$id = $this->postJson('/api/v1/simulations', $input, ['Idempotency-Key' => (string) Str::uuid()])->assertAccepted()->json('data.id');
$rows = $this->finish($id)->result_snapshot['monthly_projection']['rows'];
self::assertSame('5', $rows[0]['rate']);
self::assertSame('50.0015', $rows[0]['vat']);
self::assertSame($rule->id, $rows[0]['rule_id']);
$general = $this->postJson('/api/v1/simulations', $this->monthlyInput(), ['Idempotency-Key' => (string) Str::uuid()])->assertAccepted()->json('data.id');
self::assertSame('16', $this->finish($general)->result_snapshot['monthly_projection']['rows'][0]['rate']);
$this->postJson('/api/v1/simulations', $this->monthlyInput(['operation' => 'internal_reduced_other']), ['Idempotency-Key' => (string) Str::uuid()])->assertUnprocessable();
}
public function test_monthly_gross_unknown_scope_and_server_rate_protection_do_not_invent_net_sales(): void
{
foreach (['included', 'unknown'] as $basis) {