1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-20 14:54:15 +01:00

check cash coupons does not exceed cart amount for subscriptions

This commit is contained in:
Sylvain 2016-11-24 16:38:22 +01:00
parent ff11694e05
commit 0a08c4c32d
5 changed files with 12 additions and 6 deletions

View File

@ -177,11 +177,14 @@ Application.Controllers.controller "PlansIndexController", ["$scope", "$rootScop
updateCartPrice = ->
# first we check that a user was selected
if Object.keys($scope.ctrl.member).length > 0
$scope.cart.total = $scope.selectedPlan.amount
# apply the coupon if any
if $scope.coupon.applied
$scope.cart.total = $scope.selectedPlan.amount
# apply the coupon if any
if $scope.coupon.applied
if $scope.coupon.applied.type == 'percent_off'
discount = $scope.cart.total * $scope.coupon.applied.percent_off / 100
$scope.cart.total -= discount
else if $scope.coupon.applied.type == 'amount_off'
discount = $scope.coupon.applied.amount_off
$scope.cart.total -= discount
else
$scope.reserve.amountTotal = null

View File

@ -141,7 +141,7 @@
<div class="font-sbold">{{ 'subscription_price' | translate }} {{selectedPlan.amount | currency}}</div>
</div>
<coupon show="!ctrl.member.subscribed_plan" coupon="coupon.applied" user-id="{{ctrl.member.id}}"></coupon>
<coupon show="!ctrl.member.subscribed_plan" coupon="coupon.applied" total="selectedPlan.amount" user-id="{{ctrl.member.id}}"></coupon>
</div>
<div class="widget-footer">

View File

@ -1 +1,2 @@
json.extract! @coupon, :id, :code, :percent_off
json.extract! @coupon, :id, :code, :type, :percent_off
json.amount_off (@coupon.amount_off / 100.00) unless @coupon.amount_off.nil?

View File

@ -373,4 +373,5 @@ en:
unable_to_apply_the_coupon_because_sold_out: "Unable to apply the coupon: this code reached its quota."
unable_to_apply_the_coupon_because_already_used: "Unable to apply the coupon: you have already used this code once before."
unable_to_apply_the_coupon_because_amount_exceeded: "Unable to apply the coupon: the discount exceed the total amount of this purchase."
unable_to_apply_the_coupon_because_undefined: "Unable to apply the coupon: an unexpected error occurred, please contact the Fablab's manager."
unable_to_apply_the_coupon_because_rejected: "This code does not exists."

View File

@ -373,4 +373,5 @@ fr:
unable_to_apply_the_coupon_because_sold_out: "Impossible d'appliquer la réduction : ce code promo a atteint son quota."
unable_to_apply_the_coupon_because_already_used: "Impossible d'appliquer la réduction : vous avez déjà utilisé ce code promo par le passé."
unable_to_apply_the_coupon_because_amount_exceeded: "Impossible d'appliquer la réduction : la réduction dépasse le total de cet achat."
unable_to_apply_the_coupon_because_undefined: "Impossible d'appliquer la réduction : une erreur inattendue s'est produite, veuillez contacter le gestionnaire du Fablab."
unable_to_apply_the_coupon_because_rejected: "Ce code promo n'existe pas."