Subversion Repositories SmartDukaan

Rev

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