mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 02:26:58 +00:00
Some fixes in the account list
This commit is contained in:
@@ -165,9 +165,14 @@ class IndexController extends Controller
|
||||
$account->endBalance = $this->isInArray($endBalances, $account->id);
|
||||
$account->difference = bcsub($account->endBalance, $account->startBalance);
|
||||
$account->interest = number_format((float)$this->repository->getMetaValue($account, 'interest'), 4, '.', '');
|
||||
$account->interestPeriod = (string)trans(sprintf('firefly.interest_calc_%s', $this->repository->getMetaValue($account, 'interest_period')));
|
||||
$account->interestPeriod = (string)trans(
|
||||
sprintf('firefly.interest_calc_%s', $this->repository->getMetaValue($account, 'interest_period'))
|
||||
);
|
||||
$account->accountTypeString = (string)trans(sprintf('firefly.account_type_%s', $account->accountType->type));
|
||||
$account->location = $this->repository->getLocation($account);
|
||||
|
||||
$account->liability_direction = $this->repository->getMetaValue($account, 'liability_direction');
|
||||
$account->current_debt = $this->repository->getMetaValue($account, 'current_debt');
|
||||
}
|
||||
);
|
||||
// make paginator:
|
||||
|
@@ -28,6 +28,7 @@ use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Log;
|
||||
|
||||
@@ -101,13 +102,18 @@ class CreditRecalculateService
|
||||
// get opening balance (if present)
|
||||
$this->repository->setUser($account->user);
|
||||
$startOfDebt = $this->repository->getOpeningBalanceAmount($account) ?? '0';
|
||||
|
||||
$leftOfDebt = app('steam')->positive($startOfDebt);
|
||||
/** @var AccountMetaFactory $factory */
|
||||
$factory = app(AccountMetaFactory::class);
|
||||
$factory->crud($account, 'start_of_debt', $startOfDebt);
|
||||
$factory->crud($account, 'current_debt', $startOfDebt);
|
||||
|
||||
// update meta data:
|
||||
// now loop all transactions (except opening balance and credit thing)
|
||||
$transactions = $account->transactions()->get();
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
$leftOfDebt = $this->processTransaction($transaction, $leftOfDebt);
|
||||
}
|
||||
$factory->crud($account, 'current_debt', $leftOfDebt);
|
||||
|
||||
|
||||
Log::debug(sprintf('Done with %s(#%d)', __METHOD__, $account->id));
|
||||
@@ -230,5 +236,22 @@ class CreditRecalculateService
|
||||
$this->group = $group;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Transaction $transaction
|
||||
* @param string $amount
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function processTransaction(Transaction $transaction, string $amount): string
|
||||
{
|
||||
$journal = $transaction->transactionJournal;
|
||||
$type = $journal->transactionType->type;
|
||||
if (in_array($type, [TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER], true)) {
|
||||
$amount = bcadd($amount, bcmul($transaction->amount, '-1'));
|
||||
}
|
||||
|
||||
return $amount;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1322,6 +1322,8 @@ return [
|
||||
'account_type_Credit card' => 'Credit card',
|
||||
'liability_direction_credit' => 'I am owed this debt',
|
||||
'liability_direction_debit' => 'I owe this debt to somebody else',
|
||||
'liability_direction_credit_short' => 'Owed this debt',
|
||||
'liability_direction_debit_short' => 'Owe this debt',
|
||||
'Liability credit' => 'Liability credit',
|
||||
'budgets' => 'Budgets',
|
||||
'tags' => 'Tags',
|
||||
@@ -1393,6 +1395,7 @@ return [
|
||||
'splitByAccount' => 'Split by account',
|
||||
'coveredWithTags' => 'Covered with tags',
|
||||
'leftInBudget' => 'Left in budget',
|
||||
'left_in_debt' => 'Left',
|
||||
'sumOfSums' => 'Sum of sums',
|
||||
'noCategory' => '(no category)',
|
||||
'notCharged' => 'Not charged (yet)',
|
||||
|
@@ -11,12 +11,15 @@
|
||||
{% endif %}
|
||||
{% if objectType == 'liabilities' %}
|
||||
<th>{{ trans('list.liability_type') }}</th>
|
||||
<th>{{ trans('form.liability_direction') }}</th>
|
||||
<th>{{ trans('list.interest') }} ({{ trans('list.interest_period') }})</th>
|
||||
{% endif %}
|
||||
<th class="hidden-sm hidden-xs">{{ trans('form.account_number') }}</th>
|
||||
<th style="text-align: right;">{{ trans('list.currentBalance') }}</th>
|
||||
{% if objectType == 'liabilities' %}
|
||||
<th>Left to pay off</th>
|
||||
<th style="text-align: right;">
|
||||
{{ trans('firefly.left_in_debt') }}
|
||||
</th>
|
||||
{% endif %}
|
||||
<th class="hidden-sm hidden-xs">{{ trans('list.active') }}</th>
|
||||
{# hide last activity to make room for other stuff #}
|
||||
@@ -54,6 +57,7 @@
|
||||
{% endif %}
|
||||
{% if objectType == 'liabilities' %}
|
||||
<td>{{ account.accountTypeString }}</td>
|
||||
<td>{{ trans('firefly.liability_direction_'~account.liability_direction~'_short') }}</td>
|
||||
<td>{{ account.interest }}% ({{ account.interestPeriod|lower }})</td>
|
||||
{% endif %}
|
||||
<td class="hidden-sm hidden-xs">{{ account.iban }}{% if account.iban == '' %}{{ accountGetMetaField(account, 'account_number') }}{% endif %}</td>
|
||||
@@ -63,8 +67,8 @@
|
||||
</span>
|
||||
</td>
|
||||
{% if objectType == 'liabilities' %}
|
||||
<td>
|
||||
Test
|
||||
<td style="text-align: right;">
|
||||
<span class="text-info">{{ formatAmountByAccount(account, account.current_debt, false) }}</span>
|
||||
</td>
|
||||
{% endif %}
|
||||
<td class="hidden-sm hidden-xs">
|
||||
|
Reference in New Issue
Block a user