From 844697c885a994d36db701839a04137a501cbcee Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Thu, 2 Oct 2025 09:36:43 +0800 Subject: [PATCH] E-Invoice - Enhancement to allow EInvoice to be generated for cases with refund --- .../pages/pdfs/purchase_order_table.blade.php | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/resources/views/pages/pdfs/purchase_order_table.blade.php b/resources/views/pages/pdfs/purchase_order_table.blade.php index 5afe3643..58d2ed7e 100644 --- a/resources/views/pages/pdfs/purchase_order_table.blade.php +++ b/resources/views/pages/pdfs/purchase_order_table.blade.php @@ -105,6 +105,22 @@ @php $subtotalWithDiscount = bcsub($subtotal, $voucherDiscount, 5); + if (!$totalPayment) { + $serviceCharge = $transaction->service_charge; + } + else { + $serviceCharge = $booking->transactions() + ->where('type', TransactionType::PAYMENT) + ->where('status', ApprovalStatus::COMPLETED) + ->get() + ->sum(function ($transaction) { + return $transaction->service_charge; + }); + } + if ($paymentSumRefund && $displayedSubtotal === 0){ + $subtotal = bcsub($paymentSumRefund, $serviceCharge, 5); + $displayedSubtotal = bcsub($paymentSumRefund, $serviceCharge, 2); + } @endphp @@ -114,20 +130,6 @@ Service Charges - service_charge; - } - else { - $serviceCharge = $booking->transactions() - ->where('type', TransactionType::PAYMENT) - ->where('status', ApprovalStatus::COMPLETED) - ->get() - ->sum(function ($transaction) { - return $transaction->service_charge; - }); - } - ?> {{ number_format($serviceCharge, 2) }} @if($totalPayment && $refundedServiceCharge)