Final touches for the balance and transactions.

This commit is contained in:
James Cole
2021-04-10 17:56:09 +02:00
parent 0426fa63d0
commit 202facf43d
6 changed files with 43 additions and 10 deletions

View File

@@ -45,10 +45,8 @@ class EditController extends Controller
use ModelInformation;
private AttachmentHelperInterface $attachments;
/** @var CurrencyRepositoryInterface The currency repository */
private $currencyRepos;
/** @var AccountRepositoryInterface The account repository */
private $repository;
private CurrencyRepositoryInterface $currencyRepos;
private AccountRepositoryInterface $repository;
/**
* EditController constructor.
@@ -106,6 +104,11 @@ class EditController extends Controller
],
];
$liabilityDirections = [
'debit' => trans('firefly.liability_direction_debit'),
'credit' => trans('firefly.liability_direction_credit'),
];
// interest calculation periods:
$interestPeriods = [
'daily' => (string)trans('firefly.interest_calc_daily'),
@@ -119,7 +122,7 @@ class EditController extends Controller
}
$request->session()->forget('accounts.edit.fromUpdate');
$openingBalanceAmount = (string)$repository->getOpeningBalanceAmount($account);
$openingBalanceAmount = app('steam')->positive((string)$repository->getOpeningBalanceAmount($account));
$openingBalanceDate = $repository->getOpeningBalanceDate($account);
$currency = $this->repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();
@@ -138,6 +141,7 @@ class EditController extends Controller
'opening_balance_date' => $openingBalanceDate,
'liability_type_id' => $account->account_type_id,
'opening_balance' => $openingBalanceAmount,
'liability_direction' => $this->repository->getMetaValue($account, 'liability_direction'),
'virtual_balance' => $account->virtual_balance,
'currency_id' => $currency->id,
'include_net_worth' => $includeNetWorth,
@@ -157,6 +161,7 @@ class EditController extends Controller
'subTitle',
'subTitleIcon',
'locations',
'liabilityDirections',
'objectType',
'roles',
'preFilled',

View File

@@ -103,7 +103,7 @@ class IndexController extends Controller
$account->startBalance = $this->isInArray($startBalances, $account->id);
$account->endBalance = $this->isInArray($endBalances, $account->id);
$account->difference = bcsub($account->endBalance, $account->startBalance);
$account->interest = number_format((float)$this->repository->getMetaValue($account, 'interest'), 6, '.', '');
$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->accountTypeString = (string)trans(sprintf('firefly.account_type_%s', $account->accountType->type));
}
@@ -164,7 +164,7 @@ class IndexController extends Controller
$account->startBalance = $this->isInArray($startBalances, $account->id);
$account->endBalance = $this->isInArray($endBalances, $account->id);
$account->difference = bcsub($account->endBalance, $account->startBalance);
$account->interest = number_format((float)$this->repository->getMetaValue($account, 'interest'), 6, '.', '');
$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->accountTypeString = (string)trans(sprintf('firefly.account_type_%s', $account->accountType->type));
$account->location = $this->repository->getLocation($account);