fix(investor): simplify preparation flow, profile requests and scoped zone search
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-28 21:26:59 +02:00
parent 54d1b2a543
commit 502e3ec4d5
23 changed files with 573 additions and 101 deletions
+5 -2
View File
@@ -63,10 +63,13 @@ class InvestmentZones
$path = app(InvestmentGeography::class)->selection($filters);
if ($path !== []) {
$territoryIds = app(InvestmentGeography::class)->descendants($path[array_key_last($path)]->id);
$query->where(function ($matches) use ($territoryIds, $management): void {
$ancestorIds = array_column($path, 'id');
$query->where(function ($matches) use ($territoryIds, $ancestorIds, $management): void {
$matches->whereIn('primary_territory_id', $territoryIds)
->orWhereExists(fn ($link) => $link->selectRaw('1')->from('investment_zone_locations as zl')
->whereColumn('zl.zone_id', 'investment_zones.id')->whereIn('zl.geo_location_id', $territoryIds)
->whereColumn('zl.zone_id', 'investment_zones.id')->whereIn('zl.scope_type', ['site', 'administrative', 'legal_scope'])
->where(fn ($area) => $area->whereIn('zl.geo_location_id', $territoryIds)
->orWhere(fn ($coverage) => $coverage->where('zl.scope_type', 'legal_scope')->whereIn('zl.geo_location_id', $ancestorIds)))
->where('zl.validation_status', 'validated')->where(fn ($valid) => $valid->whereNull('zl.valid_from')->orWhereDate('zl.valid_from', '<=', today()))
->where(fn ($valid) => $valid->whereNull('zl.valid_until')->orWhereDate('zl.valid_until', '>=', today())));
if (! $management) {