Subversion Repositories SmartDukaan

Rev

Rev 12363 | Rev 12872 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5945 mandeep.dh 1
namespace java in.shop2020.model.v1.inventory
2
namespace py shop2020.thriftpy.model.v1.inventory
3
 
4
include "GenericService.thrift"
5
 
11173 vikram.rag 6
enum AmazonFCWarehouseLocation {
7
	Mumbai = 0,
8
	Bangalore = 1
9
}
10
 
5945 mandeep.dh 11
enum WarehouseLocation {
7808 anupam.sin 12
	Delhi = 0,
13
	Mumbai = 1,
12783 manish.sha 14
	Karnataka = 2,
15
	Haryana = 3,
16
	Rajasthan = 4,
17
	Telangana = 5
5945 mandeep.dh 18
}
19
 
20
struct Vendor {
21
	1:i64 id,
22
	2:string name
23
}
24
 
12280 amit.gupta 25
enum VatType {
26
	SP = 0,
27
	MRP = 1
28
}
29
 
5945 mandeep.dh 30
enum BillingType {
31
	OURS = 0,
6725 rajveer 32
	EXTERNAL = 1,
33
	OURS_EXTERNAL = 2
5945 mandeep.dh 34
}
35
 
36
enum WarehouseType {
37
    OURS = 0,
7410 amar.kumar 38
    THIRD_PARTY = 1,
39
    OURS_THIRDPARTY = 2
5945 mandeep.dh 40
}
41
 
42
enum InventoryType {
43
    GOOD = 0,
44
    BAD = 1,
45
    VIRTUAL = 2
46
}
47
 
48
enum HolidayType {
49
	WEEKLY = 0,
50
	MONTHLY = 1,
51
	SPECIFIC = 2
52
}
53
 
54
/* 
55
Warehouse fields details
56
location: it is full address
57
vendorString: some key for the warehouse
58
*/
59
struct Warehouse {
60
	1:i64 id,
61
	2:string displayName,
62
	3:string location,
63
	5:i64 addedOn,
64
	6:i64 lastCheckedOn,
65
	7:string tinNumber,
66
	8:string pincode,
67
	9:string vendorString,
68
	10:WarehouseLocation logisticsLocation,
69
	12:BillingType billingType,
70
	13:WarehouseType warehouseType,
71
	14:InventoryType inventoryType,
72
	15:Vendor vendor,
73
	16:i64 shippingWarehouseId,
74
	17:i64 billingWarehouseId,
75
	18:bool isAvailabilityMonitored,
7330 amit.gupta 76
	19:i64 transferDelayInHours,
12357 manish.sha 77
	20:i64 stateId,
78
	21:i64 source
5945 mandeep.dh 79
}
80
 
12280 amit.gupta 81
struct StateInfo{
82
	1:i64 id,
83
	2:string stateName,
84
	3:VatType vatType
85
}
86
 
87
 
5945 mandeep.dh 88
/* */
89
struct ItemInventory{
90
	1:i64 id,
91
	2:map<i64,i64> availability,
8182 amar.kumar 92
	3:map<i64,i64> reserved,
93
	4:map<i64,i64> held
5945 mandeep.dh 94
}
95
 
96
struct ItemInventoryHistory{
97
	1:i64 item_id,
98
	2:i64 warehouse_id,
99
	3:i64 timestamp,
100
	4:i64 availability
101
}
102
 
103
struct VendorItemPricing{
104
	1:i64 vendorId,
105
	2:i64 itemId,
106
	3:double transferPrice,
107
	4:double mop,
6747 amar.kumar 108
	5:double dealerPrice,
109
	6:double nlc
5945 mandeep.dh 110
}
111
 
112
struct VendorItemMapping{
113
	1:i64 vendorId,
114
	2:string itemKey,
115
	3:i64 itemId
116
}
117
 
118
struct AvailableAndReservedStock {
119
	1:i64 itemId,
120
	2:i64 available,
121
	3:i64 reserved,
122
	4:i64 minimumStock
123
}
124
 
6531 vikram.rag 125
struct IgnoredInventoryUpdateItems {
126
	1:i64 itemId,
127
	2:i64 warehouseId
6821 amar.kumar 128
}
129
 
130
struct ItemStockPurchaseParams{
131
	1:i64 item_id,
132
	2:i32 numOfDaysStock,
133
	3:i64 minStockLevel
134
}
135
 
5945 mandeep.dh 136
exception InventoryServiceException{
137
	1:i64 id,
138
	2:string message
139
}
140
 
