Constrain recurring / reminders if the client is archived / deleted

This commit is contained in:
David Bomba 2021-07-02 19:40:44 +10:00
parent 9b81521fa1
commit 7556b68b1f
2 changed files with 12 additions and 0 deletions

View File

@ -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();

View File

@ -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()) {