Criar Hotel: a CAE de hotelaria fica associada à intenção, com detalhe até ao nível 5
tests / ci (push) Canceled after 0s

Em «Actividades existentes na localização», um dossier cuja intenção é um
hotel passa a ficar associado à classe 551 «Estabelecimentos hoteleiros» da
CAE-Rev.2 (INE, 2008), por correspondência documentada no código, e a lista
mostra apenas as classes de hotelaria, da classe 551 até ao nível 5 (por
exemplo 55111 «Hotéis com restaurante»). O detalhe continua a ser escolha do
investidor, como fixa o aditamento 3 aprovado em 20/11/2026. Sem
correspondência documentada nada é associado e a lista completa mantém-se.

A lista deixa de pré-seleccionar um valor que não esteja nela: um
identificador guardado que não corresponda a uma opção já não aparece como
«Escolha guardada — designação por recuperar». As designações oficiais em
maiúsculas passam a texto corrente.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzJmxFy3izprXr5dSq91jM
This commit is contained in:
Claude
2026-12-05 00:14:01 +02:00
committed by nala
parent c558960500
commit 66316f0902
5 changed files with 120 additions and 19 deletions
+26 -3
View File
@@ -88,12 +88,13 @@ final class ProtectedSupplyAggregateTest extends TestCase
return $id;
}
private function dossier(string $sector = 'agro', string $territory = 'locality_a'): string
private function dossier(string $sector = 'agro', string $territory = 'locality_a', ?string $title = null): string
{
$id = $this->actingAs($this->owner)->postJson('/investimentos', ['title' => 'SYNTHETIC deliberate '.$sector, 'client_key' => (string) Str::uuid(), 'reuse_consent' => true])->assertCreated()->json('id');
$title ??= 'SYNTHETIC deliberate '.$sector;
$id = $this->actingAs($this->owner)->postJson('/investimentos', ['title' => $title, 'client_key' => (string) Str::uuid(), 'reuse_consent' => true])->assertCreated()->json('id');
$v = $this->getJson('/investimentos/'.$id.'/contexto')->assertOk()->json('case.version');
$body = ['version' => $v, 'selection' => ['sector' => 'sector:'.$this->sectors[$sector], 'territory' => 'territory:'.$this->geo[$territory]],
'opportunity_choices' => [], 'declarations' => ['project_title' => 'SYNTHETIC deliberate '.$sector, 'products_services' => 'SYNTHETIC deliberate activity', 'currency' => 'MZN', 'investment_budget_min' => '1000000', 'investment_budget_max' => '5000000']];
'opportunity_choices' => [], 'declarations' => ['project_title' => $title, 'products_services' => 'SYNTHETIC deliberate activity', 'currency' => 'MZN', 'investment_budget_min' => '1000000', 'investment_budget_max' => '5000000']];
$hash = $this->postJson('/investimentos/'.$id.'/contexto/previa', $body)->assertOk()->json('preview_hash');
$this->postJson('/investimentos/'.$id.'/contexto/confirmar', [...$body, 'preview_hash' => $hash, 'operation_key' => (string) Str::uuid(), 'confirm' => true])->assertOk();
@@ -200,6 +201,28 @@ final class ProtectedSupplyAggregateTest extends TestCase
$this->postJson('/investimentos/'.$id.'/contexto/oferta-agregada', ['version' => $version, 'operation_key' => (string) Str::uuid()])->assertUnauthorized();
}
public function test_a_hotel_dossier_is_associated_with_hotel_classes_down_to_level_five_and_offers_nothing_else(): void
{
// Mapa de erros, "Criar Hotel" (C03; aditamento 3): documented correspondence, the detail is the investor's choice.
$hotel = $this->dossier('hotel', 'locality_a', 'Criar Hotel');
$view = $this->actingAs($this->owner)->getJson('/investimentos/'.$hotel)->assertOk()->json();
$this->assertSame('551', $view['supply_activity_intention']['code']);
$this->assertStringContainsString('CAE-Rev.2', $view['supply_activity_intention']['basis']);
$codes = array_column($view['supply_activity_options'], 'code');
$this->assertContains('551', $codes);
$this->assertContains('5511', $codes);
$this->assertNotEmpty(array_filter($codes, fn (string $code) => strlen($code) === 5), 'level 5 is offered');
$this->assertSame([], array_values(array_filter($codes, fn (string $code) => ! str_starts_with($code, '551'))), 'only hotel classes');
$this->assertContains('55111', $codes, 'hotels with restaurant, level 5');
$this->aggregateSnapshot($hotel, ['classification_key' => $view['supply_activity_intention']['id']]);
// Without a documented correspondence nothing is associated and the full choice stays available.
$agro = $this->dossier('agro');
$other = $this->getJson('/investimentos/'.$agro)->assertOk()->json();
$this->assertNull($other['supply_activity_intention']);
$this->assertNotEmpty(array_filter(array_column($other['supply_activity_options'], 'code'), fn (string $code) => ! str_starts_with($code, '551')));
}
public function test_unpublished_classification_is_not_presented_as_an_empty_business_result(): void
{
$sector = Sector::create(['name' => 'SYNTHETIC without public CAE', 'slug' => 'qa-'.Str::lower(Str::random(16)), 'is_active' => true]);