Fix query.

This commit is contained in:
James Cole
2016-04-30 22:05:58 +02:00
parent 55b8f03590
commit 3c1ff4d21f
2 changed files with 35 additions and 7 deletions

View File

@@ -683,8 +683,17 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
}
)
->whereIn('transactions.account_id', $ids)
->having('transaction_count', '=', 1)
->transactionTypes([TransactionType::WITHDRAWAL])
->first([DB::raw('SUM(`transactions`.`amount`) as `journalAmount`')]);
->first(
[
DB::raw('SUM(`transactions`.`amount`) as `journalAmount`'),
DB::raw('COUNT(`transactions`.`id`) as `transaction_count`'),
]
);
if (is_null($entry)) {
return '0';
}
if (is_null($entry->journalAmount)) {
return '0';
}