Subversion Repositories SmartDukaan

Rev

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

Rev 19419 Rev 19989
Line 230... Line 230...
230
            print "Not able to send email. No issues, we can continue with updates."
230
            print "Not able to send email. No issues, we can continue with updates."
231
    else:
231
    else:
232
        missedInventoryUpdate.quantity += quantity
232
        missedInventoryUpdate.quantity += quantity
233
        session.commit()
233
        session.commit()
234
 
234
 
235
def add_inventory(itemId, warehouseId, quantity):
235
def add_inventory(itemId, warehouseId, quantity, skipAddition=False):
236
    current_inventory_snapshot = CurrentInventorySnapshot.get_by(item_id=itemId, warehouse_id=warehouseId)
236
    current_inventory_snapshot = CurrentInventorySnapshot.get_by(item_id=itemId, warehouse_id=warehouseId)
237
    if not current_inventory_snapshot:
237
    if not current_inventory_snapshot:
238
        current_inventory_snapshot = CurrentInventorySnapshot()
238
        current_inventory_snapshot = CurrentInventorySnapshot()
239
        current_inventory_snapshot.item_id = itemId
239
        current_inventory_snapshot.item_id = itemId
240
        current_inventory_snapshot.warehouse_id = warehouseId
240
        current_inventory_snapshot.warehouse_id = warehouseId
241
        current_inventory_snapshot.availability = 0
241
        current_inventory_snapshot.availability = 0
242
        current_inventory_snapshot.reserved = 0
242
        current_inventory_snapshot.reserved = 0
243
        current_inventory_snapshot.held = 0
243
        current_inventory_snapshot.held = 0
244
    # added the difference in the current inventory    
244
    # added the difference in the current inventory
-
 
245
    if skipAddition is None or not skipAddition:    
245
    current_inventory_snapshot.availability = current_inventory_snapshot.availability + quantity
246
        current_inventory_snapshot.availability = current_inventory_snapshot.availability + quantity
-
 
247
    else:
-
 
248
        current_inventory_snapshot.availability = quantity
246
    session.commit()
249
    session.commit()
247
    #**Update item availability cache**#
250
    #**Update item availability cache**#
248
    clear_item_availability_cache([itemId])
251
    clear_item_availability_cache([itemId])
249
    if current_inventory_snapshot.availability < 0:
252
    if current_inventory_snapshot.availability < 0:
250
        item = __get_item_from_master(itemId)
253
        item = __get_item_from_master(itemId)
Line 350... Line 353...
350
            break
353
            break
351
    if availability < 0:
354
    if availability < 0:
352
        return False
355
        return False
353
    return True
356
    return True
354
    
357
    
355
def reserve_item_in_warehouse(item_id, warehouse_id, source_id, order_id, created_timestamp, promised_shipping_timestamp, quantity):    
358
def reserve_item_in_warehouse(item_id, warehouse_id, source_id, order_id, created_timestamp, promised_shipping_timestamp, quantity):
-
 
359
        
356
    if not warehouse_id:
360
    if not warehouse_id:
357
        raise InventoryServiceException(101, "bad warehouse_id")
361
        raise InventoryServiceException(101, "bad warehouse_id")
358
        
362
        
359
    query = CurrentInventorySnapshot.query.filter_by(warehouse_id = warehouse_id, item_id = item_id)
363
    query = CurrentInventorySnapshot.query.filter_by(warehouse_id = warehouse_id, item_id = item_id)
360
    try:
364
    try:
Line 1680... Line 1684...
1680
            exceptionItems.append(vendorItemPricing.itemId)
1684
            exceptionItems.append(vendorItemPricing.itemId)
1681
    return exceptionItems
1685
    return exceptionItems
1682
 
1686
 
1683
def add_inventory_in_bulk(bulkInventoryList):
1687
def add_inventory_in_bulk(bulkInventoryList):
1684
    for item in bulkInventoryList:
1688
    for item in bulkInventoryList:
1685
        add_inventory(item.item_id, item.warehouse_id, item.inventory)
1689
        add_inventory(item.item_id, item.warehouse_id, item.inventory, True)
1686
    
1690
    
1687
        
1691
        
1688
    
1692
    
1689
1693