24 lines
2.6 KiB
PHP
24 lines
2.6 KiB
PHP
<?php
|
||
namespace Tests\Feature;
|
||
use App\Models\User;
|
||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||
use Illuminate\Support\Facades\DB;
|
||
use Illuminate\Support\Str;
|
||
use Tests\TestCase;
|
||
final class IvaMinerDraftTest extends TestCase
|
||
{
|
||
use DatabaseTransactions;
|
||
public function test_miner_imports_recover_with_P046_and_all_accepted_books_untouched(): void
|
||
{
|
||
$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()]));
|
||
$draft=json_decode(file_get_contents(base_path('tests/frontend/fixtures/iva-miners.json')),true,flags:JSON_THROW_ON_ERROR);
|
||
$id=$this->postJson('/api/v1/simulation-drafts',['personal_snapshot'=>[],'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']);$this->assertSame('opportunity:362',$recovered['context_opportunity']);$s=json_decode($recovered['modelo_a_snapshot'],true,flags:JSON_THROW_ON_ERROR);$b=$s['minerImports']['opportunity:362'];$this->assertCount(9,$b['rows']);$this->assertCount(1,$b['history']);$this->assertSame($b['rows'],$b['result']['inputs']);
|
||
foreach($b['result']['rows'] as $row){$this->assertContains($row['status'],['exempt','reduced']);$this->assertNull($row['deduction']);$this->assertStringContainsString('arts1–4PDF1',$row['source']);}
|
||
$this->assertSame('80.061728',$b['result']['rows'][7]['importVat']);$this->assertSame('exempt',$b['result']['rows'][8]['status']);
|
||
$frozen=json_decode(file_get_contents(base_path('tests/frontend/fixtures/iva-miners-preserved.json')),true,flags:JSON_THROW_ON_ERROR);$prior=json_decode($frozen['modelo_a_snapshot'],true,flags:JSON_THROW_ON_ERROR);$this->assertSame($prior,array_diff_key($s,['minerImports'=>true]));$this->assertCount(28,$s['objectiveImports']['opportunity:361']['result']['rows']);$this->assertSame('regulation_pending',$s['digitalOperations']['opportunity:359']['result']['rows'][0]['procedure']);foreach($s['travelOperations']['opportunity:360']['result']['periods'] as $period){$this->assertNull($period['vat']);$this->assertNull($period['deduction']);}
|
||
file_put_contents(base_path('outputs/iva-l1-miners-returnees-20261025/recovered.json'),json_encode($recovered,JSON_THROW_ON_ERROR|JSON_UNESCAPED_UNICODE));
|
||
}
|
||
}
|