This commit is contained in:
James Cole
2020-02-08 12:59:43 +01:00
parent cebc0d7568
commit 4cd642b8da
2 changed files with 6 additions and 5 deletions

View File

@@ -240,7 +240,7 @@ class PiggyBankController extends Controller
foreach ($collection as $piggy) { foreach ($collection as $piggy) {
$array = $transformer->transform($piggy); $array = $transformer->transform($piggy);
$account = $accountTransformer->transform($piggy->account); $account = $accountTransformer->transform($piggy->account);
$accountId = $account['id']; $accountId = (int)$account['id'];
if (!isset($accounts[$accountId])) { if (!isset($accounts[$accountId])) {
// create new: // create new:
$accounts[$accountId] = $account; $accounts[$accountId] = $account;

View File

@@ -180,10 +180,11 @@ class AccountTransformer extends AbstractTransformer
private function getCurrency(Account $account): array private function getCurrency(Account $account): array
{ {
$currency = $this->repository->getAccountCurrency($account); $currency = $this->repository->getAccountCurrency($account);
$currencyId = null; $default = app('amount')->getDefaultCurrencyByUser($account->user);
$currencyCode = null; $currencyId = $default->id;
$decimalPlaces = 2; $currencyCode = $default->code;
$currencySymbol = null; $decimalPlaces = $default->decimal_places;
$currencySymbol = $default->symbol;
if (null !== $currency) { if (null !== $currency) {
$currencyId = $currency->id; $currencyId = $currency->id;
$currencyCode = $currency->code; $currencyCode = $currency->code;