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:
@@ -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) {
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { serializeBusinessPlanSnapshot } from '../../resources/js/lib/business-financial-plan.ts';
|
||||
import { ivaTreatmentForCae } from '../../resources/js/lib/iva-activity.ts';
|
||||
import {
|
||||
monthlyIvaInput,
|
||||
monthlyIvaKey,
|
||||
monthlyIvaTreatment,
|
||||
} from '../../resources/js/lib/monthly-iva.ts';
|
||||
|
||||
const settings = { start: '2026-01', basis: 'net', declared: true, auto: true };
|
||||
function draftWith(cae) {
|
||||
const zero = Object.fromEntries(
|
||||
[
|
||||
'openingCash',
|
||||
'monthlyCollections',
|
||||
'monthlyVariableCostPayments',
|
||||
'monthlyInventoryPurchases',
|
||||
'monthlyOperatingExpenses',
|
||||
'monthlyOperatingPayments',
|
||||
'monthlyPayrollExpense',
|
||||
'monthlyPayrollPayments',
|
||||
'assetInvestment',
|
||||
'inventory',
|
||||
'receivables',
|
||||
'payables',
|
||||
'equity',
|
||||
'shareholderLoans',
|
||||
'bankLoanProceeds',
|
||||
'grants',
|
||||
'assetDepreciation',
|
||||
'monthlyInterestExpense',
|
||||
'monthlyInterestPayment',
|
||||
'monthlyPrincipalRepayment',
|
||||
].map((key) => [key, '0']),
|
||||
);
|
||||
return {
|
||||
currency: 'MZN',
|
||||
business_plan_snapshot: serializeBusinessPlanSnapshot({
|
||||
...zero,
|
||||
currency: 'MZN',
|
||||
periods: 2,
|
||||
depreciationLifeMonths: 60,
|
||||
products: [
|
||||
{
|
||||
label: 'Serviço',
|
||||
monthlyUnits: '10',
|
||||
unitPrice: '1000',
|
||||
unitVariableCost: '0',
|
||||
},
|
||||
],
|
||||
...(cae
|
||||
? {
|
||||
economicClassification: {
|
||||
code: cae,
|
||||
revision: 'CAE-Rev.2',
|
||||
sourceSha256:
|
||||
'cb3dee56db5b2c3f12e3071615725051828a9e1eba17662aa5e78d5f3356b0fc',
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
test('IVA follows the activity: health and education at 5% (artigo 17-A), everything else at 16%', () => {
|
||||
assert.equal(ivaTreatmentForCae('86201').rate, 5);
|
||||
assert.match(ivaTreatmentForCae('86201').article, /17-A\(a\)/);
|
||||
assert.equal(ivaTreatmentForCae('85300').rate, 5);
|
||||
assert.match(ivaTreatmentForCae('85300').article, /17-A\(b\)/);
|
||||
assert.match(ivaTreatmentForCae('85492').article, /17-A\(c\)/);
|
||||
assert.ok(
|
||||
ivaTreatmentForCae('85300').conditions.some((c) =>
|
||||
/reconhecido/.test(c),
|
||||
),
|
||||
);
|
||||
for (const code of ['55111', '01111', '85410'])
|
||||
assert.equal(ivaTreatmentForCae(code).rate, 16, code);
|
||||
assert.equal(ivaTreatmentForCae(undefined).fromActivity, false);
|
||||
assert.equal(ivaTreatmentForCae('55111').fromActivity, true);
|
||||
});
|
||||
|
||||
test('the monthly IVA asks the server for the reduced version only for a 17-A activity, and earlier hotel results stay current', () => {
|
||||
const clinic = monthlyIvaInput(draftWith('86201'), settings);
|
||||
assert.equal(clinic.operation, 'internal_reduced_17a_net');
|
||||
assert.equal(monthlyIvaTreatment(draftWith('86201')).rate, 5);
|
||||
const hotel = monthlyIvaInput(draftWith('55111'), settings);
|
||||
assert.equal('operation' in hotel, false);
|
||||
const unclassified = monthlyIvaInput(draftWith(null), settings);
|
||||
assert.equal(monthlyIvaKey(hotel), monthlyIvaKey(unclassified));
|
||||
assert.notEqual(
|
||||
monthlyIvaKey(clinic),
|
||||
monthlyIvaKey(hotel),
|
||||
'a change of activity makes the earlier result stale',
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user