From d8e3aadd114772c46effb293e0d2d77921684033 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 21 Jan 2018 21:12:49 +0200 Subject: [PATCH] Working on reports --- app/Ninja/Presenters/InvoiceItemPresenter.php | 14 ++++++++++++++ app/Ninja/Presenters/InvoicePresenter.php | 8 ++++++++ app/Ninja/Reports/ProductReport.php | 14 ++++++++++++++ app/Ninja/Reports/TaxRateReport.php | 8 ++++++-- resources/lang/en/texts.php | 2 ++ 5 files changed, 44 insertions(+), 2 deletions(-) diff --git a/app/Ninja/Presenters/InvoiceItemPresenter.php b/app/Ninja/Presenters/InvoiceItemPresenter.php index 0411df7a5b32..1e436cbbaa4a 100644 --- a/app/Ninja/Presenters/InvoiceItemPresenter.php +++ b/app/Ninja/Presenters/InvoiceItemPresenter.php @@ -22,4 +22,18 @@ class InvoiceItemPresenter extends EntityPresenter { return Str::limit($this->entity->notes); } + + public function tax1() + { + $item = $this->entity; + + return $item->tax_name1 . ' ' . $item->tax_rate1 . '%'; + } + + public function tax2() + { + $item = $this->entity; + + return $item->tax_name2 . ' ' . $item->tax_rate2 . '%'; + } } diff --git a/app/Ninja/Presenters/InvoicePresenter.php b/app/Ninja/Presenters/InvoicePresenter.php index d39f8464d6c0..99236c88c24a 100644 --- a/app/Ninja/Presenters/InvoicePresenter.php +++ b/app/Ninja/Presenters/InvoicePresenter.php @@ -38,6 +38,14 @@ class InvoicePresenter extends EntityPresenter return $account->formatMoney($invoice->balance, $invoice->client); } + public function paid() + { + $invoice = $this->entity; + $account = $invoice->account; + + return $account->formatMoney($invoice->amount - $invoice->balance, $invoice->client); + } + public function partial() { $invoice = $this->entity; diff --git a/app/Ninja/Reports/ProductReport.php b/app/Ninja/Reports/ProductReport.php index 2d08e114cff8..da6ea7e8deec 100644 --- a/app/Ninja/Reports/ProductReport.php +++ b/app/Ninja/Reports/ProductReport.php @@ -24,6 +24,13 @@ class ProductReport extends AbstractReport $account = auth()->user()->account; + if ($account->invoice_item_taxes) { + $columns['tax'] = ['columnSelector-false']; + if ($account->enable_second_tax_rate) { + $columns['tax'] = ['columnSelector-false']; + } + } + if ($account->custom_invoice_item_label1) { $columns[$account->custom_invoice_item_label1] = ['columnSelector-false', 'custom']; } @@ -65,6 +72,13 @@ class ProductReport extends AbstractReport Utils::roundSignificant($item->cost, 2), ]; + if ($account->invoice_item_taxes) { + $row[] = $item->present()->tax1; + if ($account->enable_second_tax_rate) { + $row[] = $item->present()->tax2; + } + } + if ($account->custom_invoice_item_label1) { $row[] = $item->custom_value1; } diff --git a/app/Ninja/Reports/TaxRateReport.php b/app/Ninja/Reports/TaxRateReport.php index 91b39b7bc43f..ff1d05a56599 100644 --- a/app/Ninja/Reports/TaxRateReport.php +++ b/app/Ninja/Reports/TaxRateReport.php @@ -14,8 +14,10 @@ class TaxRateReport extends AbstractReport 'invoice', 'tax_name', 'tax_rate', - 'amount', - 'paid', + 'tax_amount', + 'tax_paid', + 'invoice_amount' => ['columnSelector-false'], + 'payment_amount' => ['columnSelector-false'], ]; } @@ -77,6 +79,8 @@ class TaxRateReport extends AbstractReport $tax['rate'] . '%', $account->formatMoney($tax['amount'], $client), $account->formatMoney($tax['paid'], $client), + $invoice->present()->amount, + $invoice->present()->paid, ]; $this->addToTotals($client->currency_id, 'amount', $tax['amount']); diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 38b8edc2e5c7..eb02e1339ad6 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2655,6 +2655,8 @@ $LANG = array( 'client_information' => 'Client Information', 'updated_client_details' => 'Successfully updated client details', 'auto' => 'Auto', + 'tax_amount' => 'Tax Amount', + 'tax_paid' => 'Tax Paid', );