This commit is contained in:
James Cole 2016-09-03 04:54:57 +02:00
parent 2ce5142b06
commit 29af4bd1b9

View File

@ -89,16 +89,23 @@ class AccountRepository implements AccountRepositoryInterface
}
);
$query->whereIn('source.account_id', $accountIds);
$query->whereNull('source.deleted_at');
}
// remove group by
$query->getQuery()->getQuery()->groups = null;
// that should do it:
$sum = strval($query->sum('source.amount'));
$sum = bcmul($sum, '-1');
// get id's
$ids = $query->get(['transaction_journals.id'])->pluck('id')->toArray();
return $sum;
// that should do it:
$sum = $this->user->transactions()
->whereIn('transaction_journal_id', $ids)
->where('amount', '>', '0')
->whereNull('transactions.deleted_at')
->sum('amount');
return strval($sum);
}
@ -139,6 +146,8 @@ class AccountRepository implements AccountRepositoryInterface
}
// remove group by
$query->getQuery()->getQuery()->groups = null;
// get id's
$ids = $query->get(['transaction_journals.id'])->pluck('id')->toArray();
@ -185,6 +194,7 @@ class AccountRepository implements AccountRepositoryInterface
if (in_array($journal->source_account_id, $accountIds)) {
return true;
}
return false;
}
);
@ -370,6 +380,7 @@ class AccountRepository implements AccountRepositoryInterface
if (in_array($journal->destination_account_id, $accountIds)) {
return true;
}
return false;
}
);