mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Improve queries for recurring objects to exclusive disabled companies
This commit is contained in:
parent
5ddbc0f507
commit
63e6b1c26d
@ -52,6 +52,9 @@ class AutoBillCron
|
||||
->where('auto_bill_enabled', true)
|
||||
->where('balance', '>', 0)
|
||||
->where('is_deleted', false)
|
||||
->whereHas('company', function ($query) {
|
||||
$query->where('is_disabled',0);
|
||||
})
|
||||
->with('company');
|
||||
|
||||
nlog($auto_bill_partial_invoices->count(). " partial invoices to auto bill");
|
||||
@ -65,6 +68,9 @@ class AutoBillCron
|
||||
->where('auto_bill_enabled', true)
|
||||
->where('balance', '>', 0)
|
||||
->where('is_deleted', false)
|
||||
->whereHas('company', function ($query) {
|
||||
$query->where('is_disabled',0);
|
||||
})
|
||||
->with('company');
|
||||
|
||||
nlog($auto_bill_invoices->count(). " full invoices to auto bill");
|
||||
@ -85,6 +91,9 @@ class AutoBillCron
|
||||
->where('auto_bill_enabled', true)
|
||||
->where('balance', '>', 0)
|
||||
->where('is_deleted', false)
|
||||
->whereHas('company', function ($query) {
|
||||
$query->where('is_disabled',0);
|
||||
})
|
||||
->with('company');
|
||||
|
||||
nlog($auto_bill_partial_invoices->count(). " partial invoices to auto bill db = {$db}");
|
||||
@ -98,6 +107,9 @@ class AutoBillCron
|
||||
->where('auto_bill_enabled', true)
|
||||
->where('balance', '>', 0)
|
||||
->where('is_deleted', false)
|
||||
->whereHas('company', function ($query) {
|
||||
$query->where('is_disabled',0);
|
||||
})
|
||||
->with('company');
|
||||
|
||||
nlog($auto_bill_invoices->count(). " full invoices to auto bill db = {$db}");
|
||||
|
@ -66,6 +66,9 @@ class RecurringExpensesCron
|
||||
->whereNull('deleted_at')
|
||||
->where('status_id', RecurringInvoice::STATUS_ACTIVE)
|
||||
->where('remaining_cycles', '!=', '0')
|
||||
->whereHas('company', function ($query) {
|
||||
$query->where('is_disabled',0);
|
||||
})
|
||||
->with('company')
|
||||
->cursor();
|
||||
|
||||
|
@ -53,23 +53,27 @@ class RecurringInvoicesCron
|
||||
$query->where('is_deleted',0)
|
||||
->where('deleted_at', NULL);
|
||||
})
|
||||
->whereHas('company', function ($query) {
|
||||
$query->where('is_disabled',0);
|
||||
})
|
||||
->with('company')
|
||||
->cursor();
|
||||
|
||||
nlog(now()->format('Y-m-d') . ' Sending Recurring Invoices. Count = '.$recurring_invoices->count());
|
||||
|
||||
$recurring_invoices->each(function ($recurring_invoice, $key) {
|
||||
|
||||
nlog("Current date = " . now()->format("Y-m-d") . " Recurring date = " .$recurring_invoice->next_send_date);
|
||||
|
||||
if (!$recurring_invoice->company->is_disabled) {
|
||||
|
||||
try{
|
||||
SendRecurring::dispatchNow($recurring_invoice, $recurring_invoice->company->db);
|
||||
}
|
||||
catch(\Exception $e){
|
||||
nlog("Unable to sending recurring invoice {$recurring_invoice->id}");
|
||||
}
|
||||
nlog("Trying to send {$recurring_invoice->number}");
|
||||
|
||||
try{
|
||||
SendRecurring::dispatchNow($recurring_invoice, $recurring_invoice->company->db);
|
||||
}
|
||||
catch(\Exception $e){
|
||||
nlog("Unable to sending recurring invoice {$recurring_invoice->id}");
|
||||
}
|
||||
|
||||
});
|
||||
} else {
|
||||
//multiDB environment, need to
|
||||
@ -86,6 +90,9 @@ class RecurringInvoicesCron
|
||||
$query->where('is_deleted',0)
|
||||
->where('deleted_at', NULL);
|
||||
})
|
||||
->whereHas('company', function ($query) {
|
||||
$query->where('is_disabled',0);
|
||||
})
|
||||
->with('company')
|
||||
->cursor();
|
||||
|
||||
@ -94,15 +101,15 @@ class RecurringInvoicesCron
|
||||
$recurring_invoices->each(function ($recurring_invoice, $key) {
|
||||
nlog("Current date = " . now()->format("Y-m-d") . " Recurring date = " .$recurring_invoice->next_send_date ." Recurring #id = ". $recurring_invoice->id);
|
||||
|
||||
if (!$recurring_invoice->company->is_disabled) {
|
||||
|
||||
nlog("Trying to send {$recurring_invoice->number}");
|
||||
|
||||
try{
|
||||
SendRecurring::dispatchNow($recurring_invoice, $recurring_invoice->company->db);
|
||||
}
|
||||
catch(\Exception $e){
|
||||
nlog("Unable to sending recurring invoice {$recurring_invoice->id}");
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -70,6 +70,9 @@ class ReminderJob implements ShouldQueue
|
||||
$query->where('is_deleted',0)
|
||||
->where('deleted_at', NULL);
|
||||
})
|
||||
->whereHas('company', function ($query) {
|
||||
$query->where('is_disabled',0);
|
||||
})
|
||||
->with('invitations')->cursor()->each(function ($invoice) {
|
||||
|
||||
if ($invoice->isPayable()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user