6821 amar.kumar 141
struct OOSStatus {
142
	1:i64 item_id
143
	2:i64 date
144
	3:bool is_oos
145
	4:i64 num_orders
8182 amar.kumar 146
	5:i64 rto_orders
10126 amar.kumar 147
	6:i32 sourceId
6821 amar.kumar 148
}
7281 kshitij.so 149
 
150
struct AmazonInventorySnapshot {
151
    1:i64 item_id
152
    2:i64 availability
153
    3:i64 reserved
10450 vikram.rag 154
    4:bool is_oos
7281 kshitij.so 155
} 
156
 
8282 kshitij.so 157
struct AmazonFbaInventorySnapshot {
158
    1:i64 item_id
159
    2:i64 availability
11173 vikram.rag 160
    3:AmazonFCWarehouseLocation location
161
    4:i64 unfulfillable
162
    5:i64 reserved
163
    6:i64 inbound
8282 kshitij.so 164
}
165
 
8182 amar.kumar 166
struct HoldInventoryDetail {
167
	1:i64 item_id
168
	2:i64 warehouse_id
169
	3:i64 held
170
	4:i64 source
171
}
172
 
9404 vikram.rag 173
struct SnapdealInventoryItem{
174
	1:i64 item_id
175
	2:i64 availability
176
	3:i64 lastUpdatedOnSnapdeal
9495 vikram.rag 177
	4:i64 pendingOrders
10450 vikram.rag 178
	5:bool is_oos
9404 vikram.rag 179
}
180
 
10050 vikram.rag 181
struct FlipkartInventorySnapshot{
182
	1:i64 item_id
183
	2:i64 availability
184
	3:i64 createdOrders
185
	4:i64 heldOrders
10450 vikram.rag 186
	5:bool is_oos
10050 vikram.rag 187
}
9404 vikram.rag 188
 
10547 vikram.rag 189
struct SnapdealStockAtEOD{
190
	1:i64 item_id
191
	2:i64 availability
192
	3:i64 date
193
}
10050 vikram.rag 194
 
10547 vikram.rag 195
struct FlipkartStockAtEOD{
196
	1:i64 item_id
197
	2:i64 availability
198
	3:i64 date
199
}
200
 
12357 manish.sha 201
struct StockWeightedNlcInfo{
202
	1:i64 itemId,
203
	2:i64 source,
204
	3:i64 updatedTimestamp,
205
	4:i64 stockQuantity,
206
	5:string grnDetail,
207
	6:double avgWeightedNlc
208
}
10547 vikram.rag 209
 
210
 
