Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Finish multi-currency budget and account report.
James Cole8b0903c32e51
diff --git a/app/Http/Controllers/Chart/BudgetReportController.php b/app/Http/Controllers/Chart/BudgetReportController.phpindex 7f22f41a12..2de4fa6ab1 100644--- a/app/Http/Controllers/Chart/BudgetReportController.php+++ b/app/Http/Controllers/Chart/BudgetReportController.php@@ -198,7 +198,7 @@ class BudgetReportController extends Controller$spentKey = sprintf('%d-spent', $currency['currency_id']);$chartData[$spentKey] = $chartData[$spentKey] ?? ['label' => sprintf(- '%s (%s)', (string)trans('firefly.spent_in_specific_budget', ['budget' => $budget['name']]), $currency['currency_name']+ '%s (%s)', (string)trans('firefly.spent_in_specific_budget', ['budget' => $budget->name]), $currency['currency_name']),'type' => 'bar','currency_symbol' => $currency['currency_symbol'],diff --git a/app/Http/Controllers/Chart/CategoryReportController.php b/app/Http/Controllers/Chart/CategoryReportController.phpindex 58f89dd1b6..0c28b340f8 100644--- a/app/Http/Controllers/Chart/CategoryReportController.php+++ b/app/Http/Controllers/Chart/CategoryReportController.php@@ -24,10 +24,9 @@ namespace FireflyIII\Http\Controllers\Chart;use Carbon\Carbon;use FireflyIII\Generator\Chart\Basic\GeneratorInterface;-use FireflyIII\Helpers\Chart\MetaPieChartInterface;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Models\Category;-use FireflyIII\Support\CacheProperties;+use FireflyIII\Repositories\Category\OperationsRepositoryInterface;use FireflyIII\Support\Http\Controllers\AugumentData;use FireflyIII\Support\Http\Controllers\TransactionCalculation;use Illuminate\Http\JsonResponse;@@ -44,9 +43,12 @@ class CategoryReportController extends Controller/** @var GeneratorInterface Chart generation methods. */private $generator;+ /** @var OperationsRepositoryInterface */+ private $opsRepository;/*** CategoryReportController constructor.+ ** @codeCoverageIgnore*/public function __construct()@@ -54,74 +56,139 @@ class CategoryReportController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {- $this->generator = app(GeneratorInterface::class);+ $this->generator = app(GeneratorInterface::class);+ $this->opsRepository = app(OperationsRepositoryInterface::class);return $next($request);});}+ //+ // /**+ // * Chart for expenses grouped by expense account.+ // *+ // * TODO this chart is not multi-currency aware.+ // *+ // * @param Collection $accounts+ // * @param Collection $categories+ // * @param Carbon $start+ // * @param Carbon $end+ // * @param string $others+ // *+ // * @return JsonResponse+ // */+ // public function accountExpense(Collection $accounts, Collection $categories, Carbon $start, Carbon $end, string $others): JsonResponse+ // {+ // /** @var MetaPieChartInterface $helper */+ // $helper = app(MetaPieChartInterface::class);+ // $helper->setAccounts($accounts)->setCategories($categories)->setStart($start)->setEnd($end)->setCollectOtherObjects(1 === (int)$others);+ //+ // $chartData = $helper->generate('expense', 'account');+ // $data = $this->generator->pieChart($chartData);+ //+ // return response()->json($data);+ // }++ //+ // /**+ // * Chart for income grouped by revenue account.+ // *+ // * TODO this chart is not multi-currency aware.+ // *+ // * @param Collection $accounts+ // * @param Collection $categories+ // * @param Carbon $start+ // * @param Carbon $end+ // * @param string $others+ // *+ // * @return JsonResponse+ // */+ // public function accountIncome(Collection $accounts, Collection $categories, Carbon $start, Carbon $end, string $others): JsonResponse+ // {+ // /** @var MetaPieChartInterface $helper */+ // $helper = app(MetaPieChartInterface::class);+ // $helper->setAccounts($accounts);+ // $helper->setCategories($categories);+ // $helper->setStart($start);+ // $helper->setEnd($end);+ // $helper->setCollectOtherObjects(1 === (int)$others);+ // $chartData = $helper->generate('income', 'account');+ // $data = $this->generator->pieChart($chartData);+ //+ // return response()->json($data);+ // }/**- * Chart for expenses grouped by expense account.- *- * TODO this chart is not multi-currency aware.- ** @param Collection $accounts* @param Collection $categories* @param Carbon $start* @param Carbon $end- * @param string $others** @return JsonResponse*/- public function accountExpense(Collection $accounts, Collection $categories, Carbon $start, Carbon $end, string $others): JsonResponse+ public function budgetExpense(Collection $accounts, Collection $categories, Carbon $start, Carbon $end): JsonResponse{- /** @var MetaPieChartInterface $helper */- $helper = app(MetaPieChartInterface::class);- $helper->setAccounts($accounts)->setCategories($categories)->setStart($start)->setEnd($end)->setCollectOtherObjects(1 === (int)$others);+ $result = [];+ $spent = $this->opsRepository->listExpenses($start, $end, $accounts, $categories);- $chartData = $helper->generate('expense', 'account');- $data = $this->generator->pieChart($chartData);+ // loop expenses.+ foreach ($spent as $currency) {+ /** @var array $category */+ foreach ($currency['categories'] as $category) {+ foreach ($category['transaction_journals'] as $journal) {+ $objectName = $journal['budget_name'] ?? trans('firefly.no_budget');+ $title = sprintf('%s (%s)', $objectName, $currency['currency_name']);+ $result[$title] = $result[$title] ?? [+ 'amount' => '0',+ 'currency_symbol' => $currency['currency_symbol'],+ ];+ $amount = app('steam')->positive($journal['amount']);+ $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);+ }+ }+ }++ $data = $this->generator->multiCurrencyPieChart($result);return response()->json($data);}-/**- * Chart for income grouped by revenue account.- *- * TODO this chart is not multi-currency aware.- ** @param Collection $accounts* @param Collection $categories* @param Carbon $start* @param Carbon $end- * @param string $others** @return JsonResponse*/- public function accountIncome(Collection $accounts, Collection $categories, Carbon $start, Carbon $end, string $others): JsonResponse+ public function categoryExpense(Collection $accounts, Collection $categories, Carbon $start, Carbon $end): JsonResponse{- /** @var MetaPieChartInterface $helper */- $helper = app(MetaPieChartInterface::class);- $helper->setAccounts($accounts);- $helper->setCategories($categories);- $helper->setStart($start);- $helper->setEnd($end);- $helper->setCollectOtherObjects(1 === (int)$others);- $chartData = $helper->generate('income', 'account');- $data = $this->generator->pieChart($chartData);+ $result = [];+ $spent = $this->opsRepository->listExpenses($start, $end, $accounts, $categories);++ // loop expenses.+ foreach ($spent as $currency) {+ /** @var array $category */+ foreach ($currency['categories'] as $category) {+ $title = sprintf('%s (%s)', $category['name'], $currency['currency_name']);+ $result[$title] = $result[$title] ?? [+ 'amount' => '0',+ 'currency_symbol' => $currency['currency_symbol'],+ ];+ foreach ($category['transaction_journals'] as $journal) {+ $amount = app('steam')->positive($journal['amount']);+ $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);+ }+ }+ }++ $data = $this->generator->multiCurrencyPieChart($result);return response()->json($data);}-/**- * Chart for expenses grouped by expense account.- *- * TODO this chart is not multi-currency aware.- ** @param Collection $accounts* @param Collection $categories* @param Carbon $start@@ -129,165 +196,265 @@ class CategoryReportController extends Controller* @param string $others** @return JsonResponse+ **/- public function categoryExpense(Collection $accounts, Collection $categories, Carbon $start, Carbon $end, string $others): JsonResponse+ public function categoryIncome(Collection $accounts, Collection $categories, Carbon $start, Carbon $end): JsonResponse{- /** @var MetaPieChartInterface $helper */- $helper = app(MetaPieChartInterface::class);- $helper->setAccounts($accounts);- $helper->setCategories($categories);- $helper->setStart($start);- $helper->setEnd($end);- $helper->setCollectOtherObjects(1 === (int)$others);- $chartData = $helper->generate('expense', 'category');- $data = $this->generator->pieChart($chartData);+ $result = [];+ $earned = $this->opsRepository->listIncome($start, $end, $accounts, $categories);++ // loop expenses.+ foreach ($earned as $currency) {+ /** @var array $category */+ foreach ($currency['categories'] as $category) {+ $title = sprintf('%s (%s)', $category['name'], $currency['currency_name']);+ $result[$title] = $result[$title] ?? [+ 'amount' => '0',+ 'currency_symbol' => $currency['currency_symbol'],+ ];+ foreach ($category['transaction_journals'] as $journal) {+ $amount = app('steam')->positive($journal['amount']);+ $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);+ }+ }+ }++ $data = $this->generator->multiCurrencyPieChart($result);return response()->json($data);}-/**- * Piechart for income grouped by account.- *- * TODO this chart is not multi-currency aware.- ** @param Collection $accounts* @param Collection $categories* @param Carbon $start* @param Carbon $end- * @param string $others** @return JsonResponse- **/- public function categoryIncome(Collection $accounts, Collection $categories, Carbon $start, Carbon $end, string $others): JsonResponse+ public function destinationExpense(Collection $accounts, Collection $categories, Carbon $start, Carbon $end): JsonResponse{- /** @var MetaPieChartInterface $helper */- $helper = app(MetaPieChartInterface::class);- $helper->setAccounts($accounts);- $helper->setCategories($categories);- $helper->setStart($start);- $helper->setEnd($end);- $helper->setCollectOtherObjects(1 === (int)$others);- $chartData = $helper->generate('income', 'category');- $data = $this->generator->pieChart($chartData);+ $result = [];+ $spent = $this->opsRepository->listExpenses($start, $end, $accounts, $categories);++ // loop expenses.+ foreach ($spent as $currency) {+ /** @var array $category */+ foreach ($currency['categories'] as $category) {+ foreach ($category['transaction_journals'] as $journal) {+ $objectName = $journal['destination_account_name'] ?? trans('firefly.empty');+ $title = sprintf('%s (%s)', $objectName, $currency['currency_name']);+ $result[$title] = $result[$title] ?? [+ 'amount' => '0',+ 'currency_symbol' => $currency['currency_symbol'],+ ];+ $amount = app('steam')->positive($journal['amount']);+ $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);+ }+ }+ }++ $data = $this->generator->multiCurrencyPieChart($result);return response()->json($data);}+ /**+ * @param Collection $accounts+ * @param Collection $categories+ * @param Carbon $start+ * @param Carbon $end+ *+ * @return JsonResponse+ */+ public function destinationIncome(Collection $accounts, Collection $categories, Carbon $start, Carbon $end): JsonResponse+ {+ $result = [];+ $spent = $this->opsRepository->listIncome($start, $end, $accounts, $categories);++ // loop expenses.+ foreach ($spent as $currency) {+ /** @var array $category */+ foreach ($currency['categories'] as $category) {+ foreach ($category['transaction_journals'] as $journal) {+ $objectName = $journal['destination_account_name'] ?? trans('firefly.empty');+ $title = sprintf('%s (%s)', $objectName, $currency['currency_name']);+ $result[$title] = $result[$title] ?? [+ 'amount' => '0',+ 'currency_symbol' => $currency['currency_symbol'],+ ];+ $amount = app('steam')->positive($journal['amount']);+ $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);+ }+ }+ }++ $data = $this->generator->multiCurrencyPieChart($result);+ return response()->json($data);+ }/**- * Main report category chart.- *- * TODO this chart is not multi-currency aware.- ** @param Collection $accounts- * @param Collection $categories+ * @param Category $category* @param Carbon $start* @param Carbon $end** @return JsonResponse**/- public function mainChart(Collection $accounts, Collection $categories, Carbon $start, Carbon $end): JsonResponse+ public function mainChart(Collection $accounts, Category $category, Carbon $start, Carbon $end): JsonResponse{- $cache = new CacheProperties;- $cache->addProperty('chart.category.report.main');- $cache->addProperty($accounts);- $cache->addProperty($categories);- $cache->addProperty($start);- $cache->addProperty($end);- if ($cache->has()) {- return response()->json($cache->get()); // @codeCoverageIgnore- }+ $chartData = [];+ $spent = $this->opsRepository->listExpenses($start, $end, $accounts, new Collection([$category]));+ $earned = $this->opsRepository->listIncome($start, $end, $accounts, new Collection([$category]));+ $format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);- $format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);- $function = app('navigation')->preferredEndOfPeriod($start, $end);- $chartData = [];- $currentStart = clone $start;-- // prep chart data:- foreach ($categories as $category) {- $chartData[$category->id . '-in'] = [- 'label' => $category->name . ' (' . strtolower((string)trans('firefly.income')) . ')',- 'type' => 'bar',- 'yAxisID' => 'y-axis-0',- 'entries' => [],- ];- $chartData[$category->id . '-out'] = [- 'label' => $category->name . ' (' . strtolower((string)trans('firefly.expenses')) . ')',- 'type' => 'bar',- 'yAxisID' => 'y-axis-0',- 'entries' => [],- ];- // total in, total out:- $chartData[$category->id . '-total-in'] = [- 'label' => $category->name . ' (' . strtolower((string)trans('firefly.sum_of_income')) . ')',- 'type' => 'line',- 'fill' => false,- 'yAxisID' => 'y-axis-1',- 'entries' => [],- ];- $chartData[$category->id . '-total-out'] = [- 'label' => $category->name . ' (' . strtolower((string)trans('firefly.sum_of_expenses')) . ')',- 'type' => 'line',- 'fill' => false,- 'yAxisID' => 'y-axis-1',- 'entries' => [],- ];+ // loop expenses.+ foreach ($spent as $currency) {+ // add things to chart Data for each currency:+ $spentKey = sprintf('%d-spent', $currency['currency_id']);+ $chartData[$spentKey] = $chartData[$spentKey] ?? [+ 'label' => sprintf(+ '%s (%s)', (string)trans('firefly.spent_in_specific_category', ['category' => $category->name]), $currency['currency_name']+ ),+ 'type' => 'bar',+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_id' => $currency['currency_id'],+ 'entries' => $this->makeEntries($start, $end),+ ];++ foreach ($currency['categories'] as $currentCategory) {+ foreach ($currentCategory['transaction_journals'] as $journal) {+ $key = $journal['date']->formatLocalized($format);+ $amount = app('steam')->positive($journal['amount']);+ $chartData[$spentKey]['entries'][$key] = $chartData[$spentKey]['entries'][$key] ?? '0';+ $chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount);+ }+ }}- $sumOfIncome = [];- $sumOfExpense = [];-- while ($currentStart < $end) {- $currentEnd = clone $currentStart;- $currentEnd = $currentEnd->$function();- $expenses = $this->groupByCategory($this->getExpensesInCategories($accounts, $categories, $currentStart, $currentEnd));- $income = $this->groupByCategory($this->getIncomeForCategories($accounts, $categories, $currentStart, $currentEnd));- $label = $currentStart->formatLocalized($format);-- /** @var Category $category */- foreach ($categories as $category) {- $labelIn = $category->id . '-in';- $labelOut = $category->id . '-out';- $labelSumIn = $category->id . '-total-in';- $labelSumOut = $category->id . '-total-out';- $currentIncome = $income[$category->id] ?? '0';- $currentExpense = $expenses[$category->id] ?? '0';-- // add to sum:- $sumOfIncome[$category->id] = $sumOfIncome[$category->id] ?? '0';- $sumOfExpense[$category->id] = $sumOfExpense[$category->id] ?? '0';- $sumOfIncome[$category->id] = bcadd($sumOfIncome[$category->id], $currentIncome);- $sumOfExpense[$category->id] = bcadd($sumOfExpense[$category->id], $currentExpense);-- // add to chart:- $chartData[$labelIn]['entries'][$label] = $currentIncome;- $chartData[$labelOut]['entries'][$label] = $currentExpense;- $chartData[$labelSumIn]['entries'][$label] = $sumOfIncome[$category->id];- $chartData[$labelSumOut]['entries'][$label] = $sumOfExpense[$category->id];++ // loop income.+ foreach ($earned as $currency) {+ // add things to chart Data for each currency:+ $spentKey = sprintf('%d-earned', $currency['currency_id']);+ $chartData[$spentKey] = $chartData[$spentKey] ?? [+ 'label' => sprintf(+ '%s (%s)', (string)trans('firefly.earned_in_specific_category', ['category' => $category->name]), $currency['currency_name']+ ),+ 'type' => 'bar',+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_id' => $currency['currency_id'],+ 'entries' => $this->makeEntries($start, $end),+ ];++ foreach ($currency['categories'] as $currentCategory) {+ foreach ($currentCategory['transaction_journals'] as $journal) {+ $key = $journal['date']->formatLocalized($format);+ $amount = app('steam')->positive($journal['amount']);+ $chartData[$spentKey]['entries'][$key] = $chartData[$spentKey]['entries'][$key] ?? '0';+ $chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount);+ }}- /** @var Carbon $currentStart */- $currentStart = clone $currentEnd;- $currentStart->addDay();- $currentStart->startOfDay();}- // remove all empty entries to prevent cluttering:- $newSet = [];- foreach ($chartData as $key => $entry) {- if (0 === !array_sum($entry['entries'])) {- $newSet[$key] = $chartData[$key]; // @codeCoverageIgnore++ $data = $this->generator->multiSet($chartData);++ return response()->json($data);+ }++ /**+ * @param Collection $accounts+ * @param Collection $categories+ * @param Carbon $start+ * @param Carbon $end+ *+ * @return JsonResponse+ */+ public function sourceExpense(Collection $accounts, Collection $categories, Carbon $start, Carbon $end): JsonResponse+ {+ $result = [];+ $spent = $this->opsRepository->listExpenses($start, $end, $accounts, $categories);++ // loop expenses.+ foreach ($spent as $currency) {+ /** @var array $category */+ foreach ($currency['categories'] as $category) {+ foreach ($category['transaction_journals'] as $journal) {+ $objectName = $journal['source_account_name'] ?? trans('firefly.empty');+ $title = sprintf('%s (%s)', $objectName, $currency['currency_name']);+ $result[$title] = $result[$title] ?? [+ 'amount' => '0',+ 'currency_symbol' => $currency['currency_symbol'],+ ];+ $amount = app('steam')->positive($journal['amount']);+ $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);+ }}}- if (0 === count($newSet)) {- $newSet = $chartData;++ $data = $this->generator->multiCurrencyPieChart($result);++ return response()->json($data);+ }++ /**+ * @param Collection $accounts+ * @param Collection $categories+ * @param Carbon $start+ * @param Carbon $end+ *+ * @return JsonResponse+ */+ public function sourceIncome(Collection $accounts, Collection $categories, Carbon $start, Carbon $end): JsonResponse+ {+ $result = [];+ $earned = $this->opsRepository->listIncome($start, $end, $accounts, $categories);++ // loop expenses.+ foreach ($earned as $currency) {+ /** @var array $category */+ foreach ($currency['categories'] as $category) {+ foreach ($category['transaction_journals'] as $journal) {+ $objectName = $journal['source_account_name'] ?? trans('firefly.empty');+ $title = sprintf('%s (%s)', $objectName, $currency['currency_name']);+ $result[$title] = $result[$title] ?? [+ 'amount' => '0',+ 'currency_symbol' => $currency['currency_symbol'],+ ];+ $amount = app('steam')->positive($journal['amount']);+ $result[$title]['amount'] = bcadd($result[$title]['amount'], $amount);+ }+ }}- $data = $this->generator->multiSet($newSet);- $cache->store($data);++ $data = $this->generator->multiCurrencyPieChart($result);return response()->json($data);}+ /**+ * TODO duplicate function+ * @param Carbon $start+ * @param Carbon $end+ *+ * @return array+ */+ private function makeEntries(Carbon $start, Carbon $end): array+ {+ $return = [];+ $format = app('navigation')->preferredCarbonLocalizedFormat($start, $end);+ $preferredRange = app('navigation')->preferredRangeFormat($start, $end);+ $currentStart = clone $start;+ while ($currentStart <= $end) {+ $currentEnd = app('navigation')->endOfPeriod($currentStart, $preferredRange);+ $key = $currentStart->formatLocalized($format);+ $return[$key] = '0';+ $currentStart = clone $currentEnd;+ $currentStart->addDay()->startOfDay();+ }++ return $return;+ }}diff --git a/app/Http/Controllers/Report/BudgetController.php b/app/Http/Controllers/Report/BudgetController.phpindex ac82971151..65d12c0805 100644--- a/app/Http/Controllers/Report/BudgetController.php+++ b/app/Http/Controllers/Report/BudgetController.php@@ -66,6 +66,8 @@ class BudgetController extends Controller* @param Collection $budgets* @param Carbon $start* @param Carbon $end+ *+ * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View*/public function accountPerBudget(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end){@@ -171,6 +173,8 @@ class BudgetController extends Controller* @param Collection $budgets* @param Carbon $start* @param Carbon $end+ *+ * @return array|string*/public function avgExpenses(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end){@@ -181,7 +185,8 @@ class BudgetController extends Controllerforeach ($currency['budgets'] as $budget) {foreach ($budget['transaction_journals'] as $journal) {$destinationId = $journal['destination_account_id'];- $result[$destinationId] = $result[$destinationId] ?? [+ $key = sprintf('%d-%d', $destinationId, $currency['currency_id']);+ $result[$key] = $result[$key] ?? ['transactions' => 0,'sum' => '0','avg' => '0',@@ -193,10 +198,10 @@ class BudgetController extends Controller'currency_symbol' => $currency['currency_symbol'],'currency_decimal_places' => $currency['currency_decimal_places'],];- $result[$destinationId]['transactions']++;- $result[$destinationId]['sum'] = bcadd($journal['amount'], $result[$destinationId]['sum']);- $result[$destinationId]['avg'] = bcdiv($result[$destinationId]['sum'], (string)$result[$destinationId]['transactions']);- $result[$destinationId]['avg_float'] = (float)$result[$destinationId]['avg'];+ $result[$key]['transactions']++;+ $result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);+ $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);+ $result[$key]['avg_float'] = (float)$result[$key]['avg'];}}}@@ -373,6 +378,8 @@ class BudgetController extends Controller* @param Collection $budgets* @param Carbon $start* @param Carbon $end+ *+ * @return array|string*/public function topExpenses(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end){diff --git a/app/Http/Controllers/Report/CategoryController.php b/app/Http/Controllers/Report/CategoryController.phpindex e1bcec6fdc..2d06bb21c3 100644--- a/app/Http/Controllers/Report/CategoryController.php+++ b/app/Http/Controllers/Report/CategoryController.php@@ -25,6 +25,7 @@ namespace FireflyIII\Http\Controllers\Report;use Carbon\Carbon;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Models\Account;+use FireflyIII\Models\Category;use FireflyIII\Repositories\Category\CategoryRepositoryInterface;use FireflyIII\Repositories\Category\NoCategoryRepositoryInterface;use FireflyIII\Repositories\Category\OperationsRepositoryInterface;@@ -62,6 +63,105 @@ class CategoryController extends Controller);}+ /**+ * @param Collection $accounts+ * @param Collection $categories+ * @param Carbon $start+ * @param Carbon $end+ *+ * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View+ */+ public function accountPerCategory(Collection $accounts, Collection $categories, Carbon $start, Carbon $end)+ {+ $spent = $this->opsRepository->listExpenses($start, $end, $accounts, $categories);+ $earned = $this->opsRepository->listIncome($start, $end, $accounts, $categories);+ $report = [];+ /** @var Account $account */+ foreach ($accounts as $account) {+ $accountId = $account->id;+ $report[$accountId] = $report[$accountId] ?? [+ 'name' => $account->name,+ 'id' => $account->id,+ 'iban' => $account->iban,+ 'currencies' => [],+ ];+ }++ // loop expenses.+ foreach ($spent as $currency) {+ $currencyId = $currency['currency_id'];++ /** @var array $category */+ foreach ($currency['categories'] as $category) {+ foreach ($category['transaction_journals'] as $journal) {+ $sourceAccountId = $journal['source_account_id'];+ $report[$sourceAccountId]['currencies'][$currencyId] = $report[$sourceAccountId]['currencies'][$currencyId] ?? [+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'categories' => [],+ ];++ $report[$sourceAccountId]['currencies'][$currencyId]['categories'][$category['id']]+ = $report[$sourceAccountId]['currencies'][$currencyId]['categories'][$category['id']]+ ??+ [+ 'spent' => '0',+ 'earned' => '0',+ 'sum' => '0',+ ];+ $report[$sourceAccountId]['currencies'][$currencyId]['categories'][$category['id']]['spent'] = bcadd(+ $report[$sourceAccountId]['currencies'][$currencyId]['categories'][$category['id']]['spent'], $journal['amount']+ );+ $report[$sourceAccountId]['currencies'][$currencyId]['categories'][$category['id']]['sum'] = bcadd(+ $report[$sourceAccountId]['currencies'][$currencyId]['categories'][$category['id']]['sum'], $journal['amount']+ );+ }+ }+ }+++ // loop income.+ foreach ($earned as $currency) {+ $currencyId = $currency['currency_id'];++ /** @var array $category */+ foreach ($currency['categories'] as $category) {+ foreach ($category['transaction_journals'] as $journal) {+ $destinationId = $journal['destination_account_id'];+ $report[$destinationId]['currencies'][$currencyId]+ = $report[$destinationId]['currencies'][$currencyId]+ ?? [+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'categories' => [],+ ];+++ $report[$destinationId]['currencies'][$currencyId]['categories'][$category['id']]+ = $report[$destinationId]['currencies'][$currencyId]['categories'][$category['id']]+ ??+ [+ 'spent' => '0',+ 'earned' => '0',+ 'sum' => '0',+ ];+ $report[$destinationId]['currencies'][$currencyId]['categories'][$category['id']]['earned'] = bcadd(+ $report[$destinationId]['currencies'][$currencyId]['categories'][$category['id']]['earned'], $journal['amount']+ );+ $report[$destinationId]['currencies'][$currencyId]['categories'][$category['id']]['sum'] = bcadd(+ $report[$destinationId]['currencies'][$currencyId]['categories'][$category['id']]['sum'], $journal['amount']+ );+ }+ }+ }++ return view('reports.category.partials.account-per-category', compact('report', 'categories'));+ }+/*** @param Collection $accounts* @param Collection $categories@@ -153,8 +253,8 @@ class CategoryController extends Controller$report[$destinationAccountId]['currencies'][$currencyId]['sum'] = bcadd($report[$destinationAccountId]['currencies'][$currencyId]['sum'], $journal['amount']);- $sums[$currencyId]['earned_sum'] = bcadd($sums[$currencyId]['earned_sum'], $journal['amount']);- $sums[$currencyId]['total_sum'] = bcadd($sums[$currencyId]['total_sum'], $journal['amount']);+ $sums[$currencyId]['earned_sum'] = bcadd($sums[$currencyId]['earned_sum'], $journal['amount']);+ $sums[$currencyId]['total_sum'] = bcadd($sums[$currencyId]['total_sum'], $journal['amount']);}}}@@ -162,6 +262,110 @@ class CategoryController extends Controllerreturn view('reports.category.partials.accounts', compact('sums', 'report'));}+ /**+ * @param Collection $accounts+ * @param Collection $categories+ * @param Carbon $start+ * @param Carbon $end+ *+ * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View+ */+ public function categories(Collection $accounts, Collection $categories, Carbon $start, Carbon $end)+ {+ $spent = $this->opsRepository->listExpenses($start, $end, $accounts, $categories);+ $earned = $this->opsRepository->listIncome($start, $end, $accounts, $categories);+ $sums = [];+ $report = [];+ /** @var Category $category */+ foreach ($categories as $category) {+ $categoryId = $category->id;+ $report[$categoryId] = $report[$categoryId] ?? [+ 'name' => $category->name,+ 'id' => $category->id,+ 'currencies' => [],+ ];+ }+ foreach ($spent as $currency) {+ $currencyId = $currency['currency_id'];+ $sums[$currencyId] = $sums[$currencyId] ?? [+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'earned_sum' => '0',+ 'spent_sum' => '0',+ 'total_sum' => '0',+ ];+ /** @var array $category */+ foreach ($currency['categories'] as $category) {+ $categoryId = $category['id'];++ foreach ($category['transaction_journals'] as $journal) {+ // add currency info to report array:+ $report[$categoryId]['currencies'][$currencyId] = $report[$categoryId]['currencies'][$currencyId] ?? [+ 'spent' => '0',+ 'earned' => '0',+ 'sum' => '0',+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ ];+ $report[$categoryId]['currencies'][$currencyId]['spent'] = bcadd(+ $report[$categoryId]['currencies'][$currencyId]['spent'], $journal['amount']+ );+ $report[$categoryId]['currencies'][$currencyId]['sum'] = bcadd(+ $report[$categoryId]['currencies'][$currencyId]['sum'], $journal['amount']+ );++ $sums[$currencyId]['spent_sum'] = bcadd($sums[$currencyId]['spent_sum'], $journal['amount']);+ $sums[$currencyId]['total_sum'] = bcadd($sums[$currencyId]['total_sum'], $journal['amount']);+ }+ }+ }++ foreach ($earned as $currency) {+ $currencyId = $currency['currency_id'];+ $sums[$currencyId] = $sums[$currencyId] ?? [+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'earned_sum' => '0',+ 'spent_sum' => '0',+ 'total_sum' => '0',+ ];+ /** @var array $category */+ foreach ($currency['categories'] as $category) {+ $categoryId = $category['id'];++ foreach ($category['transaction_journals'] as $journal) {+ // add currency info to report array:+ $report[$categoryId]['currencies'][$currencyId] = $report[$categoryId]['currencies'][$currencyId] ?? [+ 'spent' => '0',+ 'earned' => '0',+ 'sum' => '0',+ 'currency_id' => $currency['currency_id'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_name' => $currency['currency_name'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ ];+ $report[$categoryId]['currencies'][$currencyId]['earned'] = bcadd(+ $report[$categoryId]['currencies'][$currencyId]['earned'], $journal['amount']+ );+ $report[$categoryId]['currencies'][$currencyId]['sum'] = bcadd(+ $report[$categoryId]['currencies'][$currencyId]['sum'], $journal['amount']+ );++ $sums[$currencyId]['earned_sum'] = bcadd($sums[$currencyId]['earned_sum'], $journal['amount']);+ $sums[$currencyId]['total_sum'] = bcadd($sums[$currencyId]['total_sum'], $journal['amount']);+ }+ }+ }++ return view('reports.category.partials.categories', compact('sums', 'report'));+ }+/*** Show overview of expenses in category.*@@ -371,7 +575,6 @@ class CategoryController extends Controllerreturn $result;}-/*** Show overview of operations.*@@ -538,6 +741,212 @@ class CategoryController extends Controllerreturn $result;}+ /**+ * @param Collection $accounts+ * @param Collection $categories+ * @param Carbon $start+ * @param Carbon $end+ *+ * @return array|string+ */+ public function topExpenses(Collection $accounts, Collection $categories, Carbon $start, Carbon $end)+ {+ $spent = $this->opsRepository->listExpenses($start, $end, $accounts, $categories);+ $result = [];+ foreach ($spent as $currency) {+ $currencyId = $currency['currency_id'];+ foreach ($currency['categories'] as $category) {+ foreach ($category['transaction_journals'] as $journal) {+ $result[] = [+ 'description' => $journal['description'],+ 'transaction_group_id' => $journal['transaction_group_id'],+ 'amount_float' => (float)$journal['amount'],+ 'amount' => $journal['amount'],+ 'date' => $journal['date']->formatLocalized($this->monthAndDayFormat),+ 'destination_account_name' => $journal['destination_account_name'],+ 'destination_account_id' => $journal['destination_account_id'],+ 'currency_id' => $currency['currency_id'],+ 'currency_name' => $currency['currency_name'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'category_id' => $category['id'],+ 'category_name' => $category['name'],+ ];+ }+ }+ }+ // sort by amount_float+ // sort temp array by amount.+ $amounts = array_column($result, 'amount_float');+ array_multisort($amounts, SORT_ASC, $result);++ try {+ $result = view('reports.category.partials.top-expenses', compact('result'))->render();+ // @codeCoverageIgnoreStart+ } catch (Throwable $e) {+ Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));+ $result = sprintf('Could not render view: %s', $e->getMessage());+ }++ return $result;+ }++ /**+ * @param Collection $accounts+ * @param Collection $categories+ * @param Carbon $start+ * @param Carbon $end+ *+ * @return array|string+ */+ public function topIncome(Collection $accounts, Collection $categories, Carbon $start, Carbon $end)+ {+ $spent = $this->opsRepository->listIncome($start, $end, $accounts, $categories);+ $result = [];+ foreach ($spent as $currency) {+ $currencyId = $currency['currency_id'];+ foreach ($currency['categories'] as $category) {+ foreach ($category['transaction_journals'] as $journal) {+ $result[] = [+ 'description' => $journal['description'],+ 'transaction_group_id' => $journal['transaction_group_id'],+ 'amount_float' => (float)$journal['amount'],+ 'amount' => $journal['amount'],+ 'date' => $journal['date']->formatLocalized($this->monthAndDayFormat),+ 'source_account_name' => $journal['source_account_name'],+ 'source_account_id' => $journal['source_account_id'],+ 'currency_id' => $currency['currency_id'],+ 'currency_name' => $currency['currency_name'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ 'category_id' => $category['id'],+ 'category_name' => $category['name'],+ ];+ }+ }+ }+ // sort by amount_float+ // sort temp array by amount.+ $amounts = array_column($result, 'amount_float');+ array_multisort($amounts, SORT_DESC, $result);++ try {+ $result = view('reports.category.partials.top-income', compact('result'))->render();+ // @codeCoverageIgnoreStart+ } catch (Throwable $e) {+ Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));+ $result = sprintf('Could not render view: %s', $e->getMessage());+ }++ return $result;+ }++ /**+ * @param Collection $accounts+ * @param Collection $categories+ * @param Carbon $start+ * @param Carbon $end+ *+ * @return array|string+ */+ public function avgExpenses(Collection $accounts, Collection $categories, Carbon $start, Carbon $end)+ {+ $spent = $this->opsRepository->listExpenses($start, $end, $accounts, $categories);+ $result = [];+ foreach ($spent as $currency) {+ $currencyId = $currency['currency_id'];+ foreach ($currency['categories'] as $category) {+ foreach ($category['transaction_journals'] as $journal) {+ $destinationId = $journal['destination_account_id'];+ $key = sprintf('%d-%d', $destinationId, $currency['currency_id']);+ $result[$key] = $result[$key] ?? [+ 'transactions' => 0,+ 'sum' => '0',+ 'avg' => '0',+ 'avg_float' => 0,+ 'destination_account_name' => $journal['destination_account_name'],+ 'destination_account_id' => $journal['destination_account_id'],+ 'currency_id' => $currency['currency_id'],+ 'currency_name' => $currency['currency_name'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ ];+ $result[$key]['transactions']++;+ $result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);+ $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);+ $result[$key]['avg_float'] = (float)$result[$key]['avg'];+ }+ }+ }+ // sort by amount_float+ // sort temp array by amount.+ $amounts = array_column($result, 'avg_float');+ array_multisort($amounts, SORT_ASC, $result);++ try {+ $result = view('reports.category.partials.avg-expenses', compact('result'))->render();+ // @codeCoverageIgnoreStart+ } catch (Throwable $e) {+ Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));+ $result = sprintf('Could not render view: %s', $e->getMessage());+ }++ return $result;+ }++ /**+ * @param Collection $accounts+ * @param Collection $categories+ * @param Carbon $start+ * @param Carbon $end+ *+ * @return array|string+ */+ public function avgIncome(Collection $accounts, Collection $categories, Carbon $start, Carbon $end)+ {+ $spent = $this->opsRepository->listIncome($start, $end, $accounts, $categories);+ $result = [];+ foreach ($spent as $currency) {+ $currencyId = $currency['currency_id'];+ foreach ($currency['categories'] as $category) {+ foreach ($category['transaction_journals'] as $journal) {+ $sourceId = $journal['source_account_id'];+ $key = sprintf('%d-%d', $sourceId, $currency['currency_id']);+ $result[$key] = $result[$key] ?? [+ 'transactions' => 0,+ 'sum' => '0',+ 'avg' => '0',+ 'avg_float' => 0,+ 'source_account_name' => $journal['source_account_name'],+ 'source_account_id' => $journal['source_account_id'],+ 'currency_id' => $currency['currency_id'],+ 'currency_name' => $currency['currency_name'],+ 'currency_symbol' => $currency['currency_symbol'],+ 'currency_decimal_places' => $currency['currency_decimal_places'],+ ];+ $result[$key]['transactions']++;+ $result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);+ $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);+ $result[$key]['avg_float'] = (float)$result[$key]['avg'];+ }+ }+ }+ // sort by amount_float+ // sort temp array by amount.+ $amounts = array_column($result, 'avg_float');+ array_multisort($amounts, SORT_DESC, $result);++ try {+ $result = view('reports.category.partials.avg-income', compact('result'))->render();+ // @codeCoverageIgnoreStart+ } catch (Throwable $e) {+ Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));+ $result = sprintf('Could not render view: %s', $e->getMessage());+ }++ return $result;+ }+/*** @param array $array*diff --git a/app/Repositories/Category/OperationsRepository.php b/app/Repositories/Category/OperationsRepository.phpindex a375fca03f..7742c44953 100644--- a/app/Repositories/Category/OperationsRepository.php+++ b/app/Repositories/Category/OperationsRepository.php@@ -78,7 +78,7 @@ class OperationsRepository implements OperationsRepositoryInterfaceif (null === $categories || (null !== $categories && 0 === $categories->count())) {$collector->setCategories($this->getCategories());}- $collector->withCategoryInformation()->withAccountInformation();+ $collector->withCategoryInformation()->withAccountInformation()->withBudgetInformation();$journals = $collector->getExtractedJournals();$array = [];@@ -115,9 +115,15 @@ class OperationsRepository implements OperationsRepositoryInterface$array[$currencyId]['categories'][$categoryId]['transaction_journals'][$journalId] = [- 'amount' => app('steam')->negative($journal['amount']),- 'date' => $journal['date'],- 'source_account_id' => $journal['source_account_id'],+ 'amount' => app('steam')->negative($journal['amount']),+ 'date' => $journal['date'],+ 'source_account_id' => $journal['source_account_id'],+ 'budget_name' => $journal['budget_name'],+ 'source_account_name' => $journal['source_account_name'],+ 'destination_account_id' => $journal['destination_account_id'],+ 'destination_account_name' => $journal['destination_account_name'],+ 'description' => $journal['description'],+ 'transaction_group_id' => $journal['transaction_group_id'],];}@@ -188,10 +194,14 @@ class OperationsRepository implements OperationsRepositoryInterface$array[$currencyId]['categories'][$categoryId]['transaction_journals'][$journalId] = [- 'amount' => app('steam')->positive($journal['amount']),- 'date' => $journal['date'],- 'source_account_id' => $journal['source_account_id'],- 'destination_account_id' => $journal['destination_account_id'],+ 'amount' => app('steam')->positive($journal['amount']),+ 'date' => $journal['date'],+ 'source_account_id' => $journal['source_account_id'],+ 'destination_account_id' => $journal['destination_account_id'],+ 'source_account_name' => $journal['source_account_name'],+ 'destination_account_name' => $journal['destination_account_name'],+ 'description' => $journal['description'],+ 'transaction_group_id' => $journal['transaction_group_id'],];}diff --git a/public/v1/js/ff/reports/category/month.js b/public/v1/js/ff/reports/category/month.jsindex 413d93ff79..dd88a03c05 100644--- a/public/v1/js/ff/reports/category/month.js+++ b/public/v1/js/ff/reports/category/month.js@@ -46,20 +46,23 @@ function drawChart() {loadAjaxPartial('accountsHolder', accountsUri);loadAjaxPartial('categoriesHolder', categoriesUri);+ loadAjaxPartial('accountPerCategoryHolder', accountPerCategoryUri);+ $.each($('.main_category_canvas'), function (i, v) {+ var canvas = $(v);+ columnChart(canvas.data('url'), canvas.attr('id'));+ });- // month view:- //doubleYChart(mainUri, 'in-out-chart');+ multiCurrencyPieChart(categoryOutUri, 'category-out-pie-chart');+ multiCurrencyPieChart(categoryInUri, 'category-in-pie-chart');+ multiCurrencyPieChart(budgetsOutUri, 'budgets-out-pie-chart');+ multiCurrencyPieChart(sourceOutUri, 'source-out-pie-chart');+ multiCurrencyPieChart(sourceInUri, 'source-in-pie-chart');+ multiCurrencyPieChart(destOutUri, 'dest-out-pie-chart');+ multiCurrencyPieChart(destInUri, 'dest-in-pie-chart');- // draw pie chart of income, depending on "show other transactions too":- // redrawPieChart(categoryIncomeUri, 'categories-in-pie-chart');- // redrawPieChart(categoryExpenseUri, 'categories-out-pie-chart');- // redrawPieChart(accountIncomeUri, 'accounts-in-pie-chart');- // redrawPieChart(accountExpenseUri, 'accounts-out-pie-chart');--}--function redrawPieChart(uri, container) {- "use strict";- multiCurrencyPieChart(uri, container);+ loadAjaxPartial('topExpensesHolder', topExpensesUri);+ loadAjaxPartial('avgExpensesHolder', avgExpensesUri);+ loadAjaxPartial('topIncomeHolder', topIncomeUri);+ loadAjaxPartial('avgIncomeHolder', avgIncomeUri);}diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.phpindex f0038e4086..9098291d2d 100644--- a/resources/lang/en_US/firefly.php+++ b/resources/lang/en_US/firefly.php@@ -888,11 +888,18 @@ return ['cannot_change_amount_reconciled' => 'You can\'t change the amount of reconciled transactions.','no_budget' => '(no budget)','account_per_budget' => 'Account per budget',+ 'account_per_category' => 'Account per category',+ 'empty' => '(empty)','all_other_budgets' => '(all other budgets)','all_other_accounts' => '(all other accounts)','expense_per_source_account' => 'Expenses per source account','expense_per_destination_account' => 'Expenses per destination account',+ 'income_per_destination_account' => 'Income per destination account',+ 'spent_in_specific_category' => 'Spent in category ":category"',+ 'earned_in_specific_category' => 'Earned in category ":category"',+ 'income_per_source_account' => 'Income per source account','average_spending_per_destination' => 'Average expense per destination account',+ 'average_earning_per_source' => 'Average earning per source account','no_budget_squared' => '(no budget)','perm-delete-many' => 'Deleting many items in one go can be very disruptive. Please be cautious. You can delete part of a split transaction from this page, so take care.','mass_deleted_transactions_success' => 'Deleted :amount transaction(s).',diff --git a/resources/views/v1/reports/budget/partials/avg-expenses.twig b/resources/views/v1/reports/budget/partials/avg-expenses.twigindex 90c28ec1c7..b34a2ecc63 100644--- a/resources/views/v1/reports/budget/partials/avg-expenses.twig+++ b/resources/views/v1/reports/budget/partials/avg-expenses.twig@@ -37,7 +37,7 @@<tfoot>{% if result|length > listLength %}<tr>- <td colspan="4" class="active">+ <td colspan="5" class="active"><a href="#" class="listLengthTrigger">{{ trans('firefly.show_full_list',{number:incomeTopLength}) }}</a></td></tr>diff --git a/resources/views/v1/reports/budget/partials/budgets.twig b/resources/views/v1/reports/budget/partials/budgets.twigindex 1b7c8fa880..0716387837 100644--- a/resources/views/v1/reports/budget/partials/budgets.twig+++ b/resources/views/v1/reports/budget/partials/budgets.twig@@ -20,7 +20,7 @@<td data-value="{{ budget.name }} ({{ currency.currency_name }})"><a href="{{ route('budgets.show', budget.id) }}" title="{{ budget.name }}">{{ budget.name }} ({{ currency.currency_name }})</a></td>- <td data-value="{{ currency.sym }}" style="text-align: right;">+ <td data-value="{{ currency.sum }}" style="text-align: right;">{{ formatAmountBySymbol(currency.sum, currency.currency_symbol, currency.currency_decimal_places) }}</td></tr>diff --git a/resources/views/v1/reports/budget/partials/top-expenses.twig b/resources/views/v1/reports/budget/partials/top-expenses.twigindex 96e825a8ad..8bcdee6243 100644--- a/resources/views/v1/reports/budget/partials/top-expenses.twig+++ b/resources/views/v1/reports/budget/partials/top-expenses.twig@@ -45,7 +45,7 @@<tfoot>{% if result|length > listLength %}<tr>- <td colspan="4" class="active">+ <td colspan="5" class="active"><a href="#" class="listLengthTrigger">{{ trans('firefly.show_full_list',{number:incomeTopLength}) }}</a></td></tr>diff --git a/resources/views/v1/reports/category/month.twig b/resources/views/v1/reports/category/month.twigindex 6a31812935..d054a4b6ea 100644--- a/resources/views/v1/reports/category/month.twig+++ b/resources/views/v1/reports/category/month.twig@@ -95,7 +95,7 @@</div><div class="box-body"><div style="width:100%;margin:0 auto;">- <canvas id="source-accounts-out-pie-chart" style="width:100%;height:250px;" height="250"></canvas>+ <canvas id="source-out-pie-chart" style="width:100%;height:250px;" height="250"></canvas></div></div></div>@@ -107,7 +107,7 @@</div><div class="box-body"><div style="width:100%;margin:0 auto;">- <canvas id="source-accounts-in-pie-chart" style="width:100%;height:250px;" height="250"></canvas>+ <canvas id="source-in-pie-chart" style="width:100%;height:250px;" height="250"></canvas></div></div></div>@@ -121,7 +121,7 @@</div><div class="box-body"><div style="width:100%;margin:0 auto;">- <canvas id="dest-accounts-out-pie-chart" style="width:100%;height:250px;" height="250"></canvas>+ <canvas id="dest-out-pie-chart" style="width:100%;height:250px;" height="250"></canvas></div></div></div>@@ -133,7 +133,7 @@</div><div class="box-body"><div style="width:100%;margin:0 auto;">- <canvas id="dest-accounts-in-pie-chart" style="width:100%;height:250px;" height="250"></canvas>+ <canvas id="dest-in-pie-chart" style="width:100%;height:250px;" height="250"></canvas></div></div></div>@@ -148,7 +148,7 @@<h3 class="box-title">{{ 'income_and_expenses'|_ }} ({{ category.name }})</h3></div><div class="box-body">- {#<canvas class="main_budget_canvas" data-url="{{ route('chart.category.main', [accountIds, category.id, start.format('Ymd'), end.format('Ymd')]) }}" id="in-out-chart-{{ category.id }}" style="width:100%;height:400px;" height="400" width="100%"></canvas>#}+ <canvas class="main_category_canvas" data-url="{{ route('chart.category.main', [accountIds, category.id, start.format('Ymd'), end.format('Ymd')]) }}" id="in-out-chart-{{ category.id }}" style="width:100%;height:400px;" height="400" width="100%"></canvas></div></div></div>@@ -219,6 +219,7 @@<script type="text/javascript" src="v1/js/ff/charts.js?v={{ FF_VERSION }}"></script><script type="text/javascript" src="v1/js/lib/bootstrap-sortable.js?v={{ FF_VERSION }}"></script>+ <script type="text/javascript" src="v1/js/ff/reports/all.js?v={{ FF_VERSION }}"></script><script type="text/javascript">// to report another URL:var startDate = '{{ start.format('Ymd') }}';@@ -229,22 +230,24 @@// html block URI's:var accountsUri = '{{ route('report-data.category.accounts', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';-var categoriesUri = '{{ route('report-data.category.categories', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';- {#var accountPerCategoryUri = '{{ route('report-data.category.account-per-category', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';#}- {#var avgExpensesUri = '{{ route('report-data.category.avg-expenses', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';#}- {#var topExpensesUri = '{{ route('report-data.category.top-expenses', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';#}+ var accountPerCategoryUri = '{{ route('report-data.category.account-per-category', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';- {#var avgIncomeUri = '{{ route('report-data.category.avg-income', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';#}- {#var topIncomesUri = '{{ route('report-data.category.top-income', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';#}+ // pie charts:+ var categoryOutUri = '{{ route('chart.category.category-expense', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';+ var categoryInUri = '{{ route('chart.category.category-income', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';+ var budgetsOutUri = '{{ route('chart.category.budget-expense', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';+ var sourceOutUri = '{{ route('chart.category.source-expense', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';+ var sourceInUri = '{{ route('chart.category.source-income', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';+ var destOutUri = '{{ route('chart.category.dest-expense', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';+ var destInUri = '{{ route('chart.category.dest-income', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';++ var avgExpensesUri = '{{ route('report-data.category.avg-expenses', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';+ var topExpensesUri = '{{ route('report-data.category.top-expenses', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';+ var avgIncomeUri = '{{ route('report-data.category.avg-income', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';+ var topIncomeUri = '{{ route('report-data.category.top-income', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';- // chart uri's- {#var budgetExpenseUri = '{{ route('chart.category.category-expense', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';#}- {#var categoryExpenseUri = '{{ route('chart.category.category-expense', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';#}- {#var sourceExpenseUri = '{{ route('chart.budget.source-account-expense', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';#}- {#var destinationExpenseUri = '{{ route('chart.budget.destination-account-expense', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';#}</script>- <script type="text/javascript" src="v1/js/ff/reports/all.js?v={{ FF_VERSION }}"></script><script type="text/javascript" src="v1/js/ff/reports/category/month.js?v={{ FF_VERSION }}"></script>{% endblock %}diff --git a/resources/views/v1/reports/category/partials/account-per-category.twig b/resources/views/v1/reports/category/partials/account-per-category.twignew file mode 100644index 0000000000..a45085672c--- /dev/null+++ b/resources/views/v1/reports/category/partials/account-per-category.twig@@ -0,0 +1,31 @@+<table class="table table-hover sortable">+ <thead>+ <tr>+ <th data-defaultsign="az">{{ 'name'|_ }}</th>+ {% for category in categories %}+ <th data-defaultsign="_19" style="text-align: right;">{{ category.name }}</th>+ {% endfor %}+ </tr>+ </thead>+ <tbody>+ {% for account in report %}+ {% for currency in account.currencies %}+ <tr>+ <td data-value="{{ account.name }} ({{ currency.currency_name }})">+ <a href="{{ route('accounts.show', account.id) }}" title="{{ account.iban }}">{{ account.name }} ({{ currency.currency_name }})</a>+ </td>+ {% for category in categories %}+ <td style="text-align: right;">+ {% if currency.categories[category.id] %}+ <span title="{{ 'earned'|_ }}: {{ formatAmountBySymbol(currency.categories[category.id].earned, currency.currency_symbol, currency.currency_decimal_places, false) }}, {{ 'spent'|_ }}: {{ formatAmountBySymbol(currency.categories[category.id].spent, currency.currency_symbol, currency.currency_decimal_places, false) }}"+ {{ formatAmountBySymbol(currency.categories[category.id].sum, currency.currency_symbol, currency.currency_decimal_places) }}+ {% else %}+ —+ {% endif %}+ </td>+ {% endfor %}+ </tr>+ {% endfor %}+ {% endfor %}+ </tbody>+</table>\ No newline at end of filediff --git a/resources/views/v1/reports/category/partials/avg-expenses.twig b/resources/views/v1/reports/category/partials/avg-expenses.twignew file mode 100644index 0000000000..b34a2ecc63--- /dev/null+++ b/resources/views/v1/reports/category/partials/avg-expenses.twig@@ -0,0 +1,46 @@+<table class="table table-hover sortable">+ <thead>+ <tr>+ <th data-defaultsign="az">{{ 'account'|_ }}</th>+ <th data-defaultsign="_19" style="text-align: right;">{{ 'spent_average'|_ }}</th>+ <th data-defaultsign="_19" style="text-align: right;">{{ 'total'|_ }}</th>+ <th data-defaultsign="_19">{{ 'transaction_count'|_ }}</th>+ </tr>+ </thead>+ <tbody>+ {% for row in result %}+ {% if loop.index > listLength %}+ <tr class="overListLength">+ {% else %}+ <tr>+ {% endif %}+ <td data-sortable="false">+ <a href="{{ route('accounts.show', row.destination_account_id) }}">+ {{ row.destination_account_name }}+ </a>+ </td>+ <td data-value="{{ row.avg }}" style="text-align: right;">+ {{ formatAmountBySymbol(row.avg, row.currency_symbol, row.currency_decimal_places) }}+ </td>++ <td data-value="{{ row.sum }}" style="text-align: right;">+ {{ formatAmountBySymbol(row.sum, row.currency_symbol, row.currency_decimal_places) }}+ </td>++ <td data-value="{{ row.transactions }}">+ {{ row.transactions }}+ </td>++ </tr>+ {% endfor %}+ </tbody>+ <tfoot>+ {% if result|length > listLength %}+ <tr>+ <td colspan="5" class="active">+ <a href="#" class="listLengthTrigger">{{ trans('firefly.show_full_list',{number:incomeTopLength}) }}</a>+ </td>+ </tr>+ {% endif %}+ </tfoot>+</table>diff --git a/resources/views/v1/reports/category/partials/avg-income.twig b/resources/views/v1/reports/category/partials/avg-income.twignew file mode 100644index 0000000000..b859f13a09--- /dev/null+++ b/resources/views/v1/reports/category/partials/avg-income.twig@@ -0,0 +1,46 @@+<table class="table table-hover sortable">+ <thead>+ <tr>+ <th data-defaultsign="az">{{ 'account'|_ }}</th>+ <th data-defaultsign="_19" style="text-align: right;">{{ 'spent_average'|_ }}</th>+ <th data-defaultsign="_19" style="text-align: right;">{{ 'total'|_ }}</th>+ <th data-defaultsign="_19">{{ 'transaction_count'|_ }}</th>+ </tr>+ </thead>+ <tbody>+ {% for row in result %}+ {% if loop.index > listLength %}+ <tr class="overListLength">+ {% else %}+ <tr>+ {% endif %}+ <td data-sortable="false">+ <a href="{{ route('accounts.show', row.source_account_id) }}">+ {{ row.source_account_name }}+ </a>+ </td>+ <td data-value="{{ row.avg }}" style="text-align: right;">+ {{ formatAmountBySymbol(row.avg, row.currency_symbol, row.currency_decimal_places) }}+ </td>++ <td data-value="{{ row.sum }}" style="text-align: right;">+ {{ formatAmountBySymbol(row.sum, row.currency_symbol, row.currency_decimal_places) }}+ </td>++ <td data-value="{{ row.transactions }}">+ {{ row.transactions }}+ </td>++ </tr>+ {% endfor %}+ </tbody>+ <tfoot>+ {% if result|length > listLength %}+ <tr>+ <td colspan="5" class="active">+ <a href="#" class="listLengthTrigger">{{ trans('firefly.show_full_list',{number:incomeTopLength}) }}</a>+ </td>+ </tr>+ {% endif %}+ </tfoot>+</table>diff --git a/resources/views/v1/reports/category/partials/categories.twig b/resources/views/v1/reports/category/partials/categories.twignew file mode 100644index 0000000000..0846294049--- /dev/null+++ b/resources/views/v1/reports/category/partials/categories.twig@@ -0,0 +1,56 @@+<table class="table table-hover sortable">+ <thead>+ <tr>+ <th data-defaultsign="az">{{ 'name'|_ }}</th>+ <th data-defaultsign="_19" style="text-align: right;">{{ 'spent'|_ }}</th>+ <th data-defaultsign="_19" style="text-align: right;">{{ 'earned'|_ }}</th>+ <th data-defaultsign="_19" style="text-align: right;">{{ 'sum'|_ }}</th>+ </tr>+ </thead>+ <tbody>+ {% for category in report %}+ {% if category.currencies|length == 0 %}+ <tr>+ <td data-value="{{ category.name }}">+ <a href="{{ route('categories.show', category.id) }}" title="{{ category.name }}">{{ category.name }}</a>+ </td>+ <td style="text-align: right;">—</td>+ <td style="text-align: right;">—</td>+ <td style="text-align: right;">—</td>+ </tr>+ {% endif %}+ {% for currency in category.currencies %}+ <tr>+ <td data-value="{{ category.name }} ({{ currency.currency_name }})">+ <a href="{{ route('categories.show', category.id) }}" title="{{ category.name }}">{{ category.name }} ({{ currency.currency_name }})</a>+ </td>+ <td data-value="{{ currency.spent }}" style="text-align: right;">+ {{ formatAmountBySymbol(currency.spent, currency.currency_symbol, currency.currency_decimal_places) }}+ </td>+ <td data-value="{{ currency.earned }}" style="text-align: right;">+ {{ formatAmountBySymbol(currency.earned, currency.currency_symbol, currency.currency_decimal_places) }}+ </td>+ <td data-value="{{ currency.sum }}" style="text-align: right;">+ {{ formatAmountBySymbol(currency.sum, currency.currency_symbol, currency.currency_decimal_places) }}+ </td>+ </tr>+ {% endfor %}+ {% endfor %}+ </tbody>+ <tfoot>+ {% for sum in sums %}+ <tr>+ <td>{{ 'sum'|_ }} ({{ sum.currency_name }})</td>+ <td style="text-align: right;">+ {{ formatAmountBySymbol(sum.spent_sum, sum.currency_symbol, sum.currency_decimal_places) }}+ </td>+ <td style="text-align: right;">+ {{ formatAmountBySymbol(sum.earned_sum, sum.currency_symbol, sum.currency_decimal_places) }}+ </td>+ <td style="text-align: right;">+ {{ formatAmountBySymbol(sum.total_sum, sum.currency_symbol, sum.currency_decimal_places) }}+ </td>+ </tr>+ {% endfor %}+ </tfoot>+</table>diff --git a/resources/views/v1/reports/category/partials/top-expenses.twig b/resources/views/v1/reports/category/partials/top-expenses.twignew file mode 100644index 0000000000..52e56fd701--- /dev/null+++ b/resources/views/v1/reports/category/partials/top-expenses.twig@@ -0,0 +1,54 @@+<table class="table table-hover sortable">+ <thead>+ <tr>+ <th data-defaultsort="disabled">{{ 'description'|_ }}</th>+ <th data-defaultsign="month">{{ 'date'|_ }}</th>+ <th data-defaultsign="az">{{ 'account'|_ }}</th>+ <th data-defaultsign="az">{{ 'category'|_ }}</th>+ <th data-defaultsign="_19" style="text-align: right;">{{ 'amount'|_ }}</th>+ </tr>+ </thead>+ <tbody>+ {% for row in result %}+ {% if loop.index > listLength %}+ <tr class="overListLength">+ {% else %}+ <tr>+ {% endif %}+ <td data-sortable="false">+ <a href="{{ route('transactions.show', row.transaction_group_id) }}">+ {{ row.description }}+ </a>+ </td>+ <td data-sortable="false">+ {{ row.date }}+ </td>++ <td data-sortable="false">+ <a href="{{ route('accounts.show', row.destination_account_id) }}">+ {{ row.destination_account_name }}+ </a>+ </td>+ <td data-sortable="false">+ <a href="{{ route('categories.show', row.category_id) }}">+ {{ row.category_name }}+ </a>+ </td>++ <td data-value="{{ row.amount }}" style="text-align: right;">+ {{ formatAmountBySymbol(row.amount, row.currency_symbol, row.currency_decimal_places) }}+ </td>++ </tr>+ {% endfor %}+ </tbody>+ <tfoot>+ {% if result|length > listLength %}+ <tr>+ <td colspan="5" class="active">+ <a href="#" class="listLengthTrigger">{{ trans('firefly.show_full_list',{number:incomeTopLength}) }}</a>+ </td>+ </tr>+ {% endif %}+ </tfoot>+</table>diff --git a/resources/views/v1/reports/category/partials/top-income.twig b/resources/views/v1/reports/category/partials/top-income.twignew file mode 100644index 0000000000..8c256c4d9e--- /dev/null+++ b/resources/views/v1/reports/category/partials/top-income.twig@@ -0,0 +1,54 @@+<table class="table table-hover sortable">+ <thead>+ <tr>+ <th data-defaultsort="disabled">{{ 'description'|_ }}</th>+ <th data-defaultsign="month">{{ 'date'|_ }}</th>+ <th data-defaultsign="az">{{ 'account'|_ }}</th>+ <th data-defaultsign="az">{{ 'category'|_ }}</th>+ <th data-defaultsign="_19" style="text-align: right;">{{ 'amount'|_ }}</th>+ </tr>+ </thead>+ <tbody>+ {% for row in result %}+ {% if loop.index > listLength %}+ <tr class="overListLength">+ {% else %}+ <tr>+ {% endif %}+ <td data-sortable="false">+ <a href="{{ route('transactions.show', row.transaction_group_id) }}">+ {{ row.description }}+ </a>+ </td>+ <td data-sortable="false">+ {{ row.date }}+ </td>++ <td data-sortable="false">+ <a href="{{ route('accounts.show', row.source_account_id) }}">+ {{ row.source_account_name }}+ </a>+ </td>+ <td data-sortable="false">+ <a href="{{ route('categories.show', row.category_id) }}">+ {{ row.category_name }}+ </a>+ </td>++ <td data-value="{{ row.amount }}" style="text-align: right;">+ {{ formatAmountBySymbol(row.amount, row.currency_symbol, row.currency_decimal_places) }}+ </td>++ </tr>+ {% endfor %}+ </tbody>+ <tfoot>+ {% if result|length > listLength %}+ <tr>+ <td colspan="5" class="active">+ <a href="#" class="listLengthTrigger">{{ trans('firefly.show_full_list',{number:incomeTopLength}) }}</a>+ </td>+ </tr>+ {% endif %}+ </tfoot>+</table>diff --git a/routes/web.php b/routes/web.phpindex 97871db1e5..a565962ead 100644--- a/routes/web.php+++ b/routes/web.php@@ -401,33 +401,18 @@ Route::group(Route::get('period/{category}', ['uses' => 'CategoryController@currentPeriod', 'as' => 'current']);Route::get('period/{category}/{date}', ['uses' => 'CategoryController@specificPeriod', 'as' => 'specific']);Route::get('all/{category}', ['uses' => 'CategoryController@all', 'as' => 'all']);- Route::get(- 'report-period/0/{accountList}/{start_date}/{end_date}', ['uses' => 'CategoryController@reportPeriodNoCategory', 'as' => 'period.no-category']- );+ Route::get('report-period/0/{accountList}/{start_date}/{end_date}', ['uses' => 'CategoryController@reportPeriodNoCategory', 'as' => 'period.no-category']);Route::get('report-period/{category}/{accountList}/{start_date}/{end_date}', ['uses' => 'CategoryController@reportPeriod', 'as' => 'period']);- // these charts are used in reports (category reports):- Route::get(- 'category/income/{accountList}/{categoryList}/{start_date}/{end_date}',- ['uses' => 'CategoryReportController@categoryIncome', 'as' => 'category-income']- );- Route::get(- 'category/expense/{accountList}/{categoryList}/{start_date}/{end_date}',- ['uses' => 'CategoryReportController@categoryExpense', 'as' => 'category-expense']- );- Route::get(- 'account/income/{accountList}/{categoryList}/{start_date}/{end_date}',- ['uses' => 'CategoryReportController@accountIncome', 'as' => 'account-income']- );- Route::get(- 'account/expense/{accountList}/{categoryList}/{start_date}/{end_date}',- ['uses' => 'CategoryReportController@accountExpense', 'as' => 'account-expense']- );- Route::get(- 'operations/{accountList}/{categoryList}/{start_date}/{end_date}',- ['uses' => 'CategoryReportController@mainChart', 'as' => 'main']- );+ Route::get('category/expense/{accountList}/{categoryList}/{start_date}/{end_date}', ['uses' => 'CategoryReportController@categoryExpense', 'as' => 'category-expense']);+ Route::get('category/income/{accountList}/{categoryList}/{start_date}/{end_date}', ['uses' => 'CategoryReportController@categoryIncome', 'as' => 'category-income']);+ Route::get('budget/expense/{accountList}/{categoryList}/{start_date}/{end_date}', ['uses' => 'CategoryReportController@budgetExpense', 'as' => 'budget-expense']);+ Route::get('source/expense/{accountList}/{categoryList}/{start_date}/{end_date}', ['uses' => 'CategoryReportController@sourceExpense', 'as' => 'source-expense']);+ Route::get('source/income/{accountList}/{categoryList}/{start_date}/{end_date}', ['uses' => 'CategoryReportController@sourceIncome', 'as' => 'source-income']);+ Route::get('dest/expense/{accountList}/{categoryList}/{start_date}/{end_date}', ['uses' => 'CategoryReportController@destinationExpense', 'as' => 'dest-expense']);+ Route::get('dest/income/{accountList}/{categoryList}/{start_date}/{end_date}', ['uses' => 'CategoryReportController@destinationIncome', 'as' => 'dest-income']);+ Route::get('operations/{accountList}/{category}/{start_date}/{end_date}', ['uses' => 'CategoryReportController@mainChart', 'as' => 'main']);});@@ -794,20 +779,23 @@ Route::group(['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Report', 'prefix' => 'report-data/category','as' => 'report-data.category.'], static function () {- // TODO still in use?+ // TODO three routes still in use?Route::get('operations/{accountList}/{start_date}/{end_date}', ['uses' => 'CategoryController@operations', 'as' => 'operations']);Route::get('income/{accountList}/{start_date}/{end_date}', ['uses' => 'CategoryController@income', 'as' => 'income']);Route::get('expenses/{accountList}/{start_date}/{end_date}', ['uses' => 'CategoryController@expenses', 'as' => 'expenses']);Route::get('accounts/{accountList}/{categoryList}/{start_date}/{end_date}', ['uses' => 'CategoryController@accounts', 'as' => 'accounts']);Route::get('categories/{accountList}/{categoryList}/{start_date}/{end_date}', ['uses' => 'CategoryController@categories', 'as' => 'categories']);- // Route::get(- // 'account-per-budget/{accountList}/{budgetList}/{start_date}/{end_date}',- // ['uses' => 'BudgetController@accountPerBudget', 'as' => 'account-per-budget']- // );- // Route::get('top-expenses/{accountList}/{budgetList}/{start_date}/{end_date}', ['uses' => 'BudgetController@topExpenses', 'as' => 'top-expenses']);- // Route::get('avg-expenses/{accountList}/{budgetList}/{start_date}/{end_date}', ['uses' => 'BudgetController@avgExpenses', 'as' => 'avg-expenses']);+ Route::get(+ 'account-per-category/{accountList}/{categoryList}/{start_date}/{end_date}',+ ['uses' => 'CategoryController@accountPerCategory', 'as' => 'account-per-category']+ );++ Route::get('top-expenses/{accountList}/{categoryList}/{start_date}/{end_date}', ['uses' => 'CategoryController@topExpenses', 'as' => 'top-expenses']);+ Route::get('avg-expenses/{accountList}/{categoryList}/{start_date}/{end_date}', ['uses' => 'CategoryController@avgExpenses', 'as' => 'avg-expenses']);+ Route::get('top-income/{accountList}/{categoryList}/{start_date}/{end_date}', ['uses' => 'CategoryController@topIncome', 'as' => 'top-income']);+ Route::get('avg-income/{accountList}/{categoryList}/{start_date}/{end_date}', ['uses' => 'CategoryController@avgIncome', 'as' => 'avg-income']);});@@ -835,10 +823,7 @@ Route::group(Route::get('accounts/{accountList}/{budgetList}/{start_date}/{end_date}', ['uses' => 'BudgetController@accounts', 'as' => 'accounts']);Route::get('budgets/{accountList}/{budgetList}/{start_date}/{end_date}', ['uses' => 'BudgetController@budgets', 'as' => 'budgets']);- Route::get(- 'account-per-budget/{accountList}/{budgetList}/{start_date}/{end_date}',- ['uses' => 'BudgetController@accountPerBudget', 'as' => 'account-per-budget']- );+ Route::get('account-per-budget/{accountList}/{budgetList}/{start_date}/{end_date}', ['uses' => 'BudgetController@accountPerBudget', 'as' => 'account-per-budget']);Route::get('top-expenses/{accountList}/{budgetList}/{start_date}/{end_date}', ['uses' => 'BudgetController@topExpenses', 'as' => 'top-expenses']);Route::get('avg-expenses/{accountList}/{budgetList}/{start_date}/{end_date}', ['uses' => 'BudgetController@avgExpenses', 'as' => 'avg-expenses']);