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 (['mapped', 'fractional', 'missing', 'unmapped', 'booktax'] as $case) { $d = json_decode(file_get_contents(base_path('outputs/irpc-l6-values-forms/'.$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']; $f = $m['formPreparation']; $fields = array_column($f['fields'], null, 'code'); $this->assertSame('IRPC-normal-adjustments/9', $m['version']); $this->assertSame($b['forms'], $f['input']); $this->assertContains('IRPC-normal-adjustments/8', array_column(array_column($b['history'], 'model'), 'version')); $this->assertArrayHasKey('irpcWithholdings', $s); $this->assertSame('3130', $m['taxableProfit']['numerator']); $this->assertSame($m['taxableProfit'], $m['taxableBase']); $this->assertSame(['numerator' => '5008', 'denominator' => '5'], $m['colecta']); $this->assertNull($m['assessment']['finalBalance']['payable']); $this->assertNull($fields['309–316']['value']); $this->assertFalse($f['transport']['ready']); $this->assertSame($m['colecta'], $fields['300']['value']); if ($case === 'missing') { $this->assertNull($f['netResult']); $this->assertNull($fields['200']['value']); $this->assertSame($m['taxableProfit'], $fields['260']['value']); } elseif ($case === 'unmapped' || $case === 'booktax') { $this->assertNull($fields['258']['value']); $this->assertNotEmpty($f['unmapped']); $this->assertFalse($f['reconciliation']['matches']); } else { $this->assertSame('3120', $f['netResult']['numerator']); $this->assertTrue($f['reconciliation']['matches']); $this->assertSame('0', $fields['213']['value']['numerator']); } if ($case === 'booktax') { $this->assertSame('2800', $f['netResult']['numerator']); $this->assertSame('0', $fields['213']['value']['numerator']); } if ($case === 'fractional') { $parts = array_column($f['m20'], null, 'account'); $this->assertSame(['numerator' => '601', 'denominator' => '2'], $parts['6.3']['value']); $this->assertFalse($parts['6.3']['representation']['ready']); $this->assertNull($parts['6.3']['representation']['represented']); } file_put_contents(base_path('outputs/irpc-l6-values-forms/recovered-'.$case.'.json'), json_encode($back, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE)); } } }