Subversion Repositories SmartDukaan

Rev

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

Rev 6087 Rev 6158
Line 4... Line 4...
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
7
from shop2020.model.v1.user.impl.PromotionRuleDataUtilities import get_coupon_usage_count
8
 
8
 
9
itemTuple = (7558)
9
itemTuple = (7558, 7974)
10
def execute(cart, coupon_code, args):
10
def execute(cart, coupon_code, args):
11
        
11
        
12
    if 2 <= get_coupon_usage_count(coupon_code):
12
    if 2 <= get_coupon_usage_count(coupon_code):
13
        raise PromotionException(112, 'This promotion is over.')
13
        raise PromotionException(112, 'This promotion is over.')
14
    
14
    
Line 22... Line 22...
22
    discounts = []
22
    discounts = []
23
    for line in cart.lines:
23
    for line in cart.lines:
24
        total_selling_price += line.actualPrice * line.quantity
24
        total_selling_price += line.actualPrice * line.quantity
25
        discount_value = 0
25
        discount_value = 0
26
        
26
        
27
        if line.itemId == itemTuple:
27
        if line.itemId in itemTuple:
28
            cart_has_specified_item = True
28
            cart_has_specified_item = True
29
            line.discountedPrice = round(line.actualPrice - discount, 4)
29
            line.discountedPrice = round(line.actualPrice - discount, 4)
30
            total_discounted_price += round(line.discountedPrice * line.quantity, 4)
30
            total_discounted_price += round(line.discountedPrice * line.quantity, 4)
31
            discount_value = discount
31
            discount_value = discount
32
        else:
32
        else: