feat(irpc): map short periods and foreign currency plans with explicit simulation evidence
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?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 IrpcNormalPeriodFxDraftTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
public function test_period_and_currency_source_evidence_recover_with_original_plan_and_histories():void
|
||||
{
|
||||
$db=DB::selectOne('select current_database() as name,inet_server_port() as port');$this->assertSame('simulator_fiscal_delta_20261021_test',$db->name);$this->assertSame(55441,(int)$db->port);
|
||||
config(['investor-path.enabled'=>true,'suitecrm.enabled'=>false]);$this->actingAs(User::factory()->create(['email_verified_at'=>now()]));$id=null;$etag=null;
|
||||
foreach(['short','fx','missing','loss']as$case){
|
||||
$d=json_decode(file_get_contents(base_path('outputs/irpc-l6-periods-fx/'.$case.'.json')),true,flags:JSON_THROW_ON_ERROR);$personal=['person_type'=>$d['person_type']];unset($d['person_type']);
|
||||
if($id===null)$id=$this->postJson('/api/v1/simulation-drafts',['personal_snapshot'=>$personal,'economic_snapshot'=>$d],['Idempotency-Key'=>(string)Str::uuid()])->assertCreated()->json('data.id');else$this->putJson('/api/v1/simulation-drafts/'.$id,['personal_snapshot'=>$personal,'economic_snapshot'=>$d],['If-Match'=>$etag])->assertOk();
|
||||
$r=$this->getJson('/api/v1/simulation-drafts/'.$id)->assertOk();$etag=$r->headers->get('ETag');$back=$r->json('data.economic_snapshot');$this->assertSame($d['business_plan_snapshot'],$back['business_plan_snapshot']);$this->assertSame($d['modelo_a_snapshot'],$back['modelo_a_snapshot']);
|
||||
$s=json_decode($back['modelo_a_snapshot'],true,flags:JSON_THROW_ON_ERROR);$b=$s['irpcNormal'][$d['context_opportunity']];$m=$b['result']['model'];$this->assertSame('IRPC-normal-adjustments/8',$m['version']);$this->assertSame($b['periodsFx'],$m['periodsFx']['input']);$this->assertContains('IRPC-normal-adjustments/7',array_column(array_column($b['history'],'model'),'version'));$this->assertArrayHasKey('irpcWithholdings',$s);$this->assertNull($m['assessment']['finalBalance']['payable']);$this->assertNull($m['tax']);
|
||||
if($case==='short'||$case==='fx'){$this->assertSame($case==='short'?'3130':'200320',$m['taxableProfit']['numerator']);$this->assertSame($m['taxableProfit'],$m['taxableBase']);$this->assertSame(['numerator'=>$case==='short'?'5008':'320512','denominator'=>'5'],$m['colecta']);$this->assertSame(6,$m['periodsFx']['months']);$this->assertSame([],$m['periodsFx']['pending']);}
|
||||
else{$this->assertNull($m['colecta']);if($case==='loss'){$this->assertSame('3130',$m['taxableProfit']['numerator']);$this->assertNull($m['taxableBase']);}else{$this->assertNull($m['accountingProfit']);$this->assertNotEmpty($m['periodsFx']['pending']);}}
|
||||
file_put_contents(base_path('outputs/irpc-l6-periods-fx/recovered-'.$case.'.json'),json_encode($back,JSON_THROW_ON_ERROR|JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user