Subversion Repositories SmartDukaan

Rev

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

Rev 6083 Rev 6085
Line 2... Line 2...
2
Created on 06-Jul-2011
2
Created on 06-Jul-2011
3
 
3
 
4
@author: Varun Gupta
4
@author: Varun Gupta
5
'''
5
'''
6
from shop2020.thriftpy.model.v1.user.ttypes import PromotionException, Discount
6
from shop2020.thriftpy.model.v1.user.ttypes import PromotionException, Discount
7
from shop2020.model.v1.user.impl.PromotionRuleDataUtilities import get_coupon_usage_count, get_coupon_usage_count_by_user
7
from shop2020.model.v1.user.impl.PromotionRuleDataUtilities import get_coupon_usage_count
8
from shop2020.clients.UserClient import UserClient
-
 
9
 
8
 
10
itemTuple = (7558)
9
itemTuple = (7558)
11
def execute(cart, coupon_code, args):
10
def execute(cart, coupon_code, args):
12
        
11
        
13
    if 2 <= get_coupon_usage_count(coupon_code):
12
    if 2 <= get_coupon_usage_count(coupon_code):
14
        raise PromotionException(112, 'This promotion is over.')
13
        raise PromotionException(112, 'This promotion is over.')
15
    
14
    
16
    user_client = UserClient().get_client()
-
 
17
    user = user_client.getUserByCartId(cart.id)
-
 
18
 
-
 
19
    if 2 <= get_coupon_usage_count_by_user(coupon_code, user.userId):
-
 
20
        raise PromotionException(111, 'You have already used this coupon maximum possible times.')
-
 
21
    
-
 
22
    if not cart.lines:
15
    if not cart.lines:
23
        return cart
16
        return cart
24
    
17
    
25
    total_selling_price = 0
18
    total_selling_price = 0
26
    total_discounted_price = 0
19
    total_discounted_price = 0