From f5809e8c8b9545f3183da4b3cd024440ae5cb5d1 Mon Sep 17 00:00:00 2001 From: Jack Goh Date: Wed, 8 Aug 2018 10:19:21 +0800 Subject: [PATCH] fix billing charge for x2 to 0 --- app/Http/Controllers/BookingController.php | 31 +++++++++++----------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php index 54f60487..7d8c6bf2 100644 --- a/app/Http/Controllers/BookingController.php +++ b/app/Http/Controllers/BookingController.php @@ -293,33 +293,34 @@ class BookingController extends Controller break; } - // Service charge (RMB) : if amount higher than 10,000, no service charge. if amount lower than 10,000, 20.00 service charge + // Service charge (RMB) : if amount higher than 10,000 or term x2 no service charge. if ($amount >= 10000 && ($term == 'x2_cash' || $term == 'x2_cheque' || $term == 'x2_ba')) { $svcharge = 0; } else { $svcharge = 20.00; } - $subtotal = round(($amount + $svcharge) / $rate,2); + $subtotal = round(($amount + $svcharge) / $rate, 2); // TODO : refactor if ($taxrate !=0){ - $taxAmount = round($subtotal * $taxrate - $subtotal,2); + $taxAmount = round($subtotal * $taxrate - $subtotal, 2); } else{ $taxAmount = 0; } - if ($billingChargeRate !=0){ - $billingChargeAmount = round(($amount + $svcharge) * $billingChargeRate - ($amount + $svcharge), 2); + if ($term == 'x2_cash' || $term == 'x2_cheque' || $term == 'x2_ba'){ + $billingChargeAmount = 0; } else{ - $billingChargeAmount = 0; + // TODO : billing charge rate to percentage so we do not need to minus amount + svcharge + $billingChargeAmount = round((($amount / $rate) * $billingChargeRate) - ($amount / $rate), 2); } - $billingChargeAmount = round((($amount / $rate) * $billingChargeRate) - ($amount / $rate), 2); + + $bankin_amount = round($subtotal + $taxAmount + $billingChargeAmount , 2); - $booking = new Booking(); $booking->account_name = $request->input('account_name'); $booking->account_num = $request->input('account_num'); @@ -636,14 +637,14 @@ class BookingController extends Controller $taxAmount = 0; } - if ($billingChargeRate !=0){ - $billingChargeAmount = round(($amount + $svcharge) * $billingChargeRate - ($amount + $svcharge), 2); - } - else{ + if ($term == 'x2_cash' || $term == 'x2_cheque' || $term == 'x2_ba'){ $billingChargeAmount = 0; - } - - $billingChargeAmount = round((($amount / $rate) * $billingChargeRate) - ($amount / $rate), 2); + } + else{ + // TODO : billing charge rate to percentage so we do not need to minus amount + svcharge + $billingChargeAmount = round((($amount / $rate) * $billingChargeRate) - ($amount / $rate), 2); + } + $bankin_amount = round($subtotal + $taxAmount + $billingChargeAmount , 2); return response()->json([