From ad114ed3295975997502941391d4343629399e72 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 13 Dec 2015 09:30:02 +0100 Subject: [PATCH] Remove unused methods. --- app/Helpers/Report/ReportHelper.php | 322 ------------------- app/Helpers/Report/ReportHelperInterface.php | 72 ----- 2 files changed, 394 deletions(-) diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php index 4efd0f638e..d8968deade 100644 --- a/app/Helpers/Report/ReportHelper.php +++ b/app/Helpers/Report/ReportHelper.php @@ -45,286 +45,6 @@ class ReportHelper implements ReportHelperInterface } - - /** - * This method generates a full report for the given period on all - * the users asset and cash accounts. - * - * @param Carbon $date - * @param Carbon $end - * @param $shared - * - * @return AccountCollection - */ - public function getAccountReport(Carbon $date, Carbon $end, $shared) - { - - - $accounts = $this->query->getAllAccounts($date, $end, $shared); - // remove cash account, if any: - $accounts = $accounts->filter( - function (Account $account) { - if ($account->accountType->type != 'Cash account') { - return $account; - } - - return null; - } - ); - - return $this->getAccountReportForList($date, $end, $accounts); - } - - /** - * - * The balance report contains a Balance object which in turn contains: - * - * A BalanceHeader object which contains all relevant user asset accounts for the report. - * - * A number of BalanceLine objects, which hold: - * - A budget - * - A number of BalanceEntry objects. - * - * The BalanceEntry object holds: - * - The same budget (again) - * - A user asset account as mentioned in the BalanceHeader - * - The amount of money spent on the budget by the user asset account - * - * @param Carbon $start - * @param Carbon $end - * @param boolean $shared - * - * @return Balance - */ - public function getBalanceReport(Carbon $start, Carbon $end, $shared) - { - $repository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); - $tagRepository = app('FireflyIII\Repositories\Tag\TagRepositoryInterface'); - $balance = new Balance; - - // build a balance header: - $header = new BalanceHeader; - - $accounts = $this->query->getAllAccounts($start, $end, $shared); - $budgets = $repository->getBudgets(); - foreach ($accounts as $account) { - $header->addAccount($account); - } - - /** @var BudgetModel $budget */ - foreach ($budgets as $budget) { - $line = new BalanceLine; - $line->setBudget($budget); - - // get budget amount for current period: - $rep = $repository->getCurrentRepetition($budget, $start, $end); - // could be null? - $line->setRepetition($rep); - - // loop accounts: - foreach ($accounts as $account) { - $balanceEntry = new BalanceEntry; - $balanceEntry->setAccount($account); - - // get spent: - $spent = $this->query->spentInBudgetCorrected($account, $budget, $start, $end); // I think shared is irrelevant. - - $balanceEntry->setSpent($spent); - $line->addBalanceEntry($balanceEntry); - } - // add line to balance: - $balance->addBalanceLine($line); - } - - // then a new line for without budget. - // and one for the tags: - // and one for "left unbalanced". - $empty = new BalanceLine; - $tags = new BalanceLine; - $diffLine = new BalanceLine; - - $tags->setRole(BalanceLine::ROLE_TAGROLE); - $diffLine->setRole(BalanceLine::ROLE_DIFFROLE); - - foreach ($accounts as $account) { - $spent = $this->query->spentNoBudget($account, $start, $end) * -1; - $left = $tagRepository->coveredByBalancingActs($account, $start, $end); - bcscale(2); - $diff = bcsub($spent, $left); - - // budget - $budgetEntry = new BalanceEntry; - $budgetEntry->setAccount($account); - $budgetEntry->setSpent($spent); - $empty->addBalanceEntry($budgetEntry); - - // balanced by tags - $tagEntry = new BalanceEntry; - $tagEntry->setAccount($account); - $tagEntry->setLeft($left); - $tags->addBalanceEntry($tagEntry); - - // difference: - $diffEntry = new BalanceEntry; - $diffEntry->setAccount($account); - $diffEntry->setSpent($diff); - $diffLine->addBalanceEntry($diffEntry); - - } - - $balance->addBalanceLine($empty); - $balance->addBalanceLine($tags); - $balance->addBalanceLine($diffLine); - - $balance->setBalanceHeader($header); - - return $balance; - } - - /** - * This method generates a full report for the given period on all - * the users bills and their payments. - * - * @param Carbon $start - * @param Carbon $end - * - * @return BillCollection - */ - public function getBillReport(Carbon $start, Carbon $end) - { - /** @var \FireflyIII\Repositories\Bill\BillRepositoryInterface $repository */ - $repository = app('FireflyIII\Repositories\Bill\BillRepositoryInterface'); - $bills = $repository->getBills(); - $collection = new BillCollection; - - /** @var Bill $bill */ - foreach ($bills as $bill) { - $billLine = new BillLine; - $billLine->setBill($bill); - $billLine->setActive(intval($bill->active) == 1); - $billLine->setMin($bill->amount_min); - $billLine->setMax($bill->amount_max); - - // is hit in period? - bcscale(2); - $set = $repository->getJournalsInRange($bill, $start, $end); - if ($set->count() == 0) { - $billLine->setHit(false); - } else { - $billLine->setHit(true); - $amount = '0'; - foreach ($set as $entry) { - $amount = bcadd($amount, $entry->amount); - } - $billLine->setAmount($amount); - } - - $collection->addBill($billLine); - - } - - return $collection; - - } - - - /** - * @param Carbon $start - * @param Carbon $end - * @param boolean $shared - * - * @return BudgetCollection - */ - public function getBudgetReport(Carbon $start, Carbon $end, $shared) - { - $object = new BudgetCollection; - /** @var \FireflyIII\Repositories\Budget\BudgetRepositoryInterface $repository */ - $repository = app('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); - $set = $repository->getBudgets(); - - bcscale(2); - - foreach ($set as $budget) { - - $repetitions = $repository->getBudgetLimitRepetitions($budget, $start, $end); - - // no repetition(s) for this budget: - if ($repetitions->count() == 0) { - $spent = $repository->balanceInPeriod($budget, $start, $end, $shared); - $budgetLine = new BudgetLine; - $budgetLine->setBudget($budget); - $budgetLine->setOverspent($spent); - $object->addOverspent($spent); - $object->addBudgetLine($budgetLine); - continue; - } - - // one or more repetitions for budget: - /** @var LimitRepetition $repetition */ - foreach ($repetitions as $repetition) { - $budgetLine = new BudgetLine; - $budgetLine->setBudget($budget); - $budgetLine->setRepetition($repetition); - $expenses = $repository->balanceInPeriod($budget, $repetition->startdate, $repetition->enddate, $shared); - $expenses = $expenses * -1; - $left = $expenses < $repetition->amount ? bcsub($repetition->amount, $expenses) : 0; - $spent = $expenses > $repetition->amount ? 0 : $expenses; - $overspent = $expenses > $repetition->amount ? bcsub($expenses, $repetition->amount) : 0; - - $budgetLine->setLeft($left); - $budgetLine->setSpent($spent); - $budgetLine->setOverspent($overspent); - $budgetLine->setBudgeted($repetition->amount); - - $object->addBudgeted($repetition->amount); - $object->addSpent($spent); - $object->addLeft($left); - $object->addOverspent($overspent); - $object->addBudgetLine($budgetLine); - - } - - } - - // stuff outside of budgets: - $noBudget = $repository->getWithoutBudgetSum($start, $end); - $budgetLine = new BudgetLine; - $budgetLine->setOverspent($noBudget); - $budgetLine->setSpent($noBudget); - $object->addOverspent($noBudget); - $object->addBudgetLine($budgetLine); - - return $object; - } - - /** - * @param Carbon $start - * @param Carbon $end - * @param boolean $shared - * - * @return CategoryCollection - */ - public function getCategoryReport(Carbon $start, Carbon $end, $shared) - { - $object = new CategoryCollection; - - - /** - * GET CATEGORIES: - */ - /** @var \FireflyIII\Repositories\Category\CategoryRepositoryInterface $repository */ - $repository = app('FireflyIII\Repositories\Category\CategoryRepositoryInterface'); - $set = $repository->getCategories(); - foreach ($set as $category) { - $spent = $repository->balanceInPeriod($category, $start, $end, $shared); - $category->spent = $spent; - $object->addCategory($category); - $object->addTotal($spent); - } - - return $object; - } - /** * @param Carbon $start * @param Carbon $end @@ -351,48 +71,6 @@ class ReportHelper implements ReportHelperInterface 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->expenseInPeriodCorrected($start, $end, $shared); - foreach ($set as $entry) { - $object->addToTotal($entry->amount); - $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->incomeInPeriodCorrected($start, $end, $shared); - foreach ($set as $entry) { - $object->addToTotal($entry->amount_positive); - $object->addOrCreateIncome($entry); - } - - return $object; - } - /** * @param Carbon $date * diff --git a/app/Helpers/Report/ReportHelperInterface.php b/app/Helpers/Report/ReportHelperInterface.php index 34e8aa88f8..dd894fd769 100644 --- a/app/Helpers/Report/ReportHelperInterface.php +++ b/app/Helpers/Report/ReportHelperInterface.php @@ -20,18 +20,6 @@ use Illuminate\Support\Collection; interface ReportHelperInterface { - /** - * This method generates a full report for the given period on all - * the users asset and cash accounts. - * - * @param Carbon $date - * @param Carbon $end - * @param boolean $shared - * - * @return AccountCollection - */ - public function getAccountReport(Carbon $date, Carbon $end, $shared); - /** * This method generates a full report for the given period on all * given accounts @@ -44,17 +32,6 @@ interface ReportHelperInterface */ public function getAccountReportForList(Carbon $start, Carbon $end, Collection $accounts); - /** - * This method generates a full report for the given period on all - * the users bills and their payments. - * - * @param Carbon $start - * @param Carbon $end - * - * @return BillCollection - */ - public function getBillReport(Carbon $start, Carbon $end); - /** * This method generates a full report for the given period on all * the users bills and their payments. @@ -69,15 +46,6 @@ interface ReportHelperInterface */ public function getBillReportForList(Carbon $start, Carbon $end, Collection $accounts); - /** - * @param Carbon $start - * @param Carbon $end - * @param boolean $shared - * - * @return Balance - */ - public function getBalanceReport(Carbon $start, Carbon $end, $shared); - /** * @param Carbon $start * @param Carbon $end @@ -87,15 +55,6 @@ interface ReportHelperInterface */ public function getBalanceReportForList(Carbon $start, Carbon $end, Collection $accounts); - /** - * @param Carbon $start - * @param Carbon $end - * @param boolean $shared - * - * @return BudgetCollection - */ - public function getBudgetReport(Carbon $start, Carbon $end, $shared); - /** * @param Carbon $start * @param Carbon $end @@ -105,15 +64,6 @@ interface ReportHelperInterface */ public function getBudgetReportForList(Carbon $start, Carbon $end, Collection $accounts); - /** - * @param Carbon $start - * @param Carbon $end - * @param boolean $shared - * - * @return CategoryCollection - */ - public function getCategoryReport(Carbon $start, Carbon $end, $shared); - /** * @param Carbon $start * @param Carbon $end @@ -123,17 +73,6 @@ interface ReportHelperInterface */ public function getCategoryReportForList(Carbon $start, Carbon $end, Collection $accounts); - /** - * 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 expenses during the period for a list of accounts. * @@ -145,17 +84,6 @@ interface ReportHelperInterface */ public function getExpenseReportForList($start, $end, Collection $accounts); - /** - * 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); - /** * Get a full report on the users incomes during the period for the given accounts. *