added credit limit exceed check

This commit is contained in:
Jack Goh
2018-07-03 18:12:40 +08:00
parent 2bc7542e10
commit 6c1cd5500a
2 changed files with 19 additions and 1 deletions
+13 -1
View File
@@ -22,6 +22,7 @@ class BookingController extends Controller
$user = Auth::user();
$bookings = Booking::select('id', 'created_at', 'status', 'rate', 'term', 'amount', 'bia', 'verification_status')
->where('user_id', $user->id)
->orderby('updated_at','desc')
->paginate(10);
@@ -77,7 +78,8 @@ class BookingController extends Controller
public function adminIndex(){
$user = Auth::user();
$bookings = Booking::select('id', 'created_at', 'admin_status', 'rate', 'term', 'amount', 'bia', 'verification_status')
->get();
->orderby('updated_at','desc')
->get();
// reformat to fit frontend structure
foreach ($bookings as $booking) {
@@ -524,6 +526,16 @@ class BookingController extends Controller
$term = $request->input('term');
$china_beneficiary = $request->input('china_beneficiary');
$rates = Rate::orderby('updated_at','desc')->first();
$creditLimit = SettingCredit::orderby('updated_at','desc')->first();
if (!$creditLimit){
return response()->json("Credit limit not set, please contact admin", 405);
}
if($amount > $creditLimit->rmb_credit_limit){
return response()->json(["message" => "Exceed credit limit, please contact our sales team for larger quantitiy"], 400);
}
// TODO : get marking
$marking = "123X";