diff --git a/app/Services/Invoice/ApplyPayment.php b/app/Services/Invoice/ApplyPayment.php index b606002084fd..dda5d1fcce6e 100644 --- a/app/Services/Invoice/ApplyPayment.php +++ b/app/Services/Invoice/ApplyPayment.php @@ -62,8 +62,8 @@ class ApplyPayment extends AbstractService $this->invoice->service()->clearPartial()->setStatus(Invoice::STATUS_PARTIAL)->updateBalance($this->payment_amount*-1); } - $this->invoice->service()->applyNumber->save(); - + $this->invoice->service()->applyNumber()->save(); + return $this->invoice; } } diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index ad5567fc0a56..589f6a3e24c7 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -139,8 +139,13 @@ class InvoiceService /* One liners */ public function setDueDate() { - $this->invoice->due_date = Carbon::now()->addDays($this->invoice->client->getSetting('payment_terms')); + if($this->invoice->due_date != '') + return $this; + //$this->invoice->due_date = Carbon::now()->addDays($this->invoice->client->getSetting('payment_terms')); + + $this->invoice->due_date = Carbon::parse($this->invoice->date)->addDays($this->invoice->client->getSetting('payment_terms')); + return $this; } diff --git a/app/Services/Invoice/MarkSent.php b/app/Services/Invoice/MarkSent.php index 994344bcb4b8..f31175598b08 100644 --- a/app/Services/Invoice/MarkSent.php +++ b/app/Services/Invoice/MarkSent.php @@ -45,6 +45,7 @@ class MarkSent extends AbstractService ->service() ->setStatus(Invoice::STATUS_SENT) ->applyNumber() + ->setDueDate() ->save(); $this->client->service()->updateBalance($this->invoice->balance)->save();