fix: complete InvesteMoz validation and error corrections

This commit is contained in:
2026-10-29 21:47:33 +02:00
parent 63147312e2
commit daf8623441
718 changed files with 127308 additions and 20959 deletions
+11 -4
View File
@@ -6,6 +6,7 @@ use App\Http\Controllers\InvestmentPortfolioController;
use App\Models\InvestmentDossier;
use App\Models\Opportunity;
use App\Models\Sector;
use App\Support\StructuredData;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
@@ -239,7 +240,8 @@ class InvestmentCatalogue
};
}
private function declaredProvince($query, string $name): void
/** @param Builder<Opportunity> $query */
private function declaredProvince(Builder $query, string $name): void
{
// Read the published province declaration only when no more precise territory contradicts it.
// This does not assign any canonical ID, district, post, locality or coordinates to the record.
@@ -249,7 +251,8 @@ class InvestmentCatalogue
->whereRaw('lower(btrim(opportunities.province)) = ?', [mb_strtolower(trim($name))]));
}
private function approvedCorridorProvince($query, string $provinceId): void
/** @param Builder<Opportunity> $query */
private function approvedCorridorProvince(Builder $query, string $provinceId): void
{
$code = app(InvestmentGeography::class)->publicReferences()->where('id', $provinceId)->value('source_code');
$names = [];
@@ -344,8 +347,8 @@ class InvestmentCatalogue
// A chain's documented scope comes from its public cluster, never
// from the opportunities surviving the current search.
$ids = app(OpportunityClassification::class)->targets('chain')
->whereIn('cluster_id', $result['clusters']->pluck('id'))->pluck('id');
$result['classification']['targets']['chain'] = collect($result['classification']['targets']['chain'])->whereIn('id', $ids)->values();
->whereIn('cluster_id', ($result['clusters'] ?? collect())->pluck('id'))->pluck('id');
$result['classification']['targets']['chain'] = collect(StructuredData::collectionItems($result['classification']['targets']['chain']))->whereIn('id', $ids)->values();
}
// Activities are a public classification catalogue, not evidence of
// investment availability in a territory or sector.
@@ -353,6 +356,10 @@ class InvestmentCatalogue
return $result;
}
/**
* @param array<array-key, mixed> $filters
* @return array<array-key, mixed>
*/
private function publicAssociatedIds(array $filters): array
{
$kinds = ['park_id' => ['park'], 'zee_id' => ['zone'], 'zfi_id' => ['zone'],