Fix issue with multi-currency in asset accounts.

This commit is contained in:
James Cole
2020-04-12 06:23:35 +02:00
parent 4163efba55
commit 4a7d9b130a

View File

@@ -432,9 +432,15 @@ class AccountController extends Controller
$cache->addProperty($end);
$cache->addProperty($account->id);
if ($cache->has()) {
return response()->json($cache->get()); // @codeCoverageIgnore
return response()->json($cache->get()); // @codeCoverageIgnore
}
$currencies = $this->accountRepository->getUsedCurrencies($account);
// if the account is not expense or revenue, just use the account's default currency.
if (!in_array($account->accountType->type, [AccountType::REVENUE, AccountType::EXPENSE], true)) {
$currencies= [$this->accountRepository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency()];
}
/** @var TransactionCurrency $currency */
foreach ($currencies as $currency) {
$chartData[] = $this->periodByCurrency($start, $end, $account, $currency);