| 5944 |
mandeep.dh |
1 |
'''
|
|
|
2 |
Created on 27-Apr-2010
|
|
|
3 |
|
|
|
4 |
@author: ashish
|
|
|
5 |
'''
|
| 11173 |
vikram.rag |
6 |
from elixir import *
|
| 5944 |
mandeep.dh |
7 |
from shop2020.config.client.ConfigClient import ConfigClient
|
|
|
8 |
from shop2020.model.v1.inventory.impl import DataService
|
| 5957 |
mandeep.dh |
9 |
from shop2020.model.v1.inventory.impl.Convertors import to_t_item_inventory, \
|
| 6821 |
amar.kumar |
10 |
to_t_warehouse, to_t_vendor_item_pricing, to_t_vendor, to_t_vendor_item_mapping, \
|
| 8282 |
kshitij.so |
11 |
to_t_item_stock_purchase_params, to_t_oos_status, to_t_amazon_inventory_snapshot, \
|
| 19413 |
amit.gupta |
12 |
to_t_amazon_fba_inventory_snapshot, to_t_snapdeal_inventory_snapshot, \
|
| 10050 |
vikram.rag |
13 |
to_t_hold_inventory_detail, to_t_flipkart_inventory_snapshot
|
| 5944 |
mandeep.dh |
14 |
from shop2020.model.v1.inventory.impl.DataAcessors import add_warehouse, \
|
|
|
15 |
update_inventory, retire_warehouse, get_item_availability_for_warehouse, \
|
|
|
16 |
get_item_availability_for_location, get_all_warehouses_by_status, get_Warehouse, \
|
| 5957 |
mandeep.dh |
17 |
get_all_items_for_warehouse, close_session, add_vendor, \
|
|
|
18 |
get_item_inventory_by_item_id, reserve_item_in_warehouse, \
|
|
|
19 |
reduce_reservation_count, get_all_item_pricing, add_vendor_pricing, \
|
|
|
20 |
get_item_pricing, get_all_vendors, get_item_mappings, add_vendor_item_mapping, \
|
|
|
21 |
update_inventory_history, is_alive, add_inventory, add_bad_inventory, \
|
|
|
22 |
mark_missed_inventory_updates_as_processed, update_vendor_string, \
|
|
|
23 |
get_item_keys_to_be_processed, reset_availability, get_shipping_locations, \
|
| 5944 |
mandeep.dh |
24 |
initialize, get_inventory_snapshot, clear_item_availability_cache, \
|
| 5987 |
rajveer |
25 |
reset_availability_for_warehouse, get_vendor, get_pending_orders_inventory, \
|
| 6531 |
vikram.rag |
26 |
is_order_billable, get_our_warehouse_id_for_vendor, \
|
|
|
27 |
get_item_availability_for_our_warehouses, get_monitored_warehouses_for_vendors, \
|
| 19413 |
amit.gupta |
28 |
get_ignored_warehouseids_and_itemids, \
|
|
|
29 |
insert_item_to_ignore_inventory_update_list, \
|
|
|
30 |
delete_item_from_ignore_inventory_update_list, \
|
|
|
31 |
get_all_ignored_inventoryupdate_items_count, get_ignored_inventoryupdate_itemids, \
|
|
|
32 |
update_item_stock_purchase_params, get_item_stock_purchase_params, \
|
|
|
33 |
add_oos_status_for_item, get_oos_statuses_for_x_days_for_item, \
|
|
|
34 |
get_non_zero_item_stock_purchase_params, \
|
|
|
35 |
get_billable_inventory_and_pending_orders, get_warehouse_name, \
|
|
|
36 |
get_amazon_inventory_for_item, get_all_amazon_inventory, \
|
| 7972 |
amar.kumar |
37 |
add_or_update_amazon_inventory_for_item, update_reservation_for_order, \
|
| 19413 |
amit.gupta |
38 |
get_last_n_day_sale_for_item, add_or_update_amazon_fba_inventory, \
|
|
|
39 |
add_update_hold_inventory, get_amazon_fba_inventory, \
|
|
|
40 |
get_all_amazon_fba_inventory, get_oursgood_warehouseids_for_location, \
|
|
|
41 |
get_holdinventorydetail_forItem_forWarehouseId_exceptsource, \
|
|
|
42 |
get_snapdeal_inventory_for_item, add_or_update_snapdeal_inventor_for_item, \
|
|
|
43 |
get_nlc_for_warehouse, get_snapdeal_inventory_snapshot, \
|
|
|
44 |
get_held_inventory_map_for_item, get_hold_inventory_details, \
|
|
|
45 |
add_or_update_flipkart_inventory_snapshot, get_flipkart_inventory_snapshot, \
|
|
|
46 |
get_flipkart_inventory_for_Item, get_oos_statuses_for_x_days, \
|
|
|
47 |
get_all_vendor_item_pricing, get_state_master, update_snapdeal_stock_at_eod, \
|
|
|
48 |
update_flipkart_stock_at_eod, get_wanlc_for_source, \
|
|
|
49 |
get_all_available_amazon_inventory, _task_update_item_availability_cache, \
|
|
|
50 |
add_vendor_item_pricing_in_bulk, add_inventory_in_bulk, \
|
| 22721 |
amit.gupta |
51 |
get_item_pincode_availability, get_fofo_availability, \
|
|
|
52 |
get_fofo_fulfilment_warehouse_map
|
| 5944 |
mandeep.dh |
53 |
from shop2020.model.v1.inventory.impl.DataService import Warehouse, \
|
|
|
54 |
MissedInventoryUpdate, VendorItemMapping
|
| 5957 |
mandeep.dh |
55 |
from shop2020.thriftpy.model.v1.inventory.ttypes import \
|
|
|
56 |
InventoryServiceException, WarehouseType, InventoryType, \
|
|
|
57 |
AvailableAndReservedStock
|
| 5944 |
mandeep.dh |
58 |
from shop2020.utils.Utils import log_entry, to_java_date
|
| 19413 |
amit.gupta |
59 |
|
| 5944 |
mandeep.dh |
60 |
|
|
|
61 |
class InventoryServiceHandler:
|
|
|
62 |
'''
|
|
|
63 |
classdocs
|
|
|
64 |
'''
|
|
|
65 |
|
|
|
66 |
def __init__(self, dbname='catalog', db_hostname='localhost'):
|
|
|
67 |
'''
|
|
|
68 |
Constructor
|
| 12963 |
amit.gupta |
69 |
'''
|
| 5944 |
mandeep.dh |
70 |
initialize(dbname, db_hostname)
|
|
|
71 |
try:
|
|
|
72 |
config_client = ConfigClient()
|
|
|
73 |
self.latest_arrivals_limit = int(config_client.get_property("LATEST_ARRIVALS_LIMIT"));
|
|
|
74 |
self.best_sellers_limit = int(config_client.get_property("BEST_SELLERS_LIMIT"))
|
|
|
75 |
except:
|
|
|
76 |
self.latest_arrivals_limit = 50
|
|
|
77 |
self.best_sellers_limit = 50
|
|
|
78 |
|
|
|
79 |
def addWarehouse(self, warehouse):
|
|
|
80 |
"""
|
|
|
81 |
Parameters:
|
|
|
82 |
- warehouse
|
|
|
83 |
"""
|
|
|
84 |
log_entry(self, "addWarehouse called")
|
|
|
85 |
try:
|
|
|
86 |
return add_warehouse(warehouse)
|
|
|
87 |
finally:
|
|
|
88 |
close_session()
|
|
|
89 |
|
|
|
90 |
def updateInventoryHistory(self, warehouse_id, timestamp, availability):
|
|
|
91 |
"""
|
|
|
92 |
Stores the incremental warehouse updates of items.
|
|
|
93 |
|
|
|
94 |
Parameters:
|
|
|
95 |
- warehouse_id
|
|
|
96 |
- timestamp
|
|
|
97 |
- availability
|
|
|
98 |
"""
|
|
|
99 |
try:
|
|
|
100 |
return update_inventory_history(warehouse_id, timestamp, availability)
|
|
|
101 |
finally:
|
|
|
102 |
close_session()
|
|
|
103 |
|
|
|
104 |
def updateInventory(self, warehouse_id, timestamp, availability):
|
|
|
105 |
"""
|
|
|
106 |
Parameters:
|
|
|
107 |
- warehouse_id
|
|
|
108 |
- timestamp
|
|
|
109 |
- availability
|
|
|
110 |
"""
|
|
|
111 |
log_entry(self, "update Inventory called")
|
|
|
112 |
try:
|
|
|
113 |
return update_inventory(warehouse_id, timestamp, availability)
|
|
|
114 |
finally:
|
|
|
115 |
close_session()
|
|
|
116 |
|
|
|
117 |
def addInventory(self, itemId, warehouseId, quantity):
|
|
|
118 |
"""
|
|
|
119 |
Add the inventory to existing stock.
|
|
|
120 |
|
|
|
121 |
Parameters:
|
|
|
122 |
- itemId
|
|
|
123 |
- warehouseId
|
|
|
124 |
- quantity
|
|
|
125 |
"""
|
|
|
126 |
log_entry(self, "add Inventory called")
|
|
|
127 |
try:
|
|
|
128 |
return add_inventory(itemId, warehouseId, quantity)
|
|
|
129 |
finally:
|
|
|
130 |
close_session()
|
|
|
131 |
|
|
|
132 |
def retireWarehouse(self, warehouse_id):
|
|
|
133 |
"""
|
|
|
134 |
Parameters:
|
|
|
135 |
- warehouse_id
|
|
|
136 |
"""
|
|
|
137 |
log_entry(self, "retire warehouse called")
|
|
|
138 |
try:
|
|
|
139 |
return retire_warehouse(warehouse_id)
|
|
|
140 |
finally:
|
|
|
141 |
close_session()
|
|
|
142 |
|
|
|
143 |
|
|
|
144 |
def getItemInventoryByItemId(self, item_id):
|
|
|
145 |
"""
|
|
|
146 |
Parameters:
|
|
|
147 |
- item_id
|
|
|
148 |
"""
|
|
|
149 |
log_entry(self, "item inventory requested")
|
|
|
150 |
try:
|
|
|
151 |
inventory = get_item_inventory_by_item_id(item_id)
|
|
|
152 |
return to_t_item_inventory(inventory, item_id)
|
|
|
153 |
finally:
|
|
|
154 |
close_session()
|
|
|
155 |
|
| 5978 |
rajveer |
156 |
def getItemAvailabilityAtLocation(self, itemId, sourceId):
|
| 5944 |
mandeep.dh |
157 |
"""
|
|
|
158 |
Determines the warehouse that should be used to fulfil an order for the given item.
|
|
|
159 |
It first checks all the warehouses which are in the logistics location given by the
|
|
|
160 |
warehouse_loc parameter. If none of the warehouses there have any inventory, then the
|
|
|
161 |
preferred warehouse for the item is used.
|
|
|
162 |
|
|
|
163 |
Returns an ordered list of size 4 with following elements in the given order:
|
|
|
164 |
1. Logistics location of the warehouse which was finally picked up to ship the order.
|
|
|
165 |
2. Id of the warehouse which was finally picked up.
|
|
|
166 |
3. Inventory size in the selected warehouse.
|
|
|
167 |
4. Expected delay added by the category manager.
|
|
|
168 |
|
|
|
169 |
Parameters:
|
|
|
170 |
- itemId
|
| 5978 |
rajveer |
171 |
- sourceId
|
| 5944 |
mandeep.dh |
172 |
"""
|
|
|
173 |
try:
|
| 5978 |
rajveer |
174 |
return get_item_availability_for_location(itemId, sourceId)
|
| 5944 |
mandeep.dh |
175 |
finally:
|
|
|
176 |
close_session()
|
|
|
177 |
|
|
|
178 |
def getItemAvailibilityAtWarehouse(self, warehouse_id, item_id):
|
|
|
179 |
"""
|
|
|
180 |
Parameters:
|
|
|
181 |
- warehouse_id
|
|
|
182 |
- item_id
|
|
|
183 |
"""
|
|
|
184 |
log_entry(self, "item availability at warehouse requested")
|
|
|
185 |
try:
|
|
|
186 |
return get_item_availability_for_warehouse(warehouse_id, item_id)
|
|
|
187 |
finally:
|
|
|
188 |
close_session()
|
| 6484 |
amar.kumar |
189 |
|
|
|
190 |
def getItemAvailabilitiesAtOurWarehouses(self, item_ids):
|
|
|
191 |
try:
|
|
|
192 |
return get_item_availability_for_our_warehouses(item_ids)
|
|
|
193 |
finally:
|
|
|
194 |
close_session()
|
| 5944 |
mandeep.dh |
195 |
|
|
|
196 |
def getItemInventoryHistory(self, id, item_id, warehouse_id, from_date, to_date):
|
|
|
197 |
"""
|
|
|
198 |
Parameters:
|
|
|
199 |
- id
|
|
|
200 |
- item_id
|
|
|
201 |
- warehouse_id
|
|
|
202 |
- from_date
|
|
|
203 |
- to_date
|
|
|
204 |
"""
|
|
|
205 |
pass
|
|
|
206 |
|
|
|
207 |
def getAllWarehouses(self, isActive):
|
|
|
208 |
"""
|
|
|
209 |
Parameters:
|
|
|
210 |
- isActive
|
|
|
211 |
"""
|
|
|
212 |
try:
|
|
|
213 |
if isActive:
|
|
|
214 |
warehouses = get_all_warehouses_by_status(3)
|
|
|
215 |
else:
|
|
|
216 |
warehouses = get_all_warehouses_by_status(None)
|
|
|
217 |
|
|
|
218 |
ret_warehouses = []
|
|
|
219 |
|
|
|
220 |
for warehouse in warehouses:
|
|
|
221 |
ret_warehouses.append(to_t_warehouse(warehouse))
|
|
|
222 |
return ret_warehouses
|
|
|
223 |
finally:
|
|
|
224 |
close_session()
|
|
|
225 |
|
|
|
226 |
def getWarehouse(self, warehouse_id):
|
|
|
227 |
"""
|
|
|
228 |
Parameters:
|
|
|
229 |
- warehouse_id
|
|
|
230 |
"""
|
|
|
231 |
log_entry(self, "get warehouse call")
|
|
|
232 |
try:
|
|
|
233 |
warehouse = get_Warehouse(warehouse_id)
|
|
|
234 |
if warehouse:
|
|
|
235 |
return to_t_warehouse(warehouse)
|
|
|
236 |
else:
|
|
|
237 |
raise InventoryServiceException(101, "no such warehouse: " + str(warehouse_id))
|
|
|
238 |
finally:
|
|
|
239 |
close_session()
|
|
|
240 |
|
|
|
241 |
def getAllItemsForWarehouse(self, warehouse_id):
|
|
|
242 |
"""
|
|
|
243 |
Parameters:
|
|
|
244 |
- warehouse_id
|
|
|
245 |
"""
|
|
|
246 |
log_entry(self, "getting all items for warehouse")
|
|
|
247 |
try:
|
|
|
248 |
all_items = get_all_items_for_warehouse(warehouse_id)
|
|
|
249 |
t_items = []
|
|
|
250 |
for item in all_items:
|
|
|
251 |
t_items.append(item.id)
|
|
|
252 |
return t_items
|
|
|
253 |
finally:
|
|
|
254 |
close_session()
|
|
|
255 |
|
| 5966 |
rajveer |
256 |
def isOrderBillable(self, itemId, warehouseId, sourceId, orderId):
|
| 5944 |
mandeep.dh |
257 |
"""
|
| 5966 |
rajveer |
258 |
Depending on reservation in the table, verify if we can bill this order or not.
|
|
|
259 |
|
|
|
260 |
Parameters:
|
|
|
261 |
- itemId
|
|
|
262 |
- warehouseId
|
|
|
263 |
- sourceId
|
|
|
264 |
- orderId
|
|
|
265 |
"""
|
|
|
266 |
try:
|
|
|
267 |
return is_order_billable(itemId, warehouseId, sourceId, orderId)
|
|
|
268 |
finally:
|
|
|
269 |
close_session()
|
|
|
270 |
|
|
|
271 |
def reserveItemInWarehouse(self, itemId, warehouseId, sourceId, orderId, createdTimestamp, promisedShippingTimestamp, quantity):
|
|
|
272 |
"""
|
| 5944 |
mandeep.dh |
273 |
Increases the reservation count for an item in a warehouse. Should always succeed normally.
|
|
|
274 |
|
|
|
275 |
Parameters:
|
|
|
276 |
- itemId
|
|
|
277 |
- warehouseId
|
|
|
278 |
"""
|
|
|
279 |
log_entry(self, "reserveItemInWarehouse called")
|
|
|
280 |
try:
|
| 5966 |
rajveer |
281 |
return reserve_item_in_warehouse(itemId, warehouseId, sourceId, orderId, createdTimestamp, promisedShippingTimestamp, quantity)
|
| 5944 |
mandeep.dh |
282 |
finally:
|
|
|
283 |
close_session()
|
| 7968 |
amar.kumar |
284 |
|
| 5944 |
mandeep.dh |
285 |
|
| 7968 |
amar.kumar |
286 |
def updateReservationForOrder(self, itemId, warehouseId, sourceId, orderId, createdTimestamp, promisedShippingTimestamp, quantity):
|
|
|
287 |
"""
|
|
|
288 |
Increases the reservation count for an item in a warehouse. Should always succeed normally.
|
|
|
289 |
|
|
|
290 |
Parameters:
|
|
|
291 |
- itemId
|
|
|
292 |
- warehouseId
|
|
|
293 |
"""
|
|
|
294 |
log_entry(self, "reserveItemInWarehouse called")
|
|
|
295 |
try:
|
|
|
296 |
return update_reservation_for_order(itemId, warehouseId, sourceId, orderId, createdTimestamp, promisedShippingTimestamp, quantity)
|
|
|
297 |
finally:
|
|
|
298 |
close_session()
|
|
|
299 |
|
| 5966 |
rajveer |
300 |
def reduceReservationCount(self, itemId, warehouseId, sourceId, orderId, quantity):
|
| 5944 |
mandeep.dh |
301 |
"""
|
|
|
302 |
Decreases the reservation count for an item in a warehouse. Should always succeed normally.
|
|
|
303 |
|
|
|
304 |
Parameters:
|
|
|
305 |
- itemId
|
|
|
306 |
- warehouseId
|
|
|
307 |
"""
|
|
|
308 |
log_entry(self, "reduceReservationCount called")
|
|
|
309 |
try:
|
| 5966 |
rajveer |
310 |
return reduce_reservation_count(itemId, warehouseId, sourceId, orderId, quantity)
|
| 5944 |
mandeep.dh |
311 |
finally:
|
|
|
312 |
close_session()
|
|
|
313 |
|
|
|
314 |
def getItemPricing(self, itemId, vendorId):
|
|
|
315 |
"""
|
|
|
316 |
Returns the pricing information of an item associated with the vendor of the given warehouse.
|
|
|
317 |
Raises an exception if either the item, vendor or the associated pricing information can't be found.
|
|
|
318 |
|
|
|
319 |
Parameters:
|
|
|
320 |
- itemId
|
|
|
321 |
- warehouseId
|
|
|
322 |
"""
|
|
|
323 |
try:
|
|
|
324 |
return to_t_vendor_item_pricing(get_item_pricing(itemId, vendorId))
|
|
|
325 |
finally:
|
|
|
326 |
close_session()
|
|
|
327 |
|
|
|
328 |
|
|
|
329 |
def getAllItemPricing(self, itemId):
|
|
|
330 |
"""
|
|
|
331 |
Returns list of the pricing information of an item associated an item.
|
|
|
332 |
Raises an exception if the item can't be found.
|
|
|
333 |
|
|
|
334 |
Parameters:
|
|
|
335 |
- itemId
|
|
|
336 |
"""
|
|
|
337 |
try:
|
|
|
338 |
return [to_t_vendor_item_pricing(vid) for vid in get_all_item_pricing(itemId)]
|
|
|
339 |
finally:
|
|
|
340 |
close_session()
|
| 10126 |
amar.kumar |
341 |
|
|
|
342 |
def getAllVendorItemPricing(self, itemId, vendorId):
|
|
|
343 |
"""
|
|
|
344 |
Returns list of all stored pricing information for given itemId and vendorId.
|
|
|
345 |
|
|
|
346 |
Parameters:
|
|
|
347 |
- itemId
|
|
|
348 |
- vendorId
|
|
|
349 |
"""
|
|
|
350 |
try:
|
|
|
351 |
return [to_t_vendor_item_pricing(vid) for vid in get_all_vendor_item_pricing(itemId, vendorId)]
|
|
|
352 |
finally:
|
|
|
353 |
close_session()
|
| 5944 |
mandeep.dh |
354 |
|
|
|
355 |
def addVendorItemPricing(self, vendorItemPricing):
|
|
|
356 |
"""
|
|
|
357 |
Adds vendor prices corresponding to the item. If pricing already exists then updates the prices.
|
|
|
358 |
Raises an exception if either the item or vendor can't be found corresponding to their ids.
|
|
|
359 |
|
|
|
360 |
Parameters:
|
|
|
361 |
- vendorItemPricing
|
|
|
362 |
"""
|
|
|
363 |
log_entry(self, "updateVendorItemPricing called")
|
|
|
364 |
try:
|
|
|
365 |
return add_vendor_pricing(vendorItemPricing)
|
|
|
366 |
finally:
|
|
|
367 |
close_session()
|
|
|
368 |
|
|
|
369 |
def getVendor(self, vendorId):
|
|
|
370 |
"""
|
|
|
371 |
Return a vendor for id
|
|
|
372 |
"""
|
|
|
373 |
try:
|
|
|
374 |
return to_t_vendor(get_vendor(vendorId))
|
|
|
375 |
finally:
|
|
|
376 |
close_session()
|
|
|
377 |
|
|
|
378 |
|
|
|
379 |
def getAllVendors(self, ):
|
|
|
380 |
"""
|
|
|
381 |
Return list of all vendors
|
|
|
382 |
"""
|
|
|
383 |
try:
|
|
|
384 |
return [to_t_vendor(v) for v in get_all_vendors()]
|
|
|
385 |
finally:
|
|
|
386 |
close_session()
|
|
|
387 |
|
|
|
388 |
def addVendorItemMapping(self, key, vendorItemMapping):
|
|
|
389 |
"""
|
|
|
390 |
Adds VendorItemMapping. Updates VendorItemMapping if exists corresponding to the item key.
|
|
|
391 |
|
|
|
392 |
Parameters:
|
|
|
393 |
- key
|
|
|
394 |
- vendorItemMapping
|
|
|
395 |
"""
|
|
|
396 |
log_entry(self, "addVendorItemMapping called")
|
|
|
397 |
try:
|
|
|
398 |
return add_vendor_item_mapping(key, vendorItemMapping)
|
|
|
399 |
finally:
|
|
|
400 |
close_session()
|
|
|
401 |
|
|
|
402 |
def getVendorItemMappings(self, itemId):
|
|
|
403 |
"""
|
|
|
404 |
Returns the list of vendor item mapping corresponding to itemId passed as parameter.
|
|
|
405 |
Raises an exception if item not found corresponding to itemId
|
|
|
406 |
|
|
|
407 |
Parameters:
|
|
|
408 |
- itemId
|
|
|
409 |
"""
|
|
|
410 |
try:
|
|
|
411 |
item_mappings = get_item_mappings(itemId)
|
|
|
412 |
return [to_t_vendor_item_mapping(vim) for vim in item_mappings]
|
|
|
413 |
finally:
|
|
|
414 |
close_session()
|
|
|
415 |
|
|
|
416 |
def isAlive(self, ):
|
|
|
417 |
"""
|
|
|
418 |
For checking weather service is active alive or not. It also checks connectivity with database
|
|
|
419 |
"""
|
|
|
420 |
try:
|
|
|
421 |
return is_alive()
|
|
|
422 |
finally:
|
|
|
423 |
close_session()
|
|
|
424 |
|
|
|
425 |
def closeSession(self, ):
|
|
|
426 |
"""
|
|
|
427 |
For closing the open session in sqlalchemy
|
|
|
428 |
"""
|
|
|
429 |
close_session()
|
|
|
430 |
|
|
|
431 |
def addVendor(self, vendor):
|
|
|
432 |
"""
|
|
|
433 |
add a new vendor
|
|
|
434 |
"""
|
|
|
435 |
try:
|
|
|
436 |
return add_vendor(vendor)
|
|
|
437 |
finally:
|
|
|
438 |
close_session()
|
|
|
439 |
|
|
|
440 |
def getWarehouses(self, warehouseType, inventoryType, vendorId, billingWarehouseId, shippingWarehouseId):
|
|
|
441 |
"""
|
|
|
442 |
This method returns all warehouses for a given warehosueType, inventoryType, vendor, billingWarehouse and shippingWarehouse.
|
|
|
443 |
getWarehouses(WarehouseType.OURS, InventoryType.GOOD, 3, 7, 7) would return ours warehouse with GOOD type inventory for vendor 1 for billing warehouse 7 and shipping warehouse 7
|
|
|
444 |
getWarehouses(WarehouseType.OURS, InventoryType.GOOD, 3, 7, 7) would return ours warehouse with GOOD type inventory for vendor 3 for billing warehouse 7 and shipping warehouse 7
|
|
|
445 |
getWarehouses(null, null, 3, 7, 7) would return all type warehouses with all type inventory for vendor 3 for billing warehouse 7 and shipping warehouse 7
|
|
|
446 |
getWarehouses(null, null, 0, 0, 7) would return all type warehouses with all type inventory for all vendors for all billing warehouses at shipping warehouse 7
|
|
|
447 |
|
|
|
448 |
Parameters:
|
|
|
449 |
- warehouseType
|
|
|
450 |
- inventoryType
|
|
|
451 |
- vendorId
|
|
|
452 |
- billingWarehouseId
|
|
|
453 |
- shippingWarehouseId
|
|
|
454 |
"""
|
|
|
455 |
try:
|
|
|
456 |
query = Warehouse.query
|
|
|
457 |
if warehouseType is not None:
|
|
|
458 |
query = query.filter_by(warehouseType = WarehouseType._VALUES_TO_NAMES[warehouseType])
|
|
|
459 |
if inventoryType is not None:
|
|
|
460 |
query = query.filter_by(inventoryType = InventoryType._VALUES_TO_NAMES[inventoryType])
|
|
|
461 |
if vendorId:
|
|
|
462 |
query = query.filter_by(vendor_id = vendorId)
|
|
|
463 |
if billingWarehouseId:
|
|
|
464 |
query = query.filter_by(billingWarehouseId = billingWarehouseId)
|
|
|
465 |
if shippingWarehouseId:
|
|
|
466 |
query = query.filter_by(shippingWarehouseId = shippingWarehouseId)
|
|
|
467 |
|
|
|
468 |
return [to_t_warehouse(w) for w in query.all()]
|
|
|
469 |
finally:
|
|
|
470 |
close_session()
|
|
|
471 |
|
|
|
472 |
def getItemKeysToBeProcessed(self, warehouseId):
|
|
|
473 |
"""
|
|
|
474 |
Returns the list of item keys which need to be processed for a given warehouse.
|
|
|
475 |
This is currently used by Support application to send item keys whose inventory needs
|
|
|
476 |
to be updated from PLB
|
|
|
477 |
|
|
|
478 |
Parameters:
|
|
|
479 |
- warehouseId
|
|
|
480 |
"""
|
|
|
481 |
try:
|
|
|
482 |
return get_item_keys_to_be_processed(warehouseId)
|
|
|
483 |
finally:
|
|
|
484 |
close_session()
|
|
|
485 |
|
|
|
486 |
def markMissedInventoryUpdatesAsProcessed(self, itemKey, warehouseId):
|
|
|
487 |
"""
|
|
|
488 |
Marks/Deletes missed inventory updates for a given key and warehouse.
|
|
|
489 |
This generally happens when updates from PLB are applied on the currentinventorysnapshot for an item
|
|
|
490 |
|
|
|
491 |
Parameters:
|
|
|
492 |
- itemKey
|
|
|
493 |
- warehouseId
|
|
|
494 |
"""
|
|
|
495 |
try:
|
|
|
496 |
mark_missed_inventory_updates_as_processed(itemKey, warehouseId)
|
|
|
497 |
finally:
|
|
|
498 |
close_session()
|
|
|
499 |
|
|
|
500 |
def resetAvailability(self, itemKey, vendorId, quantity, warehouseId):
|
|
|
501 |
"""
|
|
|
502 |
Resets availability of an item to the quantity mentioned in a warehouse.
|
|
|
503 |
|
|
|
504 |
Parameters:
|
|
|
505 |
- itemKey
|
|
|
506 |
- vendorId
|
|
|
507 |
- quantity
|
|
|
508 |
- warehouseId
|
|
|
509 |
"""
|
|
|
510 |
try:
|
|
|
511 |
reset_availability(itemKey, vendorId, quantity, warehouseId)
|
|
|
512 |
finally:
|
|
|
513 |
close_session()
|
|
|
514 |
|
|
|
515 |
def resetAvailabilityForWarehouse(self, warehouseId):
|
|
|
516 |
"""
|
|
|
517 |
Resets availability of a warehouse to zero.
|
|
|
518 |
|
|
|
519 |
Parameters:
|
|
|
520 |
- warehouseId
|
|
|
521 |
"""
|
|
|
522 |
try:
|
|
|
523 |
reset_availability_for_warehouse(warehouseId)
|
|
|
524 |
finally:
|
|
|
525 |
close_session()
|
|
|
526 |
|
|
|
527 |
def getIgnoredItemKeys(self, ):
|
|
|
528 |
"""
|
|
|
529 |
Returns all the item key mappings that have been ignored until date. Value of map has the warehouse id
|
|
|
530 |
and the timestamp from where alert was raised.
|
|
|
531 |
"""
|
|
|
532 |
try:
|
|
|
533 |
itemKeysMap = {}
|
|
|
534 |
for key in MissedInventoryUpdate.query.filter_by(isIgnored = 1).all():
|
|
|
535 |
itemKeysMap[key.itemKey] = { key.warehouseId : to_java_date(key.timestamp) }
|
|
|
536 |
|
|
|
537 |
return itemKeysMap
|
|
|
538 |
finally:
|
|
|
539 |
close_session()
|
|
|
540 |
|
|
|
541 |
def addBadInventory(self, itemId, warehouseId, quantity):
|
|
|
542 |
"""
|
|
|
543 |
Add the BAD type inventory to existing stock.
|
|
|
544 |
|
|
|
545 |
Parameters:
|
|
|
546 |
- itemId
|
|
|
547 |
- warehouseId
|
|
|
548 |
- quantity
|
|
|
549 |
"""
|
|
|
550 |
try:
|
|
|
551 |
add_bad_inventory(itemId, warehouseId, quantity)
|
|
|
552 |
finally:
|
|
|
553 |
close_session()
|
|
|
554 |
|
|
|
555 |
def getShippingLocations(self, ):
|
|
|
556 |
"""
|
|
|
557 |
Returns all shipping locations
|
|
|
558 |
"""
|
|
|
559 |
try:
|
|
|
560 |
return [to_t_warehouse(w) for w in get_shipping_locations()]
|
|
|
561 |
finally:
|
|
|
562 |
close_session()
|
|
|
563 |
|
|
|
564 |
def getAllVendorItemMappings(self, ):
|
|
|
565 |
"""
|
|
|
566 |
Fetches all the vendor item mappings present.
|
|
|
567 |
"""
|
|
|
568 |
try:
|
|
|
569 |
return [to_t_vendor_item_mapping(m) for m in VendorItemMapping.query.all()]
|
|
|
570 |
finally:
|
|
|
571 |
close_session()
|
|
|
572 |
|
|
|
573 |
def getInventorySnapshot(self, warehouseId):
|
|
|
574 |
"""
|
|
|
575 |
Gets items' inventory for a warehouse
|
|
|
576 |
If warehouse is passed as zero, items' inventory across all warehouses is sent
|
|
|
577 |
|
|
|
578 |
Parameters:
|
|
|
579 |
- warehouseId
|
|
|
580 |
"""
|
|
|
581 |
try:
|
|
|
582 |
resultMap = {}
|
|
|
583 |
itemInventoryMap = get_inventory_snapshot(warehouseId)
|
|
|
584 |
for key, value in itemInventoryMap.items():
|
|
|
585 |
resultMap[key] = to_t_item_inventory(value, key)
|
|
|
586 |
|
|
|
587 |
return resultMap
|
|
|
588 |
finally:
|
|
|
589 |
close_session()
|
|
|
590 |
|
|
|
591 |
def clearItemAvailabilityCache(self, ):
|
|
|
592 |
"""
|
|
|
593 |
Clear item availability cache.
|
|
|
594 |
"""
|
|
|
595 |
try:
|
| 13514 |
amit.gupta |
596 |
f = open('/catalog-dumps/catalog.items')
|
|
|
597 |
itemids = f.readline()
|
|
|
598 |
f.close()
|
|
|
599 |
if len(itemids) == 0 or "NULL" in itemids:
|
| 16214 |
amit.gupta |
600 |
pass
|
| 13514 |
amit.gupta |
601 |
else:
|
|
|
602 |
itemids = [int(itemid) for itemid in itemids.split(",")]
|
|
|
603 |
clear_item_availability_cache(itemids)
|
| 16214 |
amit.gupta |
604 |
except:
|
|
|
605 |
print "Could not read file"
|
| 5944 |
mandeep.dh |
606 |
finally:
|
|
|
607 |
close_session()
|
| 16214 |
amit.gupta |
608 |
return
|
| 5957 |
mandeep.dh |
609 |
|
| 6096 |
amit.gupta |
610 |
def clearItemAvailabilityCacheForItem(self, item_id):
|
|
|
611 |
"""
|
|
|
612 |
Clear item availability cache.
|
|
|
613 |
"""
|
|
|
614 |
try:
|
|
|
615 |
clear_item_availability_cache(item_id)
|
|
|
616 |
finally:
|
|
|
617 |
close_session()
|
|
|
618 |
|
| 5957 |
mandeep.dh |
619 |
def getPendingOrdersInventory(self, vendorId):
|
|
|
620 |
"""
|
|
|
621 |
Returns a list of inventory stock for items for which there are pending orders for the given vendor.
|
|
|
622 |
"""
|
|
|
623 |
try:
|
|
|
624 |
pending_items_inventory = get_pending_orders_inventory(vendorId)
|
|
|
625 |
return [AvailableAndReservedStock(itemId = i[0], available=i[1], reserved=i[2], minimumStock=0) for i in pending_items_inventory]
|
|
|
626 |
finally:
|
|
|
627 |
close_session()
|
|
|
628 |
|
| 5944 |
mandeep.dh |
629 |
def updateVendorString(self, warehouseId, vendorString):
|
|
|
630 |
"""
|
|
|
631 |
Parameters:
|
|
|
632 |
- warehouseId
|
|
|
633 |
- vendorString
|
|
|
634 |
"""
|
|
|
635 |
try:
|
|
|
636 |
update_vendor_string(warehouseId, vendorString)
|
|
|
637 |
finally:
|
|
|
638 |
close_session()
|
| 7718 |
amar.kumar |
639 |
def getOurWarehouseIdForVendor(self, vendorId, billingWarehouseId):
|
| 6467 |
amar.kumar |
640 |
"""
|
|
|
641 |
Returns warehouseId for our warehouse for a vendor
|
|
|
642 |
"""
|
|
|
643 |
try:
|
| 7718 |
amar.kumar |
644 |
return get_our_warehouse_id_for_vendor(vendorId, billingWarehouseId)
|
| 6467 |
amar.kumar |
645 |
finally:
|
| 6531 |
vikram.rag |
646 |
close_session()
|
|
|
647 |
def getMonitoredWarehouseForVendors(self, vendorIds):
|
|
|
648 |
"""
|
|
|
649 |
Returns monitored warehouse ids for vendors
|
|
|
650 |
"""
|
|
|
651 |
try:
|
|
|
652 |
return get_monitored_warehouses_for_vendors(vendorIds)
|
|
|
653 |
finally:
|
|
|
654 |
close_session()
|
|
|
655 |
def getIgnoredWarehouseidsAndItemids(self):
|
|
|
656 |
"""
|
|
|
657 |
Returns list of itemid and warehouseId for ignored inventory update
|
|
|
658 |
"""
|
|
|
659 |
try:
|
|
|
660 |
return get_ignored_warehouseids_and_itemids()
|
|
|
661 |
finally:
|
|
|
662 |
close_session()
|
|
|
663 |
|
|
|
664 |
def insertItemtoIgnoreInventoryUpdatelist(self,item_id,warehouse_id):
|
|
|
665 |
"""
|
|
|
666 |
Returns list of itemid and warehouseId for ignored inventory update
|
|
|
667 |
"""
|
|
|
668 |
try:
|
| 6532 |
amit.gupta |
669 |
return insert_item_to_ignore_inventory_update_list(item_id,warehouse_id)
|
| 6531 |
vikram.rag |
670 |
finally:
|
|
|
671 |
close_session()
|
|
|
672 |
def deleteItemFromIgnoredInventoryUpdateList(self,item_id,warehouse_id):
|
|
|
673 |
"""
|
|
|
674 |
Deletes warehouse and item entry from inventory update ignore list
|
|
|
675 |
"""
|
|
|
676 |
try:
|
|
|
677 |
return delete_item_from_ignore_inventory_update_list(item_id,warehouse_id)
|
|
|
678 |
finally:
|
|
|
679 |
close_session()
|
|
|
680 |
def getAllIgnoredInventoryupdateItemsCount(self):
|
|
|
681 |
"""
|
|
|
682 |
Returns all ignored inventory update item count
|
|
|
683 |
"""
|
| 6833 |
amar.kumar |
684 |
try:
|
|
|
685 |
return get_all_ignored_inventoryupdate_items_count()
|
|
|
686 |
finally:
|
|
|
687 |
close_session()
|
| 6531 |
vikram.rag |
688 |
|
|
|
689 |
|
|
|
690 |
def getIgnoredInventoryUpdateItemids(self,offset,limit):
|
|
|
691 |
"""
|
|
|
692 |
Returns all ignored inventory update items
|
|
|
693 |
"""
|
| 6833 |
amar.kumar |
694 |
try:
|
|
|
695 |
return get_ignored_inventoryupdate_itemids(offset,limit)
|
|
|
696 |
finally:
|
|
|
697 |
close_session()
|
| 6821 |
amar.kumar |
698 |
def updateItemStockPurchaseParams(self, item_id, numOfDaysStock, minStockLevel):
|
|
|
699 |
"""
|
|
|
700 |
Update/Add parameters required for heuristic purchase of Items
|
| 6833 |
amar.kumar |
701 |
"""
|
|
|
702 |
try:
|
|
|
703 |
update_item_stock_purchase_params(item_id, numOfDaysStock, minStockLevel)
|
|
|
704 |
finally:
|
|
|
705 |
close_session()
|
|
|
706 |
|
| 6821 |
amar.kumar |
707 |
def getItemStockPurchaseParams(self, item_id):
|
|
|
708 |
"""
|
|
|
709 |
Get parameters required for heuristic purchase of Items
|
| 6833 |
amar.kumar |
710 |
"""
|
|
|
711 |
try:
|
|
|
712 |
return to_t_item_stock_purchase_params(get_item_stock_purchase_params(item_id))
|
|
|
713 |
finally:
|
|
|
714 |
close_session()
|
|
|
715 |
|
| 6821 |
amar.kumar |
716 |
def addOosStatusForItem(self, oosStatusMap, date):
|
|
|
717 |
"""
|
|
|
718 |
Add OOS status for Item
|
|
|
719 |
"""
|
| 6833 |
amar.kumar |
720 |
try:
|
|
|
721 |
add_oos_status_for_item(oosStatusMap, date)
|
|
|
722 |
finally:
|
|
|
723 |
close_session()
|
|
|
724 |
|
| 9665 |
rajveer |
725 |
def getOosStatusesForXDaysForItem(self, itemId, sourceId, days):
|
| 6832 |
amar.kumar |
726 |
"""
|
| 9665 |
rajveer |
727 |
Get OOSStatus Objects for "days" number of days and sourceId for source. If sourceId is zero return for all sources.
|
| 6832 |
amar.kumar |
728 |
"""
|
| 6833 |
amar.kumar |
729 |
try:
|
| 9665 |
rajveer |
730 |
return [to_t_oos_status(oos) for oos in get_oos_statuses_for_x_days_for_item(itemId, sourceId, days)]
|
| 6833 |
amar.kumar |
731 |
finally:
|
| 6857 |
amar.kumar |
732 |
close_session()
|
|
|
733 |
|
| 10126 |
amar.kumar |
734 |
def getOosStatusesForXDays(self, sourceId, days):
|
|
|
735 |
"""
|
|
|
736 |
Get OOSStatus Objects for "days" number of days and sourceId for source. If sourceId is zero return for all sources.
|
|
|
737 |
"""
|
|
|
738 |
try:
|
|
|
739 |
return [to_t_oos_status(oos) for oos in get_oos_statuses_for_x_days(sourceId, days)]
|
|
|
740 |
finally:
|
|
|
741 |
close_session()
|
|
|
742 |
|
| 6857 |
amar.kumar |
743 |
def getNonZeroItemStockPurchaseParams(self):
|
|
|
744 |
"""
|
|
|
745 |
Get All ItemStockPurchaseParam objects where either minStockLevel or minNumOfDaysOfStock is zero
|
|
|
746 |
"""
|
|
|
747 |
try:
|
|
|
748 |
return [to_t_item_stock_purchase_params(ispp) for ispp in get_non_zero_item_stock_purchase_params()]
|
|
|
749 |
finally:
|
| 7149 |
amar.kumar |
750 |
close_session()
|
| 7972 |
amar.kumar |
751 |
|
|
|
752 |
def getLastNdaySaleForItem(self, itemId, numberOfDays):
|
|
|
753 |
"""
|
|
|
754 |
Get Sale for Last N day for an Item
|
|
|
755 |
"""
|
|
|
756 |
try:
|
|
|
757 |
return get_last_n_day_sale_for_item(itemId, numberOfDays)
|
|
|
758 |
finally:
|
|
|
759 |
close_session()
|
| 7149 |
amar.kumar |
760 |
def getBillableInventoryAndPendingOrders(self):
|
|
|
761 |
"""
|
|
|
762 |
Returns a list of inventory stock for items for which there are pending orders or have
|
|
|
763 |
billable inventory.
|
|
|
764 |
"""
|
|
|
765 |
try:
|
|
|
766 |
items_inventory = get_billable_inventory_and_pending_orders()
|
|
|
767 |
return [AvailableAndReservedStock(itemId = i[0], available=i[1], reserved=i[2], minimumStock=0) for i in items_inventory]
|
|
|
768 |
finally:
|
| 7281 |
kshitij.so |
769 |
close_session()
|
|
|
770 |
|
|
|
771 |
def getWarehouseName(self,warehouseId):
|
|
|
772 |
try:
|
|
|
773 |
name = get_warehouse_name(warehouseId)
|
|
|
774 |
return name
|
|
|
775 |
finally:
|
|
|
776 |
close_session()
|
|
|
777 |
|
|
|
778 |
def getAmazonInventoryForItem(self, amazonItemId):
|
| 7316 |
kshitij.so |
779 |
result = []
|
| 7281 |
kshitij.so |
780 |
try:
|
|
|
781 |
result = get_amazon_inventory_for_item(amazonItemId)
|
|
|
782 |
if result is not None:
|
|
|
783 |
result = to_t_amazon_inventory_snapshot(result)
|
|
|
784 |
except:
|
| 7316 |
kshitij.so |
785 |
return result
|
| 7281 |
kshitij.so |
786 |
finally:
|
|
|
787 |
close_session()
|
|
|
788 |
return result
|
|
|
789 |
|
|
|
790 |
def getAllAmazonInventory(self):
|
|
|
791 |
try:
|
|
|
792 |
amazoninventory = []
|
|
|
793 |
all_inventory = get_all_amazon_inventory()
|
|
|
794 |
for inventory in all_inventory:
|
|
|
795 |
amazoninventory.append(to_t_amazon_inventory_snapshot((inventory)))
|
|
|
796 |
return amazoninventory
|
|
|
797 |
finally:
|
|
|
798 |
close_session()
|
|
|
799 |
|
| 10450 |
vikram.rag |
800 |
def addOrUpdateAmazonInventoryForItem(self, amazoninventorysnapshot,time):
|
| 7281 |
kshitij.so |
801 |
try:
|
| 10450 |
vikram.rag |
802 |
add_or_update_amazon_inventory_for_item(amazoninventorysnapshot,time)
|
| 7281 |
kshitij.so |
803 |
finally:
|
| 8182 |
amar.kumar |
804 |
close_session()
|
|
|
805 |
|
| 8282 |
kshitij.so |
806 |
def addOrUpdateAmazonFbaInventory(self,amazonfbainventorysnapshot):
|
|
|
807 |
try:
|
| 11173 |
vikram.rag |
808 |
add_or_update_amazon_fba_inventory(amazonfbainventorysnapshot)
|
|
|
809 |
session.commit()
|
|
|
810 |
return True
|
| 8282 |
kshitij.so |
811 |
finally:
|
|
|
812 |
close_session()
|
|
|
813 |
|
| 8182 |
amar.kumar |
814 |
def addUpdateHoldInventory(self, itemId, warehouseId, holdQuantity, source):
|
|
|
815 |
try:
|
|
|
816 |
add_update_hold_inventory(itemId, warehouseId, holdQuantity, source)
|
|
|
817 |
finally:
|
| 8282 |
kshitij.so |
818 |
close_session()
|
|
|
819 |
|
|
|
820 |
def getAmazonFbaItemInventory(self,itemId):
|
| 11173 |
vikram.rag |
821 |
fba_inventory = []
|
| 8282 |
kshitij.so |
822 |
try:
|
| 11173 |
vikram.rag |
823 |
for inventory in get_amazon_fba_inventory(itemId):
|
|
|
824 |
fba_inventory.append(to_t_amazon_fba_inventory_snapshot(inventory))
|
|
|
825 |
return fba_inventory
|
| 8282 |
kshitij.so |
826 |
finally:
|
|
|
827 |
close_session()
|
|
|
828 |
|
| 8363 |
vikram.rag |
829 |
def getAllAmazonFbaItemInventory(self):
|
|
|
830 |
all_fba_inventory = []
|
| 8282 |
kshitij.so |
831 |
try:
|
| 8363 |
vikram.rag |
832 |
for inventory in get_all_amazon_fba_inventory():
|
|
|
833 |
all_fba_inventory.append(to_t_amazon_fba_inventory_snapshot(inventory))
|
|
|
834 |
return all_fba_inventory
|
| 8282 |
kshitij.so |
835 |
except:
|
|
|
836 |
return None
|
|
|
837 |
finally:
|
| 8363 |
vikram.rag |
838 |
close_session()
|
|
|
839 |
|
|
|
840 |
def getOursGoodWarehouseIdsForLocation(self,state_id):
|
|
|
841 |
ids=[]
|
| 8572 |
vikram.rag |
842 |
try:
|
|
|
843 |
for id in get_oursgood_warehouseids_for_location(state_id):
|
|
|
844 |
ids.append(id[0])
|
|
|
845 |
return ids
|
|
|
846 |
except:
|
|
|
847 |
return None
|
|
|
848 |
finally:
|
| 8954 |
vikram.rag |
849 |
close_session()
|
|
|
850 |
|
|
|
851 |
def getHoldInventoryDetailForItemForWarehouseIdExceptSource(self,item_id,warehouse_id,source):
|
|
|
852 |
try:
|
|
|
853 |
return get_holdinventorydetail_forItem_forWarehouseId_exceptsource(item_id,warehouse_id,source)
|
|
|
854 |
finally:
|
| 9404 |
vikram.rag |
855 |
close_session()
|
|
|
856 |
|
|
|
857 |
def getSnapdealInventoryForItem(self,item_id):
|
|
|
858 |
try:
|
|
|
859 |
return to_t_snapdeal_inventory_snapshot(get_snapdeal_inventory_for_item(item_id))
|
|
|
860 |
finally:
|
|
|
861 |
close_session()
|
|
|
862 |
def addOrUpdateSnapdealInventoryForItem(self,snapdealinventoryitem):
|
|
|
863 |
try:
|
|
|
864 |
add_or_update_snapdeal_inventor_for_item(snapdealinventoryitem)
|
|
|
865 |
finally:
|
|
|
866 |
close_session()
|
|
|
867 |
|
|
|
868 |
def getNlcForWarehouse(self,warehouse_id,item_id):
|
|
|
869 |
try:
|
|
|
870 |
return get_nlc_for_warehouse(warehouse_id,item_id)
|
|
|
871 |
finally:
|
| 9456 |
vikram.rag |
872 |
close_session()
|
|
|
873 |
|
| 9495 |
vikram.rag |
874 |
def addOrUpdateAllAmazonFbaInventory(self,allamazonfbainventorysnapshot):
|
| 11173 |
vikram.rag |
875 |
print 'inside handler'
|
| 9456 |
vikram.rag |
876 |
try:
|
| 9495 |
vikram.rag |
877 |
for amazonfbainventorysnapshot in allamazonfbainventorysnapshot:
|
| 11173 |
vikram.rag |
878 |
print amazonfbainventorysnapshot
|
| 9495 |
vikram.rag |
879 |
add_or_update_amazon_fba_inventory(amazonfbainventorysnapshot)
|
| 11173 |
vikram.rag |
880 |
session.commit()
|
| 9456 |
vikram.rag |
881 |
finally:
|
| 9482 |
vikram.rag |
882 |
close_session()
|
| 9495 |
vikram.rag |
883 |
|
|
|
884 |
def addOrUpdateAllSnapdealInventory(self,allsnapdealinventorysnapshot):
|
|
|
885 |
try:
|
|
|
886 |
for snapdealinventorysnapshot in allsnapdealinventorysnapshot:
|
|
|
887 |
add_or_update_snapdeal_inventor_for_item(snapdealinventorysnapshot)
|
|
|
888 |
finally:
|
|
|
889 |
close_session()
|
| 9456 |
vikram.rag |
890 |
|
| 9495 |
vikram.rag |
891 |
def getSnapdealInventorySnapshot(self):
|
| 9503 |
vikram.rag |
892 |
allsnapdealinventorysnapshot = []
|
|
|
893 |
try:
|
| 9504 |
vikram.rag |
894 |
for inventorysnapshot in get_snapdeal_inventory_snapshot():
|
|
|
895 |
allsnapdealinventorysnapshot.append(to_t_snapdeal_inventory_snapshot(inventorysnapshot))
|
|
|
896 |
return allsnapdealinventorysnapshot
|
| 9495 |
vikram.rag |
897 |
finally:
|
|
|
898 |
close_session()
|
| 9640 |
amar.kumar |
899 |
|
|
|
900 |
def getHeldInventoryMapForItem(self, itemId, warehouseId):
|
|
|
901 |
try:
|
|
|
902 |
return get_held_inventory_map_for_item(itemId, warehouseId)
|
|
|
903 |
finally:
|
|
|
904 |
close_session()
|
| 9761 |
amar.kumar |
905 |
|
|
|
906 |
def getHoldInventoryDetails(self, itemId, warehouseId, source):
|
|
|
907 |
try:
|
|
|
908 |
return [to_t_hold_inventory_detail(holdInventoryDetail) for holdInventoryDetail in get_hold_inventory_details(itemId, warehouseId, source)]
|
|
|
909 |
finally:
|
|
|
910 |
close_session()
|
| 10050 |
vikram.rag |
911 |
|
| 10450 |
vikram.rag |
912 |
def addOrUpdateFlipkartInventorySnapshot(self,flipkartInventorySnapshot,time):
|
| 10050 |
vikram.rag |
913 |
try:
|
| 10450 |
vikram.rag |
914 |
add_or_update_flipkart_inventory_snapshot(flipkartInventorySnapshot,time)
|
| 10050 |
vikram.rag |
915 |
finally:
|
|
|
916 |
close_session()
|
|
|
917 |
|
|
|
918 |
|
|
|
919 |
def getFlipkartInventorySnapshot(self):
|
|
|
920 |
try:
|
|
|
921 |
return [to_t_flipkart_inventory_snapshot(snapshot) for snapshot in get_flipkart_inventory_snapshot()]
|
|
|
922 |
finally:
|
|
|
923 |
close_session()
|
| 10097 |
kshitij.so |
924 |
|
|
|
925 |
def getFlipkartlInventoryForItem(self,item_id):
|
|
|
926 |
try:
|
|
|
927 |
return to_t_flipkart_inventory_snapshot(get_flipkart_inventory_for_Item(item_id))
|
|
|
928 |
finally:
|
|
|
929 |
close_session()
|
| 10485 |
vikram.rag |
930 |
|
|
|
931 |
def getStateMaster(self):
|
|
|
932 |
try:
|
|
|
933 |
return get_state_master()
|
|
|
934 |
finally:
|
| 10544 |
vikram.rag |
935 |
close_session()
|
|
|
936 |
|
|
|
937 |
def updateSnapdealStockAtEOD(self,allsnapdealstock):
|
|
|
938 |
try:
|
|
|
939 |
update_snapdeal_stock_at_eod(allsnapdealstock)
|
|
|
940 |
finally:
|
|
|
941 |
close_session()
|
|
|
942 |
|
|
|
943 |
def updateFlipkartStockAtEOD(self,allflipkartstock):
|
|
|
944 |
try:
|
|
|
945 |
update_flipkart_stock_at_eod(allflipkartstock)
|
|
|
946 |
finally:
|
|
|
947 |
close_session()
|
| 12363 |
kshitij.so |
948 |
|
|
|
949 |
def getWanNlcForSource(self,item_id,source):
|
|
|
950 |
try:
|
|
|
951 |
return get_wanlc_for_source(item_id,source)
|
|
|
952 |
finally:
|
|
|
953 |
close_session()
|
|
|
954 |
|
|
|
955 |
def getAllAvailableAmazonFbaItemInventory(self):
|
|
|
956 |
try:
|
|
|
957 |
amazoninventory = []
|
|
|
958 |
all_inventory = get_all_available_amazon_inventory()
|
|
|
959 |
for inventory in all_inventory:
|
| 12376 |
kshitij.so |
960 |
amazoninventory.append(to_t_amazon_fba_inventory_snapshot((inventory)))
|
| 12363 |
kshitij.so |
961 |
return amazoninventory
|
|
|
962 |
finally:
|
|
|
963 |
close_session()
|
| 17990 |
kshitij.so |
964 |
|
|
|
965 |
def updateItemAvailabilityForItemIds(self,itemIds):
|
|
|
966 |
try:
|
|
|
967 |
return _task_update_item_availability_cache(itemIds)
|
|
|
968 |
except:
|
|
|
969 |
return False
|
|
|
970 |
finally:
|
|
|
971 |
close_session()
|
| 12363 |
kshitij.so |
972 |
|
| 19247 |
kshitij.so |
973 |
def addVendorItemPricingInBulk(self,vendorItemPricingList):
|
|
|
974 |
try:
|
|
|
975 |
return add_vendor_item_pricing_in_bulk(vendorItemPricingList)
|
|
|
976 |
finally:
|
|
|
977 |
close_session()
|
|
|
978 |
|
|
|
979 |
def addInventoryInBulk(self, bulkInventoryList):
|
|
|
980 |
try:
|
|
|
981 |
add_inventory_in_bulk(bulkInventoryList)
|
|
|
982 |
finally:
|
|
|
983 |
close_session()
|
| 19413 |
amit.gupta |
984 |
|
| 19416 |
amit.gupta |
985 |
def getItemPincodeAvailability(self, itemPricingMap, pin):
|
| 19413 |
amit.gupta |
986 |
try:
|
| 20641 |
amit.gupta |
987 |
return get_item_pincode_availability(itemPricingMap, pin)
|
| 19413 |
amit.gupta |
988 |
finally:
|
| 22718 |
amit.gupta |
989 |
close_session()
|
|
|
990 |
|
|
|
991 |
def getFofoAvailability(self, itemIds):
|
|
|
992 |
try:
|
|
|
993 |
return get_fofo_availability(itemIds)
|
|
|
994 |
finally:
|
| 22721 |
amit.gupta |
995 |
close_session()
|
|
|
996 |
|
|
|
997 |
def getFofoFulFillmentWarehouseMap(self, itemIds):
|
|
|
998 |
try:
|
|
|
999 |
return get_fofo_fulfilment_warehouse_map(itemIds)
|
|
|
1000 |
finally:
|
| 19416 |
amit.gupta |
1001 |
close_session()
|