| Line 242... |
Line 242... |
| 242 |
raise InventoryServiceException(108, "warehouse id not present")
|
242 |
raise InventoryServiceException(108, "warehouse id not present")
|
| 243 |
warehouse.status = 0;
|
243 |
warehouse.status = 0;
|
| 244 |
session.commit()
|
244 |
session.commit()
|
| 245 |
|
245 |
|
| 246 |
def get_item_availability_for_warehouse(warehouse_id, item_id):
|
246 |
def get_item_availability_for_warehouse(warehouse_id, item_id):
|
| 247 |
if not warehouse_id:
|
- |
|
| 248 |
raise InventoryServiceException(101, "bad warehouse_id")
|
247 |
ignore = IgnoredInventoryUpdateItems.query.filter_by(item_id=item_id).filter_by(warehouse_id = warehouse_id).one()
|
| 249 |
if not item_id:
|
248 |
if ignore:
|
| 250 |
raise InventoryServiceException(101, "bad item_id")
|
249 |
return 0
|
| 251 |
|
250 |
|
| 252 |
warehouse = get_Warehouse(warehouse_id)
|
- |
|
| 253 |
if not warehouse:
|
- |
|
| 254 |
raise InventoryServiceException(108, "warehouse does not exist")
|
- |
|
| 255 |
|
- |
|
| 256 |
query = CurrentInventorySnapshot.query.filter_by(warehouse_id = warehouse_id)
|
- |
|
| 257 |
query = query.filter_by(item_id = item_id)
|
- |
|
| 258 |
try:
|
251 |
try:
|
| 259 |
current_inventory_snapshot = query.one()
|
252 |
current_inventory_snapshot = CurrentInventorySnapshot.query.filter_by(warehouse_id = warehouse_id).filter_by(item_id = item_id).one()
|
| 260 |
return current_inventory_snapshot.availability - current_inventory_snapshot.reserved
|
253 |
return current_inventory_snapshot.availability - current_inventory_snapshot.reserved
|
| 261 |
except:
|
254 |
except:
|
| 262 |
return 0
|
255 |
return 0
|
| 263 |
|
256 |
|
| 264 |
def get_item_availability_for_our_warehouses(item_ids):
|
257 |
def get_item_availability_for_our_warehouses(item_ids):
|
| Line 534... |
Line 527... |
| 534 |
if warehouse.id not in warehousesAvailability:
|
527 |
if warehouse.id not in warehousesAvailability:
|
| 535 |
continue
|
528 |
continue
|
| 536 |
entry = warehousesAvailability[warehouse.id]
|
529 |
entry = warehousesAvailability[warehouse.id]
|
| 537 |
if warehouse.billingWarehouseId in availabilityForBillingWarehouses:
|
530 |
if warehouse.billingWarehouseId in availabilityForBillingWarehouses:
|
| 538 |
if warehouse.billingWarehouseId is not None or warehouse.billingWarehouseId != 0:
|
531 |
if warehouse.billingWarehouseId is not None or warehouse.billingWarehouseId != 0:
|
| 539 |
availabilityForBillingWarehouses[warehouse.billingWarehouseId] = availabilityForBillingWarehouses[warehouse.billingWarehouseId] + entry.availability - entry.reserved
|
532 |
availabilityForBillingWarehouses[warehouse.billingWarehouseId] = availabilityForBillingWarehouses[warehouse.billingWarehouseId] + entry[0] - entry[1]
|
| 540 |
else:
|
533 |
else:
|
| 541 |
if warehouse.billingWarehouseId is not None or warehouse.billingWarehouseId != 0:
|
534 |
if warehouse.billingWarehouseId is not None or warehouse.billingWarehouseId != 0:
|
| 542 |
availabilityForBillingWarehouses[warehouse.billingWarehouseId] = entry[0] - entry[1]
|
535 |
availabilityForBillingWarehouses[warehouse.billingWarehouseId] = entry[0] - entry[1]
|
| 543 |
if entry[0] <= entry[1]:
|
536 |
if entry[0] <= entry[1]:
|
| 544 |
continue
|
537 |
continue
|