From 6c1cd5500af4959adf16bd26e524c4ee3737b696 Mon Sep 17 00:00:00 2001 From: Jack Goh Date: Tue, 3 Jul 2018 18:12:40 +0800 Subject: [PATCH 1/3] added credit limit exceed check --- app/Http/Controllers/BookingController.php | 14 +++++++++++++- resources/assets/js/pages/home.vue | 6 ++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php index 67ff2454..6048e53c 100644 --- a/app/Http/Controllers/BookingController.php +++ b/app/Http/Controllers/BookingController.php @@ -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"; diff --git a/resources/assets/js/pages/home.vue b/resources/assets/js/pages/home.vue index c7d32d54..f1a88da0 100644 --- a/resources/assets/js/pages/home.vue +++ b/resources/assets/js/pages/home.vue @@ -474,6 +474,12 @@ export default { this.dialogFormVisible1 = true }) .catch((error) => { + this.$message({ + showClose: true, + message: error.response.data.message, + type: 'error', + duration: 10000 + }); this.loading = false console.log(error) }) From 9badd33d8150ec32531b241b09b88d4e2cc10115 Mon Sep 17 00:00:00 2001 From: Jack Goh Date: Tue, 3 Jul 2018 18:23:26 +0800 Subject: [PATCH 2/3] commented out some undone feature navigation bar --- resources/assets/js/components/LocaleDropdown.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/assets/js/components/LocaleDropdown.vue b/resources/assets/js/components/LocaleDropdown.vue index 16a54033..0b866293 100644 --- a/resources/assets/js/components/LocaleDropdown.vue +++ b/resources/assets/js/components/LocaleDropdown.vue @@ -1,7 +1,7 @@