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,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;
}
}

View File

@ -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;
}

View File

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