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;
use App;
use Auth;
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 Illuminate\Database\Query\JoinClause;
use Illuminate\Support\Collection;
use Steam;
/**
* Class ReportHelper
@ -18,47 +16,94 @@ use Steam;
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 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);
$amountSet = $query->journalsByBudget($start, $end, $includeShared);
$amounts = Steam::makeArray($amountSet);
$budgets = Steam::mergeArrays($budgets, $amounts);
$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';
$accounts = $this->query->getAllAccounts($date, $end, $shared);
$start = 0;
$end = 0;
$diff = 0;
// find transactions to shared asset accounts, which are without a budget by default:
// which is only relevant when shared asset accounts are hidden.
if ($includeShared === false) {
$transfers = $query->sharedExpenses($start, $end)->sum('queryAmount');
$budgets[0]['spent'] += floatval($transfers) * -1;
// summarize:
foreach ($accounts as $account) {
$start += $account->startBalance;
$end += $account->endBalance;
$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;
}
}

View File

@ -3,7 +3,9 @@
namespace FireflyIII\Helpers\Report;
use Carbon\Carbon;
use Illuminate\Support\Collection;
use FireflyIII\Helpers\Collection\Account;
use FireflyIII\Helpers\Collection\Expense;
use FireflyIII\Helpers\Collection\Income;
/**
* 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 bool $includeShared
* @param Carbon $date
* @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

View File

@ -19,65 +19,6 @@ use Session;
*/
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.
*
@ -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.
*

View File

