Set recurring due date using account payment terms

This commit is contained in:
Hillel Coren 2017-02-01 13:20:14 +02:00
parent e6588ac3b2
commit 1737af10c4

View File

@ -1030,14 +1030,20 @@ class Invoice extends EntityModel implements BalanceAffecting
if($dueDate) { if($dueDate) {
return date('Y-m-d', $dueDate);// SQL format return date('Y-m-d', $dueDate);// SQL format
} }
} } elseif ($this->client->payment_terms != 0) {
else if ($this->client->payment_terms != 0) {
// No custom due date set for this invoice; use the client's payment terms // No custom due date set for this invoice; use the client's payment terms
$days = $this->client->payment_terms; $days = $this->client->payment_terms;
if ($days == -1) { if ($days == -1) {
$days = 0; $days = 0;
} }
return date('Y-m-d', strtotime('+'.$days.' day', $now)); 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));
} }
} }