versao compilada 1
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-16 09:17:28 +02:00
parent c13f250b87
commit 6a76aac80f
901 changed files with 253428 additions and 252 deletions
+7 -2
View File
@@ -3,6 +3,7 @@
namespace App\Services;
use App\Models\CrmTask;
use App\Models\LandAssistanceCase;
use App\Models\SimulationFormDraft;
use App\Models\User;
use Illuminate\Http\Request;
@@ -92,6 +93,7 @@ final class InvestorPath
'detail' => $detail, 'preparation_allowed' => $value !== 'no',
'action_gaps' => []];
}
$steps = app(FintechInvestment::class)->adjustSteps($payload, $steps);
$byCode = collect($steps)->keyBy('code');
foreach ($steps as &$step) {
foreach ($step['dependencies'] as $action => $dependencies) {
@@ -126,15 +128,17 @@ final class InvestorPath
$next = collect($steps)->first(fn ($step) => $step['preparation_allowed'] && ! in_array($step['state'], ['completed', 'approved', 'waiting_external', 'submitted', 'reviewing'], true));
$landCase = (int) $case->user_id === $actor->id
? \App\Models\LandAssistanceCase::where('user_id', $actor->id)->latest('updated_at')->get()
? LandAssistanceCase::where('user_id', $actor->id)->latest('updated_at')->get()
->first(fn ($land) => ($land->payload['investor_path_case_id'] ?? null) === $id) : null;
return ['case' => ['id' => $id, 'title' => $case->title, 'version' => $case->version, 'closed' => $case->closed_at !== null],
'journey_id' => $journey->id, 'definition_id' => $version->id, 'definition_version' => $version->version_no, 'source_sha256' => $definition['source_sha256'],
'phases' => $definition['phases'], 'steps' => $steps, 'facts' => $facts, 'fact_reasons' => $path['fact_reasons'] ?? [],
'fintech' => ($owner || $manager) && (isset($path['fintech']) || collect($path['sector_contexts'] ?? [])->contains(fn ($s) => in_array($s['slug'], ['fintech', 'tecnologias-de-informacao', 'mercado-financeiro'], true)) || collect($path['content_sources'] ?? [])->contains('return_href', '/tech-fintech')) ? app(FintechInvestment::class)->view($payload, $steps) : null,
'canWrite' => $owner && ! $case->closed_at, 'canReview' => $manager && (int) $case->user_id !== $actor->id && ! $case->closed_at,
'next' => $next ? ['code' => $next['code'], 'title' => $next['title'], 'action' => 'Preparar', 'href' => '#'.$next['code']] : null,
'results' => $results, 'requests' => $requests, 'documents' => $documents,
'sector_contexts' => ($owner || $manager) ? ($path['sector_contexts'] ?? []) : [],
'content_sources' => ($owner || $manager) ? ($path['content_sources'] ?? []) : [],
'tasks' => DB::table('tasks')->where('desk_case_id', $id)
->whereNull('deleted_at')
@@ -182,6 +186,7 @@ final class InvestorPath
$step = $this->findStep($view, $code);
abort_unless($step !== null && $step['preparation_allowed'], 422, 'Etapa dispensada de preparação; altere os pressupostos com fundamento.');
$state = $data['state'];
abort_if($state === 'completed' && ($step['fintech_review_required'] ?? false), 422, 'Os pressupostos Fintech desta revisão mudaram; preserve a preparação e atualize a conferência antes da conclusão.');
$internal = in_array($state, ['reviewing', 'correction_required'], true);
$external = in_array($state, ['approved', 'rejected', 'expired'], true);
$scope = 'investor_preparation';
@@ -210,7 +215,7 @@ final class InvestorPath
if ($state === 'completed' && in_array($code, ['S07', 'S08', 'S10', 'S11', 'S14', 'S15', 'S17', 'S18'], true)) {
abort_unless(($step['saved_state'] ?? '') === 'approved' && in_array($data['action'], ['execute', 'operate'], true), 422, 'Conclusão operacional exige acto externo documentado; use preparação enquanto aguarda.');
}
$detail = [...$data, 'scope' => $scope, 'actor_id' => $actor->id, 'recorded_at' => now()->toIso8601String()];
$detail = [...$data, 'fintech_fingerprint' => $view['fintech']['review_fingerprints'][$code] ?? null, 'scope' => $scope, 'actor_id' => $actor->id, 'recorded_at' => now()->toIso8601String()];
DB::table('journey_steps')->where('id', $step['id'])->update(['path_detail' => $this->desk->encode($detail),
'status' => in_array($state, ['completed', 'approved'], true) ? 'completed' : ($state === 'not_started' ? 'pending' : 'active'),
'version_no' => $step['version'] + 1, 'updated_at' => now()]);