From bc86edf4a66fc770b78ee37767ab7b0e5173199d Mon Sep 17 00:00:00 2001 From: denisdulici Date: Thu, 10 Jan 2019 12:19:21 +0300 Subject: [PATCH] fixed #719 --- .../Controllers/Reports/ExpenseSummary.php | 35 ++++++----- .../Reports/IncomeExpenseSummary.php | 61 +++++++++---------- .../Controllers/Reports/IncomeSummary.php | 35 ++++++----- app/Http/Controllers/Reports/ProfitLoss.php | 2 +- app/Http/Controllers/Reports/TaxSummary.php | 2 +- 5 files changed, 66 insertions(+), 69 deletions(-) diff --git a/app/Http/Controllers/Reports/ExpenseSummary.php b/app/Http/Controllers/Reports/ExpenseSummary.php index 58efbe357..1c4e617a8 100644 --- a/app/Http/Controllers/Reports/ExpenseSummary.php +++ b/app/Http/Controllers/Reports/ExpenseSummary.php @@ -157,27 +157,26 @@ class ExpenseSummary extends Controller private function setAmount(&$graph, &$totals, &$expenses, $items, $type, $date_field) { foreach ($items as $item) { - switch ($item->getTable()) { - case 'bill_payments': - $bill = $item->bill; + if ($item->getTable() == 'bill_payments') { + $bill = $item->bill; - if ($vendors = request('vendors')) { - if (!in_array($bill->vendor_id, $vendors)) { - continue; + if ($vendors = request('vendors')) { + if (!in_array($bill->vendor_id, $vendors)) { + continue; + } + } + + $item->category_id = $bill->category_id; + } + + if ($item->getTable() == 'bills') { + if ($accounts = request('accounts')) { + foreach ($item->payments as $payment) { + if (!in_array($payment->account_id, $accounts)) { + continue 2; } } - - $item->category_id = $bill->category_id; - break; - case 'bills': - if ($accounts = request('accounts')) { - foreach ($item->payments as $payment) { - if (!in_array($payment->account_id, $accounts)) { - continue 2; - } - } - } - break; + } } $month = Date::parse($item->$date_field)->format('F'); diff --git a/app/Http/Controllers/Reports/IncomeExpenseSummary.php b/app/Http/Controllers/Reports/IncomeExpenseSummary.php index 04f819529..9cf41dca4 100644 --- a/app/Http/Controllers/Reports/IncomeExpenseSummary.php +++ b/app/Http/Controllers/Reports/IncomeExpenseSummary.php @@ -202,45 +202,44 @@ class IncomeExpenseSummary extends Controller private function setAmount(&$graph, &$totals, &$compares, $items, $type, $date_field) { foreach ($items as $item) { - if ($item->getTable() == 'bill_payments' || $item->getTable() == 'invoice_payments') { + if (($item->getTable() == 'bill_payments') || ($item->getTable() == 'invoice_payments')) { $type_item = $item->$type; $item->category_id = $type_item->category_id; } - switch ($item->getTable()) { - case 'invoice_payments': - $invoice = $item->invoice; + if ($item->getTable() == 'invoice_payments') { + $invoice = $item->invoice; - if ($customers = request('customers')) { - if (!in_array($invoice->customer_id, $customers)) { - continue; + if ($customers = request('customers')) { + if (!in_array($invoice->customer_id, $customers)) { + continue; + } + } + + $item->category_id = $invoice->category_id; + } + + if ($item->getTable() == 'bill_payments') { + $bill = $item->bill; + + if ($vendors = request('vendors')) { + if (!in_array($bill->vendor_id, $vendors)) { + continue; + } + } + + $item->category_id = $bill->category_id; + } + + if (($item->getTable() == 'invoices') || ($item->getTable() == 'bills')) { + if ($accounts = request('accounts')) { + foreach ($item->payments as $payment) { + if (!in_array($payment->account_id, $accounts)) { + continue 2; } } - - $item->category_id = $invoice->category_id; - break; - case 'bill_payments': - $bill = $item->bill; - - if ($vendors = request('vendors')) { - if (!in_array($bill->vendor_id, $vendors)) { - continue; - } - } - - $item->category_id = $bill->category_id; - break; - case 'invoices': - case 'bills': - if ($accounts = request('accounts')) { - foreach ($item->payments as $payment) { - if (!in_array($payment->account_id, $accounts)) { - continue 2; - } - } - } - break; + } } $month = Date::parse($item->$date_field)->format('F'); diff --git a/app/Http/Controllers/Reports/IncomeSummary.php b/app/Http/Controllers/Reports/IncomeSummary.php index dc8ac3118..648087b0c 100644 --- a/app/Http/Controllers/Reports/IncomeSummary.php +++ b/app/Http/Controllers/Reports/IncomeSummary.php @@ -157,27 +157,26 @@ class IncomeSummary extends Controller private function setAmount(&$graph, &$totals, &$incomes, $items, $type, $date_field) { foreach ($items as $item) { - switch ($item->getTable()) { - case 'invoice_payments': - $invoice = $item->invoice; + if ($item->getTable() == 'invoice_payments') { + $invoice = $item->invoice; - if ($customers = request('customers')) { - if (!in_array($invoice->customer_id, $customers)) { - continue; + if ($customers = request('customers')) { + if (!in_array($invoice->customer_id, $customers)) { + continue; + } + } + + $item->category_id = $invoice->category_id; + } + + if ($item->getTable() == 'invoices') { + if ($accounts = request('accounts')) { + foreach ($item->payments as $payment) { + if (!in_array($payment->account_id, $accounts)) { + continue 2; } } - - $item->category_id = $invoice->category_id; - break; - case 'invoices': - if ($accounts = request('accounts')) { - foreach ($item->payments as $payment) { - if (!in_array($payment->account_id, $accounts)) { - continue 2; - } - } - } - break; + } } $month = Date::parse($item->$date_field)->format('F'); diff --git a/app/Http/Controllers/Reports/ProfitLoss.php b/app/Http/Controllers/Reports/ProfitLoss.php index a72d3c088..8bcc9e771 100644 --- a/app/Http/Controllers/Reports/ProfitLoss.php +++ b/app/Http/Controllers/Reports/ProfitLoss.php @@ -174,7 +174,7 @@ class ProfitLoss extends Controller private function setAmount(&$totals, &$compares, $items, $type, $date_field) { foreach ($items as $item) { - if (($item['table'] == 'bill_payments') || ($item['table'] == 'invoice_payments')) { + if (($item->getTable() == 'bill_payments') || ($item->getTable() == 'invoice_payments')) { $type_item = $item->$type; $item->category_id = $type_item->category_id; diff --git a/app/Http/Controllers/Reports/TaxSummary.php b/app/Http/Controllers/Reports/TaxSummary.php index f478534d2..fd8304d6d 100644 --- a/app/Http/Controllers/Reports/TaxSummary.php +++ b/app/Http/Controllers/Reports/TaxSummary.php @@ -120,7 +120,7 @@ class TaxSummary extends Controller private function setAmount(&$items, &$totals, $rows, $type, $date_field) { foreach ($rows as $row) { - if ($row->getTable() == 'bill_payments' || $row->getTable() == 'invoice_payments') { + if (($row->getTable() == 'bill_payments') || ($row->getTable() == 'invoice_payments')) { $type_row = $row->$type; $row->category_id = $type_row->category_id;