CLean up code paths for client balance

This commit is contained in:
David Bomba 2022-09-07 08:35:19 +10:00
parent 4e29459985
commit 28915d82a4
3 changed files with 3 additions and 6 deletions

View File

@ -88,7 +88,6 @@ class ApplyPayment extends AbstractService
$this->invoice $this->invoice
->client ->client
->fresh()
->service() ->service()
->updateBalance($amount_paid) ->updateBalance($amount_paid)
->save(); ->save();

View File

@ -43,7 +43,7 @@ class ApplyPaymentAmount extends AbstractService
public function run() public function run()
{ {
if ($this->invoice->status_id == Invoice::STATUS_DRAFT) { if ($this->invoice->status_id == Invoice::STATUS_DRAFT) {
$this->invoice->service()->markSent()->save(); $this->invoice = $this->invoice->service()->markSent()->save();
} }
/*Don't double pay*/ /*Don't double pay*/
@ -88,10 +88,8 @@ class ApplyPaymentAmount extends AbstractService
$this->invoice $this->invoice
->client ->client
->fresh()
->service() ->service()
->updateBalance($payment->amount * -1) ->updateBalanceAndPaidToDate($payment->amount * -1, $payment->amount)
->updatePaidToDate($payment->amount)
->save(); ->save();

View File

@ -50,7 +50,7 @@ class MarkPaid extends AbstractService
} }
if ($this->invoice->status_id == Invoice::STATUS_DRAFT) { if ($this->invoice->status_id == Invoice::STATUS_DRAFT) {
$this->invoice->service()->markSent()->save(); $this->invoice = $this->invoice->service()->markSent()->save();
} }
\DB::connection(config('database.default'))->transaction(function () { \DB::connection(config('database.default'))->transaction(function () {