fix: complete InvesteMoz validation and error corrections

This commit is contained in:
2026-10-29 21:47:33 +02:00
parent 63147312e2
commit daf8623441
718 changed files with 127308 additions and 20959 deletions
+10 -9
View File
@@ -1,4 +1,5 @@
<?php
namespace Tests\Feature;
use App\Models\User;
@@ -16,29 +17,29 @@ final class IrpcReliefsDraftTest extends TestCase
$target = DB::selectOne('select current_database() as name, inet_server_port() as port');
$this->assertSame('simulator_fiscal_delta_20261021_test', $target->name);
$this->assertSame(55441, (int) $target->port);
config(['investor-path.enabled'=>true, 'suitecrm.enabled'=>false]);
$this->actingAs(User::factory()->create(['email_verified_at'=>now()]));
config(['investor-path.enabled' => true, 'suitecrm.enabled' => false]);
$this->actingAs(User::factory()->create(['email_verified_at' => now()]));
$draft = json_decode(file_get_contents(base_path('outputs/irpc-reliefs/calculated.json')), true, flags: JSON_THROW_ON_ERROR);
$personal = ['person_type'=>$draft['person_type']];
$personal = ['person_type' => $draft['person_type']];
unset($draft['person_type']);
$id = $this->postJson('/api/v1/simulation-drafts', ['personal_snapshot'=>$personal, 'economic_snapshot'=>$draft], ['Idempotency-Key'=>(string) Str::uuid()])->assertCreated()->json('data.id');
$id = $this->postJson('/api/v1/simulation-drafts', ['personal_snapshot' => $personal, 'economic_snapshot' => $draft], ['Idempotency-Key' => (string) Str::uuid()])->assertCreated()->json('data.id');
$recovered = $this->getJson('/api/v1/simulation-drafts/'.$id)->assertOk()->json('data.economic_snapshot');
$this->assertSame($draft['modelo_a_snapshot'], $recovered['modelo_a_snapshot']);
$store = json_decode($recovered['modelo_a_snapshot'], true, flags: JSON_THROW_ON_ERROR);
$book = $store['irpcWithholdings'][$draft['context_opportunity']];
[$dispensed, $rent, $treaty, $missing] = array_slice($book['result']['rows'], -4);
$this->assertSame('dispensed', $dispensed['treatment']);
$this->assertSame(['numerator'=>'0','denominator'=>'1'], $dispensed['tax']);
$this->assertSame(['numerator' => '0', 'denominator' => '1'], $dispensed['tax']);
$this->assertSame('dispensed', $rent['treatment']);
$this->assertSame('cirpc68f', $rent['reliefRule']);
$this->assertSame(['numerator'=>'0','denominator'=>'1'], $rent['tax']);
$this->assertSame(['numerator' => '0', 'denominator' => '1'], $rent['tax']);
$this->assertSame('treaty', $treaty['treatment']);
$this->assertSame(10, $treaty['rate']);
$this->assertSame(['numerator'=>'10000','denominator'=>'1'], $treaty['tax']);
$this->assertSame(['numerator' => '10000', 'denominator' => '1'], $treaty['tax']);
$this->assertSame('indeterminate', $missing['status']);
$this->assertNull($missing['tax']);
$this->assertSame('QA certificado fiscal Portugal 2026', $book['result']['inputs'][count($book['result']['inputs'])-2]['reliefPreparation']['residenceDocument']);
$this->assertSame('QA certificado fiscal Portugal 2026', $book['result']['inputs'][count($book['result']['inputs']) - 2]['reliefPreparation']['residenceDocument']);
$this->assertNotEmpty($book['history']);
file_put_contents(base_path('outputs/irpc-reliefs/recovered.json'), json_encode($recovered, JSON_THROW_ON_ERROR|JSON_UNESCAPED_UNICODE));
file_put_contents(base_path('outputs/irpc-reliefs/recovered.json'), json_encode($recovered, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE));
}
}