From 037135e764b5578e84215c9dde3e908decc8d02a Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 18 Jan 2015 00:10:57 +0100 Subject: [PATCH] A complete gamble on my side to fix a bug where transfers FROM shared accounts were not counted as income. --- app/lib/FireflyIII/Report/Report.php | 1 + app/lib/FireflyIII/Report/ReportQuery.php | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/lib/FireflyIII/Report/Report.php b/app/lib/FireflyIII/Report/Report.php index 91a3caae95..d704cfb31a 100644 --- a/app/lib/FireflyIII/Report/Report.php +++ b/app/lib/FireflyIII/Report/Report.php @@ -46,6 +46,7 @@ class Report implements ReportInterface } /** + * This methods fails to take in account transfers FROM shared accounts. * @param Carbon $start * @param Carbon $end * @param int $limit diff --git a/app/lib/FireflyIII/Report/ReportQuery.php b/app/lib/FireflyIII/Report/ReportQuery.php index a53618adcd..a83a544d95 100644 --- a/app/lib/FireflyIII/Report/ReportQuery.php +++ b/app/lib/FireflyIII/Report/ReportQuery.php @@ -306,8 +306,23 @@ class ReportQuery implements ReportQueryInterface } ) ->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id') - ->where('transaction_types.type', 'Withdrawal') - ->where('acm_from.data', '!=', '"sharedExpense"') + // not shared, withdrawal + ->where( + function ($q) { + $q->where( + function ($q) { + $q->where('transaction_types.type', 'Withdrawal'); + $q->where('acm_from.data', '!=', '"sharedExpense"'); + } + )->orWhere( + function ($q) { + $q->where('transaction_types.type', 'Transfer'); + $q->where('acm_from.data', '=', '"sharedExpense"'); + } + ); + } + ) + // shared, transfer? ->before($end) ->after($start) ->where('transaction_journals.user_id', \Auth::user()->id)