diff --git a/app/Helpers/Collection/Account.php b/app/Helpers/Collection/Account.php
new file mode 100644
index 0000000000..9a49a3ce92
--- /dev/null
+++ b/app/Helpers/Collection/Account.php
@@ -0,0 +1,89 @@
+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;
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/Helpers/Collection/Expense.php b/app/Helpers/Collection/Expense.php
new file mode 100644
index 0000000000..fd2f0a112b
--- /dev/null
+++ b/app/Helpers/Collection/Expense.php
@@ -0,0 +1,80 @@
+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;
+ }
+}
\ No newline at end of file
diff --git a/app/Helpers/Collection/Income.php b/app/Helpers/Collection/Income.php
new file mode 100644
index 0000000000..a978ef10c4
--- /dev/null
+++ b/app/Helpers/Collection/Income.php
@@ -0,0 +1,83 @@
+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;
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php
index 08b54448c2..c5f046c432 100644
--- a/app/Helpers/Report/ReportHelper.php
+++ b/app/Helpers/Report/ReportHelper.php
@@ -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;
}
-
}
diff --git a/app/Helpers/Report/ReportHelperInterface.php b/app/Helpers/Report/ReportHelperInterface.php
index 64fecb8902..1a91975479 100644
--- a/app/Helpers/Report/ReportHelperInterface.php
+++ b/app/Helpers/Report/ReportHelperInterface.php
@@ -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
diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php
index 76d14c3be2..11031f865a 100644
--- a/app/Http/Controllers/Chart/BudgetController.php
+++ b/app/Http/Controllers/Chart/BudgetController.php
@@ -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.
*
diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php
index cecf279abc..2ae0518a7c 100644
--- a/app/Http/Controllers/ReportController.php
+++ b/app/Http/Controllers/ReportController.php
@@ -1,14 +1,17 @@
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
diff --git a/resources/lang/en/firefly.php b/resources/lang/en/firefly.php
index efaa73bce7..fd1845cfa2 100644
--- a/resources/lang/en/firefly.php
+++ b/resources/lang/en/firefly.php
@@ -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' => '',
];
diff --git a/resources/lang/nl/firefly.php b/resources/lang/nl/firefly.php
index f07a7e3f6b..12217c916b 100644
--- a/resources/lang/nl/firefly.php
+++ b/resources/lang/nl/firefly.php
@@ -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).',
];
diff --git a/resources/twig/reports/month.twig b/resources/twig/reports/month.twig
index f00f800a49..16594a5a8b 100644
--- a/resources/twig/reports/month.twig
+++ b/resources/twig/reports/month.twig
@@ -1,218 +1,241 @@
{% extends "./layout/default.twig" %}
{% block content %}
- {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, date, shared) }}
+ {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, start, shared) }}
-
-
-
-
-
- Income
+
+
+
+
+
+ {{ 'accountBalances'|_ }}
+
+
-
- {% set sum = 0 %}
- {% for entry in income %}
- {% set sum = sum + entry.queryAmount %}
+
+
+
+
+
+
+
+
+ {{ 'accountBalances'|_ }}
+
+
+
+ {{ 'account'|_ }} |
+ {{ 'balanceStartOfMonth'|_ }} |
+ {{ 'balanceEndOfMonth'|_ }} |
+ {{ 'difference'|_ }} |
+
+
+ {% for account in accounts %}
+ {{ account.name }} |
+ {{ account.startBalance|formatAmount }} |
+ {{ account.endBalance|formatAmount }} |
- {{ entry.description }}
- |
-
- {% if entry.type == 'Withdrawal' %}
- {{entry.queryAmount|formatAmountPlain}}
- {% endif %}
- {% if entry.type == 'Deposit' %}
- {{entry.queryAmount|formatAmountPlain}}
- {% endif %}
- {% if entry.type == 'Transfer' %}
- {{entry.queryAmount|formatAmountPlain}}
- {% endif %}
- |
-
- {{entry.date.format('j F Y')}}
- |
-
- {{ entry.name }}
+ {{ (account.startBalance - account.endBalance)|formatAmount }}
|
{% endfor %}
- {% if displaySum %}
+
+
+
+
+
+
+
+ {{ 'incomeVsExpenses'|_ }}
+
+
+
+ {{ 'in'|_ }} |
+ {{ totalIncome|formatAmount }} |
+
+
+ {{ 'out'|_ }} |
+ {{ (totalExpense * -1)|formatAmountPlain }} |
+
+
+ {{ 'difference'|_ }} |
+ {{ (totalIncome + totalExpense)|formatAmount }} |
+
+
+
+
+
+
+
+
+
+ {{ 'income'|_ }} ({{ trans('firefly.topX',{number: incomeTopLength}) }})
+
+
+ {% for id,row in incomes %}
+ {% if loop.index > incomeTopLength %}
+
+ {% else %}
+
+ {% endif %}
+
+ {{ row.name }}
+ {% if row.count > 1 %}
+ {{ row.count }} {{ 'transactions'|_|lower }}
+ {% endif %}
+ |
+ {{ row.amount|formatAmount }} |
+
+ {% endfor %}
+ {% if incomes|length > incomeTopLength %}
- Sum |
- {{ sum|formatAmount }} |
+
+ {{ trans('firefly.showTheRest',{number:incomeTopLength}) }}
+ |
{% endif %}
+
+ {{ 'sum'|_ }} |
+ {{ totalIncome|formatAmount }} |
+
+
+
+
+
+
+
+
+
+ {{ 'expenses'|_ }} ({{ trans('firefly.topX',{number: expenseTopLength}) }})
+
+
+ {% set sum =0 %}
+ {% for row in expenses %}
+ {% if loop.index > expenseTopLength %}
+
+ {% else %}
+
+ {% endif %}
+
+ {{ row.name }}
+ {% if row.count > 1 %}
+ {{ row.count }} {{ 'transactions'|_|lower }}
+ {% endif %}
+ |
+ {{ (row.amount*-1)|formatAmountPlain }} |
+
+ {% set sum = sum + row.amount %}
+ {% endfor %}
+ {% if expenses|length > expenseTopLength %}
+
+
+ {{ trans('firefly.showTheRest',{number:incomeTopLength}) }}
+ |
+
+ {% endif %}
+
+ {{ 'sum'|_ }} |
+ {{ (sum * -1)|formatAmountPlain }} |
+
+
+
+
+
+
+
+
+
+
+ {{ 'budgets'|_ }}
+
+
+
+ {{ 'budget'|_ }} |
+ {{ 'date'|_ }} |
+ {{ 'budgeted'|_ }} |
+ {{ 'spent'|_ }} |
+ {{ 'left'|_ }} |
+ {{ 'overspent'|_ }} |
+
+ {% for data in budgets %}
+
+
+ {% if data[0] %}
+ {{ data[0].name }}
+ {% else %}
+ {{ 'noBudget'|_ }}
+ {% endif %}
+ |
+
+ {% if data[1] %}
+ {{ data[1].startdate.formatLocalized(monthAndDayFormat) }}
+ {% endif %}
+ |
+
+ {% if data[1] %}
+ {{ data[1].amount|formatAmount }}
+ {% else %}
+ {{ 0|formatAmount }}
+ {% endif %}
+ |
+
+ {% if data[3] != 0 %}
+ {{ data[3]|formatAmount }}
+ {% endif %}
+ |
+
+ {% if data[2] != 0 %}
+ {{ data[2]|formatAmount }}
+ {% endif %}
+ |
+
+ {% if data[4] != 0 %}
+ {{ data[4]|formatAmountPlain }}
+ {% endif %}
+ |
+
+ {% endfor %}
+
+ {{ 'sum'|_ }} |
+ {{ budgetSums.budgeted|formatAmount }} |
+ {{ budgetSums.spent|formatAmount }} |
+ {{ budgetSums.left|formatAmount }} |
+ {{ budgetSums.overspent|formatAmountPlain }} |
+
-
-
-
- Expenses (top 10)
-
-
- {% set sum = 0 %}
-
- {% for id,expense in expenses %}
- {% set sum = sum + expense.queryAmount %}
-
- {% if id > 0 %}
- {{ expense.name }} |
- {% else %}
- {{ expense.name }} |
- {% endif %}
- {{ expense.queryAmount|formatAmountPlain }} |
-
- {% endfor %}
-
- Sum |
- {{ sum|formatAmountPlain }} |
-
-
-
-
-
-
-
-
- Sums
-
- {% set totalIn = 0 %}
- {% for entry in income %}
- {% set totalIn = totalIn + entry.queryAmount %}
- {% endfor %}
-
-
- In |
- {{ totalIn|formatAmount }} |
-
-
- Out |
- {{ sum|formatAmountPlain }} |
-
-
- Difference |
- {{ (totalIn - sum)|formatAmount }} |
-
-
-
-
-
-
-
-
-
-
- Budgets
-
-
-
- Budget |
- Envelope |
- Spent |
- Left |
-
- {% 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 %}
-
- {% if budget.queryAmount != 0 or budget.spent != 0 %}
-
-
- {% if id > 0 %}
- {{ budget.name }}
- {% else %}
- {{ budget.name }}
- {% endif %}
- |
- {{ budget.queryAmount|formatAmount }} |
- {{ (budget.spent*-1)|formatAmountPlain }} |
- {{ (budget.queryAmount + budget.spent)|formatAmount }} |
-
- {% endif %}
- {% endfor %}
-
- Sum |
- {{ sumEnvelope|formatAmount }} |
- {{ sumSpent|formatAmount }} |
- {{ sumLeft|formatAmount }} |
-
-
-
-
-
- Categories
+ {{ 'categories'|_ }}
- Category |
- Spent |
+ {{ 'categories'|_ }} |
+ {{ 'spent'|_ }} |
{% set sum = 0 %}
- {% for id,category in categories %}
- {% set sum = sum + category.queryAmount %}
-
-
- {% if id > 0 %}
- {{ category.name }}
- {% else %}
- {{ category.name }}
- {% endif %}
- |
- {{ (category.queryAmount * -1)|formatAmountPlain }} |
-
+ {% for data in categories %}
+ {% if data[1] > 0 %}
+
+
+ {{ data[0].name }}
+ |
+ {{ (data[1])|formatAmountPlain }} |
+
+ {% endif %}
{% endfor %}
-
- Sum |
- {{ (sum * -1)|formatAmountPlain }} |
-
-
-
-
- Accounts
-
-
-
- Account |
- Start of month |
- Current balance |
- Spent |
- Earned |
-
- {% for account in accounts %}
-
- {{ account.name }} |
- {{ account.startBalance|formatAmount }} |
- {{ account.endBalance|formatAmount }} |
-
- {% if account.startBalance - account.endBalance > 0 %}
- {{ (account.startBalance - account.endBalance)|formatAmountPlain }}
- {% endif %}
- |
-
- {% if account.startBalance - account.endBalance < 0 %}
- {{ ((account.startBalance - account.endBalance)*-1)|formatAmountPlain }}
- {% endif %}
- |
-
- {% endfor %}
-
-
@@ -220,27 +243,31 @@
- Budgets
+ {{ 'budgets'|_ }} ({{ 'splitByAccount'|_|lower }})
- Budgets |
+ {{ 'budgets'|_ }} |
{% for account in accounts %}
- {% if not account.hide %}
- {{ account.name }} |
- {% endif %}
+ {{ account.name }} |
{% endfor %}
- Left in budget
+ {{ 'leftInBudget'|_ }}
|
- {% for id,budget in budgets %}
-
- {{ budget.name }} |
- {{ budget.queryAmount|formatAmount }} |
- {% set spent = 0 %}
- {% for account in accounts %}
- {% if not account.hide %}
+ {% for data in budgets %}
+ {% if data[0] %}
+
+ {{ data[0].name }} |
+
+ {% if data[1] %}
+ {{ data[1].amount|formatAmount }}
+ {% else %}
+ {{ 0|formatAmount }}
+ {% endif %}
+ |
+ {% set spent = 0 %}
+ {% for account in accounts %}
{% if account.budgetInformation[id] %}
{% if id == 0 %}
@@ -255,14 +282,20 @@
{% else %}
| {{ 0|formatAmount }} |
{% endif %}
- {% endif %}
- {% endfor %}
- {{ (budget.queryAmount + budget.spent)|formatAmount }} |
- {{ (budget.queryAmount + spent)|formatAmount }} |
-
+ {% endfor %}
+
+ {% if data[1] %}
+ {{ (data[1].amount - data[3])|formatAmount }}
+ {% else %}
+ {{ (0 - data[3])|formatAmount }}
+ {% endif %}
+ |
+ {{ data[2]|formatAmount }} |
+
+ {% endif %}
{% endfor %}
- Balanced by transfers |
+ {{ 'balancedByTransfersAndTags'|_ }} |
{% for account in accounts %}
{% if not account.hide %}
@@ -273,7 +306,7 @@
| |
- Left unbalanced |
+ {{ 'leftUnbalanced'|_ }} |
{% for account in accounts %}
{% if not account.hide %}
@@ -293,7 +326,7 @@
|
- Sum |
+ {{ 'sum'|_ }} |
{% for account in accounts %}
{% if not account.hide %}
{{ accountAmounts[account.id]|formatAmount }} |
@@ -302,7 +335,7 @@
|
- Expected balance |
+ {{ 'expectedBalance'|_ }} |
{% for account in accounts %}
{% if not account.hide %}
{{ (account.startBalance + accountAmounts[account.id])|formatAmount }} |
@@ -320,7 +353,7 @@
- Bills
+ {{ 'bills'|_ }}
Body
@@ -331,7 +364,7 @@
- Outside of budgets
+ {{ 'outsideOfBudgets'|_ }}
Body
@@ -339,5 +372,16 @@
{% endblock %}
{% block scripts %}
+
{% endblock %}
diff --git a/resources/twig/reports/year.twig b/resources/twig/reports/year.twig
index b9acc3c2c9..faaabd1ae4 100644
--- a/resources/twig/reports/year.twig
+++ b/resources/twig/reports/year.twig
@@ -1,6 +1,6 @@
{% extends "./layout/default.twig" %}
{% block content %}
- {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, date, shared) }}
+ {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, start, shared) }}
@@ -41,7 +41,7 @@
{{ 'balanceStartOfYear'|_ }} |
{{ 'difference'|_ }} |
- {% for account in accounts %}
+ {% for account in accounts.getAccounts %}
{{ account.name }}
@@ -53,9 +53,9 @@
{% endfor %}
|
Sum of sums |
- {{ accountsSums.start|formatAmount }} |
- {{ accountsSums.end|formatAmount }} |
- {{ accountsSums.diff|formatAmount }} |
+ {{ accounts.getStart|formatAmount }} |
+ {{ accounts.getEnd|formatAmount }} |
+ {{ accounts.getDifference|formatAmount }} |
@@ -88,22 +88,22 @@
{{ 'income'|_ }} ({{ trans('firefly.topX',{number: incomeTopLength}) }})
- {% for id,row in incomes %}
+ {% for income in incomes.getIncomes %}
{% if loop.index > incomeTopLength %}
{% else %}
{% endif %}
- {{ row.name }}
- {% if row.count > 1 %}
- {{ row.count }} {{ 'transactions'|_|lower }}
+ {{ income.name }}
+ {% if income.count > 1 %}
+ {{ income.count }} {{ 'transactions'|_|lower }}
{% endif %}
|
- {{ row.amount|formatAmount }} |
+ {{ income.amount|formatAmount }} |
{% endfor %}
- {% if incomes|length > incomeTopLength %}
+ {% if incomes.getIncomes|length > incomeTopLength %}
{{ trans('firefly.showTheRest',{number:incomeTopLength}) }}
@@ -112,7 +112,7 @@
{% endif %}
|
{{ 'sum'|_ }} |
- {{ totalIncome|formatAmount }} |
+ {{ incomes.getTotal|formatAmount }} |
@@ -124,24 +124,22 @@
{{ 'expenses'|_ }} ({{ trans('firefly.topX',{number: expenseTopLength}) }})
- {% set sum =0 %}
- {% for row in expenses %}
+ {% for expense in expenses.getExpenses %}
{% if loop.index > expenseTopLength %}
{% else %}
{% endif %}
- {{ row.name }}
- {% if row.count > 1 %}
- {{ row.count }} {{ 'transactions'|_|lower }}
+ {{ expense.name }}
+ {% if expense.count > 1 %}
+ {{ expense.count }} {{ 'transactions'|_|lower }}
{% endif %}
|
- {{ (row.amount*-1)|formatAmountPlain }} |
+ {{ (expense.amount*-1)|formatAmountPlain }} |
- {% set sum = sum + row.amount %}
{% endfor %}
- {% if expenses|length > expenseTopLength %}
+ {% if expenses.getExpenses|length > expenseTopLength %}
{{ trans('firefly.showTheRest',{number:incomeTopLength}) }}
@@ -150,7 +148,7 @@
{% endif %}
|
{{ 'sum'|_ }} |
- {{ (sum * -1)|formatAmountPlain }} |
+ {{ (expenses.getTotal * -1)|formatAmountPlain }} |
@@ -191,7 +189,7 @@