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