diff --git a/app/Jobs/Cron/RecurringInvoicesCron.php b/app/Jobs/Cron/RecurringInvoicesCron.php index 0350b61749ec..ae993e180ea0 100644 --- a/app/Jobs/Cron/RecurringInvoicesCron.php +++ b/app/Jobs/Cron/RecurringInvoicesCron.php @@ -48,6 +48,10 @@ class RecurringInvoicesCron ->whereNull('deleted_at') ->where('status_id', RecurringInvoice::STATUS_ACTIVE) ->where('remaining_cycles', '!=', '0') + ->whereHas('client', function ($query) { + $query->where('is_deleted',0) + ->where('deleted_at', NULL); + }) ->with('company') ->cursor(); @@ -70,6 +74,10 @@ class RecurringInvoicesCron ->whereNull('deleted_at') ->where('status_id', RecurringInvoice::STATUS_ACTIVE) ->where('remaining_cycles', '!=', '0') + ->whereHas('client', function ($query) { + $query->where('is_deleted',0) + ->where('deleted_at', NULL); + }) ->with('company') ->cursor(); diff --git a/app/Jobs/Util/ReminderJob.php b/app/Jobs/Util/ReminderJob.php index dd0b1d521764..e51072b1a921 100644 --- a/app/Jobs/Util/ReminderJob.php +++ b/app/Jobs/Util/ReminderJob.php @@ -62,6 +62,10 @@ class ReminderJob implements ShouldQueue ->where('is_deleted', 0) ->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]) ->where('balance', '>', 0) + ->whereHas('client', function ($query) { + $query->where('is_deleted',0) + ->where('deleted_at', NULL); + }) ->with('invitations')->cursor()->each(function ($invoice) { if ($invoice->isPayable()) {