mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
E-Invoice - Fix Sales Invoice Report (with refund) inaccurate with missing records
This commit is contained in:
@@ -59,12 +59,27 @@ class ExportsSalesInvoiceWithRefundReport implements FromQuery, WithHeadings, Wi
|
||||
Log::info('ExportsSalesInvoiceWithRefundReport startDate: ' . $startDate->format('Y-m-d H:i:s'));
|
||||
Log::info('ExportsSalesInvoiceWithRefundReport endDate: ' . $endDate->format('Y-m-d H:i:s'));
|
||||
|
||||
return Booking::whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED, ApprovalStatus::SUSPENDED])
|
||||
->whereHas('transactions', function ($query) use ($startDate, $endDate) {
|
||||
$query->payments()
|
||||
->where('status', ApprovalStatus::REFUNDED)
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->latest('created_at');
|
||||
// return Booking::whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED, ApprovalStatus::SUSPENDED])
|
||||
// ->whereHas('transactions', function ($query) use ($startDate, $endDate) {
|
||||
// $query->payments()
|
||||
// ->where('status', ApprovalStatus::REFUNDED)
|
||||
// ->whereBetween('created_at', [$startDate, $endDate])
|
||||
// ->latest('created_at');
|
||||
// });
|
||||
|
||||
return Booking::whereIn('status', [
|
||||
ApprovalStatus::APPROVED,
|
||||
ApprovalStatus::COMPLETED,
|
||||
ApprovalStatus::SUSPENDED,
|
||||
])
|
||||
->whereHas('transactions', function ($transactionQuery) use ($startDate, $endDate) {
|
||||
$transactionQuery->payments()
|
||||
->whereBetween('created_at', [$startDate, $endDate])
|
||||
->latest('created_at')
|
||||
->whereHas('transactions', function ($refundQuery) {
|
||||
$refundQuery->refunds()
|
||||
->whereIn('status', [ApprovalStatus::APPROVED]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -83,7 +98,8 @@ class ExportsSalesInvoiceWithRefundReport implements FromQuery, WithHeadings, Wi
|
||||
$company = $booking->company()->first();
|
||||
|
||||
// $lastPaymentTransaction = $booking->transactions()->payments()->complete()->latest()->first();
|
||||
$lastPaymentTransaction = $booking->transactions()->payments()->where('status', ApprovalStatus::REFUNDED)->latest()->first();
|
||||
// $lastPaymentTransaction = $booking->transactions()->payments()->where('status', ApprovalStatus::REFUNDED)->latest()->first();
|
||||
$lastPaymentTransaction = $booking->transactions()->payments()->whereIn('status', [ApprovalStatus::COMPLETED, ApprovalStatus::REFUNDED])->latest()->first();
|
||||
if(!$lastPaymentTransaction){
|
||||
return $records;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user