From a06f57712d308721109283fcb9ab6298bb52f33c Mon Sep 17 00:00:00 2001 From: Jack Goh Date: Thu, 26 Jul 2018 12:26:34 +0800 Subject: [PATCH] fix user booking calculation --- app/Http/Controllers/BookingController.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php index fe14b372..72ae5813 100644 --- a/app/Http/Controllers/BookingController.php +++ b/app/Http/Controllers/BookingController.php @@ -595,9 +595,24 @@ class BookingController extends Controller $svcharge = 20.00; } - $subtotal = round($amount + $svcharge / $rate,2); - $taxAmount = round($subtotal * $taxrate,2); - $billingChargeAmount = round(($amount + $svcharge) * $billingChargeRate, 2); + $subtotal = round(($amount + $svcharge) / $rate,2); + + // TODO : refactor + if ($taxrate !=0){ + $taxAmount = round($subtotal * $taxrate - $subtotal,2); + } + else{ + $taxAmount = 0; + } + + if ($billingChargeRate !=0){ + $billingChargeAmount = round(($amount + $svcharge) * $billingChargeRate - ($amount + $svcharge), 2); + } + else{ + $billingChargeAmount = 0; + } + + $billingChargeAmount = round((($amount / $rate) * $billingChargeRate) - ($amount / $rate), 2); $bankin_amount = round($subtotal + $taxAmount + $billingChargeAmount , 2); return response()->json([