mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Reorder events when sending recurring invoice and only send a payment receipt if auto bill is enabled.
This commit is contained in:
parent
1d8d505c21
commit
6329484771
@ -84,11 +84,13 @@ class SendRecurring implements ShouldQueue
|
||||
}
|
||||
|
||||
//12-01-2023 i moved this block after fillDefaults to handle if standard invoice auto bill config has been enabled, recurring invoice should override.
|
||||
if ($this->recurring_invoice->auto_bill === 'always') {
|
||||
if ($this->recurring_invoice->auto_bill == 'always') {
|
||||
$invoice->auto_bill_enabled = true;
|
||||
} elseif ($this->recurring_invoice->auto_bill === 'optout' || $this->recurring_invoice->auto_bill === 'optin') {
|
||||
} elseif ($this->recurring_invoice->auto_bill === 'off') {
|
||||
$invoice->saveQuietly();
|
||||
} elseif ($this->recurring_invoice->auto_bill == 'optout' || $this->recurring_invoice->auto_bill == 'optin') {
|
||||
} elseif ($this->recurring_invoice->auto_bill == 'off') {
|
||||
$invoice->auto_bill_enabled = false;
|
||||
$invoice->saveQuietly();
|
||||
}
|
||||
|
||||
$invoice = $this->createRecurringInvitations($invoice);
|
||||
@ -111,7 +113,16 @@ class SendRecurring implements ShouldQueue
|
||||
|
||||
event('eloquent.created: App\Models\Invoice', $invoice);
|
||||
|
||||
if ($invoice->client->getSetting('auto_email_invoice')) {
|
||||
//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}");
|
||||
AutoBill::dispatch($invoice->id, $this->db)->delay(rand(1, 2));
|
||||
}
|
||||
elseif ($invoice->auto_bill_enabled && $invoice->client->getSetting('auto_bill_date') == 'on_due_date' && $invoice->client->getSetting('auto_email_invoice') && ($invoice->due_date && Carbon::parse($invoice->due_date)->startOfDay()->lte(now()->startOfDay()))) {
|
||||
nlog("attempting to autobill {$invoice->number}");
|
||||
AutoBill::dispatch($invoice->id, $this->db)->delay(rand(1, 2));
|
||||
}
|
||||
elseif ($invoice->client->getSetting('auto_email_invoice')) {
|
||||
//Admin notification for recurring invoice sent.
|
||||
if ($invoice->invitations->count() >= 1) {
|
||||
$invoice->entityEmailEvent($invoice->invitations->first(), 'invoice', 'email_template_invoice');
|
||||
@ -130,16 +141,7 @@ class SendRecurring implements ShouldQueue
|
||||
});
|
||||
}
|
||||
|
||||
//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}");
|
||||
AutoBill::dispatch($invoice->id, $this->db)->delay(rand(1, 2));
|
||||
} 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}");
|
||||
AutoBill::dispatch($invoice->id, $this->db)->delay(rand(1, 2));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user