@@ -84,7 +84,7 @@ class ExistingBusinessClassification
|
||||
if (($kind === 'sector' && ! ctype_digit($row['related_id'])) || ($kind !== 'sector' && ! Str::isUuid($row['related_id']))) {
|
||||
$fail('related_id', 'Identificador de referência inválido.');
|
||||
}
|
||||
if (! app(OpportunityClassification::class)->targets($kind)->where('id', $row['related_id'])->exists()) {
|
||||
if (! app(OpportunityClassification::class)->canRetainReference($kind, $row['related_id'], $row, $this->context($business)['relations'])) {
|
||||
$fail('related_id', 'Selecione uma referência existente e consultável.');
|
||||
}
|
||||
if (in_array($c['purpose'], ['regime_recognition', 'enterprise_admission', 'specific_benefit'], true) && $kind !== 'zone') {
|
||||
@@ -229,7 +229,8 @@ class ExistingBusinessClassification
|
||||
$effective = $this->effective($business, $row, $state);
|
||||
if (in_array($effective, ['archived', 'revoked'], true)) { continue; }
|
||||
$rows[] = ['dimension' => OpportunityClassification::TARGETS[$kind][2], 'target_type' => $kind, 'target_id' => (string) $row['related_id'],
|
||||
'label' => $target->{OpportunityClassification::TARGETS[$kind][1]}, 'purpose' => $c['purpose'], 'purpose_label' => OpportunityClassification::PURPOSES[$c['purpose']],
|
||||
'label' => $target->{OpportunityClassification::TARGETS[$kind][1]}, 'target_code' => $target->code ?? null,
|
||||
'reference_path' => $kind === 'activity' ? (app(EconomicReferenceCatalog::class)->activities()->firstWhere('id', $target->id)?->path ?? []) : [], 'purpose' => $c['purpose'], 'purpose_label' => OpportunityClassification::PURPOSES[$c['purpose']],
|
||||
'state' => $effective, 'source_reference' => $c['source_reference'] ?? null, 'citation' => $c['citation'] ?? null,
|
||||
'authority_id' => $c['authority_id'] ?? null, 'production_stage' => $c['production_stage'] ?? null,
|
||||
'external_status' => $c['external_status'], 'valid_from' => $c['valid_from'] ?? null, 'valid_until' => $c['valid_until'] ?? null];
|
||||
|
||||
Reference in New Issue
Block a user