Subversion Repositories SmartDukaan

Rev

Rev 5390 | Rev 5418 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5390 Rev 5394
Line 1... Line 1...
1
'''
1
'''
2
Created on 28-May-2012
2
Created on 28-May-2012
3
 
3
 
4
@author: Varun Gupta
4
@author: Varun Gupta
5
 
5
 
-
 
6
Allows first 300 users to use the coupon
-
 
7
 
6
Galaxy Y Pro Duos B5512       Discount: Rs.502
8
Galaxy Y Pro Duos B5512       Discount: Rs.502
7
Chat 322 C3222        Discount: Rs.171
9
Chat 322 C3222        Discount: Rs.171
8
Champ Deluxe Duos C3312       Discount: Rs.211
10
Champ Deluxe Duos C3312       Discount: Rs.211
9
Champ Duos E2652       Discount: Rs.155
11
Champ Duos E2652       Discount: Rs.155
10
Champ 3.5G S3770       Discount: Rs.255
12
Champ 3.5G S3770       Discount: Rs.255
Line 39... Line 41...
39
 
41
 
40
def execute(cart, coupon_code, args):
42
def execute(cart, coupon_code, args):
41
    user_client = UserClient().get_client()
43
    user_client = UserClient().get_client()
42
    user = user_client.getUserByCartId(cart.id)
44
    user = user_client.getUserByCartId(cart.id)
43
 
45
 
44
    #Allow only first 100 users to use the coupon
46
    #Allow only first 300 users to use the coupon
45
    count_coupon_usage = get_coupon_usage_count(coupon_code)
47
    count_coupon_usage = get_coupon_usage_count(coupon_code)
46
    
48
    
47
    if count_coupon_usage >= 100:
49
    if count_coupon_usage >= 300:
48
        raise PromotionException(112, 'This promotion is over.')
50
        raise PromotionException(112, 'This promotion is over.')
49
    
51
    
50
    if get_coupon_usage_count_by_user(coupon_code, user.userId) > 0:
52
    if get_coupon_usage_count_by_user(coupon_code, user.userId) > 0:
51
        raise PromotionException(112, 'This promotion is over.')
53
        raise PromotionException(112, 'This promotion is over.')
52
    
54