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 (['combined', 'autonomous', 'incompatible', 'missing', 'exception', 'negative', 'absent'] as $case) { $d = json_decode(file_get_contents(base_path('outputs/irpc-l7-combinations/'.$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']; $v = $m['special']; $c = $v['combinations']; $this->assertSame('IRPC-normal-adjustments/14', $m['version']); $this->assertSame($b['special']['combinations'], $c['input']); $this->assertContains('IRPC-normal-adjustments/13', array_column(array_column($b['history'], 'model'), 'version')); $this->assertSame('150', $b['depreciation']['assets'][0]['previousAccounting']); $this->assertSame('100', $b['depreciation']['assets'][0]['previousFiscal']); $this->assertSame('50', $b['depreciation']['assets'][0]['priorAvailable']); $this->assertSame($b['depreciation'], $v['acceleration']['normal']['input']); $this->assertSame(['scope' => 'L8', 'payable' => null, 'recoverable' => null], $v['finalBalance']); $this->assertNull($m['tax']); $this->assertArrayHasKey('irpcWithholdings', $s); if (in_array($case, ['combined', 'autonomous'], true)) { $this->assertSame('compatible', $c['status']); $this->assertSame('25', $v['acceleration']['additionalDeduction']['numerator']); $this->assertSame('15', $c['assetClaims'][0]['priorRecoveredIncluded']['numerator']); $this->assertSame('75', $c['assetClaims'][0]['acceleratedDeduction']['numerator']); $this->assertSame('16', $v['cooperative']['rate']['numerator']); $this->assertSame($case === 'combined' ? '3105' : '3205', $v['taxableBase']['numerator']); $this->assertSame(['numerator' => $case === 'combined' ? '2484' : '2739', 'denominator' => '5'], $v['combinedColecta']); if ($case === 'autonomous') { $this->assertSame('35', $v['expenses']['autonomousTax']['numerator']); $this->assertSame('0', $v['expenses']['rows'][0]['additionalProfitAdjustment']['numerator']); } } elseif (in_array($case, ['incompatible', 'missing', 'exception'], true)) { $this->assertSame($case === 'incompatible' ? 'incompatible' : 'indeterminate', $c['status']); $this->assertNull($v['taxableBase']); $this->assertNull($v['combinedColecta']); $this->assertSame('3130', $m['taxableProfit']['numerator']); } elseif ($case === 'negative') { $this->assertSame('not_applicable', $v['cooperative']['status']); $this->assertSame(['numerator' => '4968', 'denominator' => '5'], $v['colecta']); } else { $this->assertSame('absent', $v['acceleration']['status']); $this->assertSame('0', $v['acceleration']['additionalDeduction']['numerator']); $this->assertSame(['numerator' => '2504', 'denominator' => '5'], $v['colecta']); } file_put_contents(base_path('outputs/irpc-l7-combinations/recovered-'.$case.'.json'), json_encode($back, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE)); } } }