Fixed the tests.

This commit is contained in:
James Cole 2015-01-24 17:58:03 +01:00
parent 83f5b5e293
commit 1d3987ece6

View File

@ -197,15 +197,22 @@ 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) {
// 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) {
function (EloquentBuilder $q) use ($model, $accountType) {
$q->where('accounts.name', 'LIKE', '%' . $model->name . '%');
$q->where('account_types.type', 'Initial balance account');
$q->where('accounts.account_type_id', $accountType->id);
$q->where('accounts.active', 0);
}
);