Set conditionals for recurring invoices that are being restarted

This commit is contained in:
David Bomba 2022-05-17 17:47:55 +10:00
parent 14b5770a0a
commit 53b1f4911c

View File

@ -227,12 +227,21 @@ class RecurringInvoice extends BaseModel
if (!$this->next_send_date) {
return null;
}
nlog("frequency = $this->frequency_id");
nlog("frequency = $this->next_send_date");
$offset = $this->client->timezone_offset();
/* If this setting is enabled, the recurring invoice may be set in the past */
if($this->company->stop_on_unpaid_recurring) {
/* Lets set the next send date to now so we increment from today, rather than in the past*/
if(Carbon::parse($this->next_send_date)->lt(now()->subDays(3)))
$this->next_send_date = now()->format('Y-m-d');
}
/*
As we are firing at UTC+0 if our offset is negative it is technically firing the day before so we always need
to add ON a day - a day = 86400 seconds