mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-19 12:24:09 +00:00
update calculation function in booking controller
This commit is contained in:
@@ -118,32 +118,38 @@ class BookingController extends Controller
|
||||
|
||||
// TODO : cancel booking feature
|
||||
|
||||
|
||||
// TODO : get calculation
|
||||
|
||||
public function calculation(Request $request){
|
||||
$amount = $request->input('amount');
|
||||
$term = $request->input('term');
|
||||
$rates = Rate::all()->last();
|
||||
|
||||
// TODO : get marking
|
||||
$marking = "123X";
|
||||
|
||||
switch ($term) {
|
||||
case "x1_cash":
|
||||
$rate = $rates->x1_cash;
|
||||
$payment_method = "cash";
|
||||
break;
|
||||
case "x1_cheque":
|
||||
$rate = $rates->x1_cheque;
|
||||
$payment_method = "Cheque";
|
||||
break;
|
||||
case "x1_ba":
|
||||
$rate = $rates->x1_ba;
|
||||
$payment_method = "BA";
|
||||
break;
|
||||
case "x2_cash":
|
||||
$rate = $rates->x2_cash;
|
||||
$payment_method = "Cash";
|
||||
break;
|
||||
case "x2_cheque":
|
||||
$rate = $rates->x2_cheque;
|
||||
$payment_method = "Cheque";
|
||||
break;
|
||||
case "x2_ba":
|
||||
$rate = $rates->x2_ba;
|
||||
$payment_method = "BA";
|
||||
break;
|
||||
default:
|
||||
return response()->json([
|
||||
@@ -152,16 +158,21 @@ class BookingController extends Controller
|
||||
], 422);
|
||||
break;
|
||||
}
|
||||
return $rate;
|
||||
|
||||
// order number
|
||||
// date
|
||||
// customer marking
|
||||
// payment method
|
||||
// CNY RMB
|
||||
if ($amount >= 10000 && ($term == 'x2_cash' || $term = 'x2_cheque' || $term = 'x2_ba')) {
|
||||
$svcharge = 0;
|
||||
} else {
|
||||
$svcharge = 20.00;
|
||||
}
|
||||
|
||||
// Service charge
|
||||
// Rate
|
||||
// Total before GST
|
||||
$bankin_amount = round(($amount + $svcharge) / $rate + (0 * ($amount + $svcharge)), 2);
|
||||
|
||||
return response()->json([
|
||||
'customer_marking' => $marking,
|
||||
'payment_method' => $payment_method,
|
||||
'service_charge' => $svcharge,
|
||||
'rate' => $rate,
|
||||
'bankin_amount' => $bankin_amount
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,7 +295,8 @@
|
||||
return {
|
||||
status: '',
|
||||
booking: {
|
||||
amount: ''
|
||||
amount: '',
|
||||
rate: ''
|
||||
},
|
||||
bookingForm: {
|
||||
//amount: '',
|
||||
|
||||
Reference in New Issue
Block a user