From 5a31634f81bd769f71d2f774781249d3ffbdd1ea Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 4 Oct 2021 20:43:00 +1100 Subject: [PATCH] Fixes for invoice paid to date calculations on refund --- app/Services/Payment/RefundPayment.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Services/Payment/RefundPayment.php b/app/Services/Payment/RefundPayment.php index 0d10b83fa745..6d9f8a76e1eb 100644 --- a/app/Services/Payment/RefundPayment.php +++ b/app/Services/Payment/RefundPayment.php @@ -242,7 +242,8 @@ class RefundPayment $invoice->service()->updateBalance($refunded_invoice['amount'])->save(); $invoice->ledger()->updateInvoiceBalance($refunded_invoice['amount'], "Refund of payment # {$this->payment->number}")->save(); - + $invoice->paid_to_date -= $refunded_invoice['amount']; + if ($invoice->amount == $invoice->balance) { $invoice->service()->setStatus(Invoice::STATUS_SENT); } else {