From f4b68d26d68151e65040ea6c184b57ab363093de Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 23 Jan 2015 06:45:20 +0100 Subject: [PATCH] Fixed a bug where a deposit would not get linked to a cash account. --- app/lib/FireflyIII/Database/Account/Account.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/lib/FireflyIII/Database/Account/Account.php b/app/lib/FireflyIII/Database/Account/Account.php index 33a8c85ace..a6ae29c5ed 100644 --- a/app/lib/FireflyIII/Database/Account/Account.php +++ b/app/lib/FireflyIII/Database/Account/Account.php @@ -464,6 +464,16 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte $accountType = $typeRepository->findByWhat('revenue'); + // if name is "", find cash account: + if (strlen($name) == 0) { + $cashAccountType = $typeRepository->findByWhat('cash'); + + // find or create cash account: + return \Account::firstOrCreate( + ['name' => 'Cash account', 'account_type_id' => $cashAccountType->id, 'active' => 0, 'user_id' => $this->getUser()->id,] + ); + } + $data = ['user_id' => $this->getUser()->id, 'account_type_id' => $accountType->id, 'name' => $name, 'active' => 1]; return \Account::firstOrCreate($data);