Fix possible null pointer.

This commit is contained in:
James Cole
2018-03-30 22:40:20 +02:00
parent 08ff3d8ad0
commit 8f3e84df4d
16 changed files with 437 additions and 35 deletions

View File

@@ -238,12 +238,15 @@ class BoxController extends Controller
/** @var Account $account */
foreach ($accounts as $account) {
$accountCurrency = $currency;
$accountCurrency = null;
$balance = $balances[$account->id] ?? '0';
$currencyId = (int)$repository->getMetaValue($account, 'currency_id');
if ($currencyId !== 0) {
$accountCurrency = $currencyRepos->findNull($currencyId);
}
if (null === $accountCurrency) {
$accountCurrency = $currency;
}
// if the account is a credit card, subtract the virtual balance from the balance,
// to better reflect that this is not money that is actually "yours".