mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Optimized send recurring invoices command
This commit is contained in:
parent
ff911888ec
commit
3f974d0344
@ -42,12 +42,14 @@ class SendRecurringInvoices extends Command
|
|||||||
$this->info(count($invoices).' recurring invoice(s) found');
|
$this->info(count($invoices).' recurring invoice(s) found');
|
||||||
|
|
||||||
foreach ($invoices as $recurInvoice) {
|
foreach ($invoices as $recurInvoice) {
|
||||||
if (!$recurInvoice->user->confirmed) {
|
$shouldSendToday = $recurInvoice->shouldSendToday();
|
||||||
|
$this->info('Processing Invoice '.$recurInvoice->id.' - Should send '.($shouldSendToday ? 'YES' : 'NO'));
|
||||||
|
|
||||||
|
if ( ! $shouldSendToday) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$recurInvoice->account->loadLocalizationSettings($recurInvoice->client);
|
$recurInvoice->account->loadLocalizationSettings($recurInvoice->client);
|
||||||
$this->info('Processing Invoice '.$recurInvoice->id.' - Should send '.($recurInvoice->shouldSendToday() ? 'YES' : 'NO'));
|
|
||||||
$invoice = $this->invoiceRepo->createRecurringInvoice($recurInvoice);
|
$invoice = $this->invoiceRepo->createRecurringInvoice($recurInvoice);
|
||||||
|
|
||||||
if ($invoice && !$invoice->isPaid()) {
|
if ($invoice && !$invoice->isPaid()) {
|
||||||
|
@ -759,7 +759,11 @@ class Invoice extends EntityModel implements BalanceAffecting
|
|||||||
|
|
||||||
public function shouldSendToday()
|
public function shouldSendToday()
|
||||||
{
|
{
|
||||||
if (!$this->start_date || strtotime($this->start_date) > strtotime('now')) {
|
if ( ! $this->user->confirmed) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! $this->start_date || strtotime($this->start_date) > strtotime('now')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user