Remove ability to see balance.

This commit is contained in:
James Cole 2020-07-28 06:31:56 +02:00
parent ff9d8865d1
commit 012420c47d
No known key found for this signature in database
GPG Key ID: B5669F9493CDE38D
2 changed files with 8 additions and 28 deletions

View File

@ -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'));

View File

@ -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__));