mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Convert raw XORs to a construct compatible with Laravel's query builder
This commit is contained in:
@@ -257,9 +257,19 @@ class ReportHelper implements ReportHelperInterface
|
||||
->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
|
||||
->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
|
||||
->where(
|
||||
function (Builder $q) use ($ids) {
|
||||
$q->whereIn('source.account_id', $ids)
|
||||
->whereIn('destination.account_id', $ids, 'xor');
|
||||
// source.account_id in accountIds XOR destination.account_id in accountIds
|
||||
function (Builder $sourceXorDestinationQuery) use ($ids) {
|
||||
$sourceXorDestinationQuery->where(
|
||||
function (Builder $inSourceButNotDestinationQuery) use ($ids) {
|
||||
$inSourceButNotDestinationQuery->whereIn('source.account_id', $ids)
|
||||
->whereNotIn('destination.account_id', $ids);
|
||||
}
|
||||
)->orWhere(
|
||||
function (Builder $inDestinationButNotSourceQuery) use ($ids) {
|
||||
$inDestinationButNotSourceQuery->whereIn('destination.account_id', $ids)
|
||||
->whereNotIn('source.account_id', $ids);
|
||||
}
|
||||
);
|
||||
}
|
||||
)
|
||||
->get(['tags.id', 'tags.tag', 'transaction_journals.id as journal_id', 'destination.amount']);
|
||||
|
Reference in New Issue
Block a user