Subversion Repositories SmartDukaan

Rev

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

Rev 2007 Rev 2010
Line 62... Line 62...
62
        raise PromotionException(111, 'You have already used this Coupon.')
62
        raise PromotionException(111, 'You have already used this Coupon.')
63
    
63
    
64
    #Allow only first 100 users to use the coupon
64
    #Allow only first 100 users to use the coupon
65
    count_coupon_usage = get_coupon_usage_count(coupon_code)
65
    count_coupon_usage = get_coupon_usage_count(coupon_code)
66
    if count_coupon_usage >= 100:
66
    if count_coupon_usage >= 100:
67
        raise PromotionException(112, 'This Coupon is now exhausted.')
67
        raise PromotionException(112, 'This promotion is over.')
68
    
68
    
69
    if cart.lines:
69
    if cart.lines:
70
        total_selling_price = 0
70
        total_selling_price = 0
71
        
71
        
72
        for line in cart.lines:
72
        for line in cart.lines:
Line 79... Line 79...
79
        elif total_selling_price >= 5000:
79
        elif total_selling_price >= 5000:
80
            discount_perc = 0.05
80
            discount_perc = 0.05
81
        else:
81
        else:
82
            discount_perc = 0.03
82
            discount_perc = 0.03
83
        
83
        
84
        cart.totalPrice = total_selling_price
84
        cart.totalPrice = round(total_selling_price, 2)
85
        cart.discountedPrice = (1 - discount_perc) * total_selling_price
85
        cart.discountedPrice = round((1 - discount_perc) * total_selling_price, 2)
86
 
86
 
87
        for line in cart.lines:
87
        for line in cart.lines:
88
            if line.actualPrice:
88
            if line.actualPrice:
89
                line.discountedPrice = (1 - discount_perc) * line.actualPrice
89
                line.discountedPrice = round((1 - discount_perc) * line.actualPrice, 2)
90
                print "The final price, after discount is " + str(cart.discountedPrice)
90
                print "The final price, after discount is " + str(cart.discountedPrice)
91
    return cart
91
    return cart
92
 
92
 
93
def track_coupon_usage(coupon_code, transaction_id, user_id):
93
def track_coupon_usage(coupon_code, transaction_id, user_id):
94
    promotion_tracker = PromotionTracker()
94
    promotion_tracker = PromotionTracker()