exchangeRateService->convert( $transaction->currency_code ?: $transaction->account?->currency_code ?: $currency, $currency, $transaction->amount, $transaction->transaction_date->toDateString(), ); } /** * @param Collection $transactions */ protected function preloadExchangeRates(Collection $transactions, string $currency): void { $dates = $transactions ->filter(fn (Transaction $transaction): bool => strcasecmp($transaction->currency_code ?: $transaction->account?->currency_code ?: $currency, $currency) !== 0) ->map(fn (Transaction $transaction): string => $transaction->transaction_date->toDateString()) ->unique() ->values(); if ($dates->isEmpty()) { return; } $this->exchangeRateService->preloadRates($currency, $dates); } }