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('tests/frontend/fixtures/iva-foreign-operations.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']); $this->assertSame('opportunity:358', $recovered['context_opportunity']); $this->assertSame('Manica', $recovered['selection_labels']['province_id']); $store = json_decode($recovered['modelo_a_snapshot'], true, flags: JSON_THROW_ON_ERROR); $book = $store['foreignOperations']['opportunity:358']; $this->assertCount(7, $book['rows']); $this->assertSame(['potential', 'potential', 'potential', 'potential', 'indeterminate', 'not_demonstrated', 'excluded_19_2'], array_column($book['result']['rows'], 'relation19')); $this->assertSame('outside_portion', $book['result']['rows'][3]['territory']); $this->assertSame('2026-12-10', $book['result']['rows'][0]['event']['eventDate']); foreach ($book['result']['rows'] as $row) { $this->assertNull($row['deduction']); $this->assertNull($row['baseAmount']); $this->assertNull($row['vat']); $this->assertNull($row['rate']); } $this->assertSame($book['rows'], $book['result']['inputs']); $this->assertCount(1, $book['history']); $this->assertSame('potential', $book['history'][0]['rows'][0]['relation19']); $frozen = json_decode(file_get_contents(base_path('tests/frontend/fixtures/iva-foreign-operations-preserved.json')), true, flags: JSON_THROW_ON_ERROR); $prior = json_decode($frozen['modelo_a_snapshot'], true, flags: JSON_THROW_ON_ERROR); $preserved = array_diff_key($store, ['foreignOperations' => true]); foreach (['goodsLocations', 'serviceLocations', 'listedServices', 'currencyEvents'] as $map) { unset($preserved[$map]['opportunity:358']); } $this->assertSame($prior, $preserved); $this->assertSame('1250.30', $store['publicAuthorityBases']['opportunity:339']['result']['rows'][1]['baseAmount']); $this->assertNull($store['publicAuthorityBases']['opportunity:339']['result']['rows'][1]['vat']); $this->assertSame('400.00', $store['importExemptions']['opportunity:338']['result']['rows'][1]['importVat']); $this->assertNull($store['books']['opportunity:329']['result']['periods'][0]['fields']['11']); file_put_contents(base_path('outputs/iva-l1-foreign-operations-20261025/recovered.json'), json_encode($recovered, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE)); } }