Skip to content

Firefly III: a personal finances manager

Improve foreign currency display.

James Coled6ef6f3580dd
diff --git a/app/Helpers/Collector/GroupCollector.php b/app/Helpers/Collector/GroupCollector.php
index 300dca2863..e44c77237e 100644
--- a/app/Helpers/Collector/GroupCollector.php
+++ b/app/Helpers/Collector/GroupCollector.php
@@ -951,13 +951,16 @@ class GroupCollector implements GroupCollectorInterface
private function parseSums(array $groups): array
{
+ //Log::debug(sprintf('Now in parseGroups for %d group(s).', count($groups)));
/**
* @var int $groudId
* @var array $group
*/
foreach ($groups as $groudId => $group) {
+ //Log::debug(sprintf('Now in parseGroups for group #%d with %d transaction(s).', $groudId, count($group['transactions'])));
/** @var array $transaction */
foreach ($group['transactions'] as $transaction) {
+ // Log::debug(sprintf('Now in parseTransactions for transaction #%d', $transaction['transaction_journal_id']));
$currencyId = (int) $transaction['currency_id'];
if (null === $transaction['amount']) {
throw new FireflyException(sprintf('Amount is NULL for a transaction in group #%d, please investigate.', $groudId));
@@ -966,6 +969,8 @@ class GroupCollector implements GroupCollectorInterface
$pcForeignAmount = (string) ('' === $transaction['pc_foreign_amount'] ? '0' : $transaction['pc_foreign_amount']);
$foreignAmount = (string) ('' === $transaction['foreign_amount'] ? '0' : $transaction['foreign_amount']);
+ // Log::debug(sprintf('pc amount = "%s", pc foreign amount = "%s", foreign amount = "%s"', $pcAmount, $pcForeignAmount, $foreignAmount));
+
// set default:
if (!array_key_exists($currencyId, $groups[$groudId]['sums'])) {
$groups[$groudId]['sums'][$currencyId]['currency_id'] = $currencyId;
@@ -974,28 +979,30 @@ class GroupCollector implements GroupCollectorInterface
$groups[$groudId]['sums'][$currencyId]['currency_decimal_places'] = $transaction['currency_decimal_places'];
$groups[$groudId]['sums'][$currencyId]['amount'] = '0';
$groups[$groudId]['sums'][$currencyId]['pc_amount'] = '0';
+ //Log::debug(sprintf('Set amount and pc_amount to 0 for currency %s', $transaction['currency_code']));
}
$groups[$groudId]['sums'][$currencyId]['amount'] = bcadd((string) $groups[$groudId]['sums'][$currencyId]['amount'], $transaction['amount']);
$groups[$groudId]['sums'][$currencyId]['pc_amount'] = bcadd((string) $groups[$groudId]['sums'][$currencyId]['pc_amount'], $pcAmount);
if (null !== $transaction['foreign_amount'] && null !== $transaction['foreign_currency_id']) {
- $currencyId = (int) $transaction['foreign_currency_id'];
+ //Log::debug(sprintf('This transaction also has foreign amount %s %s', $transaction['foreign_currency_code'], $transaction['foreign_amount']));
+ $foreignCurrencyId = (int) $transaction['foreign_currency_id'];
// set default:
- if (!array_key_exists($currencyId, $groups[$groudId]['sums'])) {
- $groups[$groudId]['sums'][$currencyId]['currency_id'] = $currencyId;
- $groups[$groudId]['sums'][$currencyId]['currency_code'] = $transaction['foreign_currency_code'];
- $groups[$groudId]['sums'][$currencyId]['currency_symbol'] = $transaction['foreign_currency_symbol'];
- $groups[$groudId]['sums'][$currencyId]['currency_decimal_places'] = $transaction['foreign_currency_decimal_places'];
- $groups[$groudId]['sums'][$currencyId]['amount'] = '0';
- $groups[$groudId]['sums'][$currencyId]['pc_amount'] = '0';
+ if (!array_key_exists($foreignCurrencyId, $groups[$groudId]['sums'])) {
+ $groups[$groudId]['sums'][$foreignCurrencyId]['currency_id'] = $foreignCurrencyId;
+ $groups[$groudId]['sums'][$foreignCurrencyId]['currency_code'] = $transaction['foreign_currency_code'];
+ $groups[$groudId]['sums'][$foreignCurrencyId]['currency_symbol'] = $transaction['foreign_currency_symbol'];
+ $groups[$groudId]['sums'][$foreignCurrencyId]['currency_decimal_places'] = $transaction['foreign_currency_decimal_places'];
+ $groups[$groudId]['sums'][$foreignCurrencyId]['amount'] = '0';
+ $groups[$groudId]['sums'][$foreignCurrencyId]['pc_amount'] = '0';
+ //Log::debug(sprintf('Set amount and pc_amount to 0 for currency %s', $transaction['foreign_currency_code']));
}
- $groups[$groudId]['sums'][$currencyId]['amount'] = bcadd((string) $groups[$groudId]['sums'][$currencyId]['amount'], $foreignAmount);
- $groups[$groudId]['sums'][$currencyId]['pc_amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['amount'], $pcForeignAmount);
+ $groups[$groudId]['sums'][$foreignCurrencyId]['amount'] = bcadd((string) $groups[$groudId]['sums'][$foreignCurrencyId]['amount'], $foreignAmount);
+ $groups[$groudId]['sums'][$foreignCurrencyId]['pc_amount'] = bcadd((string) $groups[$groudId]['sums'][$foreignCurrencyId]['pc_amount'], $pcForeignAmount);
}
}
}
-
return $groups;
}
diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php
index cdc1e0199a..9ba9db395d 100644
--- a/app/Http/Controllers/Chart/AccountController.php
+++ b/app/Http/Controllers/Chart/AccountController.php
@@ -593,9 +593,16 @@ final class AccountController extends Controller
if ('balance' !== $key && 'pc_balance' !== $key) {
// assume it's a currency:
$setCurrency = $this->currencyRepository->findByCode((string) $key);
- $info['currency_symbol'] = $setCurrency->symbol;
- $info['currency_code'] = $setCurrency->code;
- $info['label'] = sprintf('%s (%s)', $account->name, $setCurrency->symbol);
+ // skip null and skip the primary currency.
+ if(null !== $setCurrency && $setCurrency->id === $this->primaryCurrency->id) {
+ continue;
+ }
+ if(null !== $setCurrency) {
+ $info['currency_symbol'] = $setCurrency->symbol;
+ $info['currency_code'] = $setCurrency->code;
+ $info['label'] = sprintf('%s (%s) A', $account->name, $setCurrency->symbol);
+ }
+
}
if ('balance' === $key) {
$info['currency_symbol'] = $accountCurrency->symbol;
diff --git a/app/Support/Amount.php b/app/Support/Amount.php
index 3199dcf20f..56d752e507 100644
--- a/app/Support/Amount.php
+++ b/app/Support/Amount.php
@@ -310,7 +310,6 @@ class Amount
$cache->addProperty('getPrimaryCurrencyByGroup');
$cache->addProperty($userGroup->id);
if ($cache->has()) {
- Log::debug(sprintf('getPrimaryCurrencyByUserGroup(#%d, "%s") = %s', $userGroup->id, $userGroup->title, $cache->get()->code));
return $cache->get();
}
@@ -324,6 +323,7 @@ class Amount
$userGroup->currencies()->sync([$primary->id => ['group_default' => true]]);
}
$cache->store($primary);
+ Log::debug(sprintf('getPrimaryCurrencyByUserGroup(#%d, "%s") = %s', $userGroup->id, $userGroup->title, $cache->get()->code));
return $primary;
}
diff --git a/app/Support/Http/Controllers/PeriodOverview.php b/app/Support/Http/Controllers/PeriodOverview.php
index d005212338..eafe11ed02 100644
--- a/app/Support/Http/Controllers/PeriodOverview.php
+++ b/app/Support/Http/Controllers/PeriodOverview.php
@@ -200,7 +200,7 @@ trait PeriodOverview
protected function getSingleModelPeriod(Model $model, string $period, Carbon $start, Carbon $end): array
{
- Log::debug(sprintf('Now in getSingleModelPeriod(%s #%d, %s %s)', $model::class, $model->id, $start->format('Y-m-d'), $end->format('Y-m-d')));
+ //Log::debug(sprintf('Now in getSingleModelPeriod(%s #%d, %s %s)', $model::class, $model->id, $start->format('Y-m-d'), $end->format('Y-m-d')));
$types = ['spent', 'earned', 'transferred_in', 'transferred_away'];
$return = [
'title' => Navigation::periodShow($start, $period),
@@ -313,7 +313,7 @@ trait PeriodOverview
return new Collection();
}
- Log::debug(sprintf('Now in filterStatistics("%s")', $type));
+ //Log::debug(sprintf('Now in filterStatistics("%s")', $type));
return $this->statistics->filter(static function (PeriodStatistic $statistic) use ($start, $end, $type): bool {
return $statistic->start->isSameSecond($start) && $statistic->end->isSameSecond($end) && $statistic->type === $type;
@@ -423,14 +423,14 @@ trait PeriodOverview
private function getSingleModelPeriodByType(Model $model, Carbon $start, Carbon $end, string $type): array
{
- Log::debug(sprintf(
- 'Now in getSingleModelPeriodByType(%s #%d, %s %s, %s)',
- $model::class,
- $model->id,
- $start->format('Y-m-d H:i:s.u'),
- $end->format('Y-m-d H:i:s.u'),
- $type
- ));
+// Log::debug(sprintf(
+// 'Now in getSingleModelPeriodByType(%s #%d, %s %s, %s)',
+// $model::class,
+// $model->id,
+// $start->format('Y-m-d H:i:s.u'),
+// $end->format('Y-m-d H:i:s.u'),
+// $type
+// ));
$statistics = $this->filterStatistics($start, $end, $type);
// nothing found, regenerate them.
diff --git a/app/Support/Steam.php b/app/Support/Steam.php
index 29cb39cae1..629a400f77 100644
--- a/app/Support/Steam.php
+++ b/app/Support/Steam.php
@@ -43,7 +43,6 @@ use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Safe\Exceptions\UrlException;
use ValueError;
-
use function Safe\parse_url;
use function Safe\preg_replace;
@@ -57,12 +56,13 @@ class Steam
* properly gets the balance of a range.
*/
public function accountsBalancesInRange(
- Collection $accounts,
- Carbon $start,
- Carbon $end,
+ Collection $accounts,
+ Carbon $start,
+ Carbon $end,
?TransactionCurrency $primary = null,
- ?bool $convertToPrimary = null
- ): array {
+ ?bool $convertToPrimary = null
+ ): array
+ {
return [
$this->accountsBalancesOptimized($accounts, $start, $primary, $convertToPrimary, inclusive: false),
$this->accountsBalancesOptimized($accounts, $end, $primary, $convertToPrimary),
@@ -70,67 +70,67 @@ class Steam
}
public function accountsBalancesOptimized(
- Collection $accounts,
- Carbon $date,
+ Collection $accounts,
+ Carbon $date,
?TransactionCurrency $primary = null,
- ?bool $convertToPrimary = null,
- bool $inclusive = true
- ): array {
+ ?bool $convertToPrimary = null,
+ bool $inclusive = true
+ ): array
+ {
// Log::debug(sprintf('accountsBalancesOptimized: Called for %d account(s) with date/time "%s" (inclusive: %s)', $accounts->count(), $date->toIso8601String(), var_export($inclusive, true)));
- $result = [];
+ $result = [];
$convertToPrimary ??= Amount::convertToPrimary();
$primary ??= Amount::getPrimaryCurrency();
- $currencies = $this->getCurrencies($accounts);
+ $currencies = $this->getCurrencies($accounts);
// balance(s) in all currencies for ALL accounts.
$arrayOfSums = Transaction::query()
- ->whereIn('account_id', $accounts->pluck('id')->toArray())
- ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
- ->leftJoin('transaction_currencies', 'transaction_currencies.id', '=', 'transactions.transaction_currency_id')
- ->where('transaction_journals.date', $inclusive ? '<=' : '<', $date->format('Y-m-d H:i:s'))
- ->whereNull('transaction_journals.deleted_at')
- ->groupBy(['transactions.account_id', 'transaction_currencies.code'])
- ->get(['transactions.account_id', 'transaction_currencies.code', DB::raw('SUM(transactions.amount) as sum_of_amount')])
- ->toArray()
- ;
+ ->whereIn('account_id', $accounts->pluck('id')->toArray())
+ ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
+ ->leftJoin('transaction_currencies', 'transaction_currencies.id', '=', 'transactions.transaction_currency_id')
+ ->where('transaction_journals.date', $inclusive ? '<=' : '<', $date->format('Y-m-d H:i:s'))
+ ->whereNull('transaction_journals.deleted_at')
+ ->groupBy(['transactions.account_id', 'transaction_currencies.code'])
+ ->get(['transactions.account_id', 'transaction_currencies.code', DB::raw('SUM(transactions.amount) as sum_of_amount')])
+ ->toArray();
// Log::debug('Array of sums: ', $arrayOfSums);
/** @var Account $account */
foreach ($accounts as $account) {
// this key is overwritten right away, but I must remember it is always created.
- $currency = $currencies[$account->id];
- $return = [
+ $currency = $currencies[$account->id];
+ $return = [
'pc_balance' => '0',
'balance' => '0',
];
// FIRST, add virtual balance to this.
- $virtualBalance = (string) ('' === (string) $account->virtual_balance ? '0' : $account->virtual_balance);
- $pcVirtualBalance = '0';
+ $virtualBalance = (string)('' === (string)$account->virtual_balance ? '0' : $account->virtual_balance);
+ $pcVirtualBalance = '0';
if (!$convertToPrimary) {
$return['balance'] = bcadd($return['balance'], $virtualBalance);
Log::debug(sprintf('ADD virtual balance (%s) to "balance"', $virtualBalance), $return);
}
if ($convertToPrimary) {
// the primary currency balance is combined with a converted virtual_balance:
- $converter = new ExchangeRateConverter();
- $pcVirtualBalance = $converter->convert($currency, $primary, $date, $virtualBalance);
+ $converter = new ExchangeRateConverter();
+ $pcVirtualBalance = $converter->convert($currency, $primary, $date, $virtualBalance);
Log::debug(sprintf('ADD converted virtual balance (%s) to "pc_balance"', $pcVirtualBalance));
$return['pc_balance'] = bcadd($pcVirtualBalance, $return['pc_balance']);
}
// second array
- $accountSums = array_filter($arrayOfSums, static fn (array $entry): bool => $entry['account_id'] === $account->id);
+ $accountSums = array_filter($arrayOfSums, static fn(array $entry): bool => $entry['account_id'] === $account->id);
if (0 === count($accountSums)) {
Log::debug('No sums in transactions, so return whatever we have now.', $return);
$result[$account->id] = $return;
continue;
}
- $sumsByCode = [];
+ $sumsByCode = [];
foreach ($accountSums as $accountSum) {
// $accountSum = array_values($accountSum)[0];
- $sumOfAmount = (string) $accountSum['sum_of_amount'];
+ $sumOfAmount = (string)$accountSum['sum_of_amount'];
$sumOfAmount = $this->floatalize('' === $sumOfAmount ? '0' : $sumOfAmount);
$sumsByCode[$accountSum['code']] = $sumOfAmount;
}
@@ -155,7 +155,7 @@ class Steam
if ($convertToPrimary) {
// the primary currency balance is combined with a converted virtual_balance:
- $converter = new ExchangeRateConverter();
+ $converter = new ExchangeRateConverter();
// $return['pc_balance'] = bcadd($pcVirtualBalance, $return['pc_balance']);
$sumsByCode[$primary->code] = bcadd($pcVirtualBalance, $sumsByCode[$primary->code] ?? '0');
@@ -209,10 +209,10 @@ class Steam
// Log::debug(sprintf('Trying bcround("%s",%d)', $number, $precision));
if (str_contains($number, '.')) {
if ('-' !== $number[0]) {
- return bcadd($number, '0.'.str_repeat('0', $precision).'5', $precision);
+ return bcadd($number, '0.' . str_repeat('0', $precision) . '5', $precision);
}
- return bcsub($number, '0.'.str_repeat('0', $precision).'5', $precision);
+ return bcsub($number, '0.' . str_repeat('0', $precision) . '5', $precision);
}
return $number;
@@ -354,15 +354,17 @@ class Steam
"balance": balance in the account's currency OR user's primary currency if the account has no currency
--> "pc_balance": balance in the user's primary currency, with all amounts converted to the primary currency.
"EUR": balance in EUR (or whatever currencies the account has balance in)
- TXT)]
+ TXT
+ )]
public function finalAccountBalance(
- Account $account,
- Carbon $date,
+ Account $account,
+ Carbon $date,
?TransactionCurrency $primary = null,
- ?bool $convertToPrimary = null,
- bool $inclusive = true
- ): array {
- $cache = new CacheProperties();
+ ?bool $convertToPrimary = null,
+ bool $inclusive = true
+ ): array
+ {
+ $cache = new CacheProperties();
$cache->addProperty($account->id);
$cache->addProperty($date);
if ($cache->has()) {
@@ -378,26 +380,25 @@ class Steam
$primary = Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
}
// account balance thing.
- $currencyPresent = property_exists($account, 'meta') && array_key_exists('currency', $account->meta) && null !== $account->meta['currency'];
+ $currencyPresent = property_exists($account, 'meta') && array_key_exists('currency', $account->meta) && null !== $account->meta['currency'];
if ($currencyPresent) {
$accountCurrency = $account->meta['currency'];
}
if (!$currencyPresent) {
$accountCurrency = $this->getAccountCurrency($account);
}
- $hasCurrency = null !== $accountCurrency;
- $currency = $hasCurrency ? $accountCurrency : $primary;
- $return = ['pc_balance' => '0', 'balance' => '0']; // this key is overwritten right away, but I must remember it is always created.
+ $hasCurrency = null !== $accountCurrency;
+ $currency = $hasCurrency ? $accountCurrency : $primary;
+ $return = ['pc_balance' => '0', 'balance' => '0']; // this key is overwritten right away, but I must remember it is always created.
// balance(s) in all currencies.
- $array = $account
+ $array = $account
->transactions()
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->leftJoin('transaction_currencies', 'transaction_currencies.id', '=', 'transactions.transaction_currency_id')
->where('transaction_journals.date', $inclusive ? '<=' : '<', $date->format('Y-m-d H:i:s'))
->get(['transaction_currencies.code', 'transactions.amount'])
- ->toArray()
- ;
- $others = $this->groupAndSumTransactions($array, 'code', 'amount');
+ ->toArray();
+ $others = $this->groupAndSumTransactions($array, 'code', 'amount');
// Log::debug('All balances are (joined)', $others);
// if there is no request to convert, take this as "balance" and "pc_balance".
$return['balance'] = $others[$currency->code] ?? '0';
@@ -414,7 +415,7 @@ class Steam
}
// either way, the balance is always combined with the virtual balance:
- $virtualBalance = (string) ('' === (string) $account->virtual_balance ? '0' : $account->virtual_balance);
+ $virtualBalance = (string)('' === (string)$account->virtual_balance ? '0' : $account->virtual_balance);
if ($convertToPrimary) {
// the primary currency balance is combined with a converted virtual_balance:
@@ -430,7 +431,7 @@ class Steam
// Log::debug(sprintf('Virtual balance makes the (primary currency) total %s', $return['balance']));
}
- $final = array_merge($return, $others);
+ $final = array_merge($return, $others);
// Log::debug('Final balance is', $final);
$cache->store($final);
@@ -448,7 +449,7 @@ class Steam
// Log::debug(sprintf('called finalAccountBalanceInRange(#%d, %s, %s)', $account->id, $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
// set up cache
- $cache = new CacheProperties();
+ $cache = new CacheProperties();
$cache->addProperty($account->id);
$cache->addProperty('final-balance-in-range');
$cache->addProperty($start);
@@ -460,56 +461,53 @@ class Steam
return $cache->get();
}
- $balances = [];
- $formatted = $start->format('Y-m-d');
+ $balances = [];
+ $formatted = $start->format('Y-m-d');
// Log::debug('Get first balance to start.');
// 2025-10-08 replaced finalAccountBalance with accountsBalancesOptimized:
- $primaryCurrency = Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
- $startBalance = $this->accountsBalancesOptimized(new Collection()->push($account), $start, $primaryCurrency, $convertToPrimary, false)[$account->id];
- $accountCurrency = $this->getAccountCurrency($account);
- $hasCurrency = $accountCurrency instanceof TransactionCurrency;
- $currency = $accountCurrency ?? $primaryCurrency;
+ $primaryCurrency = Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
+ $startBalance = $this->accountsBalancesOptimized(new Collection()->push($account), $start, $primaryCurrency, $convertToPrimary, false)[$account->id];
+ $accountCurrency = $this->getAccountCurrency($account);
+ $hasCurrency = $accountCurrency instanceof TransactionCurrency;
+ $currency = $accountCurrency ?? $primaryCurrency;
// Log::debug(sprintf('Currency is %s', $currency->code));
// set start balances:
if (!array_key_exists($currency->code, $startBalance)) {
// set first balance to 0 or the virtual balance of the account.
- $startBalance[$currency->code] = (string) ('' === (string) $account->virtual_balance ? '0' : $account->virtual_balance);
-
- // Log::debug(sprintf('[a] Start balance in %s is %s', $currency->code, $startBalance[$currency->code]));
+ $startBalance[$currency->code] = (string)('' === (string)$account->virtual_balance ? '0' : $account->virtual_balance);
+ Log::debug(sprintf('[a] Start balance in %s is %s', $currency->code, $startBalance[$currency->code]));
}
if ($hasCurrency && !array_key_exists($accountCurrency->code, $startBalance)) {
- $startBalance[$currency->code] = (string) ('' === (string) $account->virtual_balance ? '0' : $account->virtual_balance);
-
- // Log::debug(sprintf('[b] Start balance in %s is %s', $currency->code, $startBalance[$currency->code]));
+ $startBalance[$currency->code] = (string)('' === (string)$account->virtual_balance ? '0' : $account->virtual_balance);
+ Log::debug(sprintf('[b] Start balance in %s is %s', $currency->code, $startBalance[$currency->code]));
}
if ($hasCurrency && !array_key_exists($primaryCurrency->code, $startBalance)) {
if ($accountCurrency->id !== $primaryCurrency->id && $convertToPrimary) {
$converter = new ExchangeRateConverter();
$converted = $converter->convert($accountCurrency, $primaryCurrency, $start, $startBalance[$accountCurrency->code]);
$startBalance[$primaryCurrency->code] = $converted;
-
- // Log::debug(sprintf('[c] Also set start balance in %s to %s', $primaryCurrency->code, $converted));
+ Log::debug(sprintf('[c] Also set start balance in %s to %s because convertToPrimary = true, and this account is not in that currency.', $primaryCurrency->code, $converted));
}
if ($accountCurrency->id !== $primaryCurrency->id && !$convertToPrimary) {
- $startBalance[$primaryCurrency->code] = (string) ('' === (string) $account->virtual_balance ? '0' : $account->virtual_balance);
+ $startBalance[$primaryCurrency->code] = (string)('' === (string)$account->virtual_balance ? '0' : $account->virtual_balance);
// Log::debug(sprintf('[d] Also set start balance in %s to %s', $primaryCurrency->code, $startBalance[$primaryCurrency->code]));
}
}
if (!$hasCurrency) {
- // Log::debug(sprintf('[e] Also set start balance in %s', $primaryCurrency->code));
- $startBalance[$primaryCurrency->code] = (string) ('' === (string) $account->virtual_balance ? '0' : $account->virtual_balance);
+ // Log::debug(sprintf('[e] Also set start balance in %s', $primaryCurrency->code));
+ $startBalance[$primaryCurrency->code] = (string)('' === (string)$account->virtual_balance ? '0' : $account->virtual_balance);
}
- $currencies = [$currency->id => $currency, $primaryCurrency->id => $primaryCurrency];
+ $currencies = [$currency->id => $currency, $primaryCurrency->id => $primaryCurrency];
$balances[$formatted] = $startBalance;
- // Log::debug('Final start balance: ', $startBalance);
+ Log::debug('Final start balance: ', $startBalance);
// sums up the balance changes per day.
// Log::debug(sprintf('Date >= %s and <= %s', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
- $set = $account
+ $set = $account
->transactions()
->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
->where('transaction_journals.date', '>=', $start->format('Y-m-d H:i:s'))
@@ -518,51 +516,51 @@ class Steam
->groupBy('transactions.transaction_currency_id')
->orderBy('transaction_journals.date', 'ASC')
->whereNull('transaction_journals.deleted_at')
- ->get(['transaction_journals.date', 'transactions.transaction_currency_id', DB::raw('SUM(transactions.amount) AS sum_of_day')])
- ;
+ ->get(['transaction_journals.date', 'transactions.transaction_currency_id', DB::raw('SUM(transactions.amount) AS sum_of_day')]);
- $currentBalance = $startBalance;
- $converter = new ExchangeRateConverter();
+ $currentBalance = $startBalance;
+ $converter = new ExchangeRateConverter();
/** @var Transaction $entry */
foreach ($set as $entry) {
// get date object
- $carbon = new Carbon($entry->date, $entry->date_tz);
- $carbonKey = $carbon->format('Y-m-d');
+ $carbon = new Carbon($entry->date, $entry->date_tz);
+ $carbonKey = $carbon->format('Y-m-d');
// make sure sum is a string:
- $sumOfDay = (string) ($entry->sum_of_day ?? '0');
+ $sumOfDay = (string)($entry->sum_of_day ?? '0');
// #10426 make sure sum is not in scientific notation.
- $sumOfDay = $this->floatalize($sumOfDay);
+ $sumOfDay = $this->floatalize($sumOfDay);
// find currency of this entry, does not have to exist.
$currencies[$entry->transaction_currency_id] ??= Amount::getTransactionCurrencyById($entry->transaction_currency_id);
// make sure this $entry has its own $entryCurrency
/** @var TransactionCurrency $entryCurrency */
- $entryCurrency = $currencies[$entry->transaction_currency_id];
+ $entryCurrency = $currencies[$entry->transaction_currency_id];
// Log::debug(sprintf('Processing transaction(s) on moment %s', $carbon->format('Y-m-d H:i:s')));
// add amount to current balance in currency code.
- $currentBalance[$entryCurrency->code] ??= '0';
- $currentBalance[$entryCurrency->code] = bcadd($sumOfDay, (string) $currentBalance[$entryCurrency->code]);
+ $currentBalance[$entryCurrency->code] ??= '0';
+ $currentBalance[$entryCurrency->code] = bcadd($sumOfDay, (string)$currentBalance[$entryCurrency->code]);
// if not requested to convert to primary currency, add the amount to "balance", do nothing else.
if (!$convertToPrimary) {
- $currentBalance['balance'] = bcadd((string) $currentBalance['balance'], $sumOfDay);
+ $currentBalance['balance'] = bcadd((string)$currentBalance['balance'], $sumOfDay);
}
// if convert to primary currency add the converted amount to "pc_balance".
// if there is a request to convert, convert to "pc_balance" and use "balance" for whichever amount is in the primary currency.
if ($convertToPrimary) {
$pcSumOfDay = $converter->convert($entryCurrency, $primaryCurrency, $carbon, $sumOfDay);
- $currentBalance['pc_balance'] = bcadd((string) ($currentBalance['pc_balance'] ?? '0'), $pcSumOfDay);
+ $currentBalance['pc_balance'] = bcadd((string)($currentBalance['pc_balance'] ?? '0'), $pcSumOfDay);
+ $currentBalance[$primaryCurrency->code] = bcadd((string)($currentBalance[$primaryCurrency->code] ?? '0'), $pcSumOfDay);
// if it's the same currency as the entry, also add to balance (see other code).
if ($currency->id === $entryCurrency->id) {
- $currentBalance['balance'] = bcadd((string) $currentBalance['balance'], $sumOfDay);
+ $currentBalance['balance'] = bcadd((string)$currentBalance['balance'], $sumOfDay);
}
}
// add to final array.
- $balances[$carbonKey] = $currentBalance;
+ $balances[$carbonKey] = $currentBalance;
// Log::debug(sprintf('Updated entry [%s]', $carbonKey), $currentBalance);
}
@@ -580,26 +578,26 @@ class Steam
*/
public function floatalize(string $value): string
{
- $value = strtoupper($value);
+ $value = strtoupper($value);
if (!str_contains($value, 'E')) {
return $value;
}
// Log::debug(sprintf('Floatalizing %s', $value));
- $number = substr($value, 0, (int) strpos($value, 'E'));
+ $number = substr($value, 0, (int)strpos($value, 'E'));
if (str_contains($number, '.')) {
- $post = strlen(substr($number, (int) strpos($number, '.') + 1));
- $mantis = substr($value, (int) strpos($value, 'E') + 1);
+ $post = strlen(substr($number, (int)strpos($number, '.') + 1));
+ $mantis = substr($value, (int)strpos($value, 'E') + 1);
if ($mantis < 0) {
- $post += abs((int) $mantis);
+ $post += abs((int)$mantis);
}
// TODO careless float could break financial math.
- return number_format((float) $value, $post, '.', '');
+ return number_format((float)$value, $post, '.', '');
}
// TODO careless float could break financial math.
- return number_format((float) $value, 0, '.', '');
+ return number_format((float)$value, 0, '.', '');
}
public function formatAmountByCode(string $amount, string $code, ?bool $coloured = null): string
@@ -623,7 +621,7 @@ class Steam
public function formatAmountBySymbol(string $amount, ?string $symbol = null, ?int $decimalPlaces = null, ?bool $coloured = null): string
{
if (null === $symbol) {
- $message = sprintf(
+ $message = sprintf(
'formatAmountBySymbol("%s", %s, %d, %s) was called without a symbol. Please browse to /flush to clear your cache.',
$amount,
var_export($symbol, true),
@@ -634,8 +632,8 @@ class Steam
$currency = Amount::getPrimaryCurrency();
}
if (null !== $symbol) {
- $decimalPlaces ??= 2;
- $coloured ??= true;
+ $decimalPlaces ??= 2;
+ $coloured ??= true;
$currency = new TransactionCurrency();
$currency->symbol = $symbol;
$currency->decimal_places = $decimalPlaces;
@@ -646,8 +644,8 @@ class Steam
public function getAccountCurrency(Account $account): ?TransactionCurrency
{
- $type = $account->accountType->type;
- $list = config('firefly.valid_currency_account_types');
+ $type = $account->accountType->type;
+ $list = config('firefly.valid_currency_account_types');
// return null if not in this list.
if (!in_array($type, $list, true)) {
@@ -658,7 +656,7 @@ class Steam
return null;
}
- return Amount::getTransactionCurrencyById((int) $result->data);
+ return Amount::getTransactionCurrencyById((int)$result->data);
}
public function getHostName(string $ipAddress): string
@@ -672,11 +670,11 @@ class Steam
$hostName = $ipAddress;
}
- if ('' !== (string) $hostName && $hostName !== $ipAddress) {
+ if ('' !== (string)$hostName && $hostName !== $ipAddress) {
$host = $hostName;
}
- return (string) $host;
+ return (string)$host;
}
/**
@@ -700,19 +698,18 @@ class Steam
{
$list = [];
- $set = auth()
+ $set = auth()
->user()
->transactions()
->whereIn('transactions.account_id', $accounts)
->groupBy(['transactions.account_id', 'transaction_journals.user_id'])
- ->get(['transactions.account_id', DB::raw('MAX(transaction_journals.date) AS max_date')])
- ;
+ ->get(['transactions.account_id', DB::raw('MAX(transaction_journals.date) AS max_date')]);
/** @var Transaction $entry */
foreach ($set as $entry) {
- $date = new Carbon($entry->max_date, config('app.timezone'));
+ $date = new Carbon($entry->max_date, config('app.timezone'));
$date->setTimezone(config('app.timezone'));
- $list[(int) $entry->account_id] = $date;
+ $list[(int)$entry->account_id] = $date;
}
return $list;
@@ -728,14 +725,14 @@ class Steam
if (null !== $cached) {
return $cached;
}
- $locale = Preferences::get('locale', config('firefly.default_locale', 'equal'))->data;
+ $locale = Preferences::get('locale', config('firefly.default_locale', 'equal'))->data;
if (is_array($locale)) {
$locale = 'equal';
}
if ('equal' === $locale) {
$locale = $this->getLanguage();
}
- $locale = (string) $locale;
+ $locale = (string)$locale;
// Check for Windows to replace the locale correctly.
if ('WIN' === strtoupper(substr(PHP_OS, 0, 3))) {
@@ -774,7 +771,7 @@ class Steam
public function getSafeUrl(string $unknownUrl, string $safeUrl): string
{
// Log::debug(sprintf('getSafeUrl(%s, %s)', $unknownUrl, $safeUrl));
- $returnUrl = $safeUrl;
+ $returnUrl = $safeUrl;
// die('in get safe url');
try {
@@ -837,24 +834,24 @@ class Steam
// has a K in it, remove the K and multiply by 1024.
$bytes = bcmul(rtrim($string, 'k'), '1024');
- return (int) $bytes;
+ return (int)$bytes;
}
if (false !== stripos($string, 'm')) {
// has a M in it, remove the M and multiply by 1048576.
$bytes = bcmul(rtrim($string, 'm'), '1048576');
- return (int) $bytes;
+ return (int)$bytes;
}
if (false !== stripos($string, 'g')) {
// has a G in it, remove the G and multiply by (1024)^3.
$bytes = bcmul(rtrim($string, 'g'), '1073741824');
- return (int) $bytes;
+ return (int)$bytes;
}
- return (int) $string;
+ return (int)$string;
}
public function positive(string $amount): string
@@ -893,13 +890,13 @@ class Steam
if (null === $preference) {
$singleton->setPreference($key, $currency);
}
- $current = $amount;
+ $current = $amount;
if ($currency->id !== $primary->id) {
$current = $converter->convert($currency, $primary, $date, $amount);
// Log::debug(sprintf('Convert %s %s to %s %s', $currency->code, $amount, $primary->code, $current));
}
- $total = bcadd((string) $current, $total);
+ $total = bcadd((string)$current, $total);
}
return $total;
@@ -913,18 +910,18 @@ class Steam
$primary = Amount::getPrimaryCurrency();
$currencies[$primary->id] = $primary;
- $ids = $accounts->pluck('id')->toArray();
- $result = AccountMeta::query()->whereIn('account_id', $ids)->where('name', 'currency_id')->get();
+ $ids = $accounts->pluck('id')->toArray();
+ $result = AccountMeta::query()->whereIn('account_id', $ids)->where('name', 'currency_id')->get();
/** @var AccountMeta $item */
foreach ($result as $item) {
- $integer = (int) $item->data;
+ $integer = (int)$item->data;
if (0 !== $integer) {
- $accountPreferences[(int) $item->account_id] = $integer;
+ $accountPreferences[(int)$item->account_id] = $integer;
}
}
// collect those currencies, skip primary because we already have it.
- $set = TransactionCurrency::query()->whereIn('id', $accountPreferences)->where('id', '!=', $primary->id)->get();
+ $set = TransactionCurrency::query()->whereIn('id', $accountPreferences)->where('id', '!=', $primary->id)->get();
foreach ($set as $item) {
$currencies[$item->id] = $item;
}
@@ -935,7 +932,7 @@ class Steam
$currencyPresent = property_exists($account, 'meta') && array_key_exists('currency', $account->meta) && null !== $account->meta['currency'];
if ($currencyPresent) {
$currencyId = $account->meta['currency']->id;
- $currencies[$currencyId] ??= $account->meta['currency'];
+ $currencies[$currencyId] ??= $account->meta['currency'];
$accountCurrencies[$accountId] = $account->meta['currency'];
}
if (!$currencyPresent && !array_key_exists($accountId, $accountPreferences)) {
@@ -955,7 +952,7 @@ class Steam
foreach ($array as $item) {
$groupKey = $item[$group] ?? 'unknown';
- $return[$groupKey] = bcadd($return[$groupKey] ?? '0', (string) $item[$field]);
+ $return[$groupKey] = bcadd($return[$groupKey] ?? '0', (string)$item[$field]);
}
return $return;
diff --git a/resources/views/components/elements/transaction-amount.blade.php b/resources/views/components/elements/transaction-amount.blade.php
index 5e57341f5f..7361f004e3 100644
--- a/resources/views/components/elements/transaction-amount.blade.php
+++ b/resources/views/components/elements/transaction-amount.blade.php
@@ -1,4 +1,3 @@
-<!-- TODO amount display helper -->
{{-- deposit --}}
@if('Deposit' === $type)
{{-- amount of deposit --}}
@@ -32,7 +31,7 @@
({!! format_amount_by_symbol($foreign['amount']*-1, $foreign['currency_symbol'], $foreign['currency_decimal_places'], false) !!})
@endif
{{-- transfer in primary currency. Does not care about direction. --}}
- @if($convertToPrimary && 0 !== $pcAmount)
+ @if($convertToPrimary && 0 !== $pcAmount && $primaryCurrency->id !== $amount['currency_id'])
(~ {!! format_amount_by_symbol($pcAmount*-1, $primaryCurrency->symbol, $primaryCurrency->decimal_places) !!})
@endif
</span>
@@ -107,7 +106,7 @@
({!! format_amount_by_symbol($foreign['amount'], $foreign['currency_symbol'], $foreign['currency_decimal_places']) !!})
@endif
{{-- primary currency amount of withdrawal, if not in foreign currency --}}
- @if($convertToPrimary && 0 !== $pcAmount && $primaryCurrency->id !== $foreign['currency_id'])
+ @if($convertToPrimary && 0 !== $pcAmount && $primaryCurrency->id !== $amount['currency_id'] && $primaryCurrency->id !== $foreign['currency_id'])
(~ {!! format_amount_by_symbol($pcAmount, $primaryCurrency->symbol, $primaryCurrency->decimal_places) !!})
@endif
@endif
diff --git a/resources/views/components/generic/amount.blade.php b/resources/views/components/generic/amount.blade.php
index 16c6ba8ad0..d22397b7b7 100644
--- a/resources/views/components/generic/amount.blade.php
+++ b/resources/views/components/generic/amount.blade.php
@@ -8,7 +8,7 @@
({!! format_amount_by_symbol(bcmul($transaction['foreign_amount'], '-1'), $transaction['foreign_currency_symbol'], $transaction['foreign_currency_decimal_places']) !!})
@endif
@if($convertToPrimary && null !== $transaction['pc_amount'])
- ({!! format_amount_by_symbol(bcmul($transaction['pc_amount'], '-1'), $primaryCurrency->symbol, $primaryCurrency->decimal_places) !!})
+ (~{!! format_amount_by_symbol(bcmul($transaction['pc_amount'], '-1'), $primaryCurrency->symbol, $primaryCurrency->decimal_places) !!})
@endif
@endif
@@ -18,7 +18,7 @@
({!! format_amount_by_symbol($transaction['foreign_amount'], $transaction['foreign_currency_symbol'], $transaction['foreign_currency_decimal_places']) !!})
@endif
@if($convertToPrimary && null !== $transaction['pc_amount'])
- ({!! format_amount_by_symbol($transaction['pc_amount'], $primaryCurrency->symbol, $primaryCurrency->decimal_places) !!})
+ (~{!! format_amount_by_symbol($transaction['pc_amount'], $primaryCurrency->symbol, $primaryCurrency->decimal_places) !!})
@endif
@endif
@@ -31,7 +31,7 @@
({!! format_amount_by_symbol(bcmul($transaction['foreign_amount'],'-1'), $transaction['foreign_currency_symbol'], $transaction['foreign_currency_decimal_places'], false) !!})
@endif
@if($convertToPrimary && null !== $transaction['pc_amount'])
- ({!! format_amount_by_symbol(bcmul($transaction['pc_amount'], '-1'), $primaryCurrency->symbol, $primaryCurrency->decimal_places, false) !!})
+ (~{!! format_amount_by_symbol(bcmul($transaction['pc_amount'], '-1'), $primaryCurrency->symbol, $primaryCurrency->decimal_places, false) !!})
@endif
@endif
@@ -42,7 +42,7 @@
({!! format_amount_by_symbol($transaction['foreign_amount'], $transaction['foreign_currency_symbol'], $transaction['foreign_currency_decimal_places'], false) !!})
@endif
@if($convertToPrimary && null !== $transaction['pc_amount'])
- ({!! format_amount_by_symbol($transaction['pc_amount'], $primaryCurrency->symbol, $primaryCurrency->decimal_places, false) !!})
+ (~{!! format_amount_by_symbol($transaction['pc_amount'], $primaryCurrency->symbol, $primaryCurrency->decimal_places, false) !!})
@endif
@endif
</span>
@@ -52,23 +52,23 @@
@if(\FireflyIII\Enums\TransactionTypeEnum::OPENING_BALANCE->value === $transaction['transaction_type_type'])
{{-- Opening balance is deposited on this account (render as positive amount) --}}
@if(\FireflyIII\Enums\AccountTypeEnum::INITIAL_BALANCE->value === $transaction['source_account_type'])
- {!! format_amount_by_symbol(bcmul($transaction['amount'],'-1'), $transaction['currency_symbol'], $transaction['currency_decimal_places'], false) !!}
+ {!! format_amount_by_symbol(bcmul($transaction['amount'],'-1'), $transaction['currency_symbol'], $transaction['currency_decimal_places'], true) !!}
@if(null !== $transaction['foreign_amount'])
- ({!! format_amount_by_symbol(bcmul($transaction['foreign_amount'],'-1'), $transaction['foreign_currency_symbol'], $transaction['foreign_currency_decimal_places'], false) !!})
+ ({!! format_amount_by_symbol(bcmul($transaction['foreign_amount'],'-1'), $transaction['foreign_currency_symbol'], $transaction['foreign_currency_decimal_places'], true) !!})
@endif
@if($convertToPrimary && null !== $transaction['pc_amount'])
- ({!! format_amount_by_symbol(bcmul($transaction['pc_amount'], '-1'), $primaryCurrency->symbol, $primaryCurrency->decimal_places, false) !!})
+ (~{!! format_amount_by_symbol(bcmul($transaction['pc_amount'], '-1'), $primaryCurrency->symbol, $primaryCurrency->decimal_places, true) !!})
@endif
@endif
{{-- Opening balance is removed from this account (render as negative amount) --}}
@if(\FireflyIII\Enums\AccountTypeEnum::INITIAL_BALANCE->value === $transaction['destination_account_type'])
- {!! format_amount_by_symbol($transaction['amount'], $transaction['currency_symbol'], $transaction['currency_decimal_places'], false) !!}
+ {!! format_amount_by_symbol($transaction['amount'], $transaction['currency_symbol'], $transaction['currency_decimal_places'], true) !!}
@if(null !== $transaction['foreign_amount'])
- ({!! format_amount_by_symbol($transaction['foreign_amount'], $transaction['foreign_currency_symbol'], $transaction['foreign_currency_decimal_places'], false) !!})
+ ({!! format_amount_by_symbol($transaction['foreign_amount'], $transaction['foreign_currency_symbol'], $transaction['foreign_currency_decimal_places'], true) !!})
@endif
@if($convertToPrimary && null !== $transaction['pc_amount'])
- ({!! format_amount_by_symbol($transaction['pc_amount'], $primaryCurrency->symbol, $primaryCurrency->decimal_places, false) !!})
+ ({!! format_amount_by_symbol($transaction['pc_amount'], $primaryCurrency->symbol, $primaryCurrency->decimal_places, true) !!})
@endif
@endif
@endif
@@ -76,23 +76,23 @@
@if(\FireflyIII\Enums\TransactionTypeEnum::RECONCILIATION->value === $transaction['transaction_type_type'])
{{-- Reconciliation correction is deposited on this account (render as positive amount) --}}
@if(\FireflyIII\Enums\AccountTypeEnum::RECONCILIATION->value === $transaction['source_account_type'])
- {!! format_amount_by_symbol(bcmul($transaction['amount'],'-1'), $transaction['currency_symbol'], $transaction['currency_decimal_places'], false) !!}
+ {!! format_amount_by_symbol(bcmul($transaction['amount'],'-1'), $transaction['currency_symbol'], $transaction['currency_decimal_places'], true) !!}
@if(null !== $transaction['foreign_amount'])
- ({!! format_amount_by_symbol(bcmul($transaction['foreign_amount'],'-1'), $transaction['foreign_currency_symbol'], $transaction['foreign_currency_decimal_places'], false) !!})
+ ({!! format_amount_by_symbol(bcmul($transaction['foreign_amount'],'-1'), $transaction['foreign_currency_symbol'], $transaction['foreign_currency_decimal_places'], true) !!})
@endif
@if($convertToPrimary && null !== $transaction['pc_amount'])
- ({!! format_amount_by_symbol(bcmul($transaction['pc_amount'], '-1'), $primaryCurrency->symbol, $primaryCurrency->decimal_places, false) !!})
+ (~{!! format_amount_by_symbol(bcmul($transaction['pc_amount'], '-1'), $primaryCurrency->symbol, $primaryCurrency->decimal_places, true) !!})
@endif
@endif
{{-- Reconciliation correction is removed from this account (render as negative amount) --}}
@if(\FireflyIII\Enums\AccountTypeEnum::RECONCILIATION->value === $transaction['destination_account_type'])
- {!! format_amount_by_symbol($transaction['amount'], $transaction['currency_symbol'], $transaction['currency_decimal_places'], false) !!}
+ {!! format_amount_by_symbol($transaction['amount'], $transaction['currency_symbol'], $transaction['currency_decimal_places'], true) !!}
@if(null !== $transaction['foreign_amount'])
- ({!! format_amount_by_symbol($transaction['foreign_amount'], $transaction['foreign_currency_symbol'], $transaction['foreign_currency_decimal_places'], false) !!})
+ ({!! format_amount_by_symbol($transaction['foreign_amount'], $transaction['foreign_currency_symbol'], $transaction['foreign_currency_decimal_places'], true) !!})
@endif
@if($convertToPrimary && null !== $transaction['pc_amount'])
- ({!! format_amount_by_symbol($transaction['pc_amount'], $primaryCurrency->symbol, $primaryCurrency->decimal_places, false) !!})
+ (~{!! format_amount_by_symbol($transaction['pc_amount'], $primaryCurrency->symbol, $primaryCurrency->decimal_places, true) !!})
@endif
@endif
@endif
diff --git a/resources/views/components/lists/groups-large.blade.php b/resources/views/components/lists/groups-large.blade.php
index ca529d2d28..958f24d52e 100644
--- a/resources/views/components/lists/groups-large.blade.php
+++ b/resources/views/components/lists/groups-large.blade.php
@@ -63,24 +63,18 @@
@foreach($group['sums'] as $sum)
@if('Deposit' === $group['transaction_type'])
{!! format_amount_by_symbol($sum['amount']*-1, $sum['currency_symbol'], $sum['currency_decimal_places']) !!}
- @if($convertToPrimary && 0 !== $sum['pc_amount'])
- (~ {!! format_amount_by_symbol($sum['pc_amount']*-1, $primaryCurrency->symbol, $primaryCurrency->decimal_places) !!})
- @endif
- @if($loop->index !== count($group['sums'])-1),@endif
+ @if($convertToPrimary && 0.0 !== (float)$sum['pc_amount'] && $primaryCurrency->id !== $sum['currency_id'])
+ (~ {!! format_amount_by_symbol($sum['pc_amount']*-1, $primaryCurrency->symbol, $primaryCurrency->decimal_places) !!})@endif{{ $loop->index !== count($group['sums'])-1 ? ',' : '' }}
@elseif('Transfer' === $group['transaction_type'])
<span class="text-info money-transfer">
{!! format_amount_by_symbol($sum['amount']*-1, $sum['currency_symbol'], $sum['currency_decimal_places'], false) !!}
- @if($convertToPrimary && 0 !== $sum['pc_amount'])
- (~ {!! format_amount_by_symbol($sum['pc_amount']*-1, $primaryCurrency->symbol, $primaryCurrency->decimal_places) !!})
- @endif
- @if($loop->index !== count($group['sums'])-1),@endif
+ @if($convertToPrimary && 0 !== $sum['pc_amount'] && $primaryCurrency->id !== $sum['currency_id'])
+ (~ {!! format_amount_by_symbol($sum['pc_amount']*-1, $primaryCurrency->symbol, $primaryCurrency->decimal_places) !!})@endif{{ $loop->index !== count($group['sums'])-1 ? ',' : '' }}
</span>
@else
{!! format_amount_by_symbol($sum['amount'], $sum['currency_symbol'], $sum['currency_decimal_places']) !!}
- @if($convertToPrimary && 0 !== $sum['pc_amount'])
- (~ {!! format_amount_by_symbol($sum['pc_amount'], $primaryCurrency->symbol, $primaryCurrency->decimal_places) !!})
- @endif
- @if($loop->index !== count($group['sums'])-1),@endif
+ @if($convertToPrimary && 0 !== $sum['pc_amount'] && $primaryCurrency->id !== $sum['currency_id'])
+ (~ {!! format_amount_by_symbol($sum['pc_amount'], $primaryCurrency->symbol, $primaryCurrency->decimal_places) !!})@endif{{ $loop->index !== count($group['sums'])-1 ? ',' : '' }}
@endif
@endforeach
</td>
@@ -134,7 +128,7 @@
<td class="{{ $className }} text-end">
<x-elements.transaction-amount
:type="$transaction['transaction_type_type']"
- :amount="['amount' => $transaction['amount'], 'currency_symbol' => $transaction['currency_symbol'], 'currency_decimal_places' => $transaction['currency_decimal_places']]"
+ :amount="['amount' => $transaction['amount'], 'currency_id' => $transaction['currency_id'], 'currency_symbol' => $transaction['currency_symbol'], 'currency_decimal_places' => $transaction['currency_decimal_places']]"
:foreign="['amount' => $transaction['foreign_amount'],'currency_id' => $transaction['foreign_currency_id'], 'currency_symbol' => $transaction['foreign_currency_symbol'], 'currency_decimal_places' => $transaction['foreign_currency_decimal_places']]"
:account="$account ?? null"
:pc-amount="$transaction['pc_amount']"