Subversion Repositories SmartDukaan

Rev

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

Rev 6682 Rev 6903
Line 36... Line 36...
36
        raise PromotionException(112, 'Your usage limit for this coupon is exhausted.')
36
        raise PromotionException(112, 'Your usage limit for this coupon is exhausted.')
37
    
37
    
38
    discounts = []
38
    discounts = []
39
    
39
    
40
    if cart.lines:
40
    if cart.lines:
41
        total_selling_price = 0
-
 
42
        total_discounted_price = 0
41
        total_discounts = 0
43
        
42
        
44
        for line in cart.lines:
43
        for line in cart.lines:
45
            line_total_price = line.actualPrice * line.quantity
44
            line_total_price = line.actualPrice * line.quantity + line.insuranceAmount
46
            line_total_discount = 0
45
            line_total_discount = 0
47
            while line_total_discount < line_total_price and discount_value > 0:
46
            while line_total_discount < line_total_price and discount_value > 0:
48
                if line.actualPrice < discount_value:
47
                if line.actualPrice < discount_value:
49
                    discountGiven = line.actualPrice
48
                    discountGiven = line.actualPrice
50
                    quantity = min(line.quantity,int(discount_value/discountGiven))
49
                    quantity = min(line.quantity,int(discount_value/discountGiven))
51
                else:
50
                else:
52
                    discountGiven = discount_value
51
                    discountGiven = discount_value
53
                    quantity = 1
52
                    quantity = 1
54
                    
-
 
55
                
53
                
56
                discount = Discount()
54
                discount = Discount()
57
                discount.cart_id = cart.id
55
                discount.cart_id = cart.id
58
                discount.item_id = line.itemId
56
                discount.item_id = line.itemId
59
                discount.discount = discountGiven
57
                discount.discount = discountGiven
Line 61... Line 59...
61
                discounts.append(discount)
59
                discounts.append(discount)
62
 
60
 
63
                discount_value = discount_value - discountGiven*quantity 
61
                discount_value = discount_value - discountGiven*quantity 
64
                line_total_discount += discountGiven*quantity
62
                line_total_discount += discountGiven*quantity
65
            
63
            
66
            total_selling_price += line_total_price
64
            total_discounts += line_total_discount
67
            total_discounted_price += line_total_price - line_total_discount
-
 
68
            
65
            
69
            
-
 
70
        cart.totalPrice = total_selling_price
-
 
71
        cart.discountedPrice = total_discounted_price
66
        cart.discountedPrice = cart.totalPrice - total_discounts
72
    
67
    
73
    return cart, discounts
68
    return cart, discounts
74
 
69
 
75
def getDiscountOnItem(item):
70
def getDiscountOnItem(item):
76
    return None
71
    return None
77
72