5945 mandeep.dh 211
service InventoryService extends GenericService.GenericService{
212
 
213
	i64 addWarehouse(1:Warehouse warehouse) throws (1:InventoryServiceException cex),
214
 
215
	/**
216
	add a new vendor
217
	*/
218
	i64 addVendor(1:Vendor vendor) throws (1:InventoryServiceException cex),
219
 
220
	/**
221
	Stores the incremental warehouse updates of items.
222
	*/
223
	void updateInventoryHistory(1:i64 warehouse_id, 2:string timestamp, 3:map<string, i64> availability) throws (1:InventoryServiceException cex),
224
 
225
	/**
226
	Stores the final inventory stocks of items.
227
	*/
228
	void updateInventory(1:i64 warehouse_id, 2:string timestamp, 3:map<string, i64> availability) throws (1:InventoryServiceException cex),
229
 
230
	/**
231
	Add the inventory to existing stock.
232
	*/
233
	void addInventory(1:i64 itemId, 2:i64 warehouseId, 3:i64 quantity) throws (1:InventoryServiceException cex),
234
 
235
	//all delete methods
236
	void retireWarehouse(1:i64 warehouse_id) throws (1:InventoryServiceException cex),
237
 
238
	ItemInventory getItemInventoryByItemId(1:i64 item_id) throws (1:InventoryServiceException cex),
239
	i64 getItemAvailibilityAtWarehouse(1:i64 warehouse_id, 2:i64 item_id) throws (1:InventoryServiceException cex),
240
 
241
	/**
242
	Determines the warehouse that should be used to fulfil an order for the given item.
243
	It first checks all the warehouses which are in the logistics location given by the
244
	warehouse_loc parameter. If none of the warehouses there have any inventory, then the
245
	preferred warehouse for the item is used. 
246
 
247
	Returns an ordered list of size 4 with following elements in the given order:
248
	1. Id of the fulfillment warehouse which was finally picked up.
249
	2. Expected delay added by the category manager.
250
	3. Id of the billing warehouse which was finally picked up.
251
	 */
5978 rajveer 252
	list<i64> getItemAvailabilityAtLocation(1:i64 itemId, 2:i64 sourceId) throws (1:InventoryServiceException isex),
5945 mandeep.dh 253
 
254
	list<Warehouse> getAllWarehouses(1:bool isActive) throws (1:InventoryServiceException cex),
255
 
256
	/**
257
	 Returns the warehouse with the given id.
258
	*/
259
	Warehouse getWarehouse(1:i64 warehouse_id) throws (1:InventoryServiceException cex),
260
	list<i64> getAllItemsForWarehouse(1:i64 warehouse_id) throws (1:InventoryServiceException cex),
261
 
262
	/**
5966 rajveer 263
	Depending on reservation in the table, verify if we can bill this order or not.
264
	*/
265
	bool isOrderBillable(1:i64 itemId, 2:i64 warehouseId, 3:i64 sourceId, 4:i64 orderId),
266
 
267
	/**
5945 mandeep.dh 268
	 Increases the reservation count for an item in a warehouse. Should always succeed normally.
269
	*/
5966 rajveer 270
	bool reserveItemInWarehouse(1:i64 itemId, 2:i64 warehouseId, 3:i64 sourceId, 4:i64 orderId, 5:i64 createdTimestamp, 6:i64 promisedShippingTimestamp, 7:double quantity) throws (1:InventoryServiceException cex),
5945 mandeep.dh 271
 
272
	/**
7968 amar.kumar 273
	 Updates the reservation for Order
274
	*/
275
	bool updateReservationForOrder(1:i64 itemId, 2:i64 warehouseId, 3:i64 sourceId, 4:i64 orderId, 5:i64 createdTimestamp, 6:i64 promisedShippingTimestamp, 7:double quantity) throws (1:InventoryServiceException cex),
276
 
277
	/**
5945 mandeep.dh 278
	 Decreases the reservation count for an item in a warehouse. Should always succeed normally.
279
	*/
5966 rajveer 280
	bool reduceReservationCount(1:i64 itemId, 2:i64 warehouseId, 3:i64 sourceId, 4:i64 orderId, 5:double quantity) throws (1:InventoryServiceException cex),
5945 mandeep.dh 281
 
282
	/**
283
	Returns the pricing information of an item associated with the vendor of the given warehouse.
284
	Raises an exception if either the item, vendor or the associated pricing information can't be found.
285
	*/
286
	VendorItemPricing getItemPricing(1:i64 itemId, 2:i64 vendorId) throws (1:InventoryServiceException cex),
287
 
288
	/**
289
	Returns the list of vendor pricing information of an item.
290
	Raises an exception if item not found corresponding to itemId
291
	*/
292
	list<VendorItemPricing> getAllItemPricing(1:i64 itemId) throws (1:InventoryServiceException cex),
293
 
294
 
295
	/**
296
	Adds vendor prices corresponding to the item. If pricing already exists then updates the prices. 
297
	Raises an exception if either the item or vendor can't be found corresponding to their ids.
298
	*/
299
	void addVendorItemPricing(1:VendorItemPricing vendorItemPricing) throws (1:InventoryServiceException cex),
300
 
301
	/**
302
	Returns a vendor given its id
303
	*/
304
	Vendor getVendor(1:i64 vendorId), 
305
 
306
    /**
307
    Return list of all vendors
308
    */
309
    list<Vendor> getAllVendors(), 
310
 
311
	/**
312
	Adds VendorItemMapping. Updates VendorItemMapping if exists corresponding to the item key.  
313
	*/
314
	void addVendorItemMapping(1:string key, 2:VendorItemMapping vendorItemMapping) throws (1:InventoryServiceException cex),
315
 
316
	/**
317
	Returns the list of vendor item mapping corresponding to itemId passed as parameter.
318
	Raises an exception if item not found corresponding to itemId
319
	*/
320
	list<VendorItemMapping> getVendorItemMappings(1:i64 itemId) throws (1:InventoryServiceException cex),
321
 
322
	/**
323
	Returns a list of inventory stock for items for which there are pending orders for the given vendor.
324
	*/
325
	list<AvailableAndReservedStock> getPendingOrdersInventory(1:i64 vendorid),
326
 
327
	/**
328
	 This method returns all warehouses for a given warehosueType, inventoryType, vendor, billingWarehouse and shippingWarehouse.
329
	 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
330
	 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
331
     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
332
     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
333
	 */
334
	list<Warehouse> getWarehouses(1:WarehouseType warehouseType, 2:InventoryType inventoryType, 3:i64 vendorId, 4:i64 billingWarehouseId, 5:i64 shippingWarehouseId);
335
 
336
    /**
337
     * Resets availability of an item to the quantity mentioned in a warehouse.
338
     */
339
    void resetAvailability(1:string itemKey, 2:i64 vendorId, 3:i64 quantity, 4:i64 warehouseId) throws (1:InventoryServiceException cex);
340
 
341
    /**
342
     * Resets availability of a warehouse to zero.
343
     */
344
    void resetAvailabilityForWarehouse(1:i64 warehouseId) throws (1:InventoryServiceException cex);
345
 
346
    /**
347
     * Returns the list of item keys which need to be processed for a given warehouse.
348
     * This is currently used by Support application to send item keys whose inventory needs 
349
     * to be updated from PLB
350
     */
351
    list<string> getItemKeysToBeProcessed(1:i64 warehouseId);
352
 
353
    /**
354
     * Marks/Deletes missed inventory updates for a given key and warehouse.
355
     * This generally happens when updates from PLB are applied on the currentinventorysnapshot for an item
356
     */
357
    void markMissedInventoryUpdatesAsProcessed(1:string itemKey, 2:i64 warehouseId);
358
 
359
    /**
360
     * Returns all the item key mappings that have been ignored until date. Value of map has the warehouse id
361
     * and the timestamp from where alert was raised.
362
     */
363
    map<string, map<i64, i64>> getIgnoredItemKeys();
364
 
365
    /**
366
    Add the BAD type inventory to existing stock.
367
    */
368
    void addBadInventory(1:i64 itemId, 2:i64 warehouseId, 3:i64 quantity) throws (1:InventoryServiceException cex);
369
 
370
    /**
371
    Returns all shipping locations
372
    */    
373
    list<Warehouse> getShippingLocations();
374
 
375
    /**
376
     * Fetches all the vendor item mappings present.
377
     */    
378
    list<VendorItemMapping> getAllVendorItemMappings();
379
 
380
    /**
381
     * Gets items' inventory for a warehouse
382
     * If warehouse is passed as zero, items' inventory across all warehouses is sent
383
     */
384
    map<i64, ItemInventory> getInventorySnapshot(1:i64 warehouseId);
385
 
386
    /**
387
    * Clear item availability cache.
388
    */
389
    void clearItemAvailabilityCache();
390
 
391
    void updateVendorString(1:i64 warehouseId, 2:string vendorString);
6096 amit.gupta 392
 
393
    void clearItemAvailabilityCacheForItem(1:i64 item_id);
6467 amar.kumar 394
 
7718 amar.kumar 395
    i64 getOurWarehouseIdForVendor(1:i64 vendorId, 2:i64 billingWarehouseId);
6484 amar.kumar 396
 
397
    map<i64, i64> getItemAvailabilitiesAtOurWarehouses(1:list<i64> item_ids);
6531 vikram.rag 398
 
399
    list<i64> getMonitoredWarehouseForVendors(1:list<i64> vendorIds);
400
 
401
    list<IgnoredInventoryUpdateItems> getIgnoredWarehouseidsAndItemids();
402
 
403
    bool insertItemtoIgnoreInventoryUpdatelist(1:i64 item_id,2:i64 warehouse_id);
404
 
405
    bool deleteItemFromIgnoredInventoryUpdateList(1:i64 item_id,2:i64 warehouse_id);
406
 
407
    i32 getAllIgnoredInventoryupdateItemsCount();
408
 
409
    list<i64> getIgnoredInventoryUpdateItemids(1:i32 offset,2:i32 limit);
410
 
6821 amar.kumar 411
    void updateItemStockPurchaseParams(1:i64 item_id, 2:i32 numOfDaysStock, 3:i64 minStockLevel);
412
 
413
    ItemStockPurchaseParams getItemStockPurchaseParams(1:i64 itemId);
414
 
415
    void addOosStatusForItem(1:map<i64, bool> oosStatusMap, 2: i64 date);
6832 amar.kumar 416
 
9665 rajveer 417
    list<OOSStatus> getOosStatusesForXDaysForItem(1:i64 itemId, 2:i32 sourceId, 3:i32 days);
6857 amar.kumar 418
 
10126 amar.kumar 419
    list<OOSStatus> getOosStatusesForXDays(1:i32 sourceId, 2:i32 days);
420
 
421
    list<VendorItemPricing> getAllVendorItemPricing(1:i64 itemId, 2:i64 vendorId);
422
 
6857 amar.kumar 423
    list<ItemStockPurchaseParams> getNonZeroItemStockPurchaseParams();
7149 amar.kumar 424
 
425
    /**
426
	Returns a list of inventory stock for items for which there are pending orders or have billable inventory.
427
	*/
428
	list<AvailableAndReservedStock> getBillableInventoryAndPendingOrders();
7281 kshitij.so 429
 
430
	string getWarehouseName(1:i64 warehouse_id);
431
 
432
	AmazonInventorySnapshot getAmazonInventoryForItem(1:i64 item_id);
433
 
434
	list<AmazonInventorySnapshot> getAllAmazonInventory();
435
 
10450 vikram.rag 436
	void addOrUpdateAmazonInventoryForItem(1:AmazonInventorySnapshot amazonInventorySnapshot,2:i64 time);
7281 kshitij.so 437
 
7972 amar.kumar 438
	string getLastNdaySaleForItem(1:i64 itemId, 2:i64 numberOfDays);
439
 
8282 kshitij.so 440
	void addOrUpdateAmazonFbaInventory(1:AmazonFbaInventorySnapshot amazonfbainventorysnapshot);
9482 vikram.rag 441
 
9762 amar.kumar 442
	void addUpdateHoldInventory(1:i64 itemId, 2:i64 warehouseId, 3:i64 holdQuantity, 4:i64 source)  throws (1:InventoryServiceException cex);
8182 amar.kumar 443
 
11173 vikram.rag 444
	list<AmazonFbaInventorySnapshot> getAmazonFbaItemInventory(1:i64 itemId);
8282 kshitij.so 445
 
9404 vikram.rag 446
	list<AmazonFbaInventorySnapshot> getAllAmazonFbaItemInventory();
8282 kshitij.so 447
 
9404 vikram.rag 448
	list<i64> getOursGoodWarehouseIdsForLocation(1:i64 state_id);
8363 vikram.rag 449
 
9404 vikram.rag 450
	i64 getHoldInventoryDetailForItemForWarehouseIdExceptSource(1:i64 id,2:i64 warehouse_id,3:i64 source);
8959 vikram.rag 451
 
9404 vikram.rag 452
	SnapdealInventoryItem getSnapdealInventoryForItem(1:i64 item_id);
453
 
454
	void addOrUpdateSnapdealInventoryForItem(1:SnapdealInventoryItem snapdealinventoryitem)
455
 
456
	double getNlcForWarehouse(1:i64 warehouse_id,2:i64 item_id)
457
 
9640 amar.kumar 458
	map<i32, i64> getHeldInventoryMapForItem(1:i64 item_id, 2:i64 warehouse_id)
459
 
9495 vikram.rag 460
	void addOrUpdateAllAmazonFbaInventory(list<AmazonFbaInventorySnapshot> allamazonfbainventorysnapshot)
9456 vikram.rag 461
 
9495 vikram.rag 462
	void addOrUpdateAllSnapdealInventory(list<SnapdealInventoryItem> allsnapdealinventorysnapshot)
9482 vikram.rag 463
 
9495 vikram.rag 464
	list<SnapdealInventoryItem> getSnapdealInventorySnapshot()
465
 
9761 amar.kumar 466
	list<HoldInventoryDetail> getHoldInventoryDetails(1:i64 itemId, 2:i64 warehouseId, 3:i64 source)
467
 
10450 vikram.rag 468
	void addOrUpdateFlipkartInventorySnapshot(1:list<FlipkartInventorySnapshot> flipkartInventorySnapshot,2:i64 time)
10050 vikram.rag 469
 
470
	list<FlipkartInventorySnapshot> getFlipkartInventorySnapshot()
471
 
10097 kshitij.so 472
	FlipkartInventorySnapshot getFlipkartlInventoryForItem(1:i64 item_id)
473
 
12280 amit.gupta 474
	map<i64,StateInfo> getStateMaster()
10485 vikram.rag 475
 
10547 vikram.rag 476
	void updateSnapdealStockAtEOD(list<SnapdealStockAtEOD> allsnapdealstock)
477
 
478
	void updateFlipkartStockAtEOD(list<FlipkartStockAtEOD> allflipkartstock)
479
 
12363 kshitij.so 480
	double getWanNlcForSource(1:i64 item_id,2:i64 source)
481
 
482
	list<AmazonFbaInventorySnapshot> getAllAvailableAmazonFbaItemInventory();
483
 
484
}