Simplified report code.

This commit is contained in:
James Cole
2015-05-16 13:06:38 +02:00
parent bec58a1ee6
commit bdff275672
11 changed files with 1183 additions and 723 deletions

View File

@@ -0,0 +1,89 @@
<?php
namespace FireflyIII\Helpers\Collection;
use Illuminate\Support\Collection;
/**
* Class Account
*
* @package FireflyIII\Helpers\Collection
*/
class Account
{
/** @var Collection */
protected $accounts;
/** @var float */
protected $difference;
/** @var float */
protected $end;
/** @var float */
protected $start;
/**
* @return \Illuminate\Support\Collection
*/
public function getAccounts()
{
return $this->accounts;
}
/**
* @param \Illuminate\Support\Collection $accounts
*/
public function setAccounts($accounts)
{
$this->accounts = $accounts;
}
/**
* @return float
*/
public function getDifference()
{
return $this->difference;
}
/**
* @param float $difference
*/
public function setDifference($difference)
{
$this->difference = $difference;
}
/**
* @return float
*/
public function getEnd()
{
return $this->end;
}
/**
* @param float $end
*/
public function setEnd($end)
{
$this->end = $end;
}
/**
* @return float
*/
public function getStart()
{
return $this->start;
}
/**
* @param float $start
*/
public function setStart($start)
{
$this->start = $start;
}
}

View File

@@ -0,0 +1,80 @@
<?php
namespace FireflyIII\Helpers\Collection;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Support\Collection;
use stdClass;
/**
* Class Expense
*
* @package FireflyIII\Helpers\Collection
*/
class Expense
{
/** @var Collection */
protected $expenses;
/** @var float */
protected $total;
/**
*
*/
public function __construct()
{
$this->expenses = new Collection;
}
/**
* @param TransactionJournal $entry
*/
public function addOrCreateExpense(TransactionJournal $entry)
{
$id = $entry->account_id;
if (!$this->expenses->has($id)) {
$newObject = new stdClass;
$newObject->amount = floatval($entry->queryAmount);
$newObject->name = $entry->name;
$newObject->count = 1;
$newObject->id = $id;
$this->expenses->put($id, $newObject);
} else {
$existing = $this->expenses->get($id);
$existing->amount += floatval($entry->queryAmount);
$existing->count++;
$this->expenses->put($id, $existing);
}
}
/**
* @param $add
*/
public function addToTotal($add)
{
$this->total += floatval($add);
}
/**
* @return Collection
*/
public function getExpenses()
{
$this->expenses->sortBy(
function (stdClass $object) {
return $object->amount;
}
);
return $this->expenses;
}
/**
* @return float
*/
public function getTotal()
{
return $this->total;
}
}

View File

@@ -0,0 +1,83 @@
<?php
namespace FireflyIII\Helpers\Collection;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Support\Collection;
use stdClass;
/**
* Class Income
*
* @package FireflyIII\Helpers\Collection
*/
class Income
{
/** @var Collection */
protected $incomes;
/** @var float */
protected $total;
/**
*
*/
public function __construct()
{
$this->incomes = new Collection;
}
/**
* @param TransactionJournal $entry
*/
public function addOrCreateIncome(TransactionJournal $entry)
{
$id = $entry->account_id;
if (!$this->incomes->has($id)) {
$newObject = new stdClass;
$newObject->amount = floatval($entry->queryAmount);
$newObject->name = $entry->name;
$newObject->count = 1;
$newObject->id = $id;
$this->incomes->put($id, $newObject);
} else {
$existing = $this->incomes->get($id);
$existing->amount += floatval($entry->queryAmount);
$existing->count++;
$this->incomes->put($id, $existing);
}
}
/**
* @param $add
*/
public function addToTotal($add)
{
$this->total += floatval($add);
}
/**
* @return Collection
*/
public function getIncomes()
{
$this->incomes->sortByDesc(
function (stdClass $object) {
return $object->amount;
}
);
return $this->incomes;
}
/**
* @return float
*/
public function getTotal()
{
return $this->total;
}
}

View File

