diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php index e4bf2c43..620915ed 100644 --- a/app/Http/Controllers/BookingController.php +++ b/app/Http/Controllers/BookingController.php @@ -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); } } diff --git a/resources/assets/js/pages/home.vue b/resources/assets/js/pages/home.vue index a5928798..e602f853 100644 --- a/resources/assets/js/pages/home.vue +++ b/resources/assets/js/pages/home.vue @@ -295,7 +295,8 @@ return { status: '', booking: { - amount: '' + amount: '', + rate: '' }, bookingForm: { //amount: '',