Subversion Repositories SmartDukaan

Rev

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

Rev 5500 Rev 5501
Line 2... Line 2...
2
Created on 27-June-2012
2
Created on 27-June-2012
3
@author: Varun Gupta
3
@author: Varun Gupta
4
 
4
 
5
Max Uses: 200
5
Max Uses: 200
6
 
6
 
7
A user can use the coupon only 1 times.
-
 
8
 
-
 
9
Samsung Galaxy Ace S5830i    Rs.401 off
7
Samsung Galaxy Ace S5830i    Rs.401 off
10
Samsung Galaxy Ace Duos S6802    Rs.401 off
8
Samsung Galaxy Ace Duos S6802    Rs.401 off
11
HTC One V T320e    Rs.512 off
9
HTC One V T320e    Rs.512 off
12
HTC Desire C A320e    Rs.762 off
10
HTC Desire C A320e    Rs.762 off
13
'''
11
'''
14
from shop2020.thriftpy.model.v1.user.ttypes import PromotionException
12
from shop2020.thriftpy.model.v1.user.ttypes import PromotionException
15
from shop2020.model.v1.user.impl.PromotionRuleDataUtilities import get_coupon_usage_count, get_coupon_usage_count_by_user
13
from shop2020.model.v1.user.impl.PromotionRuleDataUtilities import get_coupon_usage_count
16
from shop2020.clients.CatalogClient import CatalogClient
-
 
17
from shop2020.thriftpy.model.v1.user.ttypes import Discount
14
from shop2020.thriftpy.model.v1.user.ttypes import Discount
18
from shop2020.clients.UserClient import UserClient
15
from shop2020.clients.UserClient import UserClient
19
 
16
 
20
def execute(cart, coupon_code, args):
17
def execute(cart, coupon_code, args):
21
    user_client = UserClient().get_client()
18
    user_client = UserClient().get_client()
Line 25... Line 22...
25
    count_coupon_usage = get_coupon_usage_count(coupon_code)
22
    count_coupon_usage = get_coupon_usage_count(coupon_code)
26
    
23
    
27
    if count_coupon_usage >= 200:
24
    if count_coupon_usage >= 200:
28
        raise PromotionException(112, 'This promotion is over.')
25
        raise PromotionException(112, 'This promotion is over.')
29
    
26
    
30
    #Allow a user to use the coupon only 5 times max.
-
 
31
    count_users_usage = get_coupon_usage_count_by_user(coupon_code, user.id)
-
 
32
    
-
 
33
    if count_users_usage > 0:
-
 
34
        raise PromotionException(111, 'This promotion is over.')
-
 
35
    
-
 
36
    discounts = []
27
    discounts = []
37
    
28
    
38
    if cart.lines:
29
    if cart.lines:
39
        total_selling_price = 0
30
        total_selling_price = 0
40
        total_discounted_price = 0
31
        total_discounted_price = 0