Subversion Repositories SmartDukaan

Rev

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

Rev 1399 Rev 1416
Line 419... Line 419...
419
 
419
 
420
def get_item_availability_for_location(warehouse_loc, item_id):
420
def get_item_availability_for_location(warehouse_loc, item_id):
421
    if warehouse_loc is None:
421
    if warehouse_loc is None:
422
        raise InventoryServiceException(101, "Bad Warehouse Location")
422
        raise InventoryServiceException(101, "Bad Warehouse Location")
423
    if not item_id:
423
    if not item_id:
424
        raise InventoryServiceException(101, "Bas Item id")
424
        raise InventoryServiceException(101, "Bad Item id")
425
    
425
    
-
 
426
    item = Item.get_by(id=item_id)
426
    warehouses = Warehouse.query.filter_by(logisticsLocation=warehouse_loc).all()
427
    warehouses = Warehouse.query.filter_by(logisticsLocation=warehouse_loc).all()
427
    warehouse_ids = [warehouse.id for warehouse in warehouses]
428
    warehouse_ids = [warehouse.id for warehouse in warehouses]
428
    warehouse_retid = -1
429
    warehouse_retid = -1
429
    global_availability = 0
430
    global_availability = 0
430
    for warehouse_id in warehouse_ids:
431
    for warehouse_id in warehouse_ids:
Line 438... Line 439...
438
            global_availability = availability
439
            global_availability = availability
439
    if warehouse_retid == -1:
440
    if warehouse_retid == -1:
440
        # This is the case when all warehouses have exhausted their
441
        # This is the case when all warehouses have exhausted their
441
        # inventory of this item or no warehouse is available in this
442
        # inventory of this item or no warehouse is available in this
442
        # location.
443
        # location.
443
        #TODO: Change 1 to be a constant read from the Config client.
-
 
444
        warehouse_retid = 1
444
        warehouse_retid = int(item.preferredWarehouse)
445
    return [warehouse_retid, global_availability]
445
    return [warehouse_retid, global_availability]
446
 
446
 
447
def get_warehouses_for_item(item_id):
447
def get_warehouses_for_item(item_id):
448
    
448
    
449
    if not item_id:
449
    if not item_id: