From 1d3987ece603838a9524fb7b60dfef0d98b51eb6 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 24 Jan 2015 17:58:03 +0100 Subject: [PATCH] Fixed the tests. --- .../FireflyIII/Database/Account/Account.php | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/app/lib/FireflyIII/Database/Account/Account.php b/app/lib/FireflyIII/Database/Account/Account.php index 6753e2eb87..65fa07483d 100644 --- a/app/lib/FireflyIII/Database/Account/Account.php +++ b/app/lib/FireflyIII/Database/Account/Account.php @@ -197,20 +197,27 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte \Transaction::whereIn('id', $transactions)->delete(); } \Event::fire('account.destroy', [$model]); - \Account:: - leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id') - ->where( - function (EloquentBuilder $q) use ($model) { - $q->where('id', $model->id); - $q->orWhere( - function (EloquentBuilder $q) use ($model) { - $q->where('accounts.name', 'LIKE', '%' . $model->name . '%'); - $q->where('account_types.type', 'Initial balance account'); - $q->where('accounts.active', 0); - } - ); + + // get account type: + /** @var \FireflyIII\Database\AccountType\AccountType $acctType */ + $acctType = \App::make('FireflyIII\Database\AccountType\AccountType'); + + $accountType = $acctType->findByWhat('initial'); + + //$q->where('account_types.type', ''); + + \Account::where( + function (EloquentBuilder $q) use ($model, $accountType) { + $q->where('id', $model->id); + $q->orWhere( + function (EloquentBuilder $q) use ($model, $accountType) { + $q->where('accounts.name', 'LIKE', '%' . $model->name . '%'); + $q->where('accounts.account_type_id', $accountType->id); + $q->where('accounts.active', 0); } - )->delete(); + ); + } + )->delete(); return true;