Subversion Repositories SmartDukaan

Rev

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

Rev 4064 Rev 4103
Line 508... Line 508...
508
        raise InventoryServiceException(101, "bad item_id")
508
        raise InventoryServiceException(101, "bad item_id")
509
        
509
        
510
    query = CurrentInventorySnapshot.query.filter_by(warehouse_id = warehouse_id, item_id = item_id)
510
    query = CurrentInventorySnapshot.query.filter_by(warehouse_id = warehouse_id, item_id = item_id)
511
    try:
511
    try:
512
        current_inventory_snapshot = query.one()
512
        current_inventory_snapshot = query.one()
513
        current_inventory_snapshot.reserved = current_inventory_snapshot.reserved + quantity
-
 
514
        session.commit()
-
 
515
        check_risky_item(item)
-
 
516
        return True
-
 
517
    except:
513
    except:
-
 
514
        current_inventory_snapshot = CurrentInventorySnapshot()
-
 
515
        current_inventory_snapshot.warehouse_id = warehouse_id
-
 
516
        current_inventory_snapshot.item_id = item_id
-
 
517
        current_inventory_snapshot.availibility = 0
518
        print "Unexpected error:", sys.exc_info()[0]
518
        current_inventory_snapshot.reserved = 0
-
 
519
        
-
 
520
    current_inventory_snapshot.reserved = current_inventory_snapshot.reserved + quantity
-
 
521
    session.commit()
-
 
522
    check_risky_item(item)
519
        return False
523
    return True
520
 
524
 
521
def reduce_reservation_count(item_id, warehouse_id, quantity):
525
def reduce_reservation_count(item_id, warehouse_id, quantity):
522
    if not warehouse_id:
526
    if not warehouse_id:
523
        raise InventoryServiceException(101, "bad warehouse_id")
527
        raise InventoryServiceException(101, "bad warehouse_id")
524
    item = get_item(item_id)
528
    item = get_item(item_id)