mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Replace native with primary where possible
This commit is contained in:
@@ -75,30 +75,30 @@ class General extends AbstractExtension
|
||||
Log::debug(sprintf('twig balance: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
|
||||
$info = Steam::finalAccountBalance($account, $date);
|
||||
$currency = Steam::getAccountCurrency($account);
|
||||
$default = Amount::getPrimaryCurrency();
|
||||
$convertToNative = Amount::convertToPrimary();
|
||||
$useNative = $convertToNative && $default->id !== $currency->id;
|
||||
$currency ??= $default;
|
||||
$primary = Amount::getPrimaryCurrency();
|
||||
$convertToPrimary = Amount::convertToPrimary();
|
||||
$usePrimary = $convertToPrimary && $primary->id !== $currency->id;
|
||||
$currency ??= $primary;
|
||||
$strings = [];
|
||||
foreach ($info as $key => $balance) {
|
||||
if ('balance' === $key) {
|
||||
// balance in account currency.
|
||||
if (!$useNative) {
|
||||
if (!$usePrimary) {
|
||||
$strings[] = app('amount')->formatAnything($currency, $balance, false);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
if ('native_balance' === $key) {
|
||||
// balance in native currency.
|
||||
if ($useNative) {
|
||||
$strings[] = app('amount')->formatAnything($default, $balance, false);
|
||||
if ('pc_balance' === $key) {
|
||||
// balance in primary currency.
|
||||
if ($usePrimary) {
|
||||
$strings[] = app('amount')->formatAnything($primary, $balance, false);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
// for multi currency accounts.
|
||||
if ($useNative && $key !== $default->code) {
|
||||
if ($usePrimary && $key !== $primary->code) {
|
||||
$strings[] = app('amount')->formatAnything(TransactionCurrency::where('code', $key)->first(), $balance, false);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user