diff --git a/app/assets/javascripts/controllers/trainings.coffee.erb b/app/assets/javascripts/controllers/trainings.coffee.erb index f503e7472..f9785ed6a 100644 --- a/app/assets/javascripts/controllers/trainings.coffee.erb +++ b/app/assets/javascripts/controllers/trainings.coffee.erb @@ -426,7 +426,6 @@ Application.Controllers.controller "ReserveTrainingController", ["$scope", "$sta if $scope.ctrl.member # reserve a training if this training will not be reserved and is not about to move and not is completed if !event.is_reserved && !$scope.slotToModify && !event.is_completed - $scope.coupon.applied = null if event != $scope.selectedTraining $scope.selectedTraining = event $scope.selectedTraining.offered = false @@ -647,7 +646,7 @@ Application.Controllers.controller "ReserveTrainingController", ["$scope", "$sta # first we check that a user was selected if Object.keys($scope.ctrl.member).length > 0 r = mkReservation($scope.ctrl.member, training) # reservation without any Plan -> we get the training price - Price.compute mkRequestParams(r, $scope.coupon.applied), (res) -> + Price.compute mkRequestParams(r), (res) -> $scope.selectedTrainingAmount = res.price else $scope.selectedTrainingAmount = null diff --git a/app/assets/javascripts/directives/coupon.coffee.erb b/app/assets/javascripts/directives/coupon.coffee.erb index 2d1aa5812..531116100 100644 --- a/app/assets/javascripts/directives/coupon.coffee.erb +++ b/app/assets/javascripts/directives/coupon.coffee.erb @@ -5,7 +5,6 @@ Application.Directives.directive 'coupon', [ 'Coupon', 'growl', '_t', (Coupon, g show: '=' coupon: '=' userId: '@' - hasSelectSlot: '=' templateUrl: '<%= asset_path "shared/_coupon.html" %>' link: ($scope, element, attributes) -> @@ -19,11 +18,6 @@ Application.Directives.directive 'coupon', [ 'Coupon', 'growl', '_t', (Coupon, g # Binding for the code inputed $scope.couponCode = null - $scope.$watch 'hasSelectSlot', (newValue) -> - unless newValue - $scope.coupon = null - $scope.couponCode = null - $scope.code.input = false ## diff --git a/app/assets/templates/machines/reserve.html.erb b/app/assets/templates/machines/reserve.html.erb index 246df7ba5..f80ffb700 100644 --- a/app/assets/templates/machines/reserve.html.erb +++ b/app/assets/templates/machines/reserve.html.erb @@ -78,7 +78,7 @@
{{ 'remove_this_slot' }}
- +
diff --git a/app/assets/templates/trainings/reserve.html.erb b/app/assets/templates/trainings/reserve.html.erb index 34adf87e6..5f03078f4 100644 --- a/app/assets/templates/trainings/reserve.html.erb +++ b/app/assets/templates/trainings/reserve.html.erb @@ -82,7 +82,7 @@ {{ 'remove_this_slot' }}
- +
diff --git a/app/services/coupon_apply_service.rb b/app/services/coupon_apply_service.rb index 3df2c56c4..f1f573abb 100644 --- a/app/services/coupon_apply_service.rb +++ b/app/services/coupon_apply_service.rb @@ -1,11 +1,11 @@ class CouponApplyService - def call(total, coupon_code) + def call(total, coupon_code, user_id = nil) price = total # if no coupon code or if code does not match, return origin price without change unless coupon_code.nil? _coupon = Coupon.find_by(code: coupon_code) - if _coupon + if not _coupon.nil? and _coupon.status(user_id) == 'active' if _coupon.type == 'percent_off' price = price - (price * _coupon.percent_off / 100.0) elsif _coupon.type == 'amount_off'