Fix payment report with partial payments

This commit is contained in:
Hillel Coren 2017-10-17 14:15:34 +03:00
parent ac5cd8a806
commit 79532ce2f6

View File

@ -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());
}
}