Subversion Repositories SmartDukaan

Rev

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

Rev 6002 Rev 6009
Line 28... Line 28...
28
    discounts = []
28
    discounts = []
29
    
29
    
30
    if cart.lines:
30
    if cart.lines:
31
        total_selling_price = 0
31
        total_selling_price = 0
32
        total_discounted_price = 0
32
        total_discounted_price = 0
33
        has_used_coupon = False
-
 
34
        
33
        
35
        for line in cart.lines:
34
        for line in cart.lines:
36
            line.discountedPrice = line.actualPrice
35
            line_total_price = line.actualPrice * line.quantity
37
            
-
 
38
            if has_used_coupon:
36
            line_total_discount = 0
39
                break
37
            while line_total_discount < line_total_price and discount_value > 0:
40
            
-
 
41
            line.discountedPrice = line.actualPrice - discount_value
38
                if line.actualPrice < discount_value:
42
            
39
                    discountGiven = line.actualPrice
43
            has_used_coupon = True
40
                    quantity = min(line.quantity,int(discount_value/discountGiven))
44
            
41
                else:
45
            total_selling_price += line.actualPrice * line.quantity
42
                    discountGiven = discount_value
46
            total_discounted_price += line.discountedPrice * line.quantity
43
                    quantity = 1
47
            
44
                    
48
            if discount_value > 0:
45
                
49
                discount = Discount()
46
                discount = Discount()
50
                discount.cart_id = cart.id
47
                discount.cart_id = cart.id
51
                discount.item_id = line.itemId
48
                discount.item_id = line.itemId
52
                discount.discount = discount_value
49
                discount.discount = discountGiven
53
                discount.quantity = 1
50
                discount.quantity = quantity
54
 
-
 
55
                discounts.append(discount)
51
                discounts.append(discount)
-
 
52
 
-
 
53
                discount_value = discount_value - discountGiven*quantity 
-
 
54
                line_total_discount += discountGiven*quantity
-
 
55
            
-
 
56
            total_selling_price += line_total_price
-
 
57
            total_discounted_price += line_total_price - line_total_discount
-
 
58
            
56
            
59
            
57
            cart.totalPrice = total_selling_price
60
        cart.totalPrice = total_selling_price
58
            cart.discountedPrice = total_discounted_price
61
        cart.discountedPrice = total_discounted_price
59
    
62
    
60
    return cart, discounts
63
    return cart, discounts
61
 
64
 
62
def getDiscountOnItem(item):
65
def getDiscountOnItem(item):
63
    return None
66
    return None
64
67