diff --git a/app/Console/Commands/SendRecurringInvoices.php b/app/Console/Commands/SendRecurringInvoices.php index 4934ca417e34..9872a09188f9 100644 --- a/app/Console/Commands/SendRecurringInvoices.php +++ b/app/Console/Commands/SendRecurringInvoices.php @@ -42,12 +42,14 @@ class SendRecurringInvoices extends Command $this->info(count($invoices).' recurring invoice(s) found'); 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; } $recurInvoice->account->loadLocalizationSettings($recurInvoice->client); - $this->info('Processing Invoice '.$recurInvoice->id.' - Should send '.($recurInvoice->shouldSendToday() ? 'YES' : 'NO')); $invoice = $this->invoiceRepo->createRecurringInvoice($recurInvoice); if ($invoice && !$invoice->isPaid()) { diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 5a645b333067..c9fddbb666bb 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -759,7 +759,11 @@ class Invoice extends EntityModel implements BalanceAffecting 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; }