This commit is contained in:
denisdulici 2019-01-10 12:19:21 +03:00
parent ef86989367
commit bc86edf4a6
5 changed files with 66 additions and 69 deletions

View File

@ -157,27 +157,26 @@ class ExpenseSummary extends Controller
private function setAmount(&$graph, &$totals, &$expenses, $items, $type, $date_field) private function setAmount(&$graph, &$totals, &$expenses, $items, $type, $date_field)
{ {
foreach ($items as $item) { foreach ($items as $item) {
switch ($item->getTable()) { if ($item->getTable() == 'bill_payments') {
case 'bill_payments': $bill = $item->bill;
$bill = $item->bill;
if ($vendors = request('vendors')) { if ($vendors = request('vendors')) {
if (!in_array($bill->vendor_id, $vendors)) { if (!in_array($bill->vendor_id, $vendors)) {
continue; 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'); $month = Date::parse($item->$date_field)->format('F');

View File

@ -202,45 +202,44 @@ class IncomeExpenseSummary extends Controller
private function setAmount(&$graph, &$totals, &$compares, $items, $type, $date_field) private function setAmount(&$graph, &$totals, &$compares, $items, $type, $date_field)
{ {
foreach ($items as $item) { 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; $type_item = $item->$type;
$item->category_id = $type_item->category_id; $item->category_id = $type_item->category_id;
} }
switch ($item->getTable()) { if ($item->getTable() == 'invoice_payments') {
case 'invoice_payments': $invoice = $item->invoice;
$invoice = $item->invoice;
if ($customers = request('customers')) { if ($customers = request('customers')) {
if (!in_array($invoice->customer_id, $customers)) { if (!in_array($invoice->customer_id, $customers)) {
continue; 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'); $month = Date::parse($item->$date_field)->format('F');

View File

@ -157,27 +157,26 @@ class IncomeSummary extends Controller
private function setAmount(&$graph, &$totals, &$incomes, $items, $type, $date_field) private function setAmount(&$graph, &$totals, &$incomes, $items, $type, $date_field)
{ {
foreach ($items as $item) { foreach ($items as $item) {
switch ($item->getTable()) { if ($item->getTable() == 'invoice_payments') {
case 'invoice_payments': $invoice = $item->invoice;
$invoice = $item->invoice;
if ($customers = request('customers')) { if ($customers = request('customers')) {
if (!in_array($invoice->customer_id, $customers)) { if (!in_array($invoice->customer_id, $customers)) {
continue; 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'); $month = Date::parse($item->$date_field)->format('F');

View File

@ -174,7 +174,7 @@ class ProfitLoss extends Controller
private function setAmount(&$totals, &$compares, $items, $type, $date_field) private function setAmount(&$totals, &$compares, $items, $type, $date_field)
{ {
foreach ($items as $item) { 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; $type_item = $item->$type;
$item->category_id = $type_item->category_id; $item->category_id = $type_item->category_id;

View File

@ -120,7 +120,7 @@ class TaxSummary extends Controller
private function setAmount(&$items, &$totals, $rows, $type, $date_field) private function setAmount(&$items, &$totals, $rows, $type, $date_field)
{ {
foreach ($rows as $row) { 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; $type_row = $row->$type;
$row->category_id = $type_row->category_id; $row->category_id = $type_row->category_id;