Subversion Repositories SmartDukaan

Rev

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