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:
@@ -57,8 +57,8 @@ class SummaryBalanceGrouped
|
||||
};
|
||||
|
||||
$return[] = [
|
||||
'key' => sprintf('%s-in-native', $title),
|
||||
'value' => $this->amounts[$key]['native'] ?? '0',
|
||||
'key' => sprintf('%s-in-pc', $title),
|
||||
'value' => $this->amounts[$key]['primary'] ?? '0',
|
||||
'currency_id' => (string) $this->default->id,
|
||||
'currency_code' => $this->default->code,
|
||||
'currency_symbol' => $this->default->symbol,
|
||||
@@ -68,8 +68,8 @@ class SummaryBalanceGrouped
|
||||
// loop 3: format amounts:
|
||||
$currencyIds = array_keys($this->amounts[self::SUM] ?? []);
|
||||
foreach ($currencyIds as $currencyId) {
|
||||
if ('native' === $currencyId) {
|
||||
// skip native entries.
|
||||
if ('primary' === $currencyId) {
|
||||
// skip primary entries.
|
||||
continue;
|
||||
}
|
||||
$currencyId = (int) $currencyId;
|
||||
@@ -112,23 +112,23 @@ class SummaryBalanceGrouped
|
||||
$amount = bcmul((string) $journal['amount'], $multiplier);
|
||||
$currency = $this->currencies[$currencyId] ?? TransactionCurrency::find($currencyId);
|
||||
$this->currencies[$currencyId] = $currency;
|
||||
$nativeAmount = $converter->convert($currency, $this->default, $journal['date'], $amount);
|
||||
$pcAmount = $converter->convert($currency, $this->default, $journal['date'], $amount);
|
||||
if ((int) $journal['foreign_currency_id'] === $this->default->id) {
|
||||
// use foreign amount instead
|
||||
$nativeAmount = $journal['foreign_amount'];
|
||||
$pcAmount = $journal['foreign_amount'];
|
||||
}
|
||||
// prep the arrays
|
||||
$this->amounts[$key] ??= [];
|
||||
$this->amounts[$key][$currencyId] ??= '0';
|
||||
$this->amounts[$key]['native'] ??= '0';
|
||||
$this->amounts[$key]['primary'] ??= '0';
|
||||
$this->amounts[self::SUM][$currencyId] ??= '0';
|
||||
$this->amounts[self::SUM]['native'] ??= '0';
|
||||
$this->amounts[self::SUM]['primary'] ??= '0';
|
||||
|
||||
// add values:
|
||||
$this->amounts[$key][$currencyId] = bcadd((string) $this->amounts[$key][$currencyId], $amount);
|
||||
$this->amounts[self::SUM][$currencyId] = bcadd((string) $this->amounts[self::SUM][$currencyId], $amount);
|
||||
$this->amounts[$key]['native'] = bcadd((string) $this->amounts[$key]['native'], (string) $nativeAmount);
|
||||
$this->amounts[self::SUM]['native'] = bcadd((string) $this->amounts[self::SUM]['native'], (string) $nativeAmount);
|
||||
$this->amounts[$key]['primary'] = bcadd((string) $this->amounts[$key]['primary'], (string) $pcAmount);
|
||||
$this->amounts[self::SUM]['primary'] = bcadd((string) $this->amounts[self::SUM]['primary'], (string) $pcAmount);
|
||||
}
|
||||
$converter->summarize();
|
||||
}
|
||||
|
Reference in New Issue
Block a user