Subversion Repositories SmartDukaan

Rev

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

Rev 3554 Rev 3557
Line 102... Line 102...
102
    if not status:
102
    if not status:
103
        raise ShoppingCartException(101, "invalid status")
103
        raise ShoppingCartException(101, "invalid status")
104
    cart.cart_status = status
104
    cart.cart_status = status
105
    session.commit()
105
    session.commit()
106
    
106
    
107
def add_item_to_cart(cart_id, item_id, quantity):
107
def add_item_to_cart(cart_id, item_id, quantity, sourceId):
108
    if not item_id:
108
    if not item_id:
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")    
Line 114... Line 114...
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
    retval = ""
118
    inventory_client = CatalogClient().get_client()
118
    inventory_client = CatalogClient().get_client()
119
    item = inventory_client.getItem(item_id)
119
    item = inventory_client.getItemForSource(item_id, sourceId)
120
    item_shipping_info = inventory_client.isActive(item_id)
120
    item_shipping_info = inventory_client.isActive(item_id)
121
    if not item_shipping_info.isActive:
121
    if not item_shipping_info.isActive:
122
        return inventory_client.getItemStatusDescription(item_id)
122
        return inventory_client.getItemStatusDescription(item_id)
123
    
123
    
124
    current_time = datetime.datetime.now()
124
    current_time = datetime.datetime.now()
Line 133... Line 133...
133
        line.cart = cart
133
        line.cart = cart
134
        line.item_id = item_id
134
        line.item_id = item_id
135
        line.quantity = quantity
135
        line.quantity = quantity
136
        line.created_on = current_time
136
        line.created_on = current_time
137
        line.updated_on = current_time
137
        line.updated_on = current_time
-
 
138
        line.actual_price = item.sellingPrice
138
        line.line_status = LineStatus.LINE_ACTIVE
139
        line.line_status = LineStatus.LINE_ACTIVE
139
    session.commit()
140
    session.commit()
140
    return retval
141
    return retval
141
 
142
 
142
def delete_item_from_cart(cart_id, item_id):
143
def delete_item_from_cart(cart_id, item_id):
Line 338... Line 339...
338
    
339
    
339
    t_line_item.unit_weight = item.weight
340
    t_line_item.unit_weight = item.weight
340
    t_line_item.total_weight = item.weight
341
    t_line_item.total_weight = item.weight
341
    return t_line_item
342
    return t_line_item
342
    
343
    
343
def validate_cart(cartId):
344
def validate_cart(cartId, sourceId):
344
    inventory_client = CatalogClient().get_client()
345
    inventory_client = CatalogClient().get_client()
345
    logistics_client = LogisticsClient().get_client()
346
    logistics_client = LogisticsClient().get_client()
346
    promotion_client = PromotionClient().get_client()
347
    promotion_client = PromotionClient().get_client()
347
    retval = ""
348
    retval = ""
348
    # No need to validate duplicate items since there are only two ways
349
    # No need to validate duplicate items since there are only two ways
Line 366... Line 367...
366
        customer_pincode = "110001"
367
        customer_pincode = "110001"
367
    cart.total_price = 0
368
    cart.total_price = 0
368
    for line in cart_lines:
369
    for line in cart_lines:
369
        old_estimate = line.estimate
370
        old_estimate = line.estimate
370
        item_id = line.item_id
371
        item_id = line.item_id
371
        item = inventory_client.getItem(item_id)
372
        item = inventory_client.getItemForSource(item_id, sourceId)
372
        item_shipping_info = inventory_client.isActive(item_id) 
373
        item_shipping_info = inventory_client.isActive(item_id) 
373
        if item_shipping_info.isActive:
374
        if item_shipping_info.isActive:
374
            if item_shipping_info.isRisky and item_shipping_info.quantity < line.quantity:
375
            if item_shipping_info.isRisky and item_shipping_info.quantity < line.quantity:
375
                line.quantity = 1
376
                line.quantity = 1
376
                retval = "Try adding a smaller quantity of " + item.brand + " " + item.modelNumber + " (" + item.color + ")"
377
                retval = "Try adding a smaller quantity of " + item.brand + " " + item.modelNumber + " (" + item.color + ")"