Subversion Repositories SmartDukaan

Rev

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

Rev 4319 Rev 4320
Line 356... Line 356...
356
        except:
356
        except:
357
            raise InventoryServiceException(108, "Some unforeseen error while updating inventory")
357
            raise InventoryServiceException(108, "Some unforeseen error while updating inventory")
358
        session.commit() 
358
        session.commit() 
359
        check_risky_item(item)
359
        check_risky_item(item)
360
 
360
 
-
 
361
def add_inventory(itemId, warehouseId, quantity):
-
 
362
    current_inventory_snapshot = CurrentInventorySnapshot.get_by(item_id=itemId, warehouse_id=warehouseId)
-
 
363
    if not current_inventory_snapshot:
-
 
364
        current_inventory_snapshot = CurrentInventorySnapshot()
-
 
365
        current_inventory_snapshot.item_id = itemId
-
 
366
        current_inventory_snapshot.warehouse_id = warehouseId
-
 
367
        current_inventory_snapshot.availibility = 0
-
 
368
        current_inventory_snapshot.reserved = 0
-
 
369
    # added the difference in the current inventory    
-
 
370
    current_inventory_snapshot.availibility = current_inventory_snapshot.availibility + quantity
-
 
371
    session.commit() 
-
 
372
    
361
def get_item_inventoy(item_id):
373
def get_item_inventoy(item_id):
362
    
374
    
363
    inventory = Item.get_by(id=item_id).currentInventory
375
    inventory = Item.get_by(id=item_id).currentInventory
364
    if not inventory:
376
    if not inventory:
365
        raise InventoryServiceException(108, "Some unforeseen error while updating inventory")
377
        raise InventoryServiceException(108, "Some unforeseen error while updating inventory")