Subversion Repositories SmartDukaan

Rev

Rev 5501 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5501 Rev 5505
Line 1... Line 1...
1
'''
1
'''
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
-
 
6
 
-
 
7
Samsung Galaxy Ace S5830i    Rs.401 off
5
Samsung Galaxy Ace S5830i    Rs.401 off
8
Samsung Galaxy Ace Duos S6802    Rs.401 off
6
Samsung Galaxy Ace Duos S6802    Rs.401 off
9
HTC One V T320e    Rs.512 off
7
HTC One V T320e    Rs.512 off
10
HTC Desire C A320e    Rs.762 off
8
HTC Desire C A320e    Rs.762 off
11
'''
9
'''
12
from shop2020.thriftpy.model.v1.user.ttypes import PromotionException
10
from shop2020.thriftpy.model.v1.user.ttypes import PromotionException
13
from shop2020.model.v1.user.impl.PromotionRuleDataUtilities import get_coupon_usage_count
-
 
14
from shop2020.thriftpy.model.v1.user.ttypes import Discount
11
from shop2020.thriftpy.model.v1.user.ttypes import Discount
15
from shop2020.clients.UserClient import UserClient
-
 
16
 
12
 
17
def execute(cart, coupon_code, args):
13
def execute(cart, coupon_code, args):
18
    user_client = UserClient().get_client()
-
 
19
    user = user_client.getUserByCartId(cart.id)
-
 
20
    
-
 
21
    #Allow only first 2000 users to use the coupon
-
 
22
    count_coupon_usage = get_coupon_usage_count(coupon_code)
-
 
23
    
-
 
24
    if count_coupon_usage >= 200:
-
 
25
        raise PromotionException(112, 'This promotion is over.')
-
 
26
    
-
 
27
    discounts = []
14
    discounts = []
28
    
15
    
29
    if cart.lines:
16
    if cart.lines:
30
        total_selling_price = 0
17
        total_selling_price = 0
31
        total_discounted_price = 0
18
        total_discounted_price = 0