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)