Catch potential nullpointers

This commit is contained in:
James Cole 2024-11-08 21:02:36 +01:00
parent 068094caac
commit b4edd3dcc4
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
2 changed files with 4 additions and 4 deletions

View File

@ -377,11 +377,11 @@ trait ModifiesPiggyBanks
}
if (array_key_exists('targetdate', $data) && '' !== $data['targetdate']) {
$piggyBank->targetdate = $data['targetdate'];
$piggyBank->targetdate_tz = $data['targetdate']->format('e');
$piggyBank->targetdate_tz = $data['targetdate']?->format('e');
}
if (array_key_exists('startdate', $data)) {
$piggyBank->startdate = $data['startdate'];
$piggyBank->startdate_tz = $data['targetdate']->format('e');
$piggyBank->startdate_tz = $data['targetdate']?->format('e');
}
$piggyBank->save();

View File

@ -236,12 +236,12 @@ class AccountBalanceCalculator
'balance' => '0',
'transaction_currency_id' => $currencyId,
'date' => $balance[1],
'date_tz' => $balance[1]->format('e'),
'date_tz' => $balance[1]?->format('e'),
]
);
$object->balance = $balance[0];
$object->date = $balance[1];
$object->date_tz = $balance[1]->format('e');
$object->date_tz = $balance[1]?->format('e');
$object->save();
}
}