From b7eeb3fcacde7480952e76108ce809180ab4d67c Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Tue, 4 Nov 2025 11:55:29 +0800 Subject: [PATCH] E-Invoice - API, Sales Invoice Report (update with voucherify info) --- .../Eloquent/Filters/DateRangeNoData.php | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) 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); }); }); })