| Line 53... |
Line 53... |
| 53 |
OOS_CALCULATION_TIME = 23
|
53 |
OOS_CALCULATION_TIME = 23
|
| 54 |
|
54 |
|
| 55 |
#right now these warehouse ids are ignored.
|
55 |
#right now these warehouse ids are ignored.
|
| 56 |
#physicalWarehouseIdsForFofo = [7678, 7681]
|
56 |
#physicalWarehouseIdsForFofo = [7678, 7681]
|
| 57 |
physicalWarehouseIdsForFofo = []
|
57 |
physicalWarehouseIdsForFofo = []
|
| 58 |
vendorWarehouseIdsForFofo = []
|
- |
|
| 59 |
|
58 |
|
| 60 |
last_date = datetime.date.today()
|
59 |
last_date = datetime.date.today()
|
| 61 |
adjusted_dates={}
|
60 |
adjusted_dates={}
|
| 62 |
|
61 |
|
| 63 |
partnerMap = {}
|
62 |
partnerMap = {}
|
| Line 79... |
Line 78... |
| 79 |
print warehouse.id, warehouse.vendor
|
78 |
print warehouse.id, warehouse.vendor
|
| 80 |
if warehouse.vendor.id==default_virtual_vendor and warehouse.warehouseType == 'THIRD_PARTY':
|
79 |
if warehouse.vendor.id==default_virtual_vendor and warehouse.warehouseType == 'THIRD_PARTY':
|
| 81 |
virtualVendorWarehouses[warehouse.state_id] = warehouse
|
80 |
virtualVendorWarehouses[warehouse.state_id] = warehouse
|
| 82 |
if warehouse.vendor.id==default_virtual_vendor and warehouse.warehouseType == 'OURS':
|
81 |
if warehouse.vendor.id==default_virtual_vendor and warehouse.warehouseType == 'OURS':
|
| 83 |
billingVendorWarehouses[warehouse.state_id] = warehouse.billingWarehouseId
|
82 |
billingVendorWarehouses[warehouse.state_id] = warehouse.billingWarehouseId
|
| 84 |
|
- |
|
| 85 |
if warehouse.billingWarehouseId in physicalWarehouseIdsForFofo:
|
- |
|
| 86 |
vendorWarehouseIdsForFofo.append(warehouse.id)
|
- |
|
| 87 |
|
83 |
|
| 88 |
print "billingVendorWarehouses", billingVendorWarehouses
|
84 |
print "billingVendorWarehouses", billingVendorWarehouses
|
| 89 |
print "virtualVendorWarehouses", virtualVendorWarehouses
|
85 |
print "virtualVendorWarehouses", virtualVendorWarehouses
|
| 90 |
|
86 |
|
| 91 |
def get_Warehouse(warehouse_id):
|
87 |
def get_Warehouse(warehouse_id):
|
| Line 152... |
Line 148... |
| 152 |
#No item availability cache for Hotspot Specific Store
|
148 |
#No item availability cache for Hotspot Specific Store
|
| 153 |
#No virtual is allowed
|
149 |
#No virtual is allowed
|
| 154 |
Ignored_inventory_items = IgnoredInventoryUpdateItems.query.filter_by(item_id=item_id).all()
|
150 |
Ignored_inventory_items = IgnoredInventoryUpdateItems.query.filter_by(item_id=item_id).all()
|
| 155 |
for Ignored_inventory_item in Ignored_inventory_items:
|
151 |
for Ignored_inventory_item in Ignored_inventory_items:
|
| 156 |
warehouses.append(Ignored_inventory_item.warehouse_id)
|
152 |
warehouses.append(Ignored_inventory_item.warehouse_id)
|
| 157 |
return warehouses + vendorWarehouseIdsForFofo
|
153 |
return warehouses
|
| 158 |
|
154 |
|
| 159 |
def update_inventory_history(warehouse_id, timestamp, availability):
|
155 |
def update_inventory_history(warehouse_id, timestamp, availability):
|
| 160 |
warehouse = get_Warehouse(warehouse_id)
|
156 |
warehouse = get_Warehouse(warehouse_id)
|
| 161 |
if not warehouse:
|
157 |
if not warehouse:
|
| 162 |
raise InventoryServiceException(107, "Warehouse? Where?")
|
158 |
raise InventoryServiceException(107, "Warehouse? Where?")
|
| Line 342... |
Line 338... |
| 342 |
if not item_ids:
|
338 |
if not item_ids:
|
| 343 |
return returnMap
|
339 |
return returnMap
|
| 344 |
for item_id in item_ids:
|
340 |
for item_id in item_ids:
|
| 345 |
returnMap[item_id] = get_item_availability_for_location(item_id, 1)[4]
|
341 |
returnMap[item_id] = get_item_availability_for_location(item_id, 1)[4]
|
| 346 |
return returnMap
|
342 |
return returnMap
|
| 347 |
#TODO: Amit Should be removed physicalWarehouseIdsForFofo
|
- |
|
| 348 |
# returnMap = {}
|
- |
|
| 349 |
# if not item_ids:
|
- |
|
| 350 |
# return returnMap
|
- |
|
| 351 |
# snapshots = CurrentInventorySnapshot.query.filter(CurrentInventorySnapshot.warehouse_id.in_(vendorWarehouseIdsForFofo)).filter(CurrentInventorySnapshot.item_id.in_(item_ids)).all()
|
- |
|
| 352 |
# for snapshot in snapshots:
|
- |
|
| 353 |
# if returnMap.has_key(snapshot.item_id):
|
- |
|
| 354 |
# returnMap[snapshot.item_id] += snapshot.availability - snapshot.reserved - snapshot.held
|
- |
|
| 355 |
# else:
|
- |
|
| 356 |
# returnMap[snapshot.item_id] = snapshot.availability - snapshot.reserved - snapshot.held
|
- |
|
| 357 |
# return returnMap
|
- |
|
| 358 |
|
343 |
|
| 359 |
def get_fofo_fulfilment_warehouse_map(itemIds):
|
344 |
def get_fofo_fulfilment_warehouse_map(itemIds):
|
| 360 |
returnMap = {}
|
345 |
returnMap = {}
|
| 361 |
snapshots = CurrentInventorySnapshot.query.filter(CurrentInventorySnapshot.warehouse_id.in_(vendorWarehouseIdsForFofo)).filter(CurrentInventorySnapshot.item_id.in_(itemIds)).all()
|
346 |
snapshots = CurrentInventorySnapshot.query.filter(CurrentInventorySnapshot.warehouse_id.in_(vendorWarehouseIdsForFofo)).filter(CurrentInventorySnapshot.item_id.in_(itemIds)).all()
|
| 362 |
for snapshot in snapshots:
|
347 |
for snapshot in snapshots:
|
| Line 688... |
Line 673... |
| 688 |
warehouse = currentInventorySnapshot.warehouse
|
673 |
warehouse = currentInventorySnapshot.warehouse
|
| 689 |
totalAvailability += availability
|
674 |
totalAvailability += availability
|
| 690 |
if totalAvailability <= 0:
|
675 |
if totalAvailability <= 0:
|
| 691 |
warehouse = virtualVendorWarehouses.get(stateId)
|
676 |
warehouse = virtualVendorWarehouses.get(stateId)
|
| 692 |
expectedDelay = 2
|
677 |
expectedDelay = 2
|
| 693 |
|
678 |
expunge(warehouse)
|
| 694 |
ia = get_item_availability_for_location(itemId, sourceId)
|
679 |
ia = get_item_availability_for_location(itemId, sourceId)
|
| 695 |
return [warehouse.id, expectedDelay, billingVendorWarehouses[stateId], ia[3], totalAvailability, ia[5]]
|
680 |
return [warehouse.id, expectedDelay, billingVendorWarehouses[stateId], ia[3], totalAvailability, ia[5]]
|
| 696 |
|
681 |
|
| 697 |
|
682 |
|
| 698 |
def get_item_availability_for_location(item_id, source_id):
|
683 |
def get_item_availability_for_location(item_id, source_id):
|