Subversion Repositories SmartDukaan

Rev

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