From 770906969daa7c7ad4469cdb6f6af8c88914e51d Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 24 Jan 2018 20:34:14 +0200 Subject: [PATCH] Added credit report --- app/Ninja/Reports/ExpenseReport.php | 3 ++- app/Ninja/Reports/InvoiceReport.php | 5 +++-- app/Ninja/Reports/QuoteReport.php | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/Ninja/Reports/ExpenseReport.php b/app/Ninja/Reports/ExpenseReport.php index 19df675f6308..bcb69ca66b17 100644 --- a/app/Ninja/Reports/ExpenseReport.php +++ b/app/Ninja/Reports/ExpenseReport.php @@ -34,6 +34,7 @@ class ExpenseReport extends AbstractReport $account = Auth::user()->account; $exportFormat = $this->options['export_format']; $with = ['client.contacts', 'vendor']; + $hasTaxRates = TaxRate::scope()->count(); if ($exportFormat == 'zip') { $with[] = ['documents']; @@ -73,7 +74,7 @@ class ExpenseReport extends AbstractReport $expense->private_notes, ]; - if (TaxRate::scope()->count()) { + if ($hasTaxRates) { $row[] = $expense->present()->taxAmount; } diff --git a/app/Ninja/Reports/InvoiceReport.php b/app/Ninja/Reports/InvoiceReport.php index 319717f40b52..710c9ba5f0d1 100644 --- a/app/Ninja/Reports/InvoiceReport.php +++ b/app/Ninja/Reports/InvoiceReport.php @@ -44,6 +44,7 @@ class InvoiceReport extends AbstractReport $account = Auth::user()->account; $statusIds = $this->options['status_ids']; $exportFormat = $this->options['export_format']; + $hasTaxRates = TaxRate::scope()->count(); $clients = Client::scope() ->orderBy('name') @@ -59,7 +60,7 @@ class InvoiceReport extends AbstractReport $query->withArchived() ->excludeFailed() ->with('payment_type', 'account_gateway.gateway'); - }, 'invoice_items']); + }, 'invoice_items', 'invoice_status']); }]); @@ -94,7 +95,7 @@ class InvoiceReport extends AbstractReport $invoice->private_notes, ]; - if (TaxRate::scope()->count()) { + if ($hasTaxRates) { $row[] = $isFirst ? $account->formatMoney($invoice->getTaxTotal(), $client) : ''; } diff --git a/app/Ninja/Reports/QuoteReport.php b/app/Ninja/Reports/QuoteReport.php index 600d3c69ff81..9dcf8d13f16e 100644 --- a/app/Ninja/Reports/QuoteReport.php +++ b/app/Ninja/Reports/QuoteReport.php @@ -41,6 +41,7 @@ class QuoteReport extends AbstractReport $account = Auth::user()->account; $statusIds = $this->options['status_ids']; $exportFormat = $this->options['export_format']; + $hasTaxRates = TaxRate::scope()->count(); $clients = Client::scope() ->orderBy('name') @@ -52,7 +53,7 @@ class QuoteReport extends AbstractReport ->statusIds($statusIds) ->where('invoice_date', '>=', $this->startDate) ->where('invoice_date', '<=', $this->endDate) - ->with(['invoice_items']); + ->with(['invoice_items', 'invoice_status']); }]); if ($this->isExport && $exportFormat == 'zip') { @@ -81,7 +82,7 @@ class QuoteReport extends AbstractReport $invoice->private_notes, ]; - if (TaxRate::scope()->count()) { + if ($hasTaxRates) { $row[] = $account->formatMoney($invoice->getTaxTotal(), $client); }