Subversion Repositories SmartDukaan

Rev

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