Subversion Repositories SmartDukaan

Rev

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