This commit is contained in:
denisdulici 2018-11-29 12:05:12 +03:00
parent b722dee962
commit c1a5b26e2c
3 changed files with 26 additions and 23 deletions

View File

@ -150,9 +150,10 @@ class ExpenseSummary extends Controller
break; break;
} }
$date = Date::parse($item->$date_field)->format('F'); $month = Date::parse($item->$date_field)->format('F');
$month_year = Date::parse($item->$date_field)->format('F-Y');
if (!isset($expenses[$item->category_id])) { if (!isset($expenses[$item->category_id]) || !isset($expenses[$item->category_id][$month]) || !isset($graph[$month_year])) {
continue; continue;
} }
@ -165,13 +166,13 @@ class ExpenseSummary extends Controller
} }
} }
$expenses[$item->category_id][$date]['amount'] += $amount; $expenses[$item->category_id][$month]['amount'] += $amount;
$expenses[$item->category_id][$date]['currency_code'] = $item->currency_code; $expenses[$item->category_id][$month]['currency_code'] = $item->currency_code;
$expenses[$item->category_id][$date]['currency_rate'] = $item->currency_rate; $expenses[$item->category_id][$month]['currency_rate'] = $item->currency_rate;
$graph[Date::parse($item->$date_field)->format('F-Y')] += $amount; $graph[$month_year] += $amount;
$totals[$date]['amount'] += $amount; $totals[$month]['amount'] += $amount;
} }
} }
} }

View File

@ -209,11 +209,12 @@ class IncomeExpenseSummary extends Controller
break; break;
} }
$date = Date::parse($item->$date_field)->format('F'); $month = Date::parse($item->$date_field)->format('F');
$month_year = Date::parse($item->$date_field)->format('F-Y');
$group = (($type == 'invoice') || ($type == 'revenue')) ? 'income' : 'expense'; $group = (($type == 'invoice') || ($type == 'revenue')) ? 'income' : 'expense';
if (!isset($compares[$group][$item->category_id])) { if (!isset($compares[$group][$item->category_id]) || !isset($compares[$group][$item->category_id][$month]) || !isset($graph[$month_year])) {
continue; continue;
} }
@ -226,18 +227,18 @@ class IncomeExpenseSummary extends Controller
} }
} }
$compares[$group][$item->category_id][$date]['amount'] += $amount; $compares[$group][$item->category_id][$month]['amount'] += $amount;
$compares[$group][$item->category_id][$date]['currency_code'] = $item->currency_code; $compares[$group][$item->category_id][$month]['currency_code'] = $item->currency_code;
$compares[$group][$item->category_id][$date]['currency_rate'] = $item->currency_rate; $compares[$group][$item->category_id][$month]['currency_rate'] = $item->currency_rate;
if ($group == 'income') { if ($group == 'income') {
$graph[Date::parse($item->$date_field)->format('F-Y')] += $amount; $graph[$month_year] += $amount;
$totals[$date]['amount'] += $amount; $totals[$month]['amount'] += $amount;
} else { } else {
$graph[Date::parse($item->$date_field)->format('F-Y')] -= $amount; $graph[$month_year] -= $amount;
$totals[$date]['amount'] -= $amount; $totals[$month]['amount'] -= $amount;
} }
} }
} }

View File

@ -150,9 +150,10 @@ class IncomeSummary extends Controller
break; break;
} }
$date = Date::parse($item->$date_field)->format('F'); $month = Date::parse($item->$date_field)->format('F');
$month_year = Date::parse($item->$date_field)->format('F-Y');
if (!isset($incomes[$item->category_id])) { if (!isset($incomes[$item->category_id]) || !isset($incomes[$item->category_id][$month]) || !isset($graph[$month_year])) {
continue; continue;
} }
@ -165,13 +166,13 @@ class IncomeSummary extends Controller
} }
} }
$incomes[$item->category_id][$date]['amount'] += $amount; $incomes[$item->category_id][$month]['amount'] += $amount;
$incomes[$item->category_id][$date]['currency_code'] = $item->currency_code; $incomes[$item->category_id][$month]['currency_code'] = $item->currency_code;
$incomes[$item->category_id][$date]['currency_rate'] = $item->currency_rate; $incomes[$item->category_id][$month]['currency_rate'] = $item->currency_rate;
$graph[Date::parse($item->$date_field)->format('F-Y')] += $amount; $graph[$month_year] += $amount;
$totals[$date]['amount'] += $amount; $totals[$month]['amount'] += $amount;
} }
} }
} }