From 79532ce2f69d134870f4ea4e004e13e6dac4e3fd Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 17 Oct 2017 14:15:34 +0300 Subject: [PATCH] Fix payment report with partial payments --- app/Ninja/Reports/PaymentReport.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Ninja/Reports/PaymentReport.php b/app/Ninja/Reports/PaymentReport.php index d448646ab989..f3589ca00360 100644 --- a/app/Ninja/Reports/PaymentReport.php +++ b/app/Ninja/Reports/PaymentReport.php @@ -20,6 +20,7 @@ class PaymentReport extends AbstractReport public function run() { $account = Auth::user()->account; + $invoiceMap = []; $payments = Payment::scope() ->orderBy('payment_date', 'desc') @@ -48,7 +49,11 @@ class PaymentReport extends AbstractReport $payment->present()->method, ]; - $this->addToTotals($client->currency_id, 'amount', $invoice->amount); + if (! isset($invoiceMap[$invoice->id])) { + $this->addToTotals($client->currency_id, 'amount', $invoice->amount); + $invoiceMap[$invoice->id] = true; + } + $this->addToTotals($client->currency_id, 'paid', $payment->getCompletedAmount()); } }