mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-21 13:24:27 +00:00
Merge branch 'master' of gitlab.com:CIEFWorldwideSdnBhd/exchange into fix/booking-integration
# Conflicts: # app/Http/Controllers/BookingController.php
This commit is contained in:
@@ -17,7 +17,7 @@ class BookingController extends Controller
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$rates = Rate::all()->last();
|
||||
$rates = Rate::orderby('updated_at','desc')->first();
|
||||
$term = $request->input('term');
|
||||
$rate = 1; // default
|
||||
switch ($term) {
|
||||
@@ -129,7 +129,7 @@ class BookingController extends Controller
|
||||
public function uploadbankslip(Request $request, $id)
|
||||
{
|
||||
$booking = Booking::where('user_id',Auth::user()->id)->where('id',$id)->first();
|
||||
|
||||
|
||||
/* Validation*/
|
||||
if (!$booking)
|
||||
{
|
||||
@@ -175,7 +175,7 @@ class BookingController extends Controller
|
||||
|
||||
public function uploadPurchaseOrder(Request $request, $id)
|
||||
{
|
||||
$booking = Booking::where('user_id',Auth::user()->id)->where('id',$id)->first();
|
||||
$booking = Booking::where('user_id',Auth::user()->id)->where('id',$id)->first();
|
||||
|
||||
/* Validation */
|
||||
if (!$booking)
|
||||
@@ -198,13 +198,12 @@ class BookingController extends Controller
|
||||
}
|
||||
/* End Validation */
|
||||
|
||||
|
||||
$filename = $user_input_file->getClientOriginalName();
|
||||
$ext = $user_input_file->getClientOriginalExtension();
|
||||
|
||||
$input['image_url'] = $filename;
|
||||
$unique_name = 'purchase_order_' . md5($filename. time());
|
||||
$unique_image_url = $unique_name. '.' .$ext;
|
||||
$unique_image_url = $unique_name. '.' .$ext;
|
||||
Storage::putFileAs(
|
||||
'image_url',/*folder name*/ $user_input_file, $unique_image_url
|
||||
);
|
||||
@@ -217,74 +216,86 @@ class BookingController extends Controller
|
||||
|
||||
return response()->json(['message'=>'Success'],200);
|
||||
}
|
||||
|
||||
public function delete(Booking $book_id)
|
||||
{
|
||||
$booking = Booking::where('user_id', Auth::user())->where('id', $book_id)->firstOrFail();
|
||||
$booking->delete($book_id);
|
||||
return response()->json($book_id, 204);
|
||||
}
|
||||
|
||||
// TODO : cancel booking feature
|
||||
|
||||
public function cancel(Request $request, $book_id)
|
||||
{
|
||||
if (!$booking = Booking::where('user_id',Auth::user()->id)->where('id',$book_id)->first())
|
||||
{
|
||||
return response()->json(['message'=>'Access denied'], 200);
|
||||
}
|
||||
|
||||
$booking->is_cancel = true;
|
||||
$booking->save();
|
||||
|
||||
return response()->json(['message'=>'Success'],200);
|
||||
}
|
||||
|
||||
public function calculation(Request $request){
|
||||
$amount = $request->input('amount');
|
||||
$term = $request->input('term');
|
||||
$china_beneficiary = $request->input('china_beneficiary');
|
||||
$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([
|
||||
'success' => false,
|
||||
'message' => 'Invalid input',
|
||||
], 422);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($amount >= 10000 && ($term == 'x2_cash' || $term = 'x2_cheque' || $term = 'x2_ba')) {
|
||||
$svcharge = 0;
|
||||
} else {
|
||||
$svcharge = 20.00;
|
||||
}
|
||||
|
||||
$bankin_amount = round(($amount + $svcharge) / $rate + (0 * ($amount + $svcharge)), 2);
|
||||
|
||||
return response()->json([
|
||||
'date' => date('Y-m-d'),
|
||||
'marking' => $marking,
|
||||
'amount' => $amount,
|
||||
'payment_method' => $payment_method,
|
||||
'service_charge' => $svcharge,
|
||||
'rate' => $rate,
|
||||
'bankin_amount' => $bankin_amount,
|
||||
'china_beneficary' => $china_beneficiary
|
||||
], 200);
|
||||
}
|
||||
$amount = $request->input('amount');
|
||||
$term = $request->input('term');
|
||||
$china_beneficiary = $request->input('china_beneficiary');
|
||||
$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([
|
||||
'success' => false,
|
||||
'message' => 'Invalid input',
|
||||
], 422);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($amount >= 10000 && ($term == 'x2_cash' || $term = 'x2_cheque' || $term = 'x2_ba')) {
|
||||
$svcharge = 0;
|
||||
} else {
|
||||
$svcharge = 20.00;
|
||||
}
|
||||
|
||||
$bankin_amount = round(($amount + $svcharge) / $rate + (0 * ($amount + $svcharge)), 2);
|
||||
|
||||
return response()->json([
|
||||
'date' => date('Y-m-d'),
|
||||
'marking' => $marking,
|
||||
'amount' => $amount,
|
||||
'payment_method' => $payment_method,
|
||||
'service_charge' => $svcharge,
|
||||
'rate' => $rate,
|
||||
'bankin_amount' => $bankin_amount,
|
||||
'china_beneficary' => $china_beneficiary
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user