Fixed when contract is archived all active field jobs for contract are cancaled

This commit is contained in:
Simon Pocrnjič
2026-04-16 21:52:17 +02:00
parent 7881508a7b
commit 187cb4f127
3 changed files with 41 additions and 32 deletions
@@ -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],