From 012420c47d470b85bcbbe13002e73287e66eb013 Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 28 Jul 2020 06:31:56 +0200 Subject: [PATCH] Remove ability to see balance. --- app/Support/Form/AccountForm.php | 16 ++-------------- app/Support/Steam.php | 20 ++++++-------------- 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/app/Support/Form/AccountForm.php b/app/Support/Form/AccountForm.php index 112df4317c..78915668db 100644 --- a/app/Support/Form/AccountForm.php +++ b/app/Support/Form/AccountForm.php @@ -27,7 +27,6 @@ namespace FireflyIII\Support\Form; use FireflyIII\Models\Account; use FireflyIII\Models\AccountType; use FireflyIII\Repositories\Account\AccountRepositoryInterface; -use Illuminate\Support\Collection; use Log; use Throwable; @@ -50,20 +49,10 @@ class AccountForm } $accountList = $repository->getActiveAccountsByType($types); $liabilityTypes = [AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN,]; - $balanceTypes = [AccountType::ASSET, AccountType::DEFAULT, AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN,]; - $defaultCurrency = app('amount')->getDefaultCurrency(); $grouped = []; /** @var Account $account */ foreach ($accountList as $account) { - $accountWithBalance = $account->name; - - if (in_array($account->accountType->type, $balanceTypes, true)) { - $balance = app('steam')->balance($account); - $currency = $repository->getAccountCurrency($account) ?? $defaultCurrency; - $formatted = app('amount')->formatAnything($currency, $balance, false); - $accountWithBalance = sprintf('%s (%s)', $account->name, $formatted); - } $role = (string)$repository->getMetaValue($account, 'account_role'); if (in_array($account->accountType->type, $liabilityTypes, true)) { $role = sprintf('l_%s', $account->accountType->type); @@ -76,8 +65,8 @@ class AccountForm $role = 'no_account_type'; } } - $key = (string)trans(sprintf('firefly.opt_group_%s', $role)); - $grouped[$key][$account->id] = $accountWithBalance; + $key = (string) trans(sprintf('firefly.opt_group_%s', $role)); + $grouped[$key][$account->id] = $account->name; } return $grouped; @@ -154,7 +143,6 @@ class AccountForm $types = [AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN, AccountType::REVENUE,]; $repository = $this->getAccountRepository(); $grouped = $this->getAccountsGrouped($types, $repository); - $cash = $repository->getCashAccount(); $key = (string)trans('firefly.cash_account_type'); $grouped[$key][$cash->id] = sprintf('(%s)', (string)trans('firefly.cash')); diff --git a/app/Support/Steam.php b/app/Support/Steam.php index b2162212cb..b25e8851a1 100644 --- a/app/Support/Steam.php +++ b/app/Support/Steam.php @@ -47,7 +47,7 @@ class Steam * * @return string */ - public function balance(Account $account, Carbon $date = null, ?TransactionCurrency $currency = null): string + public function balance(Account $account, Carbon $date, ?TransactionCurrency $currency = null): string { if ('testing' === config('app.env')) { Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__)); @@ -60,9 +60,6 @@ class Steam if ($cache->has()) { return $cache->get(); // @codeCoverageIgnore } - if (null === $date) { - $date = Carbon::now()->endOfMonth(); - } /** @var AccountRepositoryInterface $repository */ $repository = app(AccountRepositoryInterface::class); if (null === $currency) { @@ -260,14 +257,12 @@ class Steam } /** - * Gets balance at the end of current month by default - * * @param \FireflyIII\Models\Account $account * @param \Carbon\Carbon $date * * @return array */ - public function balancePerCurrency(Account $account, Carbon $date = null): array + public function balancePerCurrency(Account $account, Carbon $date): array { if ('testing' === config('app.env')) { Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__)); @@ -280,9 +275,6 @@ class Steam if ($cache->has()) { return $cache->get(); // @codeCoverageIgnore } - if (null === $date) { - $date = Carbon::now()->endOfMonth(); - } $query = $account->transactions() ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59')) @@ -299,14 +291,14 @@ class Steam } /** - * This method always ignores the virtual balance. Gets balance at the end of current month by default + * This method always ignores the virtual balance. * * @param \Illuminate\Support\Collection $accounts * @param \Carbon\Carbon $date * * @return array */ - public function balancesByAccounts(Collection $accounts, Carbon $date = null): array + public function balancesByAccounts(Collection $accounts, Carbon $date): array { if ('testing' === config('app.env')) { Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__)); @@ -334,14 +326,14 @@ class Steam } /** - * Same as above, but also groups per currency. Gets balance at the end of current month by default + * Same as above, but also groups per currency. * * @param \Illuminate\Support\Collection $accounts * @param \Carbon\Carbon $date * * @return array */ - public function balancesPerCurrencyByAccounts(Collection $accounts, Carbon $date = null): array + public function balancesPerCurrencyByAccounts(Collection $accounts, Carbon $date): array { if ('testing' === config('app.env')) { Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__));