mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-14 00:04:24 +00:00
More PHP8.4 updates
This commit is contained in:
@@ -38,7 +38,7 @@ class AccountBalanceGrouped
|
||||
{
|
||||
private array $accountIds;
|
||||
private string $carbonFormat;
|
||||
private ExchangeRateConverter $converter;
|
||||
private readonly ExchangeRateConverter $converter;
|
||||
private array $currencies = [];
|
||||
private array $data = [];
|
||||
private TransactionCurrency $default;
|
||||
@@ -157,7 +157,7 @@ class AccountBalanceGrouped
|
||||
|
||||
// get conversion rate
|
||||
$rate = $this->getRate($currency, $journal['date']);
|
||||
$amountConverted = bcmul($amount, $rate);
|
||||
$amountConverted = bcmul((string) $amount, $rate);
|
||||
|
||||
// perhaps transaction already has the foreign amount in the native currency.
|
||||
if ((int) $journal['foreign_currency_id'] === $this->default->id) {
|
||||
@@ -166,11 +166,11 @@ class AccountBalanceGrouped
|
||||
}
|
||||
|
||||
// add normal entry
|
||||
$this->data[$currencyId][$period][$key] = bcadd($this->data[$currencyId][$period][$key], $amount);
|
||||
$this->data[$currencyId][$period][$key] = bcadd((string) $this->data[$currencyId][$period][$key], (string) $amount);
|
||||
|
||||
// add converted entry
|
||||
$convertedKey = sprintf('native_%s', $key);
|
||||
$this->data[$currencyId][$period][$convertedKey] = bcadd($this->data[$currencyId][$period][$convertedKey], $amountConverted);
|
||||
$this->data[$currencyId][$period][$convertedKey] = bcadd((string) $this->data[$currencyId][$period][$convertedKey], (string) $amountConverted);
|
||||
}
|
||||
|
||||
private function findCurrency(int $currencyId): TransactionCurrency
|
||||
|
@@ -33,7 +33,7 @@ class SummaryBalanceGrouped
|
||||
private const string SUM = 'sum';
|
||||
private array $amounts = [];
|
||||
private array $currencies;
|
||||
private CurrencyRepositoryInterface $currencyRepository;
|
||||
private readonly CurrencyRepositoryInterface $currencyRepository;
|
||||
private TransactionCurrency $default;
|
||||
private array $keys;
|
||||
|
||||
@@ -109,7 +109,7 @@ class SummaryBalanceGrouped
|
||||
foreach ($journals as $journal) {
|
||||
// transaction info:
|
||||
$currencyId = (int) $journal['currency_id'];
|
||||
$amount = bcmul($journal['amount'], $multiplier);
|
||||
$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);
|
||||
@@ -125,10 +125,10 @@ class SummaryBalanceGrouped
|
||||
$this->amounts[self::SUM]['native'] ??= '0';
|
||||
|
||||
// add values:
|
||||
$this->amounts[$key][$currencyId] = bcadd($this->amounts[$key][$currencyId], $amount);
|
||||
$this->amounts[self::SUM][$currencyId] = bcadd($this->amounts[self::SUM][$currencyId], $amount);
|
||||
$this->amounts[$key]['native'] = bcadd($this->amounts[$key]['native'], $nativeAmount);
|
||||
$this->amounts[self::SUM]['native'] = bcadd($this->amounts[self::SUM]['native'], $nativeAmount);
|
||||
$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);
|
||||
}
|
||||
$converter->summarize();
|
||||
}
|
||||
|
Reference in New Issue
Block a user