Fixed when contract is archived all active field jobs for contract are cancaled
This commit is contained in:
parent
7881508a7b
commit
187cb4f127
|
|
@ -14,7 +14,6 @@
|
|||
use App\Services\Sms\SmsService;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
|
|
@ -120,20 +119,26 @@ public function __invoke(SmsService $sms): Response
|
|||
}
|
||||
}
|
||||
|
||||
if (! $contract) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $fj->id,
|
||||
'priority' => $fj->priority,
|
||||
'assigned_at' => $fj->assigned_at?->toIso8601String(),
|
||||
'created_at' => $fj->created_at?->toIso8601String(),
|
||||
'contract' => $contract ? [
|
||||
'contract' => [
|
||||
'uuid' => $contract->uuid,
|
||||
'reference' => $contract->reference,
|
||||
'client_case_uuid' => optional($contract->clientCase)->uuid,
|
||||
'person_full_name' => optional(optional($contract->clientCase)->person)->full_name,
|
||||
'segment_id' => $segmentId,
|
||||
] : null,
|
||||
],
|
||||
];
|
||||
});
|
||||
})
|
||||
->filter()
|
||||
->values();
|
||||
});
|
||||
|
||||
// System health for timestamp
|
||||
|
|
|
|||
|
|
@ -36,6 +36,14 @@ public function handle(DecisionEventContext $context, array $config = []): void
|
|||
$setting->reactivate = (bool) $config['reactivate'];
|
||||
}
|
||||
|
||||
// Cancel all active FieldJobs for this contract before archiving (raw update to avoid boot-event side effects)
|
||||
\DB::table('field_jobs')
|
||||
->where('contract_id', $contractId)
|
||||
->whereNull('completed_at')
|
||||
->whereNull('cancelled_at')
|
||||
->whereNull('deleted_at')
|
||||
->update(['cancelled_at' => now(), 'updated_at' => now()]);
|
||||
|
||||
$results = app(ArchiveExecutor::class)->executeSetting(
|
||||
$setting,
|
||||
['contract_id' => $contractId],
|
||||
|
|
|
|||
|
|
@ -73,13 +73,8 @@ function safeCaseHref(uuid, segment = null) {
|
|||
v-if="fieldJobsAssignedToday && fieldJobsAssignedToday.length > 0"
|
||||
>
|
||||
<div class="flex flex-col gap-1 px-1">
|
||||
<Item
|
||||
v-for="f in fieldJobsAssignedToday"
|
||||
:key="f.id"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
as-child
|
||||
>
|
||||
<template v-for="f in fieldJobsAssignedToday" :key="f.id">
|
||||
<Item v-if="f.contract" variant="outline" size="sm" as-child>
|
||||
<a :href="safeCaseHref(f.contract.client_case_uuid, f.contract.segment_id)">
|
||||
<ItemMedia>
|
||||
<span class="w-2 h-2 mt-2 rounded-full bg-primary" />
|
||||
|
|
@ -98,6 +93,7 @@ function safeCaseHref(uuid, segment = null) {
|
|||
</ItemActions>
|
||||
</a>
|
||||
</Item>
|
||||
</template>
|
||||
</div>
|
||||
</ScrollArea>
|
||||
<div
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user