Set due date when invoice is marked as sent

This commit is contained in:
David Bomba 2020-05-28 14:18:34 +10:00
parent 0485ffe912
commit b28cdd488b
3 changed files with 9 additions and 3 deletions

View File

@ -62,7 +62,7 @@ class ApplyPayment extends AbstractService
$this->invoice->service()->clearPartial()->setStatus(Invoice::STATUS_PARTIAL)->updateBalance($this->payment_amount*-1); $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; return $this->invoice;
} }

View File

@ -139,7 +139,12 @@ class InvoiceService
/* One liners */ /* One liners */
public function setDueDate() 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; return $this;
} }

View File

@ -45,6 +45,7 @@ class MarkSent extends AbstractService
->service() ->service()
->setStatus(Invoice::STATUS_SENT) ->setStatus(Invoice::STATUS_SENT)
->applyNumber() ->applyNumber()
->setDueDate()
->save(); ->save();
$this->client->service()->updateBalance($this->invoice->balance)->save(); $this->client->service()->updateBalance($this->invoice->balance)->save();