Subversion Repositories SmartDukaan

Rev

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

Rev 2815 Rev 2983
Line 109... Line 109...
109
        raise ShoppingCartException(101, "item_id cannot be null")
109
        raise ShoppingCartException(101, "item_id cannot be null")
110
    
110
    
111
    if not quantity:
111
    if not quantity:
112
        raise ShoppingCartException(101, "quantity cannot be null")    
112
        raise ShoppingCartException(101, "quantity cannot be null")    
113
 
113
 
114
    cart = Cart.get_by(id = cart_id)
114
    cart = Cart.get_by(id = cart_id)    
115
    if not cart:
115
    if not cart:
116
        raise ShoppingCartException(101, "no cart attached to this id")
116
        raise ShoppingCartException(101, "no cart attached to this id")
-
 
117
    retval = ""
117
    inventory_client = InventoryClient().get_client()
118
    inventory_client = InventoryClient().get_client()
118
    if not inventory_client.isActive(item_id):
119
    item = inventory_client.getItem(item_id)
-
 
120
    item_shipping_info = inventory_client.isActive(item_id)
-
 
121
    if not item_shipping_info.isActive:
119
        return inventory_client.getItemStatusDescription(item_id)
122
        return inventory_client.getItemStatusDescription(item_id)
120
    
123
    
121
    current_time = datetime.datetime.now()
124
    current_time = datetime.datetime.now()
122
    cart.updated_on = current_time
125
    cart.updated_on = current_time
123
    line = get_line(item_id, cart_id, None,True)
126
    line = get_line(item_id, cart_id, None,True)
Line 132... Line 135...
132
        line.quantity = quantity
135
        line.quantity = quantity
133
        line.created_on = current_time
136
        line.created_on = current_time
134
        line.updated_on = current_time
137
        line.updated_on = current_time
135
        line.line_status = LineStatus.LINE_ACTIVE
138
        line.line_status = LineStatus.LINE_ACTIVE
136
    session.commit()
139
    session.commit()
137
    return ""
140
    return retval
138
    #validate_cart(cart_id)
-
 
139
 
141
 
140
def delete_item_from_cart(cart_id, item_id):
142
def delete_item_from_cart(cart_id, item_id):
141
    if not item_id:
143
    if not item_id:
142
        raise ShoppingCartException(101, "item_id cannot be null")
144
        raise ShoppingCartException(101, "item_id cannot be null")
143
    cart = Cart.get_by(id = cart_id)
145
    cart = Cart.get_by(id = cart_id)
Line 336... Line 338...
336
    cart.total_price = 0
338
    cart.total_price = 0
337
    for line in cart_lines:
339
    for line in cart_lines:
338
        old_estimate = line.estimate
340
        old_estimate = line.estimate
339
        item_id = line.item_id
341
        item_id = line.item_id
340
        item = inventory_client.getItem(item_id)
342
        item = inventory_client.getItem(item_id)
341
        if inventory_client.isActive(item_id):
343
        item_shipping_info = inventory_client.isActive(item_id) 
-
 
344
        if item_shipping_info.isActive:
-
 
345
            if item_shipping_info.isRisky and item_shipping_info.quantity < line.quantity:
-
 
346
                line.quantity = 1
-
 
347
                retval = "Try adding a smaller quantity of " + item.brand + " " + item.modelNumber + " (" + item.color + ")"
-
 
348
            
342
            line.actual_price = item.sellingPrice 
349
            line.actual_price = item.sellingPrice 
343
            cart.total_price = cart.total_price + (line.actual_price * line.quantity)
350
            cart.total_price = cart.total_price + (line.actual_price * line.quantity)
344
            try:
351
            try:
345
                item_delivery_estimate = logistics_client.getLogisticsEstimation(item_id, customer_pincode).deliveryTime
352
                item_delivery_estimate = logistics_client.getLogisticsEstimation(item_id, customer_pincode).deliveryTime
346
            except LogisticsServiceException:
353
            except LogisticsServiceException: