Merge branch 'fix/billing-charge' into 'master'

fix billing charge for x2 to 0

See merge request CIEFWorldwideSdnBhd/exchange!104
This commit is contained in:
Jack Goh
2018-08-08 02:24:29 +00:00
+16 -15
View File
@@ -293,33 +293,34 @@ class BookingController extends Controller
break; 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')) { if ($amount >= 10000 && ($term == 'x2_cash' || $term == 'x2_cheque' || $term == 'x2_ba')) {
$svcharge = 0; $svcharge = 0;
} else { } else {
$svcharge = 20.00; $svcharge = 20.00;
} }
$subtotal = round(($amount + $svcharge) / $rate,2); $subtotal = round(($amount + $svcharge) / $rate, 2);
// TODO : refactor // TODO : refactor
if ($taxrate !=0){ if ($taxrate !=0){
$taxAmount = round($subtotal * $taxrate - $subtotal,2); $taxAmount = round($subtotal * $taxrate - $subtotal, 2);
} }
else{ else{
$taxAmount = 0; $taxAmount = 0;
} }
if ($billingChargeRate !=0){ if ($term == 'x2_cash' || $term == 'x2_cheque' || $term == 'x2_ba'){
$billingChargeAmount = round(($amount + $svcharge) * $billingChargeRate - ($amount + $svcharge), 2); $billingChargeAmount = 0;
} }
else{ 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); $bankin_amount = round($subtotal + $taxAmount + $billingChargeAmount , 2);
$booking = new Booking(); $booking = new Booking();
$booking->account_name = $request->input('account_name'); $booking->account_name = $request->input('account_name');
$booking->account_num = $request->input('account_num'); $booking->account_num = $request->input('account_num');
@@ -636,14 +637,14 @@ class BookingController extends Controller
$taxAmount = 0; $taxAmount = 0;
} }
if ($billingChargeRate !=0){ if ($term == 'x2_cash' || $term == 'x2_cheque' || $term == 'x2_ba'){
$billingChargeAmount = round(($amount + $svcharge) * $billingChargeRate - ($amount + $svcharge), 2);
}
else{
$billingChargeAmount = 0; $billingChargeAmount = 0;
} }
else{
$billingChargeAmount = round((($amount / $rate) * $billingChargeRate) - ($amount / $rate), 2); // 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); $bankin_amount = round($subtotal + $taxAmount + $billingChargeAmount , 2);
return response()->json([ return response()->json([