Subversion Repositories SmartDukaan

Rev

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