Subversion Repositories SmartDukaan

Rev

Rev 6682 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6682 Rev 6903
Line 37... Line 37...
37
    
37
    
38
    
38
    
39
    discounts = []
39
    discounts = []
40
    
40
    
41
    if cart.lines:
41
    if cart.lines:
42
        total_selling_price = 0
-
 
43
        productFound = False
42
        productFound = False
44
        for line in cart.lines:
43
        for line in cart.lines:
45
            line_total_price = line.actualPrice * line.quantity
-
 
46
            if (not productFound and line.actualPrice >= minPrice):
44
            if (not productFound and line.actualPrice >= minPrice):
47
                discount = Discount()
45
                discount = Discount()
48
                discount.cart_id = cart.id
46
                discount.cart_id = cart.id
49
                discount.item_id = line.itemId
47
                discount.item_id = line.itemId
50
                discount.quantity = 1
48
                discount.quantity = 1
51
                discount.discount = discount_value
49
                discount.discount = discount_value
52
                discounts.append(discount)
50
                discounts.append(discount)
53
                productFound = True
51
                productFound = True
54
            total_selling_price += line_total_price
-
 
55
            
52
            
56
            
53
            
57
        if productFound:
54
        if productFound:
58
            cart.totalPrice = total_selling_price
-
 
59
            cart.discountedPrice = total_selling_price - discount_value
55
            cart.discountedPrice = cart.totalPrice - discount_value
60
        else:
56
        else:
61
            raise PromotionException(114, 'Your cart should have at least one item with selling price above Rs.' + str(minPrice)+ '.')
57
            raise PromotionException(114, 'Your cart should have at least one item with selling price above Rs.' + str(minPrice)+ '.')
62
            
58
            
63
            
59
            
64
    return cart, discounts
60
    return cart, discounts