mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Performance improvements for recurring invoices
This commit is contained in:
parent
524fad7bf4
commit
e63d99c2d1
@ -102,7 +102,6 @@ class RecurringInvoicesCron
|
||||
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.' Recurring #id = '.$recurring_invoice->id);
|
||||
|
||||
nlog("Trying to send {$recurring_invoice->number}");
|
||||
|
||||
|
@ -15,6 +15,7 @@ use App\DataMapper\Analytics\SendRecurringFailure;
|
||||
use App\Events\Invoice\InvoiceWasEmailed;
|
||||
use App\Factory\InvoiceInvitationFactory;
|
||||
use App\Factory\RecurringInvoiceToInvoiceFactory;
|
||||
use App\Jobs\Cron\AutoBill;
|
||||
use App\Jobs\Entity\EmailEntity;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\RecurringInvoice;
|
||||
@ -107,21 +108,12 @@ class SendRecurring implements ShouldQueue
|
||||
$this->recurring_invoice->setCompleted();
|
||||
}
|
||||
|
||||
nlog('next send date = '.$this->recurring_invoice->next_send_date);
|
||||
nlog('remaining cycles = '.$this->recurring_invoice->remaining_cycles);
|
||||
nlog('last send date = '.$this->recurring_invoice->last_sent_date);
|
||||
// nlog('next send date = '.$this->recurring_invoice->next_send_date);
|
||||
// nlog('remaining cycles = '.$this->recurring_invoice->remaining_cycles);
|
||||
// nlog('last send date = '.$this->recurring_invoice->last_sent_date);
|
||||
|
||||
$this->recurring_invoice->save();
|
||||
|
||||
/*
|
||||
|
||||
if ($this->recurring_invoice->company->pause_recurring_until_paid){
|
||||
$this->recurring_invoice->service()
|
||||
->stop();
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
event('eloquent.created: App\Models\Invoice', $invoice);
|
||||
|
||||
if ($invoice->client->getSetting('auto_email_invoice')) {
|
||||
@ -147,11 +139,14 @@ class SendRecurring implements ShouldQueue
|
||||
|
||||
if ($invoice->client->getSetting('auto_bill_date') == 'on_send_date' && $invoice->auto_bill_enabled) {
|
||||
nlog("attempting to autobill {$invoice->number}");
|
||||
$invoice->service()->autoBill();
|
||||
// $invoice->service()->autoBill();
|
||||
AutoBill::dispatch($invoice, $this->db)->delay(20);
|
||||
|
||||
} elseif ($invoice->client->getSetting('auto_bill_date') == 'on_due_date' && $invoice->auto_bill_enabled) {
|
||||
if ($invoice->due_date && Carbon::parse($invoice->due_date)->startOfDay()->lte(now()->startOfDay())) {
|
||||
nlog("attempting to autobill {$invoice->number}");
|
||||
$invoice->service()->autoBill();
|
||||
// $invoice->service()->autoBill();
|
||||
AutoBill::dispatch($invoice, $this->db)->delay(20);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -188,3 +183,17 @@ class SendRecurring implements ShouldQueue
|
||||
nlog(print_r($exception->getMessage(), 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 1/8/2022
|
||||
*
|
||||
* Improvements here include moving the emailentity and autobilling into the queue.
|
||||
*
|
||||
* Further improvements could using the CompanyRecurringCron.php stub which divides
|
||||
* the recurring invoices into companies and spins them off into their own queue to
|
||||
* improve parallel processing.
|
||||
*
|
||||
* Need to be careful we do not overload redis and OOM.
|
||||
*/
|
Loading…
x
Reference in New Issue
Block a user