Subversion Repositories SmartDukaan

Rev

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