Subversion Repositories SmartDukaan

Rev

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

Rev 2286 Rev 2341
Line 522... Line 522...
522
        except:
522
        except:
523
            availability = 0    
523
            availability = 0    
524
        if availability > global_availability:
524
        if availability > global_availability:
525
            warehouse_retid = warehouse_id
525
            warehouse_retid = warehouse_id
526
            global_availability = availability
526
            global_availability = availability
-
 
527
    
527
    if warehouse_retid == -1:
528
    if warehouse_retid == -1:
528
        # This is the case when all warehouses have exhausted their
529
        # This is the case when all warehouses have exhausted their
529
        # inventory of this item or no warehouse is available in this
530
        # inventory of this item or no warehouse is available in this
530
        # location.
531
        # location.
531
        warehouse_retid = int(item.preferredWarehouse)
532
        warehouse_retid = int(item.preferredWarehouse)
-
 
533
        warehouse = Warehouse.get_by(warehouse_retid)
-
 
534
        try:
-
 
535
            current_inventory_snapshot = CurrentInventorySnapshot.query.filter_by(warehouse_id = warehouse_retid, item_id = item_id).one()
-
 
536
            global_availability = current_inventory_snapshot.availibility - current_inventory_snapshot.reserved
-
 
537
        except:
-
 
538
            global_availability = 0
-
 
539
 
532
    return [warehouse_retid, global_availability]
540
    return [warehouse.logisticsLocation, warehouse_retid, global_availability]
533
 
541
 
534
def get_warehouses_for_item(item_id):
542
def get_warehouses_for_item(item_id):
535
    
543
    
536
    if not item_id:
544
    if not item_id:
537
        raise InventoryServiceException(101, "bad item_id")
545
        raise InventoryServiceException(101, "bad item_id")