From 42493625d0827f623e5f7b47bc6f6b6a24e1fc02 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 30 Aug 2025 12:22:00 +0800 Subject: [PATCH 1/2] Fix cannot approve po probem for 1 booking reported by Sin Yee --- .../CreateInvoiceTransactionProcessor.php | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php index 799032ab..afacb35f 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php @@ -22,6 +22,7 @@ use App\Classes\ValueObjects\Constants\KVPKey; use App\Models\Booking; use App\Models\SegmentConstant; use Carbon\Carbon; +use Exception; use Illuminate\Support\Facades\Log; class CreateInvoiceTransactionProcessor @@ -214,8 +215,23 @@ class CreateInvoiceTransactionProcessor $booking_currency_average_rate = $this->calculatesBookingCurrencyAverageRate->execute($booking, TransactionType::BILL); - $transaction = $booking->transactions()->payments()->where('status', ApprovalStatus::COMPLETED)->first() - ->transactions()->where('type', TransactionType::BILL)->first(); + $paymentTransaction = $booking->transactions()->payments()->where('status', ApprovalStatus::COMPLETED)->first(); + + $transaction = null; + if($paymentTransaction){ + $transaction = $paymentTransaction->transactions()->where('type', TransactionType::BILL)->first(); + } + else{ // Special handling for refund cases (When a refund is deleted via DeleteRefundTransactionLogic, a booking payment transaction is set to ApprovalStatus::APPROVED) + $temp = $booking->transactions()->payments()->where('status', ApprovalStatus::APPROVED)->first(); + // Lets check if there is a refund case + $refund = $temp->transactions()->refunds()->where('status', ApprovalStatus::APPROVED)->first(); + if($refund){ + $transaction = $temp; + } + else{ + throw new Exception("No payment found for booking '$booking->id'."); + } + } $transaction_object = new TransactionObject( $billNumber, From d23550daf54ef26fefc3a2d3d0f90916bb20639d Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Wed, 3 Sep 2025 14:43:01 +0800 Subject: [PATCH 2/2] E-Invoice - Minor update on Delivery Order PDF --- resources/views/pages/pdfs/deliver_order.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/pages/pdfs/deliver_order.blade.php b/resources/views/pages/pdfs/deliver_order.blade.php index d16a68f5..f06e4174 100644 --- a/resources/views/pages/pdfs/deliver_order.blade.php +++ b/resources/views/pages/pdfs/deliver_order.blade.php @@ -30,7 +30,7 @@ -
EDO: {{ $transaction->bill_no }}
+
EDO: {{ str_replace(['EINV-', 'INV-'], 'EDO-', $transaction->bill_no) }}
REF: {{ $transaction->booking->marking }}
Date: {{