1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Pseudo code for auto-pausing recurring invoices

This commit is contained in:
David Bomba 2021-10-20 18:07:33 +11:00
parent 121c9d2cfd
commit f878dc5cd4
2 changed files with 34 additions and 0 deletions

View File

@ -110,6 +110,16 @@ class SendRecurring implements ShouldQueue
$this->recurring_invoice->save();
/*
if ($this->recurring_invoice->company->pause_recurring_until_paid){
$this->recurring_invoice->service()
->stop();
}
*/
//Admin notification for recurring invoice sent.
if ($invoice->invitations->count() >= 1 ) {
$invoice->entityEmailEvent($invoice->invitations->first(), 'invoice', 'email_template_invoice');

View File

@ -483,6 +483,30 @@ class InvoiceService
}
/*
//if paid invoice is attached to a recurring invoice - check if we need to unpause the recurring invoice
if ($this->invoice->status_id == Invoice::STATUS_PAID &&
$this->invoice->recurring_id &&
$this->invoice->company->pause_recurring_until_paid &&
($this->invoice->recurring_invoice->status_id != RecurringInvoice::STATUS_ACTIVE || $this->invoice->recurring_invoice->status_id != RecurringInvoice::STATUS_COMPLETED))
{
$recurring_invoice = $this->invoice->recurring_invoice;
// Check next_send_date if it is in the past - calculate
$next_send_date = Carbon::parse($recurring_invoice->next_send_date)->startOfDay();
if(next_send_date->lt(now())){
$recurring_invoice->next_send_date = $recurring_invoice->nextDateByFrequency(now()->format('Y-m-d'));
$recurring_invoice->save();
}
// Start the recurring invoice
$recurring_invoice->service()
->start();
}
*/
return $this;
}