@@ -2,13 +2,11 @@
namespace FireflyIII\Helpers\Report; namespace FireflyIII\Helpers\Report;
use App;
use Auth;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Helpers\Collection\Account as AccountCollection;
use FireflyIII\Helpers\Collection\Expense;
use FireflyIII\Helpers\Collection\Income;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use Illuminate\Database\Query\JoinClause;
use Illuminate\Support\Collection;
use Steam;
/** /**
* Class ReportHelper * Class ReportHelper
@@ -18,47 +16,94 @@ use Steam;
class ReportHelper implements ReportHelperInterface class ReportHelper implements ReportHelperInterface
{ {
/** @var ReportQueryInterface */
protected $query;
/** /**
* This method gets some kind of list for a monthly overview. * @param ReportHelperInterface $helper
*/
public function __construct(ReportQueryInterface $query)
{
$this->query = $query;
}
/**
* This method generates a full report for the given period on all
* the users asset and cash accounts.
* *
* @param Carbon $date * @param Carbon $date
* @param bool $includeShared * @param Carbon $end
* @param $shared
* *
* @return Collection * @return Account
*/ */
public function getBudgetsForMonth(Carbon $date, $includeShared = false) public function getAccountReport(Carbon $date, Carbon $end, $shared)
{ {
/** @var \FireflyIII\Helpers\Report\ReportQueryInterface $query */
$query = App::make('FireflyIII\Helpers\Report\ReportQueryInterface');
$start = clone $date;
$start->startOfMonth();
$end = clone $date;
$end->endOfMonth();
$set = Auth::user()->budgets()->orderBy('budgets.name', 'ASC')
->leftJoin(
'budget_limits', function (JoinClause $join) use ($date) {
$join->on('budget_limits.budget_id', '=', 'budgets.id')->where('budget_limits.startdate', '=', $date->format('Y-m-d'));
}
)
->get(['budgets.*', 'budget_limits.amount as queryAmount']);
$budgets = Steam::makeArray($set); $accounts = $this->query->getAllAccounts($date, $end, $shared);
$amountSet = $query->journalsByBudget($start, $end, $includeShared); $start = 0;
$amounts = Steam::makeArray($amountSet); $end = 0;
$budgets = Steam::mergeArrays($budgets, $amounts); $diff = 0;
$budgets[0]['spent'] = isset($budgets[0]['spent']) ? $budgets[0]['spent'] : 0.0;
$budgets[0]['queryAmount'] = isset($budgets[0]['queryAmount']) ? $budgets[0]['queryAmount'] : 0.0;
$budgets[0]['name'] = 'No budget';
// find transactions to shared asset accounts, which are without a budget by default: // summarize:
// which is only relevant when shared asset accounts are hidden. foreach ($accounts as $account) {
if ($includeShared === false) { $start += $account->startBalance;
$transfers = $query->sharedExpenses($start, $end)->sum('queryAmount'); $end += $account->endBalance;
$budgets[0]['spent'] += floatval($transfers) * -1; $diff += ($account->endBalance - $account->startBalance);
} }
return $budgets; $object = new AccountCollection;
$object->setStart($start);
$object->setEnd($end);
$object->setDifference($diff);
$object->setAccounts($accounts);
return $object;
}
/**
* Get a full report on the users expenses during the period.
*
* @param Carbon $start
* @param Carbon $end
* @param boolean $shared
*
* @return Expense
*/
public function getExpenseReport($start, $end, $shared)
{
$object = new Expense;
$set = $this->query->expenseInPeriod($start, $end, $shared);
foreach ($set as $entry) {
$object->addToTotal($entry->queryAmount);
$object->addOrCreateExpense($entry);
}
return $object;
}
/**
* Get a full report on the users incomes during the period.
*
* @param Carbon $start
* @param Carbon $end
* @param boolean $shared
*
* @return Income
*/
public function getIncomeReport($start, $end, $shared)
{
$object = new Income;
$set = $this->query->incomeInPeriod($start, $end, $shared);
foreach ($set as $entry) {
$object->addToTotal($entry->queryAmount);
$object->addOrCreateIncome($entry);
}
return $object;
} }
/** /**
@@ -84,5 +129,4 @@ class ReportHelper implements ReportHelperInterface
return $months; return $months;
} }
} }

View File

@@ -3,7 +3,9 @@
namespace FireflyIII\Helpers\Report; namespace FireflyIII\Helpers\Report;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Support\Collection; use FireflyIII\Helpers\Collection\Account;
use FireflyIII\Helpers\Collection\Expense;
use FireflyIII\Helpers\Collection\Income;
/** /**
* Interface ReportHelperInterface * Interface ReportHelperInterface
@@ -14,14 +16,38 @@ interface ReportHelperInterface
{ {
/** /**
* This method gets some kind of list for a monthly overview. * This method generates a full report for the given period on all
* the users asset and cash accounts.
* *
* @param Carbon $date * @param Carbon $date
* @param bool $includeShared * @param Carbon $end
* @param boolean $shared
* *
* @return Collection * @return Account
*/ */
public function getBudgetsForMonth(Carbon $date, $includeShared = false); public function getAccountReport(Carbon $date, Carbon $end, $shared);
/**
* Get a full report on the users expenses during the period.
*
* @param Carbon $start
* @param Carbon $end
* @param boolean $shared
*
* @return Expense
*/
public function getExpenseReport($start, $end, $shared);
/**
* Get a full report on the users incomes during the period.
*
* @param Carbon $start
* @param Carbon $end
* @param boolean $shared
*
* @return Income
*/
public function getIncomeReport($start, $end, $shared);
/** /**
* @param Carbon $date * @param Carbon $date

View File

@@ -19,65 +19,6 @@ use Session;
*/ */
class BudgetController extends Controller class BudgetController extends Controller
{ {
/**
* Shows a budget list with spent/left/overspent.
*
* @param GChart $chart
* @param BudgetRepositoryInterface $repository
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function frontpage(GChart $chart, BudgetRepositoryInterface $repository)
{
$chart->addColumn(trans('firefly.budget'), 'string');
$chart->addColumn(trans('firefly.left'), 'number');
$chart->addColumn(trans('firefly.spent'), 'number');
$chart->addColumn(trans('firefly.overspent'), 'number');
$budgets = $repository->getBudgets();
$start = Session::get('start', Carbon::now()->startOfMonth());
$end = Session::get('end', Carbon::now()->endOfMonth());
$allEntries = new Collection;
foreach ($budgets as $budget) {
$repetitions = $repository->getBudgetLimitRepetitions($budget, $start, $end);
if ($repetitions->count() == 0) {
$expenses = $repository->sumBudgetExpensesInPeriod($budget, $start, $end);
$allEntries->push([$budget->name, 0, 0, $expenses]);
continue;
}
/** @var LimitRepetition $repetition */
foreach ($repetitions as $repetition) {
$expenses = $repository->sumBudgetExpensesInPeriod($budget, $repetition->startdate, $repetition->enddate);
$left = $expenses < floatval($repetition->amount) ? floatval($repetition->amount) - $expenses : 0;
$spent = $expenses > floatval($repetition->amount) ? 0 : $expenses;
$overspent = $expenses > floatval($repetition->amount) ? $expenses - floatval($repetition->amount) : 0;
$allEntries->push(
[$budget->name . ' (' . $repetition->startdate->formatLocalized($this->monthAndDayFormat) . ')',
$left,
$spent,
$overspent
]
);
}
}
$noBudgetExpenses = $repository->getWithoutBudgetSum($start, $end);
$allEntries->push([trans('firefly.noBudget'), 0, 0, $noBudgetExpenses]);
foreach ($allEntries as $entry) {
if ($entry[1] != 0 || $entry[2] != 0 || $entry[3] != 0) {
$chart->addRow($entry[0], $entry[1], $entry[2], $entry[3]);
}
}
$chart->generate();
return Response::json($chart->getData());
}
/** /**
* Shows the amount left in a specific budget limit. * Shows the amount left in a specific budget limit.
* *
@@ -114,6 +55,64 @@ class BudgetController extends Controller
} }
/**
* Shows a budget list with spent/left/overspent.
*
* @param GChart $chart
* @param BudgetRepositoryInterface $repository
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function frontpage(GChart $chart, BudgetRepositoryInterface $repository)
{
$chart->addColumn(trans('firefly.budget'), 'string');
$chart->addColumn(trans('firefly.left'), 'number');
$chart->addColumn(trans('firefly.spent'), 'number');
$chart->addColumn(trans('firefly.overspent'), 'number');
$budgets = $repository->getBudgets();
$start = Session::get('start', Carbon::now()->startOfMonth());
$end = Session::get('end', Carbon::now()->endOfMonth());
$allEntries = new Collection;
foreach ($budgets as $budget) {
$repetitions = $repository->getBudgetLimitRepetitions($budget, $start, $end);
if ($repetitions->count() == 0) {
$expenses = $repository->spentInPeriod($budget, $start, $end, true);
$allEntries->push([$budget->name, 0, 0, $expenses]);
continue;
}
/** @var LimitRepetition $repetition */
foreach ($repetitions as $repetition) {
$expenses = $repository->spentInPeriod($budget, $repetition->startdate, $repetition->enddate, true);
$left = $expenses < floatval($repetition->amount) ? floatval($repetition->amount) - $expenses : 0;
$spent = $expenses > floatval($repetition->amount) ? 0 : $expenses;
$overspent = $expenses > floatval($repetition->amount) ? $expenses - floatval($repetition->amount) : 0;
$allEntries->push(
[$budget->name . ' (' . $repetition->startdate->formatLocalized($this->monthAndDayFormat) . ')',
$left,
$spent,
$overspent
]
);
}
}
$noBudgetExpenses = $repository->getWithoutBudgetSum($start, $end);
$allEntries->push([trans('firefly.noBudget'), 0, 0, $noBudgetExpenses]);
foreach ($allEntries as $entry) {
if ($entry[1] != 0 || $entry[2] != 0 || $entry[3] != 0) {
$chart->addRow($entry[0], $entry[1], $entry[2], $entry[3]);
}
}
$chart->generate();
return Response::json($chart->getData());
}
/** /**
* Show a yearly overview for a budget. * Show a yearly overview for a budget.
* *

View File

@@ -1,14 +1,17 @@
<?php namespace FireflyIII\Http\Controllers; <?php namespace FireflyIII\Http\Controllers;
use App;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Helpers\Report\ReportHelperInterface; use FireflyIII\Helpers\Report\ReportHelperInterface;
use FireflyIII\Helpers\Report\ReportQueryInterface; use FireflyIII\Helpers\Report\ReportQueryInterface;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\Budget;
use FireflyIII\Models\LimitRepetition;
use FireflyIII\Models\Preference; use FireflyIII\Models\Preference;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Illuminate\Support\Collection;
use Session; use Session;
use Steam;
use View; use View;
/** /**
@@ -48,8 +51,6 @@ class ReportController extends Controller
{ {
$start = Session::get('first'); $start = Session::get('first');
$months = $this->helper->listOfMonths($start); $months = $this->helper->listOfMonths($start);
$title = 'Reports';
$mainTitleIcon = 'fa-line-chart';
// does the user have shared accounts? // does the user have shared accounts?
$accounts = $repository->getAccounts(['Default account', 'Asset account']); $accounts = $repository->getAccounts(['Default account', 'Asset account']);
@@ -63,7 +64,7 @@ class ReportController extends Controller
} }
return view('reports.index', compact('months', 'title', 'mainTitleIcon', 'hasShared')); return view('reports.index', compact('months', 'hasShared'));
} }
/** /**
@@ -143,157 +144,29 @@ class ReportController extends Controller
*/ */
public function month($year = '2014', $month = '1', $shared = false) public function month($year = '2014', $month = '1', $shared = false)
{ {
$date = new Carbon($year . '-' . $month . '-01'); $start = new Carbon($year . '-' . $month . '-01');
$subTitle = 'Report for ' . $date->format('F Y'); $subTitle = trans('firefly.reportForMonth', ['date' => $start->formatLocalized($this->monthFormat)]);
$subTitleIcon = 'fa-calendar'; $subTitleIcon = 'fa-calendar';
$displaySum = true; // to show sums in report. $end = clone $start;
$end = clone $date;
$start = clone $date;
if ($shared == 'shared') {
$shared = true;
}
// set start and end.
$start->startOfMonth();
$end->endOfMonth();
// get all income and expenses. it's OK.
$income = $this->query->incomeInPeriod($start, $end, $shared);
$expensesSet = $this->query->journalsByExpenseAccount($start, $end, $shared);
/**
* INCLUDE ORIGINAL BUDGET REPORT HERE:
*/
// should show shared reports?
/** @var Preference $pref */
$accountAmounts = []; // array with sums of spent amounts on each account.
$accounts = $this->query->getAllAccounts($start, $end, $shared); // all accounts and some data.
foreach ($accounts as $account) {
$budgets = $this->query->getBudgetSummary($account, $start, $end);// get budget summary for this account:
$balancedAmount = $this->query->balancedTransactionsSum($account, $start, $end);
$accountAmounts[$account->id] = $balancedAmount;
// balance out the transactions (see transaction groups & tags) ^^
// array with budget information for each account:
$array = [];
// should always hide account
$hide = true;
// loop all budgets
/** @var \FireflyIII\Models\Budget $budget */
foreach ($budgets as $budget) {
$id = intval($budget->id);
$data = $budget->toArray();
$array[$id] = $data;
// no longer hide account if any budget has money in it.
if (floatval($data['queryAmount']) != 0) {
$hide = false;
}
$accountAmounts[$account->id] += $data['queryAmount'];
}
$account->hide = $hide;
$account->budgetInformation = $array;
$account->balancedAmount = $balancedAmount;
}
/**
* END ORIGINAL BUDGET REPORT
*/
/**
* Start getBudgetsForMonth DONE
*/
$budgets = $this->helper->getBudgetsForMonth($date, $shared);
/**
* End getBudgetsForMonth DONE
*/
/**
* Start getCategoriesForMonth DONE
*/
// all categories.
$result = $this->query->journalsByCategory($start, $end);
$categories = Steam::makeArray($result);
// all transfers
if ($shared === false) {
$result = $this->query->sharedExpensesByCategory($start, $end);
$transfers = Steam::makeArray($result);
$merged = Steam::mergeArrays($categories, $transfers);
} else {
$merged = $categories;
}
// sort.
$sorted = Steam::sortNegativeArray($merged);
// limit to $limit:
$categories = Steam::limitArray($sorted, 10);
/**
* End getCategoriesForMonth DONE
*/
// clean up and sort expenses:
$expenses = Steam::makeArray($expensesSet);
$expenses = Steam::sortArray($expenses);
$expenses = Steam::limitArray($expenses, 10);
return view(
'reports.month',
compact(
'income', 'expenses', 'budgets', 'accounts', 'categories', 'shared',
'date', 'subTitle', 'displaySum', 'subTitleIcon'
)
);
}
/**
* @param $year
*
* @return $this
*/
public function year($year, $shared = false)
{
$date = new Carbon('01-01-' . $year);
$end = clone $date;
$subTitle = trans('firefly.reportForYear', ['year' => $year]);
$subTitleIcon = 'fa-bar-chart';
$totalExpense = 0; $totalExpense = 0;
$totalIncome = 0; $totalIncome = 0;
$incomeTopLength = 8; $incomeTopLength = 8;
$expenseTopLength = 8; $expenseTopLength = 8;
if ($shared == 'shared') { if ($shared == 'shared') {
$shared = true; $shared = true;
$subTitle = trans('firefly.reportForYearShared', ['year' => $year]); $subTitle = trans('firefly.reportForMonthShared', ['date' => $start->formatLocalized($this->monthFormat)]);
}
$end->endOfYear();
/**
* ALL ACCOUNTS
* Summarized as well.
*/
$accounts = $this->query->getAllAccounts($date, $end, $shared);
$accountsSums = ['start' => 0, 'end' => 0, 'diff' => 0];
// summarize:
foreach ($accounts as $account) {
$accountsSums['start'] += $account->startBalance;
$accountsSums['end'] += $account->endBalance;
$accountsSums['diff'] += ($account->endBalance - $account->startBalance);
} }
$end->endOfMonth();
// all accounts:
$accounts = $this->helper->getAccountReport($start, $end, $shared);
/** /**
* ALL INCOMES. * ALL INCOMES.
* Grouped, sorted and summarized. * Grouped, sorted and summarized.
*/ */
$set = $this->query->incomeInPeriod($date, $end, $shared); $set = $this->query->incomeInPeriod($start, $end, $shared);
// group, sort and sum: // group, sort and sum:
$incomes = []; $incomes = [];
foreach ($set as $entry) { foreach ($set as $entry) {
@@ -327,7 +200,7 @@ class ReportController extends Controller
* GET ALL EXPENSES * GET ALL EXPENSES
* Summarized. * Summarized.
*/ */
$set = $this->query->expenseInPeriod($date, $end, $shared); $set = $this->query->expenseInPeriod($start, $end, $shared);
// group, sort and sum: // group, sort and sum:
$expenses = []; $expenses = [];
foreach ($set as $entry) { foreach ($set as $entry) {
@@ -357,14 +230,214 @@ class ReportController extends Controller
); );
unset($set, $id); unset($set, $id);
/**
* DO BUDGETS.
*/
/** @var \FireflyIII\Repositories\Budget\BudgetRepositoryInterface $repository */
$repository = App::make('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
$set = $repository->getBudgets();
$budgets = new Collection;
$budgetSums = ['budgeted' => 0, 'spent' => 0, 'left' => 0, 'overspent' => 0];
/** @var Budget $budget */
foreach ($set as $budget) {
$repetitions = $repository->getBudgetLimitRepetitions($budget, $start, $end);
if ($repetitions->count() == 0) {
$exp = $repository->spentInPeriod($budget, $start, $end, $shared);
$budgets->push([$budget, null, 0, 0, $exp]);
$budgetSums['overspent'] += $exp;
continue;
}
/** @var LimitRepetition $repetition */
foreach ($repetitions as $repetition) {
$exp = $repository->spentInPeriod($budget, $repetition->startdate, $repetition->enddate, $shared);
$left = $exp < floatval($repetition->amount) ? floatval($repetition->amount) - $exp : 0;
$spent = $exp > floatval($repetition->amount) ? 0 : $exp;
$overspent = $exp > floatval($repetition->amount) ? $exp - floatval($repetition->amount) : 0;
$budgetSums['budgeted'] += floatval($repetition->amount);
$budgetSums['spent'] += $spent;
$budgetSums['left'] += $left;
$budgetSums['overspent'] += $overspent;
$budgets->push([$budget, $repetition, $left, $spent, $overspent]);
}
}
$noBudgetExpenses = $repository->getWithoutBudgetSum($start, $end);
$budgets->push([null, null, 0, 0, $noBudgetExpenses]);
$budgetSums['overspent'] += $noBudgetExpenses;
unset($noBudgetExpenses, $repository, $set, $repetition, $repetitions, $exp);
/**
* GET CATEGORIES:
*/
/** @var \FireflyIII\Repositories\Category\CategoryRepositoryInterface $repository */
$repository = App::make('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
$set = $repository->getCategories();
$categories = [];
$categorySum = 0;
foreach ($set as $category) {
$spent = $repository->spentInPeriod($category, $start, $end, $shared);
$categories[] = [$category, $spent];
$categorySum += $spent;
}
// no category:
// sort with callback:
uasort(
$categories, function ($a, $b) {
if ($a[1] == $b[1]) {
return 0;
}
return ($a[1] < $b[1]) ? 1 : -1;
}
);
unset($set, $repository, $spent);
return view(
'reports.month',
compact(
'start', 'shared',
'subTitle', 'subTitleIcon',
'accounts', 'accountsSums',
'incomes', 'totalIncome', 'incomeTopLength',
'expenses', 'totalExpense', 'expenseTopLength',
'budgets', 'budgetSums',
'categories', 'categorySum'
)
);
// get all income and expenses. it's OK.
// $income = $this->query->incomeInPeriod($start, $end, $shared);
// $expensesSet = $this->query->journalsByExpenseAccount($start, $end, $shared);
//
// /**
// * INCLUDE ORIGINAL BUDGET REPORT HERE:
// */
// // should show shared reports?
// /** @var Preference $pref */
// $accountAmounts = []; // array with sums of spent amounts on each account.
// $accounts = $this->query->getAllAccounts($start, $end, $shared); // all accounts and some data.
//
// foreach ($accounts as $account) {
//
// $budgets = $this->query->getBudgetSummary($account, $start, $end);// get budget summary for this account:
// $balancedAmount = $this->query->balancedTransactionsSum($account, $start, $end);
// $accountAmounts[$account->id] = $balancedAmount;
// // balance out the transactions (see transaction groups & tags) ^^
//
// // array with budget information for each account:
// $array = [];
// // should always hide account
// $hide = true;
// // loop all budgets
// /** @var \FireflyIII\Models\Budget $budget */
// foreach ($budgets as $budget) {
// $id = intval($budget->id);
// $data = $budget->toArray();
// $array[$id] = $data;
//
// // no longer hide account if any budget has money in it.
// if (floatval($data['queryAmount']) != 0) {
// $hide = false;
// }
// $accountAmounts[$account->id] += $data['queryAmount'];
// }
// $account->hide = $hide;
// $account->budgetInformation = $array;
// $account->balancedAmount = $balancedAmount;
//
// }
// /**
// * END ORIGINAL BUDGET REPORT
// */
//
// /**
// * Start getBudgetsForMonth DONE
// */
// $budgets = $this->helper->getBudgetsForMonth($date, $shared);
//
// /**
// * End getBudgetsForMonth DONE
// */
// /**
// * Start getCategoriesForMonth DONE
// */
// // all categories.
// $result = $this->query->journalsByCategory($start, $end);
// $categories = Steam::makeArray($result);
//
//
// // all transfers
// if ($shared === false) {
// $result = $this->query->sharedExpensesByCategory($start, $end);
// $transfers = Steam::makeArray($result);
// $merged = Steam::mergeArrays($categories, $transfers);
// } else {
// $merged = $categories;
// }
//
//
// // sort.
// $sorted = Steam::sortNegativeArray($merged);
//
// // limit to $limit:
// $categories = Steam::limitArray($sorted, 10);
//
// /**
// * End getCategoriesForMonth DONE
// */
//
//
// // clean up and sort expenses:
// $expenses = Steam::makeArray($expensesSet);
// $expenses = Steam::sortArray($expenses);
// $expenses = Steam::limitArray($expenses, 10);
//
//
// return view(
// 'reports.month',
// compact(
// 'income', 'expenses', 'budgets', 'accounts', 'categories', 'shared',
// 'date', 'subTitle', 'displaySum', 'subTitleIcon'
// )
// );
}
/**
* @param $year
*
* @return $this
*/
public function year($year, $shared = false)
{
$start = new Carbon('01-01-' . $year);
$end = clone $start;
$subTitle = trans('firefly.reportForYear', ['year' => $year]);
$subTitleIcon = 'fa-bar-chart';
$incomeTopLength = 8;
$expenseTopLength = 8;
if ($shared == 'shared') {
$shared = true;
$subTitle = trans('firefly.reportForYearShared', ['year' => $year]);
}
$end->endOfYear();
$accounts = $this->helper->getAccountReport($start, $end, $shared);
$incomes = $this->helper->getIncomeReport($start, $end, $shared);
$expenses = $this->helper->getExpenseReport($start, $end, $shared);
return view( return view(
'reports.year', 'reports.year',
compact( compact(
'date', // the date for this report. 'start', // the date for this report.
'shared', // is a shared report? 'shared', // is a shared report?
'totalExpense', 'totalIncome', // total income and expense.
'accounts', // all accounts 'accounts', // all accounts
'accountsSums', // sums for all accounts
'incomes', 'expenses', // expenses and incomes. 'incomes', 'expenses', // expenses and incomes.
'subTitle', 'subTitleIcon', // subtitle and subtitle icon. 'subTitle', 'subTitleIcon', // subtitle and subtitle icon.
'incomeTopLength', // length of income top X 'incomeTopLength', // length of income top X

View File

@@ -88,10 +88,22 @@ return [
'reportForYear' => 'Yearly report for :year', 'reportForYear' => 'Yearly report for :year',
'reportForYearShared' => 'Yearly report for :year (including shared accounts)', 'reportForYearShared' => 'Yearly report for :year (including shared accounts)',
'reportForMonth' => 'Montly report for :year',
'reportForMonthShared' => 'Montly report for :year (including shared accounts)',
'incomeVsExpenses' => 'Income vs. expenses', 'incomeVsExpenses' => 'Income vs. expenses',
'accountBalances' => 'Account balances', 'accountBalances' => 'Account balances',
'balanceStartOfYear' => 'Balance at start of year', 'balanceStartOfYear' => 'Balance at start of year',
'balanceEndOfYear' => 'Balance at end of year', 'balanceEndOfYear' => 'Balance at end of year',
'balanceStartOfMonth' => 'Balance at end of month',
'balanceEndOfMonth' => 'Balance at end of month',
'account' => 'Account',
'splitByAccount' => 'Split by account',
'balancedByTransfersAndTags' => 'Balanced by transfers and tags',
'leftUnbalanced' => 'Left unbalanced',
'expectedBalance' => 'Expected balance',
'outsideOfBudgets' => 'Outside of budgets',
'difference' => 'Difference', 'difference' => 'Difference',
'in' => 'In', 'in' => 'In',
'out' => 'Out', 'out' => 'Out',

View File

@@ -88,10 +88,22 @@ return [
'reportForYear' => 'Jaaroverzicht :year', 'reportForYear' => 'Jaaroverzicht :year',
'reportForYearShared' => 'Jaaroverzicht :year (inclusief gedeelde rekeningen)', 'reportForYearShared' => 'Jaaroverzicht :year (inclusief gedeelde rekeningen)',
'reportForMonth' => 'Maandoverzicht van :date',
'reportForMonthShared' => 'Maandoverzicht van :date (inclusief gedeelde rekeningen)',
'incomeVsExpenses' => 'Inkomsten tegenover uitgaven', 'incomeVsExpenses' => 'Inkomsten tegenover uitgaven',
'accountBalances' => 'Rekeningsaldi', 'accountBalances' => 'Rekeningsaldi',
'balanceStartOfYear' => 'Saldo aan het begin van het jaar', 'balanceStartOfYear' => 'Saldo aan het begin van het jaar',
'balanceEndOfYear' => 'Saldo aan het einde van het jaar', 'balanceEndOfYear' => 'Saldo aan het einde van het jaar',
'balanceStartOfMonth' => 'Saldo aan het einde van de maand',
'balanceEndOfMonth' => 'Saldo aan het einde van de maand',
'account' => 'Rekening',
'splitByAccount' => 'Per betaalrekening',
'balancedByTransfersAndTags' => 'Gecorrigeerd met overschrijvingen en tags',
'leftUnbalanced' => 'Ongecorrigeerd',
'expectedBalance' => 'Verwacht saldo',
'outsideOfBudgets' => 'Buiten budgetten',
'difference' => 'Verschil', 'difference' => 'Verschil',
'in' => 'In', 'in' => 'In',
'out' => 'Uit', 'out' => 'Uit',

View File

@@ -1,197 +1,34 @@
{% extends "./layout/default.twig" %} {% extends "./layout/default.twig" %}
{% block content %} {% block content %}
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, date, shared) }} {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, start, shared) }}
<div class="row"> <div class="row">
<div class="col-lg-5 col-md-5 col-sm-12">
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-long-arrow-right fa-fw"></i>
Income
</div>
<table class="table table-bordered">
{% set sum = 0 %}
{% for entry in income %}
{% set sum = sum + entry.queryAmount %}
<tr>
<td>
<a href="{{ route('transactions.show',entry.id) }}" title="{{ entry.description }}">{{ entry.description }}</a>
</td>
<td>
{% if entry.type == 'Withdrawal' %}
<span class="text-danger">{{entry.queryAmount|formatAmountPlain}}</span>
{% endif %}
{% if entry.type == 'Deposit' %}
<span class="text-success">{{entry.queryAmount|formatAmountPlain}}</span>
{% endif %}
{% if entry.type == 'Transfer' %}
<span class="text-info">{{entry.queryAmount|formatAmountPlain}}</span>
{% endif %}
</td>
<td>
{{entry.date.format('j F Y')}}
</td>
<td>
<a href="{{route('accounts.show',entry.account_id)}}">{{ entry.name }}</a>
</td>
</tr>
{% endfor %}
{% if displaySum %}
<tr>
<td><em>Sum</em></td>
<td colspan="3">{{ sum|formatAmount }}</td>
</tr>
{% endif %}
</table>
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-12">
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-long-arrow-left fa-fw"></i>
Expenses (top 10)
</div>
<table class="table table-bordered">
{% set sum = 0 %}
{% for id,expense in expenses %}
{% set sum = sum + expense.queryAmount %}
<tr>
{% if id > 0 %}
<td><a href="{{route('accounts.show',id)}}">{{ expense.name }}</a></td>
{% else %}
<td><em>{{ expense.name }}</em></td>
{% endif %}
<td><span class="text-danger">{{ expense.queryAmount|formatAmountPlain }}</span></td>
</tr>
{% endfor %}
<tr>
<td><em>Sum</em></td>
<td><span class="text-danger">{{ sum|formatAmountPlain }}</span></td>
</tr>
</table>
</div>
</div>
<div class="col-lg-3 col-md-4 col-sm-12">
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-exchange fa-fw"></i>
Sums
</div>
{% set totalIn = 0 %}
{% for entry in income %}
{% set totalIn = totalIn + entry.queryAmount %}
{% endfor %}
<table class="table table-bordered">
<tr>
<td>In</td>
<td>{{ totalIn|formatAmount }}</td>
</tr>
<tr>
<td>Out</td>
<td><span class="text-danger">{{ sum|formatAmountPlain }}</span></td>
</tr>
<tr>
<td>Difference</td>
<td>{{ (totalIn - sum)|formatAmount }}</td>
</tr>
</table>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-tasks fa-fw"></i>
Budgets
</div>
<table class="table table-bordered">
<tr>
<th>Budget</th>
<th>Envelope</th>
<th>Spent</th>
<th>Left</th>
</tr>
{% set sumSpent = 0 %}
{% set sumEnvelope = 0 %}
{% set sumLeft = 0 %}
{% for id,budget in budgets %}
{% set sumSpent = sumSpent + budget.spent %}
{% set sumEnvelope = sumEnvelope + budget.queryAmount %}
{% set sumLeft = sumLeft + budget.queryAmount + budget.spent %}
<!-- only display when relevant: -->
{% if budget.queryAmount != 0 or budget.spent != 0 %}
<tr>
<td>
{% if id > 0 %}
<a href="{{route('budgets.show',id)}}">{{ budget.name }}</a>
{% else %}
<em>{{ budget.name }}</em>
{% endif %}
</td>
<td>{{ budget.queryAmount|formatAmount }}</td>
<td><span class="text-danger">{{ (budget.spent*-1)|formatAmountPlain }}</span></td>
<td>{{ (budget.queryAmount + budget.spent)|formatAmount }}</td>
</tr>
{% endif %}
{% endfor %}
<tr>
<td><em>Sum</em></td>
<td>{{ sumEnvelope|formatAmount }}</td>
<td>{{ sumSpent|formatAmount }}</td>
<td>{{ sumLeft|formatAmount }}</td>
</tr>
</table>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-bar-chart fa-fw"></i>
Categories
</div>
<table class="table table-bordered">
<tr>
<th>Category</th>
<th>Spent</th>
</tr>
{% set sum = 0 %}
{% for id,category in categories %}
{% set sum = sum + category.queryAmount %}
<tr>
<td>
{% if id > 0 %}
<a href="{{route('categories.show',id)}}">{{ category.name }}</a>
{% else %}
<em>{{ category.name }}</em>
{% endif %}
</td>
<td><span class="text-danger">{{ (category.queryAmount * -1)|formatAmountPlain }}</span></td>
</tr>
{% endfor %}
<tr>
<td><em>Sum</em></td>
<td><span class="text-danger">{{ (sum * -1)|formatAmountPlain }}</span></td>
</tr>
</table>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12"> <div class="col-lg-12 col-md-12 col-sm-12">
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-line-chart"></i>
{{ 'accountBalances'|_ }}
</div>
<div class="panel-body">
<div id="account-balances-chart"></div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<i class="fa fa-fw fa-credit-card"></i> <i class="fa fa-fw fa-credit-card"></i>
Accounts {{ 'accountBalances'|_ }}
</div> </div>
<table class="table table-bordered table-striped"> <table class="table table-bordered table-striped">
<tr> <tr>
<th>Account</th> <th>{{ 'account'|_ }}</th>
<th>Start of month</th> <th>{{ 'balanceStartOfMonth'|_ }}</th>
<th>Current balance</th> <th>{{ 'balanceEndOfMonth'|_ }}</th>
<th>Spent</th> <th>{{ 'difference'|_ }}</th>
<th>Earned</th>
</tr> </tr>
{% for account in accounts %} {% for account in accounts %}
@@ -200,47 +37,237 @@
<td>{{ account.startBalance|formatAmount }}</td> <td>{{ account.startBalance|formatAmount }}</td>
<td>{{ account.endBalance|formatAmount }}</td> <td>{{ account.endBalance|formatAmount }}</td>
<td> <td>
{% if account.startBalance - account.endBalance > 0 %} {{ (account.startBalance - account.endBalance)|formatAmount }}
<span class="text-danger">{{ (account.startBalance - account.endBalance)|formatAmountPlain }}</span> </td>
</tr>
{% endfor %}
</table>
</div>
<!-- income vs expenses -->
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-fw fa-exchange"></i>
{{ 'incomeVsExpenses'|_ }}
</div>
<table class="table table-bordered table-striped">
<tr>
<td>{{ 'in'|_ }}</td>
<td>{{ totalIncome|formatAmount }}</td>
</tr>
<tr>
<td>{{ 'out'|_ }}</td>
<td><span class="text-danger">{{ (totalExpense * -1)|formatAmountPlain }}</span></td>
</tr>
<tr>
<td>{{ 'difference'|_ }}</td>
<td>{{ (totalIncome + totalExpense)|formatAmount }}</td>
</tr>
</table>
</div>
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
<!-- income -->
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-long-arrow-right fa-fw"></i>
{{ 'income'|_ }} ({{ trans('firefly.topX',{number: incomeTopLength}) }})
</div>
<table class="table">
{% for id,row in incomes %}
{% if loop.index > incomeTopLength %}
<tr class="collapse out incomesCollapsed">
{% else %}
<tr>
{% endif %}
<td>
<a href="{{ route('accounts.show',id) }}" title="{{ row.name }}">{{ row.name }}</a>
{% if row.count > 1 %}
<br /><small>{{ row.count }} {{ 'transactions'|_|lower }}</small>
{% endif %}
</td>
<td>{{ row.amount|formatAmount }}</td>
</tr>
{% endfor %}
{% if incomes|length > incomeTopLength %}
<tr>
<td colspan="2" class="active">
<a href="#" id="showIncomes">{{ trans('firefly.showTheRest',{number:incomeTopLength}) }}</a>
</td>
</tr>
{% endif %}
<tr>
<td><em>{{ 'sum'|_ }}</em></td>
<td>{{ totalIncome|formatAmount }}</td>
</tr>
</table>
</div>
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
<!-- expenses -->
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-long-arrow-left fa-fw"></i>
{{ 'expenses'|_ }} ({{ trans('firefly.topX',{number: expenseTopLength}) }})
</div>
<table class="table">
{% set sum =0 %}
{% for row in expenses %}
{% if loop.index > expenseTopLength %}
<tr class="collapse out expenseCollapsed">
{% else %}
<tr>
{% endif %}
<td>
<a href="{{ route('accounts.show',row.id) }}">{{ row.name }}</a>
{% if row.count > 1 %}
<br /><small>{{ row.count }} {{ 'transactions'|_|lower }}</small>
{% endif %}
</td>
<td><span class="text-danger">{{ (row.amount*-1)|formatAmountPlain }}</span></td>
</tr>
{% set sum = sum + row.amount %}
{% endfor %}
{% if expenses|length > expenseTopLength %}
<tr>
<td colspan="2" class="active">
<a href="#" id="showExpenses">{{ trans('firefly.showTheRest',{number:incomeTopLength}) }}</a>
</td>
</tr>
{% endif %}
<tr>
<td><em>{{ 'sum'|_ }}</em></td>
<td><span class="text-danger">{{ (sum * -1)|formatAmountPlain }}</span></td>
</tr>
</table>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-12">
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-tasks fa-fw"></i>
{{ 'budgets'|_ }}
</div>
<table class="table table-bordered">
<tr>
<th>{{ 'budget'|_ }}</th>
<th>{{ 'date'|_ }}</th>
<th>{{ 'budgeted'|_ }}</th>
<th>{{ 'spent'|_ }}</th>
<th>{{ 'left'|_ }}</th>
<th>{{ 'overspent'|_ }}</th>
</tr>
{% for data in budgets %}
<tr>
<td>
{% if data[0] %}
<a href="{{route('budgets.show',data[0].id)}}">{{ data[0].name }}</a>
{% else %}
<em>{{ 'noBudget'|_ }}</em>
{% endif %} {% endif %}
</td> </td>
<td> <td>
{% if account.startBalance - account.endBalance < 0 %} {% if data[1] %}
<span class="text-success">{{ ((account.startBalance - account.endBalance)*-1)|formatAmountPlain }}</span> {{ data[1].startdate.formatLocalized(monthAndDayFormat) }}
{% endif %}
</td>
<td>
{% if data[1] %}
{{ data[1].amount|formatAmount }}
{% else %}
{{ 0|formatAmount }}
{% endif %}
</td>
<td>
{% if data[3] != 0 %}
{{ data[3]|formatAmount }}
{% endif %}
</td>
<td>
{% if data[2] != 0 %}
{{ data[2]|formatAmount }}
{% endif %}
</td>
<td>
{% if data[4] != 0 %}
<span class="text-danger">{{ data[4]|formatAmountPlain }}</span>
{% endif %} {% endif %}
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
<tr>
<td colspan="2"><em>{{ 'sum'|_ }}</em></td>
<td>{{ budgetSums.budgeted|formatAmount }}</td>
<td>{{ budgetSums.spent|formatAmount }}</td>
<td>{{ budgetSums.left|formatAmount }}</td>
<td><span class="text-danger">{{ budgetSums.overspent|formatAmountPlain }}</span></td>
</tr>
</table>
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-12">
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-bar-chart fa-fw"></i>
{{ 'categories'|_ }}
</div>
<table class="table table-bordered">
<tr>
<th>{{ 'categories'|_ }}</th>
<th>{{ 'spent'|_ }}</th>
</tr>
{% set sum = 0 %}
{% for data in categories %}
{% if data[1] > 0 %}
<tr>
<td>
<a href="{{route('categories.show',data[0].id)}}">{{ data[0].name }}</a>
</td>
<td><span class="text-danger">{{ (data[1])|formatAmountPlain }}</span></td>
</tr>
{% endif %}
{% endfor %}
</table> </table>
</div> </div>
</div> </div>
</div> </div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
</div>
</div>
<div class="row"> <div class="row">
<div class="col-lg-12 col-md-12 col-sm-12"> <div class="col-lg-12 col-md-12 col-sm-12">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<i class="fa fa-sort-amount-asc fa-fw"></i> <i class="fa fa-sort-amount-asc fa-fw"></i>
Budgets {{ 'budgets'|_ }} ({{ 'splitByAccount'|_|lower }})
</div> </div>
<table class="table table-bordered table-striped"> <table class="table table-bordered table-striped">
<tr> <tr>
<th colspan="2">Budgets</th> <th colspan="2">{{ 'budgets'|_ }}</th>
{% for account in accounts %} {% for account in accounts %}
{% if not account.hide %}
<th><a href="{{route('accounts.show',account.id)}}">{{ account.name }}</a></th> <th><a href="{{route('accounts.show',account.id)}}">{{ account.name }}</a></th>
{% endif %}
{% endfor %} {% endfor %}
<th colspan="2"> <th colspan="2">
Left in budget {{ 'leftInBudget'|_ }}
</th> </th>
</tr> </tr>
{% for id,budget in budgets %} {% for data in budgets %}
{% if data[0] %}
<tr> <tr>
<td>{{ budget.name }}</td> <td>{{ data[0].name }}</td>
<td>{{ budget.queryAmount|formatAmount }}</td> <td>
{% if data[1] %}
{{ data[1].amount|formatAmount }}
{% else %}
{{ 0|formatAmount }}
{% endif %}
</td>
{% set spent = 0 %} {% set spent = 0 %}
{% for account in accounts %} {% for account in accounts %}
{% if not account.hide %}
{% if account.budgetInformation[id] %} {% if account.budgetInformation[id] %}
<td> <td>
{% if id == 0 %} {% if id == 0 %}
@@ -255,14 +282,20 @@
{% else %} {% else %}
<td>{{ 0|formatAmount }}</td> <td>{{ 0|formatAmount }}</td>
{% endif %} {% endif %}
{% endfor %}
<td>
{% if data[1] %}
{{ (data[1].amount - data[3])|formatAmount }}
{% else %}
{{ (0 - data[3])|formatAmount }}
{% endif %}
</td>
<td>{{ data[2]|formatAmount }}</td>
</tr>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
<td>{{ (budget.queryAmount + budget.spent)|formatAmount }}</td>
<td>{{ (budget.queryAmount + spent)|formatAmount }}</td>
</tr>
{% endfor %}
<tr> <tr>
<td colspan="2">Balanced by transfers</td> <td colspan="2">{{ 'balancedByTransfersAndTags'|_ }}</td>
{% for account in accounts %} {% for account in accounts %}
{% if not account.hide %} {% if not account.hide %}
<td> <td>
@@ -273,7 +306,7 @@
<td colspan="2">&nbsp;</td> <td colspan="2">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td colspan="2">Left unbalanced</td> <td colspan="2">{{ 'leftUnbalanced'|_ }}</td>
{% for account in accounts %} {% for account in accounts %}
{% if not account.hide %} {% if not account.hide %}
@@ -293,7 +326,7 @@
<td colspan="2">&nbsp;</td> <td colspan="2">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td colspan="2"><em>Sum</em></td> <td colspan="2"><em>{{ 'sum'|_ }}</em></td>
{% for account in accounts %} {% for account in accounts %}
{% if not account.hide %} {% if not account.hide %}
<td>{{ accountAmounts[account.id]|formatAmount }}</td> <td>{{ accountAmounts[account.id]|formatAmount }}</td>
@@ -302,7 +335,7 @@
<td colspan="2">&nbsp;</td> <td colspan="2">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td colspan="2">Expected balance</td> <td colspan="2">{{ 'expectedBalance'|_ }}</td>
{% for account in accounts %} {% for account in accounts %}
{% if not account.hide %} {% if not account.hide %}
<td>{{ (account.startBalance + accountAmounts[account.id])|formatAmount }}</td> <td>{{ (account.startBalance + accountAmounts[account.id])|formatAmount }}</td>
@@ -320,7 +353,7 @@
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<i class="fa fa-calendar-o fa-fw"></i> <i class="fa fa-calendar-o fa-fw"></i>
Bills {{ 'bills'|_ }}
</div> </div>
<div class="panel-body">Body</div> <div class="panel-body">Body</div>
</div> </div>
@@ -331,7 +364,7 @@
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<i class="fa fa-fw fa-folder-o"></i> <i class="fa fa-fw fa-folder-o"></i>
Outside of budgets {{ 'outsideOfBudgets'|_ }}
</div> </div>
<div class="panel-body">Body</div> <div class="panel-body">Body</div>
</div> </div>
@@ -339,5 +372,16 @@
</div> </div>
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
<script type="text/javascript">
var shared = {% if shared %}'/shared'{% else %}''{% endif %};
var incomeTopLength = {{ incomeTopLength }};
var expenseTopLength = {{ expenseTopLength }};
var incomeRestShow = false; // starts hidden.
var expenseRestShow = false; // starts hidden.
var showTheRest = '{{ trans('firefly.showTheRest',{number:incomeTopLength}) }}';
var hideTheRest = '{{ trans('firefly.hideTheRest',{number:incomeTopLength}) }}';
var showTheRestExpense = '{{ trans('firefly.showTheRest',{number:expenseTopLength}) }}';
var hideTheRestExpense = '{{ trans('firefly.hideTheRest',{number:expenseTopLength}) }}';
</script>
<script type="text/javascript" src="js/reports.js"></script> <script type="text/javascript" src="js/reports.js"></script>
{% endblock %} {% endblock %}

View File

@@ -1,6 +1,6 @@
{% extends "./layout/default.twig" %} {% extends "./layout/default.twig" %}
{% block content %} {% block content %}
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, date, shared) }} {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, start, shared) }}
<div class="row"> <div class="row">
<div class="col-lg-10 col-md-8 col-sm-12"> <div class="col-lg-10 col-md-8 col-sm-12">
@@ -41,7 +41,7 @@
<th>{{ 'balanceStartOfYear'|_ }}</th> <th>{{ 'balanceStartOfYear'|_ }}</th>
<th>{{ 'difference'|_ }}</th> <th>{{ 'difference'|_ }}</th>
</tr> </tr>
{% for account in accounts %} {% for account in accounts.getAccounts %}
<tr> <tr>
<td> <td>
<a href="{{ route('accounts.show',account.id) }}" title="{{ account.name }}">{{ account.name }}</a> <a href="{{ route('accounts.show',account.id) }}" title="{{ account.name }}">{{ account.name }}</a>
@@ -53,9 +53,9 @@
{% endfor %} {% endfor %}
<tr> <tr>
<td><em>Sum of sums</em></td> <td><em>Sum of sums</em></td>
<td>{{ accountsSums.start|formatAmount }}</td> <td>{{ accounts.getStart|formatAmount }}</td>
<td>{{ accountsSums.end|formatAmount }}</td> <td>{{ accounts.getEnd|formatAmount }}</td>
<td>{{ accountsSums.diff|formatAmount }}</td> <td>{{ accounts.getDifference|formatAmount }}</td>
</tr> </tr>
</table> </table>
</div> </div>
@@ -88,22 +88,22 @@
{{ 'income'|_ }} ({{ trans('firefly.topX',{number: incomeTopLength}) }}) {{ 'income'|_ }} ({{ trans('firefly.topX',{number: incomeTopLength}) }})
</div> </div>
<table class="table"> <table class="table">
{% for id,row in incomes %} {% for income in incomes.getIncomes %}
{% if loop.index > incomeTopLength %} {% if loop.index > incomeTopLength %}
<tr class="collapse out incomesCollapsed"> <tr class="collapse out incomesCollapsed">
{% else %} {% else %}
<tr> <tr>
{% endif %} {% endif %}
<td> <td>
<a href="{{ route('accounts.show',id) }}" title="{{ row.name }}">{{ row.name }}</a> <a href="{{ route('accounts.show',income.id) }}" title="{{ income.name }}">{{ income.name }}</a>
{% if row.count > 1 %} {% if income.count > 1 %}
<br /><small>{{ row.count }} {{ 'transactions'|_|lower }}</small> <br /><small>{{ income.count }} {{ 'transactions'|_|lower }}</small>
{% endif %} {% endif %}
</td> </td>
<td>{{ row.amount|formatAmount }}</td> <td>{{ income.amount|formatAmount }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
{% if incomes|length > incomeTopLength %} {% if incomes.getIncomes|length > incomeTopLength %}
<tr> <tr>
<td colspan="2" class="active"> <td colspan="2" class="active">
<a href="#" id="showIncomes">{{ trans('firefly.showTheRest',{number:incomeTopLength}) }}</a> <a href="#" id="showIncomes">{{ trans('firefly.showTheRest',{number:incomeTopLength}) }}</a>
@@ -112,7 +112,7 @@
{% endif %} {% endif %}
<tr> <tr>
<td><em>{{ 'sum'|_ }}</em></td> <td><em>{{ 'sum'|_ }}</em></td>
<td>{{ totalIncome|formatAmount }}</td> <td>{{ incomes.getTotal|formatAmount }}</td>
</tr> </tr>
</table> </table>
</div> </div>
@@ -124,24 +124,22 @@
{{ 'expenses'|_ }} ({{ trans('firefly.topX',{number: expenseTopLength}) }}) {{ 'expenses'|_ }} ({{ trans('firefly.topX',{number: expenseTopLength}) }})
</div> </div>
<table class="table"> <table class="table">
{% set sum =0 %} {% for expense in expenses.getExpenses %}
{% for row in expenses %}
{% if loop.index > expenseTopLength %} {% if loop.index > expenseTopLength %}
<tr class="collapse out expenseCollapsed"> <tr class="collapse out expenseCollapsed">
{% else %} {% else %}
<tr> <tr>
{% endif %} {% endif %}
<td> <td>
<a href="{{ route('accounts.show',row.id) }}">{{ row.name }}</a> <a href="{{ route('accounts.show',expense.id) }}">{{ expense.name }}</a>
{% if row.count > 1 %} {% if expense.count > 1 %}
<br /><small>{{ row.count }} {{ 'transactions'|_|lower }}</small> <br /><small>{{ expense.count }} {{ 'transactions'|_|lower }}</small>
{% endif %} {% endif %}
</td> </td>
<td><span class="text-danger">{{ (row.amount*-1)|formatAmountPlain }}</span></td> <td><span class="text-danger">{{ (expense.amount*-1)|formatAmountPlain }}</span></td>
</tr> </tr>
{% set sum = sum + row.amount %}
{% endfor %} {% endfor %}
{% if expenses|length > expenseTopLength %} {% if expenses.getExpenses|length > expenseTopLength %}
<tr> <tr>
<td colspan="2" class="active"> <td colspan="2" class="active">
<a href="#" id="showExpenses">{{ trans('firefly.showTheRest',{number:incomeTopLength}) }}</a> <a href="#" id="showExpenses">{{ trans('firefly.showTheRest',{number:incomeTopLength}) }}</a>
@@ -150,7 +148,7 @@
{% endif %} {% endif %}
<tr> <tr>
<td><em>{{ 'sum'|_ }}</em></td> <td><em>{{ 'sum'|_ }}</em></td>
<td><span class="text-danger">{{ (sum * -1)|formatAmountPlain }}</span></td> <td><span class="text-danger">{{ (expenses.getTotal * -1)|formatAmountPlain }}</span></td>
</tr> </tr>
</table> </table>
</div> </div>
@@ -191,7 +189,7 @@
<script type="text/javascript" src="js/gcharts.js"></script> <script type="text/javascript" src="js/gcharts.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var year = '{{date.year}}'; var year = '{{start.year}}';
var shared = {% if shared %}'/shared'{% else %}''{% endif %}; var shared = {% if shared %}'/shared'{% else %}''{% endif %};
var incomeTopLength = {{ incomeTopLength }}; var incomeTopLength = {{ incomeTopLength }};
var expenseTopLength = {{ expenseTopLength }}; var expenseTopLength = {{ expenseTopLength }};