Added credit report

This commit is contained in:
Hillel Coren 2018-01-24 20:34:14 +02:00
parent 1e0c46d9ba
commit 770906969d
3 changed files with 8 additions and 5 deletions

View File

@ -34,6 +34,7 @@ class ExpenseReport extends AbstractReport
$account = Auth::user()->account; $account = Auth::user()->account;
$exportFormat = $this->options['export_format']; $exportFormat = $this->options['export_format'];
$with = ['client.contacts', 'vendor']; $with = ['client.contacts', 'vendor'];
$hasTaxRates = TaxRate::scope()->count();
if ($exportFormat == 'zip') { if ($exportFormat == 'zip') {
$with[] = ['documents']; $with[] = ['documents'];
@ -73,7 +74,7 @@ class ExpenseReport extends AbstractReport
$expense->private_notes, $expense->private_notes,
]; ];
if (TaxRate::scope()->count()) { if ($hasTaxRates) {
$row[] = $expense->present()->taxAmount; $row[] = $expense->present()->taxAmount;
} }

View File

@ -44,6 +44,7 @@ class InvoiceReport extends AbstractReport
$account = Auth::user()->account; $account = Auth::user()->account;
$statusIds = $this->options['status_ids']; $statusIds = $this->options['status_ids'];
$exportFormat = $this->options['export_format']; $exportFormat = $this->options['export_format'];
$hasTaxRates = TaxRate::scope()->count();
$clients = Client::scope() $clients = Client::scope()
->orderBy('name') ->orderBy('name')
@ -59,7 +60,7 @@ class InvoiceReport extends AbstractReport
$query->withArchived() $query->withArchived()
->excludeFailed() ->excludeFailed()
->with('payment_type', 'account_gateway.gateway'); ->with('payment_type', 'account_gateway.gateway');
}, 'invoice_items']); }, 'invoice_items', 'invoice_status']);
}]); }]);
@ -94,7 +95,7 @@ class InvoiceReport extends AbstractReport
$invoice->private_notes, $invoice->private_notes,
]; ];
if (TaxRate::scope()->count()) { if ($hasTaxRates) {
$row[] = $isFirst ? $account->formatMoney($invoice->getTaxTotal(), $client) : ''; $row[] = $isFirst ? $account->formatMoney($invoice->getTaxTotal(), $client) : '';
} }

View File

@ -41,6 +41,7 @@ class QuoteReport extends AbstractReport
$account = Auth::user()->account; $account = Auth::user()->account;
$statusIds = $this->options['status_ids']; $statusIds = $this->options['status_ids'];
$exportFormat = $this->options['export_format']; $exportFormat = $this->options['export_format'];
$hasTaxRates = TaxRate::scope()->count();
$clients = Client::scope() $clients = Client::scope()
->orderBy('name') ->orderBy('name')
@ -52,7 +53,7 @@ class QuoteReport extends AbstractReport
->statusIds($statusIds) ->statusIds($statusIds)
->where('invoice_date', '>=', $this->startDate) ->where('invoice_date', '>=', $this->startDate)
->where('invoice_date', '<=', $this->endDate) ->where('invoice_date', '<=', $this->endDate)
->with(['invoice_items']); ->with(['invoice_items', 'invoice_status']);
}]); }]);
if ($this->isExport && $exportFormat == 'zip') { if ($this->isExport && $exportFormat == 'zip') {
@ -81,7 +82,7 @@ class QuoteReport extends AbstractReport
$invoice->private_notes, $invoice->private_notes,
]; ];
if (TaxRate::scope()->count()) { if ($hasTaxRates) {
$row[] = $account->formatMoney($invoice->getTaxTotal(), $client); $row[] = $account->formatMoney($invoice->getTaxTotal(), $client);
} }