oportunidades 7
tests / ci (push) Waiting to run

This commit is contained in:
2026-10-13 11:40:29 +02:00
parent 20971d523f
commit 287e991486
2902 changed files with 1085456 additions and 25957 deletions
+13 -1
View File
@@ -13,6 +13,9 @@ class OpportunityWorkflowTasks
public function ensure(Opportunity $record, string $kind, string $title): string
{
$key = 'portal-opportunity:'.$record->id.':'.$kind.':'.($record->workflow_context['content_revision'] ?? 1);
if (isset($record->workflow_context['review_cycle'])) {
$key .= ':cycle:'.$record->workflow_context['review_cycle'];
}
$existing = DB::table('tasks')->where('source_system', 'opportunity-workflow')->where('external_id', $key)->first();
if ($existing) {
return $existing->id;
@@ -32,11 +35,20 @@ class OpportunityWorkflowTasks
DB::table('tasks')->where('id', $taskId)->update(['assignee_user_id' => $subject->id, 'status' => 'in_progress', 'version_no' => DB::raw('version_no+1')]);
}
public function closedReviewBinding(Opportunity $record, ?string $id): bool
{
return $id !== null && DB::table('tasks')->where('id', $id)->where('source_system', 'opportunity-workflow')
->where('external_id', 'like', 'portal-opportunity:'.$record->id.':opportunity_review:%')->where('status', 'done')->exists();
}
public function complete(?string $taskId, string $outcome): void
{
if ($taskId) {
// Existing CRM outcome is a varchar(80) summary. The full reason is
// retained in the versioned workflow decision and its audit event.
$summary = mb_strlen($outcome) > 80 ? mb_substr($outcome, 0, 79).'…' : $outcome;
DB::table('tasks')->where('id', $taskId)->where('source_system', 'opportunity-workflow')->whereIn('status', ['open', 'in_progress'])
->update(['status' => 'done', 'outcome' => $outcome, 'completed_at' => now(), 'version_no' => DB::raw('version_no+1')]);
->update(['status' => 'done', 'outcome' => $summary, 'completed_at' => now(), 'version_no' => DB::raw('version_no+1')]);
}
}