Add payment details to invoice report
This commit is contained in:
parent
40ce28c433
commit
56ad438dd3
1 changed files with 19 additions and 13 deletions
|
|
@ -354,8 +354,8 @@ class ReportController extends BaseController
|
|||
|
||||
private function generateInvoiceReport($startDate, $endDate, $isExport)
|
||||
{
|
||||
$columns = ['client', 'invoice_number', 'invoice_date', 'amount', 'paid', 'balance'];
|
||||
|
||||
$columns = ['client', 'invoice_number', 'invoice_date', 'amount', 'payment_date', 'paid', 'method'];
|
||||
|
||||
$account = Auth::user()->account;
|
||||
$displayData = [];
|
||||
$reportTotals = [];
|
||||
|
|
@ -379,19 +379,25 @@ class ReportController extends BaseController
|
|||
}]);
|
||||
|
||||
foreach ($clients->get() as $client) {
|
||||
$currencyId = $client->currency_id ?: Auth::user()->account->getCurrencyId();
|
||||
foreach ($client->invoices as $invoice) {
|
||||
|
||||
$payments = count($invoice->payments) ? $invoice->payments : [false];
|
||||
foreach ($payments as $payment) {
|
||||
$displayData[] = [
|
||||
$isExport ? $client->getDisplayName() : $client->present()->link,
|
||||
$isExport ? $invoice->invoice_number : $invoice->present()->link,
|
||||
$invoice->present()->invoice_date,
|
||||
$account->formatMoney($invoice->amount, $client),
|
||||
$payment ? $payment->present()->payment_date : '',
|
||||
$payment ? $account->formatMoney($payment->amount, $client) : '',
|
||||
$payment ? $payment->present()->method : '',
|
||||
];
|
||||
if ($payment) {
|
||||
$reportTotals = $this->addToTotals($reportTotals, $client->currency_id, 'paid', $payment->amount);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($client->invoices as $invoice) {
|
||||
$displayData[] = [
|
||||
$isExport ? $client->getDisplayName() : $client->present()->link,
|
||||
$isExport ? $invoice->invoice_number : $invoice->present()->link,
|
||||
$invoice->present()->invoice_date,
|
||||
$account->formatMoney($invoice->amount, $client),
|
||||
$account->formatMoney($invoice->getAmountPaid(), $client),
|
||||
$account->formatMoney($invoice->balance, $client),
|
||||
];
|
||||
$reportTotals = $this->addToTotals($reportTotals, $client->currency_id, 'amount', $invoice->amount);
|
||||
$reportTotals = $this->addToTotals($reportTotals, $client->currency_id, 'paid', $invoice->getAmountPaid());
|
||||
$reportTotals = $this->addToTotals($reportTotals, $client->currency_id, 'balance', $invoice->balance);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue