From 1737af10c41e0fb525ecf1702fd63911646ca0d1 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 1 Feb 2017 13:20:14 +0200 Subject: [PATCH] Set recurring due date using account payment terms --- app/Models/Invoice.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 0a56fe6ca753..e58afced97fd 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -1030,14 +1030,20 @@ class Invoice extends EntityModel implements BalanceAffecting if($dueDate) { return date('Y-m-d', $dueDate);// SQL format } - } - else if ($this->client->payment_terms != 0) { + } elseif ($this->client->payment_terms != 0) { // No custom due date set for this invoice; use the client's payment terms $days = $this->client->payment_terms; if ($days == -1) { $days = 0; } return date('Y-m-d', strtotime('+'.$days.' day', $now)); + } elseif ($this->account->payment_terms != 0) { + // No custom due date set for this invoice; use the client's payment terms + $days = $this->account->payment_terms; + if ($days == -1) { + $days = 0; + } + return date('Y-m-d', strtotime('+'.$days.' day', $now)); } }