From aa2ce980bc0290d52c622388656d1c6c9f49a347 Mon Sep 17 00:00:00 2001 From: Omair Saleh Date: Thu, 27 Oct 2022 15:57:27 +0800 Subject: [PATCH] fix export invoice --- .../Exports/Services/ExportsPaymentTransactions.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Classes/Modules/Exports/Services/ExportsPaymentTransactions.php b/app/Classes/Modules/Exports/Services/ExportsPaymentTransactions.php index 1d0fb9fe..d810fc9b 100644 --- a/app/Classes/Modules/Exports/Services/ExportsPaymentTransactions.php +++ b/app/Classes/Modules/Exports/Services/ExportsPaymentTransactions.php @@ -69,10 +69,15 @@ class ExportsPaymentTransactions implements FromQuery, WithHeadings, WithHeading ]); } elseif($start_date && !$end_date) { - $query->where('created_at', '>=', Carbon::parse($start_date)->format('Y-m-d 0:00:00')); + $query->whereHas('transactions', function($transaction) use ($start_date) { + $transaction->where('type', TransactionType::PAYMENT)->where('updated_at', '>=', Carbon::parse($start_date)->format('Y-m-d 0:00:00')); + }); + } elseif(!$start_date && $end_date) { - $query->where('created_at', '<=', Carbon::parse($end_date)->format('Y-m-d 23:59:59')); + $query->whereHas('transactions', function($transaction) use ($end_date) { + $transaction->where('type', TransactionType::PAYMENT)->where('updated_at', '>=', Carbon::parse($end_date)->format('Y-m-d 0:00:00')); + }); } return $query;