diff --git a/app/Classes/General/Eloquent/Filters/DateRangeNoData.php b/app/Classes/General/Eloquent/Filters/DateRangeNoData.php index 833477ae..e0d730e5 100644 --- a/app/Classes/General/Eloquent/Filters/DateRangeNoData.php +++ b/app/Classes/General/Eloquent/Filters/DateRangeNoData.php @@ -92,14 +92,14 @@ class DateRangeNoData implements Filter $q->where('created_at', '<', '2025-07-01 00:00:00'); }); }) - ->whereHas('transactions', function ($query) { - $query->where('type', TransactionType::INVOICE) - ->whereDoesntHave('attributesKVP', function ($invoiceQuery) { - $invoiceQuery->where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE); + ->where(function ($query){ + $query + ->whereDoesntHave('transactions.attributesKVP', function ($subQuery) { + $subQuery->where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE); + }) + ->whereDoesntHave('attributesKVP', function ($subQuery) { + $subQuery->where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE); }); - }) - ->whereDoesntHave('attributesKVP', function ($invoiceQuery) { - $invoiceQuery->where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE); }); }) // OR bookings with refunds @@ -119,14 +119,15 @@ class DateRangeNoData implements Filter $q->where('created_at', '<', '2025-07-01 00:00:00'); }); }) - ->whereHas('transactions', function ($query) { - $query->where('type', TransactionType::INVOICE) - ->whereDoesntHave('attributesKVP', function ($invoiceQuery) { - $invoiceQuery->where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE); + ->where(function ($query){ + $query + ->whereDoesntHave('transactions.attributesKVP', function ($subQuery) { + $subQuery->where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE); + }) + + ->whereDoesntHave('attributesKVP', function ($subQuery) { + $subQuery->where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE); }); - }) - ->whereDoesntHave('attributesKVP', function ($invoiceQuery) { - $invoiceQuery->where('key', KVPKey::AUTOCOUNT_DOCNO_INVOICE); }); }); })