@ -1,14 +1,17 @@
<?php namespace FireflyIII\Http\Controllers;
use App;
use Carbon\Carbon;
use FireflyIII\Helpers\Report\ReportHelperInterface;
use FireflyIII\Helpers\Report\ReportQueryInterface;
use FireflyIII\Models\Account;
use FireflyIII\Models\Budget;
use FireflyIII\Models\LimitRepetition;
use FireflyIII\Models\Preference;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Illuminate\Support\Collection;
use Session;
use Steam;
use View;
/**
@ -46,10 +49,8 @@ class ReportController extends Controller
*/
public function index(AccountRepositoryInterface $repository)
{
$start = Session::get('first');
$months = $this->helper->listOfMonths($start);
$title = 'Reports';
$mainTitleIcon = 'fa-line-chart';
$start = Session::get('first');
$months = $this->helper->listOfMonths($start);
// does the user have shared accounts?
$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)
{
$date = new Carbon($year . '-' . $month . '-01');
$subTitle = 'Report for ' . $date->format('F Y');
$subTitleIcon = 'fa-calendar';
$displaySum = true; // to show sums in report.
$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';
$start = new Carbon($year . '-' . $month . '-01');
$subTitle = trans('firefly.reportForMonth', ['date' => $start->formatLocalized($this->monthFormat)]);
$subTitleIcon = 'fa-calendar';
$end = clone $start;
$totalExpense = 0;
$totalIncome = 0;
$incomeTopLength = 8;
$expenseTopLength = 8;
if ($shared == 'shared') {
$shared = true;
$subTitle = trans('firefly.reportForYearShared', ['year' => $year]);
}
$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);
$subTitle = trans('firefly.reportForMonthShared', ['date' => $start->formatLocalized($this->monthFormat)]);
}
$end->endOfMonth();
// all accounts:
$accounts = $this->helper->getAccountReport($start, $end, $shared);
/**
* ALL INCOMES.
* Grouped, sorted and summarized.
*/
$set = $this->query->incomeInPeriod($date, $end, $shared);
$set = $this->query->incomeInPeriod($start, $end, $shared);
// group, sort and sum:
$incomes = [];
foreach ($set as $entry) {
@ -327,7 +200,7 @@ class ReportController extends Controller
* GET ALL EXPENSES
* Summarized.
*/
$set = $this->query->expenseInPeriod($date, $end, $shared);
$set = $this->query->expenseInPeriod($start, $end, $shared);
// group, sort and sum:
$expenses = [];
foreach ($set as $entry) {
@ -357,14 +230,214 @@ class ReportController extends Controller
);
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(
'reports.year',
compact(
'date', // the date for this report.
'start', // the date for this report.
'shared', // is a shared report?
'totalExpense', 'totalIncome', // total income and expense.
'accounts', // all accounts
'accountsSums', // sums for all accounts
'incomes', 'expenses', // expenses and incomes.
'subTitle', 'subTitleIcon', // subtitle and subtitle icon.
'incomeTopLength', // length of income top X

View File

@ -2,135 +2,147 @@
// general fields and things.
return [
'test' => 'You have selected English.',
'close' => 'Close',
'pleaseHold' => 'Please hold...',
'mandatoryFields' => 'Mandatory fields',
'optionalFields' => 'Optional fields',
'options' => 'Options',
'something' => 'Something!',
'actions' => 'Actions',
'edit' => 'Edit',
'delete' => 'Delete',
'welcomeBack' => 'What\'s playing?',
'test' => 'You have selected English.',
'close' => 'Close',
'pleaseHold' => 'Please hold...',
'mandatoryFields' => 'Mandatory fields',
'optionalFields' => 'Optional fields',
'options' => 'Options',
'something' => 'Something!',
'actions' => 'Actions',
'edit' => 'Edit',
'delete' => 'Delete',
'welcomeBack' => 'What\'s playing?',
// new user:
'welcome' => 'Welcome to Firefly!',
'createNewAsset' => 'Create a new asset account to get started. This will allow you to create transactions and start your financial management',
'createNewAssetButton' => 'Create new asset account',
'welcome' => 'Welcome to Firefly!',
'createNewAsset' => 'Create a new asset account to get started. This will allow you to create transactions and start your financial management',
'createNewAssetButton' => 'Create new asset account',
// home page:
'yourAccounts' => 'Your accounts',
'budgetsAndSpending' => 'Budgets and spending',
'savings' => 'Savings',
'markAsSavingsToContinue' => 'Mark your asset accounts as "Savings account" to fill this panel',
'createPiggyToContinue' => 'Create piggy banks to fill this panel.',
'newWithdrawal' => 'New expense',
'newDeposit' => 'New deposit',
'newTransfer' => 'New transfer',
'moneyIn' => 'Money in',
'moneyOut' => 'Money out',
'billsToPay' => 'Bills to pay',
'billsPaid' => 'Bills paid',
'viewDetails' => 'View details',
'divided' => 'divided',
'toDivide' => 'left to divide',
'yourAccounts' => 'Your accounts',
'budgetsAndSpending' => 'Budgets and spending',
'savings' => 'Savings',
'markAsSavingsToContinue' => 'Mark your asset accounts as "Savings account" to fill this panel',
'createPiggyToContinue' => 'Create piggy banks to fill this panel.',
'newWithdrawal' => 'New expense',
'newDeposit' => 'New deposit',
'newTransfer' => 'New transfer',
'moneyIn' => 'Money in',
'moneyOut' => 'Money out',
'billsToPay' => 'Bills to pay',
'billsPaid' => 'Bills paid',
'viewDetails' => 'View details',
'divided' => 'divided',
'toDivide' => 'left to divide',
// menu and titles, should be recycled as often as possible:
'toggleNavigation' => 'Toggle navigation',
'seeAllReminders' => 'See all reminders',
'reminders' => 'Reminders',
'currency' => 'Currency',
'preferences' => 'Preferences',
'logout' => 'Logout',
'searchPlaceholder' => 'Search...',
'dashboard' => 'Dashboard',
'currencies' => 'Currencies',
'accounts' => 'Accounts',
'assetAccounts' => 'Asset accounts',
'expenseAccounts' => 'Expense accounts',
'revenueAccounts' => 'Revenue accounts',
'Asset account' => 'Asset account',
'Expense account' => 'Expense account',
'Revenue Account' => 'Revenue account',
'budgets' => 'Budgets',
'categories' => 'Categories',
'tags' => 'Tags',
'reports' => 'Reports',
'transactions' => 'Transactions',
'expenses' => 'Expenses',
'income' => 'Revenue / income',
'transfers' => 'Transfer',
'moneyManagement' => 'Money management',
'piggyBanks' => 'Piggy banks',
'bills' => 'Bills',
'createNew' => 'Create new',
'withdrawal' => 'Withdrawal',
'deposit' => 'Deposit',
'transfer' => 'Transfer',
'Withdrawal' => 'Withdrawal',
'Deposit' => 'Deposit',
'Transfer' => 'Transfer',
'bill' => 'Rekening',
'yes' => 'Yes',
'no' => 'No',
'amount' => 'Amount',
'newBalance' => 'New balance',
'overview' => 'Overview',
'saveOnAccount' => 'Save on account',
'unknown' => 'Unknown',
'daily' => 'Daily',
'weekly' => 'Weekly',
'monthly' => 'Monthly',
'quarterly' => 'Quarterly',
'half-year' => 'Every six months',
'yearly' => 'Yearly',
'toggleNavigation' => 'Toggle navigation',
'seeAllReminders' => 'See all reminders',
'reminders' => 'Reminders',
'currency' => 'Currency',
'preferences' => 'Preferences',
'logout' => 'Logout',
'searchPlaceholder' => 'Search...',
'dashboard' => 'Dashboard',
'currencies' => 'Currencies',
'accounts' => 'Accounts',
'assetAccounts' => 'Asset accounts',
'expenseAccounts' => 'Expense accounts',
'revenueAccounts' => 'Revenue accounts',
'Asset account' => 'Asset account',
'Expense account' => 'Expense account',
'Revenue Account' => 'Revenue account',
'budgets' => 'Budgets',
'categories' => 'Categories',
'tags' => 'Tags',
'reports' => 'Reports',
'transactions' => 'Transactions',
'expenses' => 'Expenses',
'income' => 'Revenue / income',
'transfers' => 'Transfer',
'moneyManagement' => 'Money management',
'piggyBanks' => 'Piggy banks',
'bills' => 'Bills',
'createNew' => 'Create new',
'withdrawal' => 'Withdrawal',
'deposit' => 'Deposit',
'transfer' => 'Transfer',
'Withdrawal' => 'Withdrawal',
'Deposit' => 'Deposit',
'Transfer' => 'Transfer',
'bill' => 'Rekening',
'yes' => 'Yes',
'no' => 'No',
'amount' => 'Amount',
'newBalance' => 'New balance',
'overview' => 'Overview',
'saveOnAccount' => 'Save on account',
'unknown' => 'Unknown',
'daily' => 'Daily',
'weekly' => 'Weekly',
'monthly' => 'Monthly',
'quarterly' => 'Quarterly',
'half-year' => 'Every six months',
'yearly' => 'Yearly',
'reportForYear' => 'Yearly report for :year',
'reportForYearShared' => 'Yearly report for :year (including shared accounts)',
'incomeVsExpenses' => 'Income vs. expenses',
'accountBalances' => 'Account balances',
'balanceStartOfYear' => 'Balance at start of year',
'balanceEndOfYear' => 'Balance at end of year',
'difference' => 'Difference',
'in' => 'In',
'out' => 'Out',
'topX' => 'top :number',
'showTheRest' => 'Show everything',
'hideTheRest' => 'Show only the top :number',
'reportForYear' => 'Yearly report for :year',
'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',
'accountBalances' => 'Account balances',
'balanceStartOfYear' => 'Balance at start 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',
'in' => 'In',
'out' => 'Out',
'topX' => 'top :number',
'showTheRest' => 'Show everything',
'hideTheRest' => 'Show only the top :number',
// charts:
'dayOfMonth' => 'Day of the month',
'month' => 'Month',
'budget' => 'Budget',
'spent' => 'Spent',
'overspent' => 'Overspent',
'left' => 'Left',
'noCategory' => '(no category)',
'noBudget' => '(no budget)',
'category' => 'Category',
'maxAmount' => 'Maximum amount',
'minAmount' => 'Minumum amount',
'billEntry' => 'Current bill entry',
'name' => 'Name',
'date' => 'Date',
'paid' => 'Paid',
'unpaid' => 'Unpaid',
'day' => 'Day',
'budgeted' => 'Budgeted',
'period' => 'Period',
'balance' => 'Balance',
'summary' => 'Summary',
'sum' => 'Sum',
'average' => 'Average',
'balanceFor' => 'Balance for :name',
'dayOfMonth' => 'Day of the month',
'month' => 'Month',
'budget' => 'Budget',
'spent' => 'Spent',
'overspent' => 'Overspent',
'left' => 'Left',
'noCategory' => '(no category)',
'noBudget' => '(no budget)',
'category' => 'Category',
'maxAmount' => 'Maximum amount',
'minAmount' => 'Minumum amount',
'billEntry' => 'Current bill entry',
'name' => 'Name',
'date' => 'Date',
'paid' => 'Paid',
'unpaid' => 'Unpaid',
'day' => 'Day',
'budgeted' => 'Budgeted',
'period' => 'Period',
'balance' => 'Balance',
'summary' => 'Summary',
'sum' => 'Sum',
'average' => 'Average',
'balanceFor' => 'Balance for :name',
'asset_accounts' => 'Asset accounts',
'expense_accounts' => 'Expense accounts',
'revenue_accounts' => 'Revenue accounts',
'asset_accounts' => 'Asset accounts',
'expense_accounts' => 'Expense accounts',
'revenue_accounts' => 'Revenue accounts',
// some extra help:
'accountExtraHelp_asset' => '',
'accountExtraHelp_expense' => '',
'accountExtraHelp_revenue' => '',
'accountExtraHelp_asset' => '',
'accountExtraHelp_expense' => '',
'accountExtraHelp_revenue' => '',
];

View File

@ -2,142 +2,154 @@
// general fields and things.
return [
'test' => 'Nederlands geselecteerd!',
'close' => 'Sluiten',
'pleaseHold' => 'Momentje...',
'mandatoryFields' => 'Verplichte velden',
'optionalFields' => 'Optionele velden',
'options' => 'Opties',
'something' => 'Iets!',
'actions' => 'Acties',
'edit' => 'Wijzig',
'delete' => 'Verwijder',
'welcomeBack' => 'Hoe staat het er voor?',
'test' => 'Nederlands geselecteerd!',
'close' => 'Sluiten',
'pleaseHold' => 'Momentje...',
'mandatoryFields' => 'Verplichte velden',
'optionalFields' => 'Optionele velden',
'options' => 'Opties',
'something' => 'Iets!',
'actions' => 'Acties',
'edit' => 'Wijzig',
'delete' => 'Verwijder',
'welcomeBack' => 'Hoe staat het er voor?',
// new user:
'welcome' => 'Welkom bij Firefly!',
'createNewAsset' => 'Maak om te beginnen een nieuwe betaalrekening. Dit is je start van je financiële beheer.',
'createNewAssetButton' => 'Maak een nieuwe betaalrekening',
'welcome' => 'Welkom bij Firefly!',
'createNewAsset' => 'Maak om te beginnen een nieuwe betaalrekening. Dit is je start van je financiële beheer.',
'createNewAssetButton' => 'Maak een nieuwe betaalrekening',
// home page:
'yourAccounts' => 'Je betaalrekeningen',
'budgetsAndSpending' => 'Budgetten en uitgaven',
'savings' => 'Sparen',
'markAsSavingsToContinue' => 'Om hier wat te zien stel je je betaalrekeningen in als "spaarrekening".',
'createPiggyToContinue' => 'Maak spaarpotjes om hier iets te zien.',
'newWithdrawal' => 'Nieuwe uitgave',
'newDeposit' => 'Nieuwe inkomsten',
'newTransfer' => 'Nieuwe overschrijving',
'moneyIn' => 'Inkomsten',
'moneyOut' => 'Uitgaven',
'billsToPay' => 'Openstaande rekeningen',
'billsPaid' => 'Betaalde rekeningen',
'viewDetails' => 'Meer info',
'divided' => 'verdeeld',
'toDivide' => 'te verdelen',
'yourAccounts' => 'Je betaalrekeningen',
'budgetsAndSpending' => 'Budgetten en uitgaven',
'savings' => 'Sparen',
'markAsSavingsToContinue' => 'Om hier wat te zien stel je je betaalrekeningen in als "spaarrekening".',
'createPiggyToContinue' => 'Maak spaarpotjes om hier iets te zien.',
'newWithdrawal' => 'Nieuwe uitgave',
'newDeposit' => 'Nieuwe inkomsten',
'newTransfer' => 'Nieuwe overschrijving',
'moneyIn' => 'Inkomsten',
'moneyOut' => 'Uitgaven',
'billsToPay' => 'Openstaande rekeningen',
'billsPaid' => 'Betaalde rekeningen',
'viewDetails' => 'Meer info',
'divided' => 'verdeeld',
'toDivide' => 'te verdelen',
// menu and titles, should be recycled as often as possible:
'toggleNavigation' => 'Navigatie aan of uit',
'seeAllReminders' => 'Bekijk alle herinneringen',
'reminders' => 'Herinneringen',
'currency' => 'Munteenheden',
'preferences' => 'Voorkeuren',
'logout' => 'Uitloggen',
'searchPlaceholder' => 'Zoeken...',
'dashboard' => 'Dashboard',
'currencies' => 'Munteenheden',
'accounts' => 'Rekeningen',
'assetAccounts' => 'Betaalrekeningen',
'expenseAccounts' => 'Crediteuren',
'revenueAccounts' => 'Debiteuren',
'Asset account' => 'Betaalrekening',
'Expense account' => 'Crediteur',
'Revenue Account' => 'Debiteur',
'budgets' => 'Budgetten',
'categories' => 'Categorieën',
'tags' => 'Tags',
'reports' => 'Overzichten',
'transactions' => 'Transacties',
'expenses' => 'Uitgaven',
'income' => 'Inkomsten',
'transfers' => 'Overschrijvingen',
'moneyManagement' => 'Geldbeheer',
'piggyBanks' => 'Spaarpotjes',
'bills' => 'Rekeningen',
'createNew' => 'Nieuw',
'withdrawal' => 'Uitgave',
'deposit' => 'Inkomsten',
'transfer' => 'Overschrijving',
'Withdrawal' => 'Uitgave',
'Deposit' => 'Inkomsten',
'Transfer' => 'Overschrijving',
'bill' => 'Rekening',
'yes' => 'Ja',
'no' => 'Nee',
'amount' => 'Bedrag',
'newBalance' => 'Nieuw saldo',
'overview' => 'Overzicht',
'saveOnAccount' => 'Sparen op rekening',
'unknown' => 'Onbekend',
'daily' => 'Dagelijks',
'weekly' => 'Wekelijks',
'monthly' => 'Maandelijks',
'quarterly' => 'Elk kwartaal',
'half-year' => 'Elk half jaar',
'yearly' => 'Jaarlijks',
'toggleNavigation' => 'Navigatie aan of uit',
'seeAllReminders' => 'Bekijk alle herinneringen',
'reminders' => 'Herinneringen',
'currency' => 'Munteenheden',
'preferences' => 'Voorkeuren',
'logout' => 'Uitloggen',
'searchPlaceholder' => 'Zoeken...',
'dashboard' => 'Dashboard',
'currencies' => 'Munteenheden',
'accounts' => 'Rekeningen',
'assetAccounts' => 'Betaalrekeningen',
'expenseAccounts' => 'Crediteuren',
'revenueAccounts' => 'Debiteuren',
'Asset account' => 'Betaalrekening',
'Expense account' => 'Crediteur',
'Revenue Account' => 'Debiteur',
'budgets' => 'Budgetten',
'categories' => 'Categorieën',
'tags' => 'Tags',
'reports' => 'Overzichten',
'transactions' => 'Transacties',
'expenses' => 'Uitgaven',
'income' => 'Inkomsten',
'transfers' => 'Overschrijvingen',
'moneyManagement' => 'Geldbeheer',
'piggyBanks' => 'Spaarpotjes',
'bills' => 'Rekeningen',
'createNew' => 'Nieuw',
'withdrawal' => 'Uitgave',
'deposit' => 'Inkomsten',
'transfer' => 'Overschrijving',
'Withdrawal' => 'Uitgave',
'Deposit' => 'Inkomsten',
'Transfer' => 'Overschrijving',
'bill' => 'Rekening',
'yes' => 'Ja',
'no' => 'Nee',
'amount' => 'Bedrag',
'newBalance' => 'Nieuw saldo',
'overview' => 'Overzicht',
'saveOnAccount' => 'Sparen op rekening',
'unknown' => 'Onbekend',
'daily' => 'Dagelijks',
'weekly' => 'Wekelijks',
'monthly' => 'Maandelijks',
'quarterly' => 'Elk kwartaal',
'half-year' => 'Elk half jaar',
'yearly' => 'Jaarlijks',
'reportForYear' => 'Jaaroverzicht :year',
'reportForYearShared' => 'Jaaroverzicht :year (inclusief gedeelde rekeningen)',
'incomeVsExpenses' => 'Inkomsten tegenover uitgaven',
'accountBalances' => 'Rekeningsaldi',
'balanceStartOfYear' => 'Saldo aan het begin van het jaar',
'balanceEndOfYear' => 'Saldo aan het einde van het jaar',
'difference' => 'Verschil',
'in' => 'In',
'out' => 'Uit',
'topX' => 'top :number',
'showTheRest' => 'Laat alles zien',
'hideTheRest' => 'Laat alleen de top :number zien',
'reportForYear' => 'Jaaroverzicht :year',
'reportForYearShared' => 'Jaaroverzicht :year (inclusief gedeelde rekeningen)',
'reportForMonth' => 'Maandoverzicht van :date',
'reportForMonthShared' => 'Maandoverzicht van :date (inclusief gedeelde rekeningen)',
'incomeVsExpenses' => 'Inkomsten tegenover uitgaven',
'accountBalances' => 'Rekeningsaldi',
'balanceStartOfYear' => 'Saldo aan het begin 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',
'in' => 'In',
'out' => 'Uit',
'topX' => 'top :number',
'showTheRest' => 'Laat alles zien',
'hideTheRest' => 'Laat alleen de top :number zien',
// charts:
'dayOfMonth' => 'Dag vd maand',
'month' => 'Maand',
'budget' => 'Budget',
'spent' => 'Uitgegeven',
'overspent' => 'Teveel uitgegeven',
'left' => 'Over',
'noCategory' => '(geen categorie)',
'noBudget' => '(geen budget)',
'category' => 'Categorie',
'maxAmount' => 'Maximaal bedrag',
'minAmount' => 'Minimaal bedrag',
'billEntry' => 'Bedrag voor deze rekening',
'name' => 'Naam',
'date' => 'Datum',
'paid' => 'Betaald',
'unpaid' => 'Niet betaald',
'day' => 'Dag',
'budgeted' => 'Gebudgetteerd',
'period' => 'Periode',
'balance' => 'Saldo',
'summary' => 'Samenvatting',
'sum' => 'Som',
'average' => 'Gemiddeld',
'balanceFor' => 'Saldo op :name',
'dayOfMonth' => 'Dag vd maand',
'month' => 'Maand',
'budget' => 'Budget',
'spent' => 'Uitgegeven',
'overspent' => 'Teveel uitgegeven',
'left' => 'Over',
'noCategory' => '(geen categorie)',
'noBudget' => '(geen budget)',
'category' => 'Categorie',
'maxAmount' => 'Maximaal bedrag',
'minAmount' => 'Minimaal bedrag',
'billEntry' => 'Bedrag voor deze rekening',
'name' => 'Naam',
'date' => 'Datum',
'paid' => 'Betaald',
'unpaid' => 'Niet betaald',
'day' => 'Dag',
'budgeted' => 'Gebudgetteerd',
'period' => 'Periode',
'balance' => 'Saldo',
'summary' => 'Samenvatting',
'sum' => 'Som',
'average' => 'Gemiddeld',
'balanceFor' => 'Saldo op :name',
'asset_accounts' => 'Betaalrekeningen',
'expense_accounts' => 'Crediteuren',
'revenue_accounts' => 'Debiteuren',
'asset_accounts' => 'Betaalrekeningen',
'expense_accounts' => 'Crediteuren',
'revenue_accounts' => 'Debiteuren',
// some extra help:
'accountExtraHelp_asset' => '',
'accountExtraHelp_expense' => 'Een crediteur is een persoon of een bedrijf waar je geld aan moet betalen. Je staat bij ze in het krijt. Een verwarrende' .
' term misschien, maar zo werkt het nou eenmaal. De supermarkt, je huurbaas of de bank zijn crediteuren. Jouw ' .
'geld (krediet) gaat naar hen toe. De term komt uit de wereld van de boekhouding. De uitgaves die je hier ziet zijn ' .
'positief, want je kijkt uit hun perspectief. Zodra jij afrekent in een winkel, komt het geld er bij hen bij (positief).',
'accountExtraHelp_revenue' => 'Als je geld krijgt van een bedrijf of een persoon is dat een debiteur. ' .
'Dat kan salaris zijn, of een andere betaling. ' .
' Ze hebben een schuld (debet) aan jou. De term komt uit de wereld van de boekhouding.' .
' De inkomsten die je hier ziet zijn negatief, want je kijkt uit hun perspectief. Zodra een debiteur geld naar jou ' .
'overmaakt gaat het er bij hen af (negatief).',
'accountExtraHelp_asset' => '',
'accountExtraHelp_expense' => 'Een crediteur is een persoon of een bedrijf waar je geld aan moet betalen. Je staat bij ze in het krijt. Een verwarrende' .
' term misschien, maar zo werkt het nou eenmaal. De supermarkt, je huurbaas of de bank zijn crediteuren. Jouw ' .
'geld (krediet) gaat naar hen toe. De term komt uit de wereld van de boekhouding. De uitgaves die je hier ziet zijn ' .
'positief, want je kijkt uit hun perspectief. Zodra jij afrekent in een winkel, komt het geld er bij hen bij (positief).',
'accountExtraHelp_revenue' => 'Als je geld krijgt van een bedrijf of een persoon is dat een debiteur. ' .
'Dat kan salaris zijn, of een andere betaling. ' .
' Ze hebben een schuld (debet) aan jou. De term komt uit de wereld van de boekhouding.' .
' De inkomsten die je hier ziet zijn negatief, want je kijkt uit hun perspectief. Zodra een debiteur geld naar jou ' .
'overmaakt gaat het er bij hen af (negatief).',
];

View File

@ -1,218 +1,241 @@
{% extends "./layout/default.twig" %}
{% block content %}
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, date, shared) }}
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, start, shared) }}
<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 class="row">
<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>
<table class="table table-bordered">
{% set sum = 0 %}
{% for entry in income %}
{% set sum = sum + entry.queryAmount %}
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-fw fa-credit-card"></i>
{{ 'accountBalances'|_ }}
</div>
<table class="table table-bordered table-striped">
<tr>
<th>{{ 'account'|_ }}</th>
<th>{{ 'balanceStartOfMonth'|_ }}</th>
<th>{{ 'balanceEndOfMonth'|_ }}</th>
<th>{{ 'difference'|_ }}</th>
</tr>
{% for account in accounts %}
<tr>
<td><a href="{{route('accounts.show',account.id)}}">{{ account.name }}</a></td>
<td>{{ account.startBalance|formatAmount }}</td>
<td>{{ account.endBalance|formatAmount }}</td>
<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>
{{ (account.startBalance - account.endBalance)|formatAmount }}
</td>
</tr>
{% endfor %}
{% if displaySum %}
</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><em>Sum</em></td>
<td colspan="3">{{ sum|formatAmount }}</td>
<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 %}
</td>
<td>
{% if data[1] %}
{{ 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 %}
</td>
</tr>
{% 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-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
{{ 'categories'|_ }}
</div>
<table class="table table-bordered">
<tr>
<th>Category</th>
<th>Spent</th>
<th>{{ 'categories'|_ }}</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>
{% 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 %}
<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="panel panel-default">
<div class="panel-heading">
<i class="fa fa-fw fa-credit-card"></i>
Accounts
</div>
<table class="table table-bordered table-striped">
<tr>
<th>Account</th>
<th>Start of month</th>
<th>Current balance</th>
<th>Spent</th>
<th>Earned</th>
</tr>
{% for account in accounts %}
<tr>
<td><a href="{{route('accounts.show',account.id)}}">{{ account.name }}</a></td>
<td>{{ account.startBalance|formatAmount }}</td>
<td>{{ account.endBalance|formatAmount }}</td>
<td>
{% if account.startBalance - account.endBalance > 0 %}
<span class="text-danger">{{ (account.startBalance - account.endBalance)|formatAmountPlain }}</span>
{% endif %}
</td>
<td>
{% if account.startBalance - account.endBalance < 0 %}
<span class="text-success">{{ ((account.startBalance - account.endBalance)*-1)|formatAmountPlain }}</span>
{% endif %}
</td>
</tr>
{% endfor %}
</table>
</div>
</div>
</div>
<div class="row">
@ -220,27 +243,31 @@
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-sort-amount-asc fa-fw"></i>
Budgets
{{ 'budgets'|_ }} ({{ 'splitByAccount'|_|lower }})
</div>
<table class="table table-bordered table-striped">
<tr>
<th colspan="2">Budgets</th>
<th colspan="2">{{ 'budgets'|_ }}</th>
{% for account in accounts %}
{% if not account.hide %}
<th><a href="{{route('accounts.show',account.id)}}">{{ account.name }}</a></th>
{% endif %}
<th><a href="{{route('accounts.show',account.id)}}">{{ account.name }}</a></th>
{% endfor %}
<th colspan="2">
Left in budget
{{ 'leftInBudget'|_ }}
</th>
</tr>
{% for id,budget in budgets %}
<tr>
<td>{{ budget.name }}</td>
<td>{{ budget.queryAmount|formatAmount }}</td>
{% set spent = 0 %}
{% for account in accounts %}
{% if not account.hide %}
{% for data in budgets %}
{% if data[0] %}
<tr>
<td>{{ data[0].name }}</td>
<td>
{% if data[1] %}
{{ data[1].amount|formatAmount }}
{% else %}
{{ 0|formatAmount }}
{% endif %}
</td>
{% set spent = 0 %}
{% for account in accounts %}
{% if account.budgetInformation[id] %}
<td>
{% if id == 0 %}
@ -255,14 +282,20 @@
{% else %}
<td>{{ 0|formatAmount }}</td>
{% endif %}
{% endif %}
{% endfor %}
<td>{{ (budget.queryAmount + budget.spent)|formatAmount }}</td>
<td>{{ (budget.queryAmount + spent)|formatAmount }}</td>
</tr>
{% 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 %}
{% endfor %}
<tr>
<td colspan="2">Balanced by transfers</td>
<td colspan="2">{{ 'balancedByTransfersAndTags'|_ }}</td>
{% for account in accounts %}
{% if not account.hide %}
<td>
@ -273,7 +306,7 @@
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2">Left unbalanced</td>
<td colspan="2">{{ 'leftUnbalanced'|_ }}</td>
{% for account in accounts %}
{% if not account.hide %}
@ -293,7 +326,7 @@
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2"><em>Sum</em></td>
<td colspan="2"><em>{{ 'sum'|_ }}</em></td>
{% for account in accounts %}
{% if not account.hide %}
<td>{{ accountAmounts[account.id]|formatAmount }}</td>
@ -302,7 +335,7 @@
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2">Expected balance</td>
<td colspan="2">{{ 'expectedBalance'|_ }}</td>
{% for account in accounts %}
{% if not account.hide %}
<td>{{ (account.startBalance + accountAmounts[account.id])|formatAmount }}</td>
@ -320,7 +353,7 @@
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-calendar-o fa-fw"></i>
Bills
{{ 'bills'|_ }}
</div>
<div class="panel-body">Body</div>
</div>
@ -331,7 +364,7 @@
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-fw fa-folder-o"></i>
Outside of budgets
{{ 'outsideOfBudgets'|_ }}
</div>
<div class="panel-body">Body</div>
</div>
@ -339,5 +372,16 @@
</div>
{% endblock %}
{% 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>
{% endblock %}

View File

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