mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-17 17:57:09 +00:00
Final code for #384
This commit is contained in:
269
app/Http/Controllers/Chart/ExpenseReportController.php
Normal file
269
app/Http/Controllers/Chart/ExpenseReportController.php
Normal file
@@ -0,0 +1,269 @@
|
||||
<?php
|
||||
/**
|
||||
* ExpenseReportController.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Chart;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Illuminate\Support\Collection;
|
||||
use Navigation;
|
||||
use Response;
|
||||
|
||||
/**
|
||||
* Separate controller because many helper functions are shared.
|
||||
*
|
||||
* Class ExpenseReportController
|
||||
*/
|
||||
class ExpenseReportController extends Controller
|
||||
{
|
||||
/** @var AccountRepositoryInterface */
|
||||
protected $accountRepository;
|
||||
/** @var GeneratorInterface */
|
||||
protected $generator;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
$this->generator = app(GeneratorInterface::class);
|
||||
$this->accountRepository = app(AccountRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $expense
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function mainChart(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
|
||||
{
|
||||
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty('chart.expense.report.main');
|
||||
$cache->addProperty($accounts);
|
||||
$cache->addProperty($expense);
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
if ($cache->has()) {
|
||||
// return Response::json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$format = Navigation::preferredCarbonLocalizedFormat($start, $end);
|
||||
$function = Navigation::preferredEndOfPeriod($start, $end);
|
||||
$chartData = [];
|
||||
$currentStart = clone $start;
|
||||
$combined = $this->combineAccounts($expense);
|
||||
|
||||
// make "all" set:
|
||||
$all = new Collection;
|
||||
foreach ($combined as $name => $combi) {
|
||||
$all = $all->merge($combi);
|
||||
}
|
||||
|
||||
// prep chart data:
|
||||
foreach ($combined as $name => $combi) {
|
||||
// first is always expense account:
|
||||
/** @var Account $exp */
|
||||
$exp = $combi->first();
|
||||
$chartData[$exp->id . '-in'] = [
|
||||
'label' => $name . ' (' . strtolower(strval(trans('firefly.income'))) . ')',
|
||||
'type' => 'bar',
|
||||
'yAxisID' => 'y-axis-0',
|
||||
'entries' => [],
|
||||
];
|
||||
$chartData[$exp->id . '-out'] = [
|
||||
'label' => $name . ' (' . strtolower(strval(trans('firefly.expenses'))) . ')',
|
||||
'type' => 'bar',
|
||||
'yAxisID' => 'y-axis-0',
|
||||
'entries' => [],
|
||||
];
|
||||
// total in, total out:
|
||||
$chartData[$exp->id . '-total-in'] = [
|
||||
'label' => $name . ' (' . strtolower(strval(trans('firefly.sum_of_income'))) . ')',
|
||||
'type' => 'line',
|
||||
'fill' => false,
|
||||
'yAxisID' => 'y-axis-1',
|
||||
'entries' => [],
|
||||
];
|
||||
$chartData[$exp->id . '-total-out'] = [
|
||||
'label' => $name . ' (' . strtolower(strval(trans('firefly.sum_of_expenses'))) . ')',
|
||||
'type' => 'line',
|
||||
'fill' => false,
|
||||
'yAxisID' => 'y-axis-1',
|
||||
'entries' => [],
|
||||
];
|
||||
}
|
||||
|
||||
$sumOfIncome = [];
|
||||
$sumOfExpense = [];
|
||||
|
||||
while ($currentStart < $end) {
|
||||
$currentEnd = clone $currentStart;
|
||||
$currentEnd = $currentEnd->$function();
|
||||
|
||||
// get expenses grouped by opposing name:
|
||||
$expenses = $this->groupByName($this->getExpenses($accounts, $all, $currentStart, $currentEnd));
|
||||
$income = $this->groupByName($this->getIncome($accounts, $all, $currentStart, $currentEnd));
|
||||
$label = $currentStart->formatLocalized($format);
|
||||
|
||||
foreach ($combined as $name => $combi) {
|
||||
// first is always expense account:
|
||||
/** @var Account $exp */
|
||||
$exp = $combi->first();
|
||||
$labelIn = $exp->id . '-in';
|
||||
$labelOut = $exp->id . '-out';
|
||||
$labelSumIn = $exp->id . '-total-in';
|
||||
$labelSumOut = $exp->id . '-total-out';
|
||||
$currentIncome = $income[$name] ?? '0';
|
||||
$currentExpense = $expenses[$name] ?? '0';
|
||||
|
||||
// add to sum:
|
||||
$sumOfIncome[$exp->id] = $sumOfIncome[$exp->id] ?? '0';
|
||||
$sumOfExpense[$exp->id] = $sumOfExpense[$exp->id] ?? '0';
|
||||
$sumOfIncome[$exp->id] = bcadd($sumOfIncome[$exp->id], $currentIncome);
|
||||
$sumOfExpense[$exp->id] = bcadd($sumOfExpense[$exp->id], $currentExpense);
|
||||
|
||||
// add to chart:
|
||||
$chartData[$labelIn]['entries'][$label] = $currentIncome;
|
||||
$chartData[$labelOut]['entries'][$label] = $currentExpense;
|
||||
$chartData[$labelSumIn]['entries'][$label] = $sumOfIncome[$exp->id];
|
||||
$chartData[$labelSumOut]['entries'][$label] = $sumOfExpense[$exp->id];
|
||||
}
|
||||
$currentStart = clone $currentEnd;
|
||||
$currentStart->addDay();
|
||||
}
|
||||
// remove all empty entries to prevent cluttering:
|
||||
$newSet = [];
|
||||
foreach ($chartData as $key => $entry) {
|
||||
if (0 === !array_sum($entry['entries'])) {
|
||||
$newSet[$key] = $chartData[$key];
|
||||
}
|
||||
}
|
||||
if (0 === count($newSet)) {
|
||||
$newSet = $chartData; // @codeCoverageIgnore
|
||||
}
|
||||
$data = $this->generator->multiSet($newSet);
|
||||
$cache->store($data);
|
||||
|
||||
return Response::json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function combineAccounts(Collection $accounts): array
|
||||
{
|
||||
$combined = [];
|
||||
/** @var Account $expenseAccount */
|
||||
foreach ($accounts as $expenseAccount) {
|
||||
$collection = new Collection;
|
||||
$collection->push($expenseAccount);
|
||||
|
||||
$revenue = $this->accountRepository->findByName($expenseAccount->name, [AccountType::REVENUE]);
|
||||
if (!is_null($revenue->id)) {
|
||||
$collection->push($revenue);
|
||||
}
|
||||
$combined[$expenseAccount->name] = $collection;
|
||||
}
|
||||
|
||||
return $combined;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $opposing
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
private function getExpenses(Collection $accounts, Collection $opposing, Carbon $start, Carbon $end): Collection
|
||||
{
|
||||
/** @var JournalCollectorInterface $collector */
|
||||
$collector = app(JournalCollectorInterface::class);
|
||||
$collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setOpposingAccounts($opposing);
|
||||
|
||||
$transactions = $collector->getJournals();
|
||||
|
||||
return $transactions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Collection $opposing
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
private function getIncome(Collection $accounts, Collection $opposing, Carbon $start, Carbon $end): Collection
|
||||
{
|
||||
/** @var JournalCollectorInterface $collector */
|
||||
/** @var JournalCollectorInterface $collector */
|
||||
$collector = app(JournalCollectorInterface::class);
|
||||
$collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->setOpposingAccounts($opposing);
|
||||
|
||||
$transactions = $collector->getJournals();
|
||||
|
||||
return $transactions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $set
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function groupByName(Collection $set): array
|
||||
{
|
||||
// group by opposing account name.
|
||||
$grouped = [];
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($set as $transaction) {
|
||||
$name = $transaction->opposing_account_name;
|
||||
$grouped[$name] = $grouped[$name] ?? '0';
|
||||
$grouped[$name] = bcadd($transaction->transaction_amount, $grouped[$name]);
|
||||
}
|
||||
|
||||
return $grouped;
|
||||
}
|
||||
}
|
@@ -28,6 +28,7 @@ use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
@@ -88,13 +89,13 @@ class ExpenseController extends Controller
|
||||
$all = $all->merge($combi);
|
||||
}
|
||||
// now find spent / earned:
|
||||
$spent = $this->spentByBudget($accounts, $all, $start, $end);
|
||||
$spent = $this->spentByBudget($accounts, $all, $start, $end);
|
||||
// join arrays somehow:
|
||||
$together = [];
|
||||
foreach ($spent as $categoryId => $spentInfo) {
|
||||
if (!isset($together[$categoryId])) {
|
||||
$together[$categoryId]['spent'] = $spentInfo;
|
||||
$together[$categoryId]['budget'] = $spentInfo['name'];
|
||||
$together[$categoryId]['budget'] = $spentInfo['name'];
|
||||
$together[$categoryId]['grand_total'] = '0';
|
||||
}
|
||||
$together[$categoryId]['grand_total'] = bcadd($spentInfo['grand_total'], $together[$categoryId]['grand_total']);
|
||||
@@ -150,7 +151,7 @@ class ExpenseController extends Controller
|
||||
unset($spentInfo);
|
||||
foreach ($earned as $categoryId => $earnedInfo) {
|
||||
if (!isset($together[$categoryId])) {
|
||||
$together[$categoryId]['earned'] = $earnedInfo;
|
||||
$together[$categoryId]['earned'] = $earnedInfo;
|
||||
$together[$categoryId]['category'] = $earnedInfo['name'];
|
||||
$together[$categoryId]['grand_total'] = '0';
|
||||
}
|
||||
@@ -210,6 +211,76 @@ class ExpenseController extends Controller
|
||||
|
||||
}
|
||||
|
||||
public function topExpense(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
|
||||
{
|
||||
// Properties for cache:
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('expense-budget');
|
||||
$cache->addProperty($accounts->pluck('id')->toArray());
|
||||
$cache->addProperty($expense->pluck('id')->toArray());
|
||||
if ($cache->has()) {
|
||||
//return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
$combined = $this->combineAccounts($expense);
|
||||
$all = new Collection;
|
||||
foreach ($combined as $name => $combi) {
|
||||
$all = $all->merge($combi);
|
||||
}
|
||||
// get all expenses in period:
|
||||
/** @var JournalCollectorInterface $collector */
|
||||
$collector = app(JournalCollectorInterface::class);
|
||||
$collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setAccounts($accounts);
|
||||
$collector->setOpposingAccounts($all);
|
||||
$set = $collector->getJournals();
|
||||
$sorted = $set->sortBy(
|
||||
function (Transaction $transaction) {
|
||||
return floatval($transaction->transaction_amount);
|
||||
}
|
||||
);
|
||||
$result = view('reports.partials.top-transactions', compact('sorted'))->render();
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function topIncome(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)
|
||||
{
|
||||
// Properties for cache:
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('expense-budget');
|
||||
$cache->addProperty($accounts->pluck('id')->toArray());
|
||||
$cache->addProperty($expense->pluck('id')->toArray());
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
$combined = $this->combineAccounts($expense);
|
||||
$all = new Collection;
|
||||
foreach ($combined as $name => $combi) {
|
||||
$all = $all->merge($combi);
|
||||
}
|
||||
// get all expenses in period:
|
||||
/** @var JournalCollectorInterface $collector */
|
||||
$collector = app(JournalCollectorInterface::class);
|
||||
$collector->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->setAccounts($accounts);
|
||||
$collector->setOpposingAccounts($all);
|
||||
$set = $collector->getJournals();
|
||||
$sorted = $set->sortByDesc(
|
||||
function (Transaction $transaction) {
|
||||
return floatval($transaction->transaction_amount);
|
||||
}
|
||||
);
|
||||
$result = view('reports.partials.top-transactions', compact('sorted'))->render();
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
*
|
||||
@@ -348,7 +419,7 @@ class ExpenseController extends Controller
|
||||
$sum = [];
|
||||
// loop to support multi currency
|
||||
foreach ($set as $transaction) {
|
||||
$currencyId = $transaction->transaction_currency_id;
|
||||
$currencyId = $transaction->transaction_currency_id;
|
||||
$budgetName = $transaction->transaction_budget_name;
|
||||
$budgetId = intval($transaction->transaction_budget_id);
|
||||
// if null, grab from journal:
|
||||
@@ -369,7 +440,7 @@ class ExpenseController extends Controller
|
||||
'per_currency' => [
|
||||
$currencyId => [
|
||||
'sum' => '0',
|
||||
'budget' => [
|
||||
'budget' => [
|
||||
'id' => $budgetId,
|
||||
'name' => $budgetName,
|
||||
],
|
||||
|
@@ -54,7 +54,7 @@ return [
|
||||
'import_pre' => [
|
||||
'bunq' => 'FireflyIII\Support\Import\Prerequisites\BunqPrerequisites',
|
||||
'spectre' => 'FireflyIII\Support\Import\Prerequisites\SpectrePrerequisites',
|
||||
'plaid' => 'FireflyIII\Support\Import\Prerequisites\PlairPrerequisites',
|
||||
'plaid' => 'FireflyIII\Support\Import\Prerequisites\PlaidPrerequisites',
|
||||
],
|
||||
'import_info' => [
|
||||
'bunq' => 'FireflyIII\Support\Import\Information\BunqInformation',
|
||||
|
57
public/js/ff/reports/account/all.js
vendored
57
public/js/ff/reports/account/all.js
vendored
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* all.js
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
function loadAjaxPartial(holder, uri) {
|
||||
"use strict";
|
||||
$.get(uri).done(function (data) {
|
||||
displayAjaxPartial(data, holder);
|
||||
}).fail(function () {
|
||||
failAjaxPartial(uri, holder);
|
||||
});
|
||||
}
|
||||
|
||||
function failAjaxPartial(uri, holder) {
|
||||
"use strict";
|
||||
var holderObject = $('#' + holder);
|
||||
holderObject.parent().find('.overlay').remove();
|
||||
holderObject.addClass('general-chart-error');
|
||||
|
||||
}
|
||||
|
||||
function displayAjaxPartial(data, holder) {
|
||||
"use strict";
|
||||
var obj = $('#' + holder);
|
||||
obj.html(data);
|
||||
obj.parent().find('.overlay').remove();
|
||||
|
||||
// call some often needed recalculations and what-not:
|
||||
|
||||
// find a sortable table and make it sortable:
|
||||
if (typeof $.bootstrapSortable === "function") {
|
||||
$.bootstrapSortable(true);
|
||||
}
|
||||
|
||||
// find the info click things and respond to them:
|
||||
triggerInfoClick();
|
||||
|
||||
// trigger list thing
|
||||
listLengthInitial();
|
||||
|
||||
}
|
3
public/js/ff/reports/account/month.js
vendored
3
public/js/ff/reports/account/month.js
vendored
@@ -36,5 +36,6 @@ function drawChart() {
|
||||
|
||||
// month view:
|
||||
// draw account chart
|
||||
lineChart(mainUri, 'in-out-chart');
|
||||
// month view:
|
||||
doubleYChart(mainUri, 'in-out-chart');
|
||||
}
|
136
public/js/ff/reports/all.js
vendored
Normal file
136
public/js/ff/reports/all.js
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
function loadAjaxPartial(holder, uri) {
|
||||
"use strict";
|
||||
$.get(uri).done(function (data) {
|
||||
displayAjaxPartial(data, holder);
|
||||
}).fail(function () {
|
||||
failAjaxPartial(uri, holder);
|
||||
});
|
||||
}
|
||||
|
||||
function failAjaxPartial(uri, holder) {
|
||||
"use strict";
|
||||
var holderObject = $('#' + holder);
|
||||
holderObject.parent().find('.overlay').remove();
|
||||
holderObject.addClass('general-chart-error');
|
||||
|
||||
}
|
||||
|
||||
|
||||
function createCookie(name, value, days) {
|
||||
"use strict";
|
||||
var expires;
|
||||
|
||||
if (days) {
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
||||
expires = "; expires=" + date.toGMTString();
|
||||
} else {
|
||||
expires = "";
|
||||
}
|
||||
document.cookie = encodeURIComponent(name) + "=" + encodeURIComponent(value) + expires + "; path=/";
|
||||
}
|
||||
|
||||
function readCookie(name) {
|
||||
"use strict";
|
||||
var nameEQ = encodeURIComponent(name) + "=";
|
||||
var ca = document.cookie.split(';');
|
||||
for (var i = 0; i < ca.length; i++) {
|
||||
var c = ca[i];
|
||||
while (c.charAt(0) === ' ') {
|
||||
c = c.substring(1, c.length);
|
||||
}
|
||||
if (c.indexOf(nameEQ) === 0) {
|
||||
return decodeURIComponent(c.substring(nameEQ.length, c.length));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
function triggerInfoClick() {
|
||||
"use strict";
|
||||
// find the little info buttons and respond to them.
|
||||
$('.firefly-info-button').unbind('click').click(clickInfoButton);
|
||||
}
|
||||
|
||||
function clickInfoButton(e) {
|
||||
"use strict";
|
||||
// find all data tags, regardless of what they are:
|
||||
var element = $(e.target);
|
||||
var attributes = element.data();
|
||||
|
||||
// set wait cursor
|
||||
$('body').addClass('waiting');
|
||||
|
||||
// add some more elements:
|
||||
attributes.startDate = startDate;
|
||||
attributes.endDate = endDate;
|
||||
attributes.accounts = accountIds;
|
||||
|
||||
$.getJSON('popup/general', {attributes: attributes}).done(respondInfoButton).fail(errorInfoButton);
|
||||
}
|
||||
|
||||
function errorInfoButton() {
|
||||
"use strict";
|
||||
// remove wait cursor
|
||||
$('body').removeClass('waiting');
|
||||
alert('Apologies. The requested data is not (yet) available.');
|
||||
}
|
||||
|
||||
function respondInfoButton(data) {
|
||||
"use strict";
|
||||
// remove wait cursor
|
||||
$('body').removeClass('waiting');
|
||||
$('#defaultModal').empty().html(data.html).modal('show');
|
||||
|
||||
}
|
||||
|
||||
function displayAjaxPartial(data, holder) {
|
||||
"use strict";
|
||||
var obj = $('#' + holder);
|
||||
obj.html(data);
|
||||
obj.parent().find('.overlay').remove();
|
||||
|
||||
// call some often needed recalculations and what-not:
|
||||
|
||||
// find a sortable table and make it sortable:
|
||||
if (typeof $.bootstrapSortable === "function") {
|
||||
$.bootstrapSortable(true);
|
||||
}
|
||||
|
||||
// find the info click things and respond to them:
|
||||
triggerInfoClick();
|
||||
|
||||
// trigger list thing
|
||||
listLengthInitial();
|
||||
|
||||
// budget thing in year and multi year report:
|
||||
$('.budget-chart-activate').unbind('click').on('click', clickBudgetChart);
|
||||
|
||||
// category thing in year and multi year report:
|
||||
$('.category-chart-activate').unbind('click').on('click', clickCategoryChart);
|
||||
}
|
||||
|
||||
function clickCategoryChart(e) {
|
||||
"use strict";
|
||||
var link = $(e.target);
|
||||
var categoryId = link.data('category');
|
||||
$('#category_help').remove();
|
||||
|
||||
var URL = 'chart/category/report-period/' + categoryId + '/' + accountIds + '/' + startDate + '/' + endDate;
|
||||
var container = 'category_chart';
|
||||
columnChart(URL, container);
|
||||
return false;
|
||||
}
|
||||
|
||||
function clickBudgetChart(e) {
|
||||
"use strict";
|
||||
var link = $(e.target);
|
||||
var budgetId = link.data('budget');
|
||||
$('#budget_help').remove();
|
||||
|
||||
var URL = 'chart/budget/period/' + budgetId + '/' + accountIds + '/' + startDate + '/' + endDate;
|
||||
var container = 'budget_chart';
|
||||
columnChart(URL, container);
|
||||
return false;
|
||||
}
|
32
public/js/ff/reports/audit/all.js
vendored
32
public/js/ff/reports/audit/all.js
vendored
@@ -86,35 +86,3 @@ function showOnlyColumns(checkboxes) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function createCookie(name, value, days) {
|
||||
"use strict";
|
||||
var expires;
|
||||
|
||||
if (days) {
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
||||
expires = "; expires=" + date.toGMTString();
|
||||
} else {
|
||||
expires = "";
|
||||
}
|
||||
document.cookie = encodeURIComponent(name) + "=" + encodeURIComponent(value) + expires + "; path=/";
|
||||
}
|
||||
|
||||
function readCookie(name) {
|
||||
"use strict";
|
||||
var nameEQ = encodeURIComponent(name) + "=";
|
||||
var ca = document.cookie.split(';');
|
||||
for (var i = 0; i < ca.length; i++) {
|
||||
var c = ca[i];
|
||||
while (c.charAt(0) === ' ') {
|
||||
c = c.substring(1, c.length);
|
||||
}
|
||||
if (c.indexOf(nameEQ) === 0) {
|
||||
return decodeURIComponent(c.substring(nameEQ.length, c.length));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
20
public/js/ff/reports/budget/all.js
vendored
20
public/js/ff/reports/budget/all.js
vendored
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* all.js
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
20
public/js/ff/reports/category/all.js
vendored
20
public/js/ff/reports/category/all.js
vendored
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* all.js
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
105
public/js/ff/reports/default/all.js
vendored
105
public/js/ff/reports/default/all.js
vendored
@@ -33,108 +33,3 @@ $(function () {
|
||||
loadAjaxPartial('incomeVsExpenseReport', incExpReportUri);
|
||||
|
||||
});
|
||||
|
||||
function triggerInfoClick() {
|
||||
"use strict";
|
||||
// find the little info buttons and respond to them.
|
||||
$('.firefly-info-button').unbind('click').click(clickInfoButton);
|
||||
}
|
||||
|
||||
function clickInfoButton(e) {
|
||||
"use strict";
|
||||
// find all data tags, regardless of what they are:
|
||||
var element = $(e.target);
|
||||
var attributes = element.data();
|
||||
|
||||
// set wait cursor
|
||||
$('body').addClass('waiting');
|
||||
|
||||
// add some more elements:
|
||||
attributes.startDate = startDate;
|
||||
attributes.endDate = endDate;
|
||||
attributes.accounts = accountIds;
|
||||
|
||||
$.getJSON('popup/general', {attributes: attributes}).done(respondInfoButton).fail(errorInfoButton);
|
||||
}
|
||||
|
||||
function errorInfoButton() {
|
||||
"use strict";
|
||||
// remove wait cursor
|
||||
$('body').removeClass('waiting');
|
||||
alert('Apologies. The requested data is not (yet) available.');
|
||||
}
|
||||
|
||||
function respondInfoButton(data) {
|
||||
"use strict";
|
||||
// remove wait cursor
|
||||
$('body').removeClass('waiting');
|
||||
$('#defaultModal').empty().html(data.html).modal('show');
|
||||
|
||||
}
|
||||
|
||||
function loadAjaxPartial(holder, uri) {
|
||||
"use strict";
|
||||
$.get(uri).done(function (data) {
|
||||
displayAjaxPartial(data, holder);
|
||||
}).fail(function () {
|
||||
failAjaxPartial(uri, holder);
|
||||
});
|
||||
}
|
||||
|
||||
function displayAjaxPartial(data, holder) {
|
||||
"use strict";
|
||||
var obj = $('#' + holder);
|
||||
obj.html(data);
|
||||
obj.parent().find('.overlay').remove();
|
||||
|
||||
// call some often needed recalculations and what-not:
|
||||
|
||||
// find a sortable table and make it sortable:
|
||||
if (typeof $.bootstrapSortable === "function") {
|
||||
$.bootstrapSortable(true);
|
||||
}
|
||||
|
||||
// find the info click things and respond to them:
|
||||
triggerInfoClick();
|
||||
|
||||
// trigger list thing
|
||||
listLengthInitial();
|
||||
|
||||
// budget thing in year and multi year report:
|
||||
$('.budget-chart-activate').unbind('click').on('click', clickBudgetChart);
|
||||
|
||||
// category thing in year and multi year report:
|
||||
$('.category-chart-activate').unbind('click').on('click', clickCategoryChart);
|
||||
}
|
||||
|
||||
function failAjaxPartial(uri, holder) {
|
||||
"use strict";
|
||||
var holderObject = $('#' + holder);
|
||||
holderObject.parent().find('.overlay').remove();
|
||||
holderObject.addClass('general-chart-error');
|
||||
|
||||
}
|
||||
|
||||
function clickCategoryChart(e) {
|
||||
"use strict";
|
||||
var link = $(e.target);
|
||||
var categoryId = link.data('category');
|
||||
$('#category_help').remove();
|
||||
|
||||
var URL = 'chart/category/report-period/' + categoryId + '/' + accountIds + '/' + startDate + '/' + endDate;
|
||||
var container = 'category_chart';
|
||||
columnChart(URL, container);
|
||||
return false;
|
||||
}
|
||||
|
||||
function clickBudgetChart(e) {
|
||||
"use strict";
|
||||
var link = $(e.target);
|
||||
var budgetId = link.data('budget');
|
||||
$('#budget_help').remove();
|
||||
|
||||
var URL = 'chart/budget/period/' + budgetId + '/' + accountIds + '/' + startDate + '/' + endDate;
|
||||
var container = 'budget_chart';
|
||||
columnChart(URL, container);
|
||||
return false;
|
||||
}
|
30
public/js/ff/reports/index.js
vendored
30
public/js/ff/reports/index.js
vendored
@@ -179,33 +179,3 @@ function preSelectDate(e) {
|
||||
}
|
||||
|
||||
|
||||
function createCookie(name, value, days) {
|
||||
"use strict";
|
||||
var expires;
|
||||
|
||||
if (days) {
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
||||
expires = "; expires=" + date.toGMTString();
|
||||
} else {
|
||||
expires = "";
|
||||
}
|
||||
document.cookie = encodeURIComponent(name) + "=" + encodeURIComponent(value) + expires + "; path=/";
|
||||
}
|
||||
|
||||
function readCookie(name) {
|
||||
"use strict";
|
||||
var nameEQ = encodeURIComponent(name) + "=";
|
||||
var ca = document.cookie.split(';');
|
||||
for (var i = 0; i < ca.length; i++) {
|
||||
var c = ca[i];
|
||||
while (c.charAt(0) === ' ') {
|
||||
c = c.substring(1, c.length);
|
||||
}
|
||||
if (c.indexOf(nameEQ) === 0) {
|
||||
return decodeURIComponent(c.substring(nameEQ.length, c.length));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
20
public/js/ff/reports/tag/all.js
vendored
20
public/js/ff/reports/tag/all.js
vendored
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* all.js
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
@@ -127,7 +127,7 @@
|
||||
</script>
|
||||
|
||||
|
||||
<script type="text/javascript" src="js/ff/reports/account/all.js?v={{ FF_VERSION }}"></script>
|
||||
<script type="text/javascript" src="js/ff/reports/all.js?v={{ FF_VERSION }}"></script>
|
||||
<script type="text/javascript" src="js/ff/reports/account/month.js?v={{ FF_VERSION }}"></script>
|
||||
|
||||
{% endblock %}
|
||||
|
@@ -86,5 +86,6 @@
|
||||
<script type="text/javascript">
|
||||
var hideable = {{ hideable|json_encode|raw }};
|
||||
</script>
|
||||
<script type="text/javascript" src="js/ff/reports/all.js?v={{ FF_VERSION }}"></script>
|
||||
<script type="text/javascript" src="js/ff/reports/audit/all.js?v={{ FF_VERSION }}"></script>
|
||||
{% endblock %}
|
||||
|
@@ -260,7 +260,7 @@
|
||||
</script>
|
||||
|
||||
|
||||
<script type="text/javascript" src="js/ff/reports/budget/all.js?v={{ FF_VERSION }}"></script>
|
||||
<script type="text/javascript" src="js/ff/reports/all.js?v={{ FF_VERSION }}"></script>
|
||||
<script type="text/javascript" src="js/ff/reports/budget/month.js?v={{ FF_VERSION }}"></script>
|
||||
|
||||
{% endblock %}
|
||||
|
@@ -397,7 +397,7 @@
|
||||
</script>
|
||||
|
||||
|
||||
<script type="text/javascript" src="js/ff/reports/category/all.js?v={{ FF_VERSION }}"></script>
|
||||
<script type="text/javascript" src="js/ff/reports/all.js?v={{ FF_VERSION }}"></script>
|
||||
<script type="text/javascript" src="js/ff/reports/category/month.js?v={{ FF_VERSION }}"></script>
|
||||
|
||||
{% endblock %}
|
||||
|
@@ -171,6 +171,7 @@
|
||||
var accountChartUri = '{{ route('chart.account.report', [accountIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||
|
||||
</script>
|
||||
<script type="text/javascript" src="js/ff/reports/all.js?v={{ FF_VERSION }}"></script>
|
||||
<script type="text/javascript" src="js/ff/reports/default/all.js?v={{ FF_VERSION }}"></script>
|
||||
<script type="text/javascript" src="js/ff/reports/default/month.js?v={{ FF_VERSION }}"></script>
|
||||
{% endblock %}
|
||||
|
@@ -222,6 +222,7 @@
|
||||
var categoryIncomeUri = '{{ route('report-data.category.income', [accountIds, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||
|
||||
</script>
|
||||
<script type="text/javascript" src="js/ff/reports/all.js?v={{ FF_VERSION }}"></script>
|
||||
<script type="text/javascript" src="js/ff/reports/default/all.js?v={{ FF_VERSION }}"></script>
|
||||
<script type="text/javascript" src="js/ff/reports/default/multi-year.js?v={{ FF_VERSION }}"></script>
|
||||
{% endblock %}
|
||||
|
@@ -217,7 +217,7 @@
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src="js/ff/reports/all.js?v={{ FF_VERSION }}"></script>
|
||||
<script type="text/javascript" src="js/ff/reports/default/all.js?v={{ FF_VERSION }}"></script>
|
||||
<script type="text/javascript" src="js/ff/reports/default/year.js?v={{ FF_VERSION }}"></script>
|
||||
|
||||
|
@@ -179,5 +179,6 @@
|
||||
var filterPlaceholder = "{{ trans('firefly.multi_select_filter_placeholder')|escape('js') }}";
|
||||
</script>
|
||||
<script type="text/javascript" src="js/lib/bootstrap-multiselect.js?v={{ FF_VERSION }}"></script>
|
||||
<script type="text/javascript" src="js/ff/reports/all.js?v={{ FF_VERSION }}"></script>
|
||||
<script type="text/javascript" src="js/ff/reports/index.js?v={{ FF_VERSION }}"></script>
|
||||
{% endblock %}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
<table class="table table-hover sortable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:66%;" data-defaultsign="az">{{ 'category'|_ }}</th>
|
||||
<th style="width:34%;" data-defaultsort="_19">{{ 'spent'|_ }}</th>
|
||||
<th style="width:66%;" data-defaultsign="az" data-defaultsort="asc">{{ 'category'|_ }}</th>
|
||||
<th style="width:34%;" data-defaultsign="_19">{{ 'spent'|_ }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@@ -1,9 +1,9 @@
|
||||
<table class="table table-hover sortable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:50%;" data-defaultsign="az">{{ 'category'|_ }}</th>
|
||||
<th style="width:25%;" data-defaultsort="_19">{{ 'spent'|_ }}</th>
|
||||
<th style="width:25%;" data-defaultsort="_19">{{ 'earned'|_ }}</th>
|
||||
<th style="width:50%;" data-defaultsign="az" data-defaultsort="asc">{{ 'category'|_ }}</th>
|
||||
<th style="width:25%;" data-defaultsign="_19">{{ 'spent'|_ }}</th>
|
||||
<th style="width:25%;" data-defaultsign="_19">{{ 'earned'|_ }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@@ -3,8 +3,8 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:50%;" data-defaultsign="az">{{ 'name'|_ }}</th>
|
||||
<th style="width:25%;" class="hidden-xs" data-defaultsort="_19">{{ 'spent'|_ }}</th>
|
||||
<th style="width:25%;" class="hidden-xs" data-defaultsort="_19">{{ 'earned'|_ }}</th>
|
||||
<th style="width:25%;" class="hidden-xs" data-defaultsign="_19">{{ 'spent'|_ }}</th>
|
||||
<th style="width:25%;" class="hidden-xs" data-defaultsign="_19">{{ 'earned'|_ }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
24
resources/views/reports/partials/top-transactions.twig
Normal file
24
resources/views/reports/partials/top-transactions.twig
Normal file
@@ -0,0 +1,24 @@
|
||||
<table class="table table-hover sortable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-defaultsign="az">{{ 'account'|_ }}</th>
|
||||
<th data-defaultsign="az">{{ 'description'|_ }}</th>
|
||||
<th data-defaultsign="month">{{ 'date'|_ }}</th>
|
||||
<th style="width:25%;" class="hidden-xs" data-defaultsign="_19">{{ 'amount'|_ }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for transaction in sorted %}
|
||||
<tr>
|
||||
<td data-value="{{ transaction.opposing_account_name }}">
|
||||
<a href="{{ route('accounts.show',transaction.opposing_account_id) }}">{{ transaction.opposing_account_name }}</a>
|
||||
</td>
|
||||
<td data-value="{{ transaction.description }}">{{ transaction.description }}</td>
|
||||
<td data-value="{{ transaction.date.format('Y-m-d') }}">
|
||||
{{ transaction.date.formatLocalized(monthAndDayFormat) }}
|
||||
</td>
|
||||
<td style="text-align: right;" data-value="{{ transaction.transaction_amount }}"><span style="margin-right:5px;">{{ transaction|transactionAmount }}</span></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
@@ -422,8 +422,7 @@
|
||||
var mainUri = '{{ route('chart.tag.main', [accountIds, tagTags, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||
</script>
|
||||
|
||||
|
||||
<script type="text/javascript" src="js/ff/reports/tag/all.js?v={{ FF_VERSION }}"></script>
|
||||
<script type="text/javascript" src="js/ff/reports/all.js?v={{ FF_VERSION }}"></script>
|
||||
<script type="text/javascript" src="js/ff/reports/tag/month.js?v={{ FF_VERSION }}"></script>
|
||||
|
||||
{% endblock %}
|
||||
|
@@ -623,8 +623,8 @@ Route::group(
|
||||
Route::get('budget/{accountList}/{expenseList}/{start_date}/{end_date}', ['uses' => 'ExpenseController@budget', 'as' => 'budget']);
|
||||
|
||||
//expense earned top X
|
||||
Route::get('expenses/{accountList}/{expenseList}/{start_date}/{end_date}', ['uses' => 'ExpenseController@topX', 'as' => 'expenses']);
|
||||
Route::get('income/{accountList}/{expenseList}/{start_date}/{end_date}', ['uses' => 'ExpenseController@topXPeriod', 'as' => 'income']);
|
||||
Route::get('expenses/{accountList}/{expenseList}/{start_date}/{end_date}', ['uses' => 'ExpenseController@topExpense', 'as' => 'expenses']);
|
||||
Route::get('income/{accountList}/{expenseList}/{start_date}/{end_date}', ['uses' => 'ExpenseController@topIncome', 'as' => 'income']);
|
||||
|
||||
}
|
||||
);
|
||||
|
Reference in New Issue
Block a user