Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Refactor names.
James Cole59f57c96e93c
diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.phpindex d8968deade..1fc82f9af5 100644--- a/app/Helpers/Report/ReportHelper.php+++ b/app/Helpers/Report/ReportHelper.php@@ -52,7 +52,7 @@ class ReportHelper implements ReportHelperInterface** @return CategoryCollection*/- public function getCategoryReportForList(Carbon $start, Carbon $end, Collection $accounts)+ public function getCategoryReport(Carbon $start, Carbon $end, Collection $accounts){$object = new CategoryCollection;@@ -118,7 +118,7 @@ class ReportHelper implements ReportHelperInterface** @return AccountCollection*/- public function getAccountReportForList(Carbon $start, Carbon $end, Collection $accounts)+ public function getAccountReport(Carbon $start, Carbon $end, Collection $accounts){$startAmount = '0';$endAmount = '0';@@ -167,10 +167,10 @@ class ReportHelper implements ReportHelperInterface** @return Income*/- public function getIncomeReportForList($start, $end, Collection $accounts)+ public function getIncomeReport($start, $end, Collection $accounts){$object = new Income;- $set = $this->query->incomeInPeriodCorrectedForList($start, $end, $accounts);+ $set = $this->query->incomeInPeriod($start, $end, $accounts);foreach ($set as $entry) {$object->addToTotal($entry->amount_positive);$object->addOrCreateIncome($entry);@@ -188,10 +188,10 @@ class ReportHelper implements ReportHelperInterface** @return Expense*/- public function getExpenseReportForList($start, $end, Collection $accounts)+ public function getExpenseReport($start, $end, Collection $accounts){$object = new Expense;- $set = $this->query->expenseInPeriodCorrectedForList($start, $end, $accounts);+ $set = $this->query->expenseInPeriod($start, $end, $accounts);foreach ($set as $entry) {$object->addToTotal($entry->amount); // can be positive, if it's a transfer$object->addOrCreateExpense($entry);@@ -207,7 +207,7 @@ class ReportHelper implements ReportHelperInterface** @return BudgetCollection*/- public function getBudgetReportForList(Carbon $start, Carbon $end, Collection $accounts)+ public function getBudgetReport(Carbon $start, Carbon $end, Collection $accounts){$object = new BudgetCollection;/** @var \FireflyIII\Repositories\Budget\BudgetRepositoryInterface $repository */@@ -280,7 +280,7 @@ class ReportHelper implements ReportHelperInterface** @return Balance*/- public function getBalanceReportForList(Carbon $start, Carbon $end, Collection $accounts)+ public function getBalanceReport(Carbon $start, Carbon $end, Collection $accounts){$repository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');$tagRepository = app('FireflyIII\Repositories\Tag\TagRepositoryInterface');@@ -309,7 +309,7 @@ class ReportHelper implements ReportHelperInterface$balanceEntry->setAccount($account);// get spent:- $spent = $this->query->spentInBudgetCorrected($account, $budget, $start, $end); // I think shared is irrelevant.+ $spent = $this->query->spentInBudget($account, $budget, $start, $end); // I think shared is irrelevant.$balanceEntry->setSpent($spent);$line->addBalanceEntry($balanceEntry);@@ -375,7 +375,7 @@ class ReportHelper implements ReportHelperInterface** @return BillCollection*/- public function getBillReportForList(Carbon $start, Carbon $end, Collection $accounts)+ public function getBillReport(Carbon $start, Carbon $end, Collection $accounts){/** @var \FireflyIII\Repositories\Bill\BillRepositoryInterface $repository */$repository = app('FireflyIII\Repositories\Bill\BillRepositoryInterface');diff --git a/app/Helpers/Report/ReportHelperInterface.php b/app/Helpers/Report/ReportHelperInterface.phpindex dd894fd769..f52036cac2 100644--- a/app/Helpers/Report/ReportHelperInterface.php+++ b/app/Helpers/Report/ReportHelperInterface.php@@ -30,7 +30,7 @@ interface ReportHelperInterface** @return AccountCollection*/- public function getAccountReportForList(Carbon $start, Carbon $end, Collection $accounts);+ public function getAccountReport(Carbon $start, Carbon $end, Collection $accounts);/*** This method generates a full report for the given period on all@@ -44,7 +44,7 @@ interface ReportHelperInterface** @return BillCollection*/- public function getBillReportForList(Carbon $start, Carbon $end, Collection $accounts);+ public function getBillReport(Carbon $start, Carbon $end, Collection $accounts);/*** @param Carbon $start@@ -53,7 +53,7 @@ interface ReportHelperInterface** @return Balance*/- public function getBalanceReportForList(Carbon $start, Carbon $end, Collection $accounts);+ public function getBalanceReport(Carbon $start, Carbon $end, Collection $accounts);/*** @param Carbon $start@@ -62,7 +62,7 @@ interface ReportHelperInterface** @return BudgetCollection*/- public function getBudgetReportForList(Carbon $start, Carbon $end, Collection $accounts);+ public function getBudgetReport(Carbon $start, Carbon $end, Collection $accounts);/*** @param Carbon $start@@ -71,7 +71,7 @@ interface ReportHelperInterface** @return CategoryCollection*/- public function getCategoryReportForList(Carbon $start, Carbon $end, Collection $accounts);+ public function getCategoryReport(Carbon $start, Carbon $end, Collection $accounts);/*** Get a full report on the users expenses during the period for a list of accounts.@@ -82,7 +82,7 @@ interface ReportHelperInterface** @return Expense*/- public function getExpenseReportForList($start, $end, Collection $accounts);+ public function getExpenseReport($start, $end, Collection $accounts);/*** Get a full report on the users incomes during the period for the given accounts.@@ -93,7 +93,7 @@ interface ReportHelperInterface** @return Income*/- public function getIncomeReportForList($start, $end, Collection $accounts);+ public function getIncomeReport($start, $end, Collection $accounts);/*** @param Carbon $datediff --git a/app/Helpers/Report/ReportQuery.php b/app/Helpers/Report/ReportQuery.phpindex b89602a2e9..727bf19a36 100644--- a/app/Helpers/Report/ReportQuery.php+++ b/app/Helpers/Report/ReportQuery.php@@ -30,7 +30,7 @@ class ReportQuery implements ReportQueryInterface** @return float*/- public function spentInBudgetCorrected(Account $account, Budget $budget, Carbon $start, Carbon $end)+ public function spentInBudget(Account $account, Budget $budget, Carbon $start, Carbon $end){return Auth::user()->transactionjournals()@@ -112,7 +112,7 @@ class ReportQuery implements ReportQueryInterface** @return Collection*/- public function incomeInPeriodCorrectedForList(Carbon $start, Carbon $end, Collection $accounts)+ public function incomeInPeriod(Carbon $start, Carbon $end, Collection $accounts){$query = $this->queryJournalsWithTransactions($start, $end);@@ -198,7 +198,7 @@ class ReportQuery implements ReportQueryInterface* @return Collection**/- public function expenseInPeriodCorrectedForList(Carbon $start, Carbon $end, Collection $accounts)+ public function expenseInPeriod(Carbon $start, Carbon $end, Collection $accounts){$ids = [];diff --git a/app/Helpers/Report/ReportQueryInterface.php b/app/Helpers/Report/ReportQueryInterface.phpindex 3f0913ad14..7805542a3f 100644--- a/app/Helpers/Report/ReportQueryInterface.php+++ b/app/Helpers/Report/ReportQueryInterface.php@@ -29,7 +29,7 @@ interface ReportQueryInterface* @return Collection**/- public function expenseInPeriodCorrectedForList(Carbon $start, Carbon $end, Collection $accounts);+ public function expenseInPeriod(Carbon $start, Carbon $end, Collection $accounts);/*** This method works the same way as ReportQueryInterface::incomeInPeriod does, but instead of returning results@@ -42,7 +42,7 @@ interface ReportQueryInterface** @return Collection*/- public function incomeInPeriodCorrectedForList(Carbon $start, Carbon $end, Collection $accounts);+ public function incomeInPeriod(Carbon $start, Carbon $end, Collection $accounts);/*** Covers tags as well.@@ -54,7 +54,7 @@ interface ReportQueryInterface** @return float*/- public function spentInBudgetCorrected(Account $account, Budget $budget, Carbon $start, Carbon $end);+ public function spentInBudget(Account $account, Budget $budget, Carbon $start, Carbon $end);/*** @param Account $accountdiff --git a/app/Http/Controllers/Chart/ReportController.php b/app/Http/Controllers/Chart/ReportController.phpindex 14482cda59..b8ca4071f1 100644--- a/app/Http/Controllers/Chart/ReportController.php+++ b/app/Http/Controllers/Chart/ReportController.php@@ -60,8 +60,8 @@ class ReportController extends Controller$month = clone $start;$month->endOfMonth();// total income and total expenses:- $incomeSum = $query->incomeInPeriodCorrectedForList($start, $month, $accounts)->sum('amount_positive');- $expenseSum = $query->expenseInPeriodCorrectedForList($start, $month, $accounts)->sum('amount_positive');+ $incomeSum = $query->incomeInPeriod($start, $month, $accounts)->sum('amount_positive');+ $expenseSum = $query->expenseInPeriod($start, $month, $accounts)->sum('amount_positive');$entries->push([clone $start, $incomeSum, $expenseSum]);@@ -109,8 +109,8 @@ class ReportController extends Controller$month = clone $start;$month->endOfMonth();// total income and total expenses:- $currentIncome = $query->incomeInPeriodCorrectedForList($start, $month, $accounts)->sum('amount_positive');- $currentExpense = $query->expenseInPeriodCorrectedForList($start, $month, $accounts)->sum('amount_positive');+ $currentIncome = $query->incomeInPeriod($start, $month, $accounts)->sum('amount_positive');+ $currentExpense = $query->expenseInPeriod($start, $month, $accounts)->sum('amount_positive');$income = bcadd($income, $currentIncome);$expense = bcadd($expense, $currentExpense);diff --git a/app/Http/Controllers/JsonController.php b/app/Http/Controllers/JsonController.phpindex 5c335c8f49..28b331a165 100644--- a/app/Http/Controllers/JsonController.php+++ b/app/Http/Controllers/JsonController.php@@ -192,7 +192,7 @@ class JsonController extends Controllerreturn Response::json($cache->get()); // @codeCoverageIgnore}$accounts = $accountRepository->getAccounts(['Default account', 'Asset account', 'Cash account']);- $amount = $reportQuery->incomeInPeriodCorrectedForList($start, $end, $accounts)->sum('amount');+ $amount = $reportQuery->incomeInPeriod($start, $end, $accounts)->sum('amount');$data = ['box' => 'in', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];$cache->store($data);@@ -221,7 +221,7 @@ class JsonController extends Controllerreturn Response::json($cache->get()); // @codeCoverageIgnore}- $amount = $reportQuery->expenseInPeriodCorrectedForList($start, $end, $accounts)->sum('amount');+ $amount = $reportQuery->expenseInPeriod($start, $end, $accounts)->sum('amount');$amount = $amount * -1;$data = ['box' => 'out', 'amount' => Amount::format($amount, false), 'amount_raw' => $amount];diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.phpindex 2113cf7329..bb91eda66b 100644--- a/app/Http/Controllers/ReportController.php+++ b/app/Http/Controllers/ReportController.php@@ -75,9 +75,9 @@ class ReportController extends Controller$incomeTopLength = 8;$expenseTopLength = 8;- $accountReport = $this->helper->getAccountReportForList($start, $end, $accounts);- $incomes = $this->helper->getIncomeReportForList($start, $end, $accounts);- $expenses = $this->helper->getExpenseReportForList($start, $end, $accounts);+ $accountReport = $this->helper->getAccountReport($start, $end, $accounts);+ $incomes = $this->helper->getIncomeReport($start, $end, $accounts);+ $expenses = $this->helper->getExpenseReport($start, $end, $accounts);Session::flash('gaEventCategory', 'report');Session::flash('gaEventAction', 'year');@@ -118,13 +118,13 @@ class ReportController extends Controller$expenseTopLength = 8;// get report stuff!- $accountReport = $this->helper->getAccountReportForList($start, $end, $accounts);- $incomes = $this->helper->getIncomeReportForList($start, $end, $accounts);- $expenses = $this->helper->getExpenseReportForList($start, $end, $accounts);- $budgets = $this->helper->getBudgetReportForList($start, $end, $accounts);- $categories = $this->helper->getCategoryReportForList($start, $end, $accounts);- $balance = $this->helper->getBalanceReportForList($start, $end, $accounts);- $bills = $this->helper->getBillReportForList($start, $end, $accounts);+ $accountReport = $this->helper->getAccountReport($start, $end, $accounts);+ $incomes = $this->helper->getIncomeReport($start, $end, $accounts);+ $expenses = $this->helper->getExpenseReport($start, $end, $accounts);+ $budgets = $this->helper->getBudgetReport($start, $end, $accounts);+ $categories = $this->helper->getCategoryReport($start, $end, $accounts);+ $balance = $this->helper->getBalanceReport($start, $end, $accounts);+ $bills = $this->helper->getBillReport($start, $end, $accounts);// and some id's, joined:$accountIds = [];