mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Fix for invoice report totals
This commit is contained in:
parent
1d3efda4ea
commit
13fbb880e1
@ -299,7 +299,7 @@ class ReportController extends BaseController
|
|||||||
$account->formatMoney($tax['paid'], $client)
|
$account->formatMoney($tax['paid'], $client)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$reportTotals = $this->addToTotals($reportTotals, $client->currency_id, 'amount', $tax['amount']);
|
$reportTotals = $this->addToTotals($reportTotals, $client->currency_id, 'amount', $tax['amount']);
|
||||||
$reportTotals = $this->addToTotals($reportTotals, $client->currency_id, 'paid', $tax['paid']);
|
$reportTotals = $this->addToTotals($reportTotals, $client->currency_id, 'paid', $tax['paid']);
|
||||||
}
|
}
|
||||||
@ -320,7 +320,7 @@ class ReportController extends BaseController
|
|||||||
$account = Auth::user()->account;
|
$account = Auth::user()->account;
|
||||||
$displayData = [];
|
$displayData = [];
|
||||||
$reportTotals = [];
|
$reportTotals = [];
|
||||||
|
|
||||||
$payments = Payment::scope()
|
$payments = Payment::scope()
|
||||||
->withTrashed()
|
->withTrashed()
|
||||||
->where('is_deleted', '=', false)
|
->where('is_deleted', '=', false)
|
||||||
@ -350,7 +350,7 @@ class ReportController extends BaseController
|
|||||||
$reportTotals = $this->addToTotals($reportTotals, $client->currency_id, 'amount', $invoice->amount);
|
$reportTotals = $this->addToTotals($reportTotals, $client->currency_id, 'amount', $invoice->amount);
|
||||||
$reportTotals = $this->addToTotals($reportTotals, $client->currency_id, 'paid', $payment->amount);
|
$reportTotals = $this->addToTotals($reportTotals, $client->currency_id, 'paid', $payment->amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'columns' => $columns,
|
'columns' => $columns,
|
||||||
'displayData' => $displayData,
|
'displayData' => $displayData,
|
||||||
@ -361,11 +361,11 @@ class ReportController extends BaseController
|
|||||||
private function generateInvoiceReport($startDate, $endDate, $isExport)
|
private function generateInvoiceReport($startDate, $endDate, $isExport)
|
||||||
{
|
{
|
||||||
$columns = ['client', 'invoice_number', 'invoice_date', 'amount', 'payment_date', 'paid', 'method'];
|
$columns = ['client', 'invoice_number', 'invoice_date', 'amount', 'payment_date', 'paid', 'method'];
|
||||||
|
|
||||||
$account = Auth::user()->account;
|
$account = Auth::user()->account;
|
||||||
$displayData = [];
|
$displayData = [];
|
||||||
$reportTotals = [];
|
$reportTotals = [];
|
||||||
|
|
||||||
$clients = Client::scope()
|
$clients = Client::scope()
|
||||||
->withTrashed()
|
->withTrashed()
|
||||||
->with('contacts')
|
->with('contacts')
|
||||||
@ -383,10 +383,10 @@ class ReportController extends BaseController
|
|||||||
}, 'invoice_items'])
|
}, 'invoice_items'])
|
||||||
->withTrashed();
|
->withTrashed();
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
foreach ($clients->get() as $client) {
|
foreach ($clients->get() as $client) {
|
||||||
foreach ($client->invoices as $invoice) {
|
foreach ($client->invoices as $invoice) {
|
||||||
|
|
||||||
$payments = count($invoice->payments) ? $invoice->payments : [false];
|
$payments = count($invoice->payments) ? $invoice->payments : [false];
|
||||||
foreach ($payments as $payment) {
|
foreach ($payments as $payment) {
|
||||||
$displayData[] = [
|
$displayData[] = [
|
||||||
@ -397,10 +397,8 @@ class ReportController extends BaseController
|
|||||||
$payment ? $payment->present()->payment_date : '',
|
$payment ? $payment->present()->payment_date : '',
|
||||||
$payment ? $account->formatMoney($payment->amount, $client) : '',
|
$payment ? $account->formatMoney($payment->amount, $client) : '',
|
||||||
$payment ? $payment->present()->method : '',
|
$payment ? $payment->present()->method : '',
|
||||||
];
|
];
|
||||||
if ($payment) {
|
$reportTotals = $this->addToTotals($reportTotals, $client->currency_id, 'paid', $payment ? $payment->amount : 0);
|
||||||
$reportTotals = $this->addToTotals($reportTotals, $client->currency_id, 'paid', $payment->amount);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$reportTotals = $this->addToTotals($reportTotals, $client->currency_id, 'amount', $invoice->amount);
|
$reportTotals = $this->addToTotals($reportTotals, $client->currency_id, 'amount', $invoice->amount);
|
||||||
@ -491,7 +489,7 @@ class ReportController extends BaseController
|
|||||||
|
|
||||||
$reportTotals = $this->addToTotals($reportTotals, $expense->expense_currency_id, 'amount', $amount);
|
$reportTotals = $this->addToTotals($reportTotals, $expense->expense_currency_id, 'amount', $amount);
|
||||||
$reportTotals = $this->addToTotals($reportTotals, $expense->invoice_currency_id, 'amount', 0);
|
$reportTotals = $this->addToTotals($reportTotals, $expense->invoice_currency_id, 'amount', 0);
|
||||||
|
|
||||||
$reportTotals = $this->addToTotals($reportTotals, $expense->invoice_currency_id, 'invoiced', $invoiced);
|
$reportTotals = $this->addToTotals($reportTotals, $expense->invoice_currency_id, 'invoiced', $invoiced);
|
||||||
$reportTotals = $this->addToTotals($reportTotals, $expense->expense_currency_id, 'invoiced', 0);
|
$reportTotals = $this->addToTotals($reportTotals, $expense->expense_currency_id, 'invoiced', 0);
|
||||||
}
|
}
|
||||||
@ -518,14 +516,14 @@ class ReportController extends BaseController
|
|||||||
private function export($reportType, $data, $columns, $totals)
|
private function export($reportType, $data, $columns, $totals)
|
||||||
{
|
{
|
||||||
$output = fopen('php://output', 'w') or Utils::fatalError();
|
$output = fopen('php://output', 'w') or Utils::fatalError();
|
||||||
$reportType = trans("texts.{$reportType}s");
|
$reportType = trans("texts.{$reportType}s");
|
||||||
$date = date('Y-m-d');
|
$date = date('Y-m-d');
|
||||||
|
|
||||||
header('Content-Type:application/csv');
|
header('Content-Type:application/csv');
|
||||||
header("Content-Disposition:attachment;filename={$date}_Ninja_{$reportType}.csv");
|
header("Content-Disposition:attachment;filename={$date}_Ninja_{$reportType}.csv");
|
||||||
|
|
||||||
Utils::exportData($output, $data, Utils::trans($columns));
|
Utils::exportData($output, $data, Utils::trans($columns));
|
||||||
|
|
||||||
fwrite($output, trans('texts.totals'));
|
fwrite($output, trans('texts.totals'));
|
||||||
foreach ($totals as $currencyId => $fields) {
|
foreach ($totals as $currencyId => $fields) {
|
||||||
foreach ($fields as $key => $value) {
|
foreach ($fields as $key => $value) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user