From 4bd14fec7369c14583c4f0e03f1b041448158f4b Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Tue, 2 Dec 2025 16:59:02 +0800 Subject: [PATCH] E-Invoice - Fix booking with full refund has no Ref at Sales Report API that generates record with no autocount data --- .../CreateInvoiceTransactionV2Processor.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionV2Processor.php b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionV2Processor.php index 1450cef6..d4e6ee8e 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionV2Processor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionV2Processor.php @@ -127,18 +127,16 @@ class CreateInvoiceTransactionV2Processor return; } - if($generateEInvoiceRefund){ + $purchaseOrder = $booking->transactions() + ->where('type', TransactionType::PURCHASE_ORDER) + ->complete() + ->first(); + if(!$purchaseOrder && $generateEInvoiceRefund){ $purchaseOrder = $booking->transactions() ->where('type', TransactionType::PURCHASE_ORDER) ->where('status', ApprovalStatus::PENDING_SUBMISSION) ->first(); } - else{ - $purchaseOrder = $booking->transactions() - ->where('type', TransactionType::PURCHASE_ORDER) - ->complete() - ->first(); - } $constants = SegmentConstant::where('reference', SegmentConstants::SERVICE_TYPE)->where('detail->id', $booking->service->id)->first();