update calculation function in booking controller

This commit is contained in:
Jack Goh
2018-06-15 23:21:30 +08:00
parent a449d4f30c
commit 7299685a40
2 changed files with 25 additions and 13 deletions
+23 -12
View File
@@ -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);
}
}
+2 -1
View File
@@ -295,7 +295,8 @@
return {
status: '',
booking: {
amount: ''
amount: '',
rate: ''
},
bookingForm: {
//amount: '',