A complete gamble on my side to fix a bug where transfers FROM shared accounts were not counted as income.

This commit is contained in:
James Cole
2015-01-18 00:10:57 +01:00
parent 21e89c3b64
commit 037135e764
2 changed files with 18 additions and 2 deletions

View File

@@ -46,6 +46,7 @@ class Report implements ReportInterface
} }
/** /**
* This methods fails to take in account transfers FROM shared accounts.
* @param Carbon $start * @param Carbon $start
* @param Carbon $end * @param Carbon $end
* @param int $limit * @param int $limit

View File

@@ -306,8 +306,23 @@ class ReportQuery implements ReportQueryInterface
} }
) )
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id') ->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
->where('transaction_types.type', 'Withdrawal') // not shared, withdrawal
->where('acm_from.data', '!=', '"sharedExpense"') ->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) ->before($end)
->after($start) ->after($start)
->where('transaction_journals.user_id', \Auth::user()->id) ->where('transaction_journals.user_id', \Auth::user()->id)