From 1423d5b3141c1433c0cb0ab820dc5d4250772d21 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 12 Dec 2015 12:36:36 +0100 Subject: [PATCH] Expand query, let's see what happens. --- app/Helpers/Report/ReportQuery.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/Helpers/Report/ReportQuery.php b/app/Helpers/Report/ReportQuery.php index 34db15cdb0..5f39c72dd0 100644 --- a/app/Helpers/Report/ReportQuery.php +++ b/app/Helpers/Report/ReportQuery.php @@ -279,12 +279,15 @@ class ReportQuery implements ReportQueryInterface $ids[] = $account->id; } - // only get deposits not to a shared account - // and transfers to a shared account. - // OR is a deposit // OR is a transfer FROM a shared account to NOT a shared account. // + // New idea: from the perspective of a shared account, + // a transfer from a not-shared account is income! + // so: + // OR is a transfer from NOT a shared account to a shared account. + + $query->where( function (Builder $query) { @@ -300,6 +303,13 @@ class ReportQuery implements ReportQueryInterface $q->where('acm_to.data', '!=', '"sharedAsset"'); } ); + $query->orWhere( + function (Builder $q) { + $q->where('transaction_types.type', TransactionType::TRANSFER); + $q->where('acm_from.data', '!=', '"sharedAsset"'); + $q->where('acm_to.data', '=', '"sharedAsset"'); + } + ); } );