From d49809c939abe3b11c729742c9e0dabbb6d891b3 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 23 Jul 2022 20:15:55 +0200 Subject: [PATCH] Fix https://github.com/firefly-iii/firefly-iii/issues/6260 --- app/Http/Controllers/Chart/AccountController.php | 8 ++++---- app/Transformers/TransactionGroupTransformer.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php index 806b4b8a04..a7f97e8c1d 100644 --- a/app/Http/Controllers/Chart/AccountController.php +++ b/app/Http/Controllers/Chart/AccountController.php @@ -119,8 +119,8 @@ class AccountController extends Controller // see if there is an accompanying start amount. // grab the difference and find the currency. - $startAmount = $startBalances[$accountId][$currencyId] ?? '0'; - $diff = bcsub($endAmount, $startAmount); + $startAmount = (string) ($startBalances[$accountId][$currencyId] ?? '0') + $diff = bcsub((string)$endAmount, $startAmount); $currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->find($currencyId); if (0 !== bccomp($diff, '0')) { // store the values in a temporary array. @@ -578,8 +578,8 @@ class AccountController extends Controller // see if there is an accompanying start amount. // grab the difference and find the currency. - $startAmount = $startBalances[$accountId][$currencyId] ?? '0'; - $diff = bcsub($endAmount, $startAmount); + $startAmount = (string)($startBalances[$accountId][$currencyId] ?? '0'); + $diff = bcsub((string) $endAmount, $startAmount); $currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->find($currencyId); if (0 !== bccomp($diff, '0')) { // store the values in a temporary array. diff --git a/app/Transformers/TransactionGroupTransformer.php b/app/Transformers/TransactionGroupTransformer.php index b60fab159b..70c2814bb6 100644 --- a/app/Transformers/TransactionGroupTransformer.php +++ b/app/Transformers/TransactionGroupTransformer.php @@ -353,7 +353,7 @@ class TransactionGroupTransformer extends AbstractTransformer $destination = $this->getDestinationTransaction($journal); $type = $journal->transactionType->type; $amount = $this->getAmount($type, (string) $source->amount); - $foreignAmount = $this->getForeignAmount($type, $source->foreign_amount); + $foreignAmount = $this->getForeignAmount($type, null === $source->foreign_amount ? null : (string) $source->foreign_amount); $metaFieldData = $this->groupRepos->getMetaFields($journal->id, $this->metaFields); $metaDates = $this->getDates($this->groupRepos->getMetaDateFields($journal->id, $this->metaDateFields)); $currency = $source->transactionCurrency;