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)