From 99920389b419201c5980784bed409fa9b60805bc Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 14 Oct 2020 11:11:24 +1100 Subject: [PATCH] Credit payments --- app/Services/Credit/ApplyPayment.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Services/Credit/ApplyPayment.php b/app/Services/Credit/ApplyPayment.php index a85ff9853475..e9a5665e5f39 100644 --- a/app/Services/Credit/ApplyPayment.php +++ b/app/Services/Credit/ApplyPayment.php @@ -74,6 +74,8 @@ class ApplyPayment } + $this->applyPaymentToCredit(); + $this->addPaymentToLedger(); return $this->credit; @@ -90,7 +92,7 @@ class ApplyPayment $credit_item->quantity = 1; $credit_item->cost = $this->amount_applied * -1; - $credit_items = $credit->line_items; + $credit_items = $this->credit->line_items; $credit_items[] = $credit_item; $this->credit->line_items = $credit_items; @@ -141,8 +143,10 @@ class ApplyPayment event(new InvoiceWasUpdated($this->invoice, $this->invoice->company, Ninja::eventVars())); - if((int)$this->invoice->balance == 0) + if((int)$this->invoice->balance == 0){ + $this->invoice->service()->deletePdf(); event(new InvoiceWasPaid($this->invoice, $this->payment->company, Ninja::eventVars())); + } } }