27 lines
3.1 KiB
PHP
27 lines
3.1 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 IvaBeverageRestitutionDraftTest extends TestCase
|
|
{
|
|
use DatabaseTransactions;
|
|
public function test_beverage_restitution_recovers_invoice_classification_exclusive_route_decision_receipt_and_all_previous_maps(): 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('outputs/iva-l3-e-20261025/calculated.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']);
|
|
$s=json_decode($recovered['modelo_a_snapshot'],true,flags:JSON_THROW_ON_ERROR);$b=$s['ivaBeverageRestitutions']['opportunity:375'];$this->assertCount(1,$b['rows']);$this->assertCount(1,$b['history']);$r=$b['result']['rows'][0];$this->assertSame('determined',$r['status']);
|
|
foreach(['requested'=>'16','approved'=>'12','received'=>'7','awaitingReceipt'=>'5','notGranted'=>'4']as $f=>$v)$this->assertSame(['numerator'=>$v,'denominator'=>'1'],$r[$f]);
|
|
$i=$b['result']['inputs'][0];$this->assertSame('SYNTHETIC QA facturaBE1',$i['source']['documentRef']);$this->assertSame('1-bebidas',$i['source']['documentLine']);$this->assertSame('beverage-supply',$i['source']['operationId']);$this->assertSame('yes',$i['exclusive']);$this->assertSame('SYNTHETIC QA decisãoBE1',$i['decisionReference']);
|
|
$this->assertSame('0.00',$s['books']['opportunity:375']['result']['rows'][0]['deductible']);$this->assertSame('refund',$s['books']['opportunity:375']['rows'][0]['bc']['beveragePath']);
|
|
foreach(['iva-l3e-preserved','iva-l3ab-preserved']as $fixture){$accepted=json_decode(file_get_contents(base_path('tests/frontend/fixtures/'.$fixture.'.json')),true,flags:JSON_THROW_ON_ERROR);foreach(json_decode($accepted['modelo_a_snapshot'],true,flags:JSON_THROW_ON_ERROR)as $key=>$map){if($key==='version')continue;foreach($map as $context=>$original)$this->assertSame($original,$s[$key][$context]);}}
|
|
$this->assertSame(['numerator'=>'72','denominator'=>'1'],$s['ivaClosures']['opportunity:373']['result']['rows'][2]['fields']['24']);$this->assertSame(['numerator'=>'450000','denominator'=>'1'],$s['ivaRefunds']['opportunity:374']['result']['rows'][0]['received']);
|
|
file_put_contents(base_path('outputs/iva-l3-e-20261025/recovered.json'),json_encode($recovered,JSON_THROW_ON_ERROR|JSON_UNESCAPED_UNICODE));
|
|
}
|
|
}
|