Fixed a bug where a deposit would not get linked to a cash account.

This commit is contained in:
James Cole 2015-01-23 06:45:20 +01:00
parent 1887977b92
commit f4b68d26d6

View File

@ -464,6 +464,16 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
$accountType = $typeRepository->findByWhat('revenue'); $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]; $data = ['user_id' => $this->getUser()->id, 'account_type_id' => $accountType->id, 'name' => $name, 'active' => 1];
return \Account::firstOrCreate($data); return \Account::firstOrCreate($data);