Catch various errors.

This commit is contained in:
James Cole
2018-07-26 06:27:52 +02:00
parent 6bcfea1de4
commit 89be30c4b9
19 changed files with 76 additions and 50 deletions

View File

@@ -41,17 +41,18 @@ class AccountUpdateService
* @param array $data
*
* @return Account
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function update(Account $account, array $data): Account
{
// update the account itself:
$account->name = $data['name'];
$account->active = $data['active'];
$account->virtual_balance = trim($data['virtualBalance']) === '' ? '0' : $data['virtualBalance'];
$account->virtual_balance = '' === trim($data['virtualBalance']) ? '0' : $data['virtualBalance'];
$account->iban = $data['iban'];
$account->save();
if (isset($data['currency_id']) && $data['currency_id'] === 0) {
if (isset($data['currency_id']) && 0 === $data['currency_id']) {
unset($data['currency_id']);
}