From 46ae50b569a7d5f5b25461fa3a94adf0ba2bd153 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Mon, 10 Jul 2023 21:59:08 +0800 Subject: [PATCH] fix invoice decimals bug --- resources/views/pages/pdfs/invoice.blade.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/resources/views/pages/pdfs/invoice.blade.php b/resources/views/pages/pdfs/invoice.blade.php index 92e42b83..d6b2383d 100644 --- a/resources/views/pages/pdfs/invoice.blade.php +++ b/resources/views/pages/pdfs/invoice.blade.php @@ -174,15 +174,21 @@ Total + @php + $service_charge = (float)number_format($transaction->service_charge, 2,'.',''); + $tax = (float)number_format($transaction->tax, 2,'.',''); + $rounded_voucher = (float)number_format($voucher_discount, 2,'.',''); + @endphp @if($transaction->booking()->first()->fix_currency_id !== 1) @php - $service_charge = (float)number_format($transaction->service_charge, 2,'.',''); - $tax = (float)number_format($transaction->tax, 2,'.',''); - $rounded_voucher = (float)number_format($voucher_discount, 2,'.',''); + $rounded_subtotal = (float)number_format($subtotal, 2,'.',''); @endphp - {{ number_format($subtotal + $service_charge + $tax + $rounded_voucher, 2) }} + {{ number_format($rounded_subtotal + $service_charge + $tax + $rounded_voucher, 2) }} @else - {{ number_format($transaction->amount + $transaction->service_charge + $transaction->tax + $voucher_discount, 2) }} + @php + $rounded_transaction_amount = (float)number_format($transaction->amount, 2,'.',''); + @endphp + {{ number_format($rounded_transaction_amount + $service_charge + $tax + $rounded_voucher, 2) }} @endif