From 89024a173b66e2a0d2092e659818330a8ca599a6 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 18 Mar 2022 12:27:27 +1100 Subject: [PATCH] Update client paid to date for full amount with overpayments --- app/Services/Payment/UpdateInvoicePayment.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Services/Payment/UpdateInvoicePayment.php b/app/Services/Payment/UpdateInvoicePayment.php index 1cbd644ad9c9..1a7529058ec7 100644 --- a/app/Services/Payment/UpdateInvoicePayment.php +++ b/app/Services/Payment/UpdateInvoicePayment.php @@ -55,6 +55,11 @@ class UpdateInvoicePayment $paid_amount = $paid_invoice->amount; } + $client + ->service() + ->updatePaidToDate($paid_amount) + ->save(); + /* Need to determine here is we have an OVER payment - if YES only apply the max invoice amount */ if($paid_amount > $invoice->partial && $paid_amount > $invoice->balance) $paid_amount = $invoice->balance; @@ -77,7 +82,6 @@ class UpdateInvoicePayment $client ->service() ->updateBalance($paid_amount * -1) - ->updatePaidToDate($paid_amount) ->save(); $pivot_invoice = $this->payment->invoices->first(function ($inv) use ($paid_invoice) {