| Line 46... |
Line 46... |
| 46 |
skippedItems = { 175 : [27, 2160, 2175, 2163, 2158, 7128, 26, 2154],
|
46 |
skippedItems = { 175 : [27, 2160, 2175, 2163, 2158, 7128, 26, 2154],
|
| 47 |
193 : [5839] }
|
47 |
193 : [5839] }
|
| 48 |
|
48 |
|
| 49 |
pincodePricingServiceabilityMap = {}
|
49 |
pincodePricingServiceabilityMap = {}
|
| 50 |
warehouseMap = {}
|
50 |
warehouseMap = {}
|
| 51 |
logisticsLocationWarehouseMap = {}
|
51 |
stateWarehouseMap = {}
|
| 52 |
|
52 |
|
| 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]
|
| Line 58... |
Line 58... |
| 58 |
vendorWarehouseIdsForFofo = []
|
58 |
vendorWarehouseIdsForFofo = []
|
| 59 |
|
59 |
|
| 60 |
last_date = datetime.date.today()
|
60 |
last_date = datetime.date.today()
|
| 61 |
adjusted_dates={}
|
61 |
adjusted_dates={}
|
| 62 |
|
62 |
|
| - |
|
63 |
partnerMap = {}
|
| - |
|
64 |
|
| 63 |
def initialize(dbname='inventory', db_hostname="localhost"):
|
65 |
def initialize(dbname='inventory', db_hostname="localhost"):
|
| 64 |
DataService.initialize(dbname, db_hostname)
|
66 |
DataService.initialize(dbname, db_hostname)
|
| 65 |
__populateWarehouseMap()
|
67 |
__populateWarehouseMap()
|
| 66 |
|
68 |
|
| 67 |
def __populateWarehouseMap():
|
69 |
def __populateWarehouseMap():
|
| 68 |
warehouses = Warehouse.query.filter(Warehouse.warehouseType.in_(['OURS', 'THIRD_PARTY'])).filter(Warehouse.inventoryType == 'GOOD').all()
|
70 |
warehouses = Warehouse.query.filter(Warehouse.warehouseType.in_(['OURS', 'THIRD_PARTY'])).filter(Warehouse.inventoryType == 'GOOD').all()
|
| 69 |
for warehouse in warehouses:
|
71 |
for warehouse in warehouses:
|
| 70 |
warehouseMap[warehouse.id] = warehouse
|
72 |
warehouseMap[warehouse.id] = warehouse
|
| 71 |
if not logisticsLocationWarehouseMap.has_key(warehouse.logisticsLocation):
|
73 |
if not stateWarehouseMap.has_key(warehouse.state_id):
|
| 72 |
logisticsLocationWarehouseMap[warehouse.logisticsLocation] = []
|
74 |
stateWarehouseMap[warehouse.state_id] = []
|
| 73 |
logisticsLocationWarehouseMap[warehouse.logisticsLocation].append(warehouse.id)
|
75 |
stateWarehouseMap[warehouse.logisticsLocation].append(warehouse.id)
|
| 74 |
if warehouse.billingWarehouseId in physicalWarehouseIdsForFofo:
|
76 |
if warehouse.billingWarehouseId in physicalWarehouseIdsForFofo:
|
| 75 |
vendorWarehouseIdsForFofo.append(warehouse.id)
|
77 |
vendorWarehouseIdsForFofo.append(warehouse.id)
|
| 76 |
|
78 |
|
| 77 |
|
79 |
|
| 78 |
def get_Warehouse(warehouse_id):
|
80 |
def get_Warehouse(warehouse_id):
|
| Line 453... |
Line 455... |
| 453 |
|
455 |
|
| 454 |
def update_reservation_for_order(item_id, warehouse_id, source_id, order_id, created_timestamp, promised_shipping_timestamp, quantity):
|
456 |
def update_reservation_for_order(item_id, warehouse_id, source_id, order_id, created_timestamp, promised_shipping_timestamp, quantity):
|
| 455 |
if not warehouse_id:
|
457 |
if not warehouse_id:
|
| 456 |
raise InventoryServiceException(101, "bad warehouse_id")
|
458 |
raise InventoryServiceException(101, "bad warehouse_id")
|
| 457 |
warehouse = get_Warehouse(warehouse_id)
|
459 |
warehouse = get_Warehouse(warehouse_id)
|
| 458 |
item_pricing = get_item_pricing(item_id, warehouse.vendor.id)
|
460 |
'''item_pricing = get_item_pricing(item_id, warehouse.vendor.id)
|
| 459 |
if not item_pricing:
|
461 |
if not item_pricing:
|
| 460 |
raise InventoryServiceException(101, "No Pricing Info found for vendor and Item")
|
462 |
raise InventoryServiceException(101, "No Pricing Info found for vendor and Item")'''
|
| 461 |
query = CurrentInventorySnapshot.query.filter_by(warehouse_id = warehouse_id, item_id = item_id)
|
463 |
query = CurrentInventorySnapshot.query.filter_by(warehouse_id = warehouse_id, item_id = item_id)
|
| 462 |
try:
|
464 |
try:
|
| 463 |
new_current_inventory_snapshot = query.one()
|
465 |
new_current_inventory_snapshot = query.one()
|
| 464 |
except:
|
466 |
except:
|
| 465 |
new_current_inventory_snapshot = CurrentInventorySnapshot()
|
467 |
new_current_inventory_snapshot = CurrentInventorySnapshot()
|
| Line 659... |
Line 661... |
| 659 |
return False
|
661 |
return False
|
| 660 |
|
662 |
|
| 661 |
#This is not the source as in snapdeal or website, this source is to incorporate different pricing depending upon source id.
|
663 |
#This is not the source as in snapdeal or website, this source is to incorporate different pricing depending upon source id.
|
| 662 |
#i.e. if user visiting to our site has specific source he would see pricing on that source basis. Default source is 1.
|
664 |
#i.e. if user visiting to our site has specific source he would see pricing on that source basis. Default source is 1.
|
| 663 |
# Have to add another source id 2 for fofo warehouses
|
665 |
# Have to add another source id 2 for fofo warehouses
|
| - |
|
666 |
|
| - |
|
667 |
def get_item_availability_for_user(itemId, sourceId, stateId):
|
| - |
|
668 |
currentInventorySnapshots = get_item_inventory_by_item_id(itemId)
|
| - |
|
669 |
if len(currentInventorySnapshots) > 0:
|
| - |
|
670 |
for currentInventorySnapshot in currentInventorySnapshots:
|
| - |
|
671 |
warehouseIds = stateWarehouseMap.get(stateId)
|
| - |
|
672 |
if warehouseIds:
|
| - |
|
673 |
if warehouseMap[currentInventorySnapshot.warehouseId].state_id == stateId:
|
| - |
|
674 |
pass
|
| - |
|
675 |
|
| - |
|
676 |
|
| 664 |
def get_item_availability_for_location(item_id, source_id):
|
677 |
def get_item_availability_for_location(item_id, source_id):
|
| 665 |
item_availability = ItemAvailabilityCache.get_by(itemId=item_id, sourceId = source_id)
|
678 |
item_availability = ItemAvailabilityCache.get_by(itemId=item_id, sourceId = source_id)
|
| 666 |
if item_availability:
|
679 |
if item_availability:
|
| 667 |
return [item_availability.warehouseId, item_availability.expectedDelay, item_availability.billingWarehouseId, item_availability.sellingPrice, item_availability.totalAvailability, item_availability.weight]
|
680 |
return [item_availability.warehouseId, item_availability.expectedDelay, item_availability.billingWarehouseId, item_availability.sellingPrice, item_availability.totalAvailability, item_availability.weight]
|
| 668 |
#return [item_availability.warehouseId, item_availability.expectedDelay, item_availability.billingWarehouseId, item_availability.sellingPrice, 0, item_availability.weight]
|
681 |
#return [item_availability.warehouseId, item_availability.expectedDelay, item_availability.billingWarehouseId, item_availability.sellingPrice, 0, item_availability.weight]
|