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()])); $id = null; $etag = null; foreach (['monthly', 'fraction', 'missing', 'negative', 'absent'] as $case) { $d = json_decode(file_get_contents(base_path('outputs/irpc-l7-months/'.$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['modelo_a_snapshot'], $back['modelo_a_snapshot']); $this->assertSame($d['business_plan_snapshot'], $back['business_plan_snapshot']); $s = json_decode($back['modelo_a_snapshot'], true, flags: JSON_THROW_ON_ERROR); $b = $s['irpcNormal'][$d['context_opportunity']]; $m = $b['result']['model']; $a = $m['special']['acceleration']; $this->assertSame('IRPC-normal-adjustments/11', $m['version']); $this->assertSame($b['special']['acceleration']['monthly'], $a['monthly']['input']); $this->assertContains('IRPC-normal-adjustments/10', array_column(array_column($b['history'], 'model'), 'version')); $this->assertSame($b['depreciation'], $a['normal']['input']); $this->assertSame('L8', $m['special']['finalBalance']['scope']); $this->assertNull($m['special']['finalBalance']['payable']); $this->assertNull($m['special']['finalBalance']['recoverable']); $this->assertNull($m['tax']); $this->assertArrayHasKey('irpcWithholdings', $s); if ($case === 'monthly') { $v = $a['monthly']['assets'][0]; $this->assertSame(6, $v['months']); $this->assertSame('50', $v['normalQuota']['numerator']); $this->assertSame('75', $v['acceleratedQuota']['numerator']); $this->assertSame('60', $v['acceleratedDeduction']['numerator']); $this->assertSame('10', $a['additionalDeduction']['numerator']); $this->assertSame('6310', $m['taxableProfit']['numerator']); $this->assertSame('6300', $m['special']['taxableProfit']['numerator']); $this->assertSame('2016', $m['special']['colecta']['numerator']); $this->assertSame($b['depreciation'], $a['accelerated']['input']); } elseif ($case === 'fraction') { $v = $a['monthly']['assets'][0]; $this->assertSame(1, $v['months']); $this->assertSame(['numerator' => '25', 'denominator' => '3'], $v['normalQuota']); $this->assertSame(['numerator' => '25', 'denominator' => '6'], $a['additionalDeduction']); } elseif ($case === 'missing') { $this->assertSame('indeterminate', $a['status']); $this->assertNull($a['additionalDeduction']); $this->assertSame('6310', $m['taxableProfit']['numerator']); $this->assertNull($m['special']['colecta']); } elseif ($case === 'negative') { $this->assertSame('not_applicable', $a['rows'][0]['status']); $this->assertFalse($a['monthly']['assets'][0]['applied']); $this->assertSame('0', $a['additionalDeduction']['numerator']); } else { $this->assertSame('absent', $a['status']); $this->assertSame([], $a['monthly']['assets']); $this->assertSame('0', $a['additionalDeduction']['numerator']); } file_put_contents(base_path('outputs/irpc-l7-months/recovered-'.$case.'.json'), json_encode($back, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE)); } } }