mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Do not autobilling recurring invoices in draft state
This commit is contained in:
parent
1dc24bb734
commit
8170831b73
@ -99,7 +99,6 @@ class SendRecurring implements ShouldQueue
|
||||
/* 09-01-2022 ensure we create the PDFs at this point in time! */
|
||||
$invoice->service()->touchPdf(true);
|
||||
|
||||
//nlog('updating recurring invoice dates');
|
||||
/* Set next date here to prevent a recurring loop forming */
|
||||
$this->recurring_invoice->next_send_date = $this->recurring_invoice->nextSendDate();
|
||||
$this->recurring_invoice->next_send_date_client = $this->recurring_invoice->nextSendDateClient();
|
||||
@ -111,10 +110,6 @@ 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);
|
||||
|
||||
$this->recurring_invoice->save();
|
||||
|
||||
event('eloquent.created: App\Models\Invoice', $invoice);
|
||||
@ -125,8 +120,6 @@ class SendRecurring implements ShouldQueue
|
||||
$invoice->entityEmailEvent($invoice->invitations->first(), 'invoice', 'email_template_invoice');
|
||||
}
|
||||
|
||||
nlog("Invoice {$invoice->number} created");
|
||||
|
||||
$invoice->invitations->each(function ($invitation) use ($invoice) {
|
||||
if ($invitation->contact && ! $invitation->contact->trashed() && strlen($invitation->contact->email) >= 1 && $invoice->client->getSetting('auto_email_invoice')) {
|
||||
try {
|
||||
@ -140,15 +133,14 @@ class SendRecurring implements ShouldQueue
|
||||
});
|
||||
}
|
||||
|
||||
if ($invoice->client->getSetting('auto_bill_date') == 'on_send_date' && $invoice->auto_bill_enabled) {
|
||||
//auto bill, BUT NOT DRAFTS!!
|
||||
if ($invoice->auto_bill_enabled && $invoice->client->getSetting('auto_bill_date') == 'on_send_date' && $invoice->client->getSetting('auto_email_invoice')) {
|
||||
nlog("attempting to autobill {$invoice->number}");
|
||||
// $invoice->service()->autoBill();
|
||||
AutoBill::dispatch($invoice->id, $this->db)->delay(rand(1,2));
|
||||
|
||||
} elseif ($invoice->client->getSetting('auto_bill_date') == 'on_due_date' && $invoice->auto_bill_enabled) {
|
||||
} elseif ($invoice->auto_bill_enabled && $invoice->client->getSetting('auto_bill_date') == 'on_due_date' && $invoice->client->getSetting('auto_email_invoice')) {
|
||||
if ($invoice->due_date && Carbon::parse($invoice->due_date)->startOfDay()->lte(now()->startOfDay())) {
|
||||
nlog("attempting to autobill {$invoice->number}");
|
||||
// $invoice->service()->autoBill();
|
||||
AutoBill::dispatch($invoice->id, $this->db)->delay(rand(1,2));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user