Fix query.

This commit is contained in:
James Cole 2015-12-12 20:10:52 +01:00
parent 9bd1503cb4
commit a985e09282

View File

@ -288,7 +288,6 @@ class ReportQuery implements ReportQueryInterface
// OR is a transfer from NOT a shared account to a shared account.
$query->where(
function (Builder $query) {
$query->where(
@ -367,28 +366,20 @@ class ReportQuery implements ReportQueryInterface
$query = $this->queryJournalsWithTransactions($start, $end);
// withdrawals from any account are an expense.
// transfers away, to an account not in the list, are an expense.
$query->where(
function (Builder $query) {
function (Builder $query) use ($ids) {
$query->where(
function (Builder $q) { // only get withdrawals from any account:
function (Builder $q) {
$q->where('transaction_types.type', TransactionType::WITHDRAWAL);
//$q->where('acm_from.data', '!=', '"sharedAsset"');
}
);
$query->orWhere(
function (Builder $q) { // and transfers from a shared account to a not-shared account.
function (Builder $q) use ($ids) {
$q->where('transaction_types.type', TransactionType::TRANSFER);
$q->where('acm_to.data', '=', '"sharedAsset"');
$q->where('acm_from.data', '!=', '"sharedAsset"');
}
);
// OR transfers from a NOT shared account to a shared account.
$query->orWhere(
function (Builder $q) { // and transfers from a shared account to a not-shared account.
$q->where('transaction_types.type', TransactionType::TRANSFER);
$q->where('acm_to.data', '!=', '"sharedAsset"');
$q->where('acm_from.data', '=', '"sharedAsset"');
$q->whereNotIn('ac_to.id', $ids);
}
);
}