Subversion Repositories SmartDukaan

Rev

Rev 19247 | Rev 19415 | 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
 
19247 kshitij.so 213
struct BulkAddInventory{
214
	1:i64 item_id,
215
	2:i64 warehouse_id,
216
	3:i64 inventory
217
}
19413 amit.gupta 218
struct ItemLocationAvailability{
219
	1:i64 itemId,
220
	2:i64 locationId,
221
	3:i64 physicalQty,
222
	4:i64 virtualQty,
223
	5:i64 minTransferDelay,
224
	6:i64 maxTransferDelay
225
}
10547 vikram.rag 226
 
19413 amit.gupta 227
struct ItemPincodeAvailability{
228
	1:i64 itemId,
229
	2:string pinCode,
230
	3:i64 vatQty,
231
	4:i64 totalQty,
232
	5:i64 minDeliveryDate,
233
	6:i64 maxDeliveryDate
234
}
19247 kshitij.so 235
 
5945 mandeep.dh 236
service InventoryService extends GenericService.GenericService{
237
 
238
	i64 addWarehouse(1:Warehouse warehouse) throws (1:InventoryServiceException cex),
239
 
240
	/**
241
	add a new vendor
242
	*/
243
	i64 addVendor(1:Vendor vendor) throws (1:InventoryServiceException cex),
244
 
245
	/**
246
	Stores the incremental warehouse updates of items.
247
	*/
248
	void updateInventoryHistory(1:i64 warehouse_id, 2:string timestamp, 3:map<string, i64> availability) throws (1:InventoryServiceException cex),
249
 
250
	/**
251
	Stores the final inventory stocks of items.
252
	*/
253
	void updateInventory(1:i64 warehouse_id, 2:string timestamp, 3:map<string, i64> availability) throws (1:InventoryServiceException cex),
254
 
255
	/**
256
	Add the inventory to existing stock.
257
	*/
258
	void addInventory(1:i64 itemId, 2:i64 warehouseId, 3:i64 quantity) throws (1:InventoryServiceException cex),
259
 
260
	//all delete methods
261
	void retireWarehouse(1:i64 warehouse_id) throws (1:InventoryServiceException cex),
262
 
263
	ItemInventory getItemInventoryByItemId(1:i64 item_id) throws (1:InventoryServiceException cex),
264
	i64 getItemAvailibilityAtWarehouse(1:i64 warehouse_id, 2:i64 item_id) throws (1:InventoryServiceException cex),
265
 
266
	/**
267
	Determines the warehouse that should be used to fulfil an order for the given item.
268
	It first checks all the warehouses which are in the logistics location given by the
269
	warehouse_loc parameter. If none of the warehouses there have any inventory, then the
270
	preferred warehouse for the item is used. 
271
 
272
	Returns an ordered list of size 4 with following elements in the given order:
273
	1. Id of the fulfillment warehouse which was finally picked up.
274
	2. Expected delay added by the category manager.
275
	3. Id of the billing warehouse which was finally picked up.
276
	 */
5978 rajveer 277
	list<i64> getItemAvailabilityAtLocation(1:i64 itemId, 2:i64 sourceId) throws (1:InventoryServiceException isex),
5945 mandeep.dh 278
 
279
	list<Warehouse> getAllWarehouses(1:bool isActive) throws (1:InventoryServiceException cex),
280
 
281
	/**
282
	 Returns the warehouse with the given id.
283
	*/
284
	Warehouse getWarehouse(1:i64 warehouse_id) throws (1:InventoryServiceException cex),
285
	list<i64> getAllItemsForWarehouse(1:i64 warehouse_id) throws (1:InventoryServiceException cex),
286
 
287
	/**
5966 rajveer 288
	Depending on reservation in the table, verify if we can bill this order or not.
289
	*/
290
	bool isOrderBillable(1:i64 itemId, 2:i64 warehouseId, 3:i64 sourceId, 4:i64 orderId),
291
 
292
	/**
5945 mandeep.dh 293
	 Increases the reservation count for an item in a warehouse. Should always succeed normally.
294
	*/
5966 rajveer 295
	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 296
 
297
	/**
7968 amar.kumar 298
	 Updates the reservation for Order
299
	*/
300
	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),
301
 
302
	/**
5945 mandeep.dh 303
	 Decreases the reservation count for an item in a warehouse. Should always succeed normally.
304
	*/
5966 rajveer 305
	bool reduceReservationCount(1:i64 itemId, 2:i64 warehouseId, 3:i64 sourceId, 4:i64 orderId, 5:double quantity) throws (1:InventoryServiceException cex),
5945 mandeep.dh 306
 
307
	/**
308
	Returns the pricing information of an item associated with the vendor of the given warehouse.
309
	Raises an exception if either the item, vendor or the associated pricing information can't be found.
310
	*/
311
	VendorItemPricing getItemPricing(1:i64 itemId, 2:i64 vendorId) throws (1:InventoryServiceException cex),
312
 
313
	/**
314
	Returns the list of vendor pricing information of an item.
315
	Raises an exception if item not found corresponding to itemId
316
	*/
317
	list<VendorItemPricing> getAllItemPricing(1:i64 itemId) throws (1:InventoryServiceException cex),
318
 
319
 
320
	/**
321
	Adds vendor prices corresponding to the item. If pricing already exists then updates the prices. 
322
	Raises an exception if either the item or vendor can't be found corresponding to their ids.
323
	*/
324
	void addVendorItemPricing(1:VendorItemPricing vendorItemPricing) throws (1:InventoryServiceException cex),
325
 
326
	/**
327
	Returns a vendor given its id
328
	*/
329
	Vendor getVendor(1:i64 vendorId), 
330
 
331
    /**
332
    Return list of all vendors
333
    */
334
    list<Vendor> getAllVendors(), 
335
 
336
	/**
337
	Adds VendorItemMapping. Updates VendorItemMapping if exists corresponding to the item key.  
338
	*/
339
	void addVendorItemMapping(1:string key, 2:VendorItemMapping vendorItemMapping) throws (1:InventoryServiceException cex),
340
 
341
	/**
342
	Returns the list of vendor item mapping corresponding to itemId passed as parameter.
343
	Raises an exception if item not found corresponding to itemId
344
	*/
345
	list<VendorItemMapping> getVendorItemMappings(1:i64 itemId) throws (1:InventoryServiceException cex),
346
 
347
	/**
348
	Returns a list of inventory stock for items for which there are pending orders for the given vendor.
349
	*/
350
	list<AvailableAndReservedStock> getPendingOrdersInventory(1:i64 vendorid),
351
 
352
	/**
353
	 This method returns all warehouses for a given warehosueType, inventoryType, vendor, billingWarehouse and shippingWarehouse.
354
	 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
355
	 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
356
     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
357
     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
358
	 */
359
	list<Warehouse> getWarehouses(1:WarehouseType warehouseType, 2:InventoryType inventoryType, 3:i64 vendorId, 4:i64 billingWarehouseId, 5:i64 shippingWarehouseId);
360
 
361
    /**
362
     * Resets availability of an item to the quantity mentioned in a warehouse.
363
     */
364
    void resetAvailability(1:string itemKey, 2:i64 vendorId, 3:i64 quantity, 4:i64 warehouseId) throws (1:InventoryServiceException cex);
365
 
366
    /**
367
     * Resets availability of a warehouse to zero.
368
     */
369
    void resetAvailabilityForWarehouse(1:i64 warehouseId) throws (1:InventoryServiceException cex);
370
 
371
    /**
372
     * Returns the list of item keys which need to be processed for a given warehouse.
373
     * This is currently used by Support application to send item keys whose inventory needs 
374
     * to be updated from PLB
375
     */
376
    list<string> getItemKeysToBeProcessed(1:i64 warehouseId);
377
 
378
    /**
379
     * Marks/Deletes missed inventory updates for a given key and warehouse.
380
     * This generally happens when updates from PLB are applied on the currentinventorysnapshot for an item
381
     */
382
    void markMissedInventoryUpdatesAsProcessed(1:string itemKey, 2:i64 warehouseId);
383
 
384
    /**
385
     * Returns all the item key mappings that have been ignored until date. Value of map has the warehouse id
386
     * and the timestamp from where alert was raised.
387
     */
388
    map<string, map<i64, i64>> getIgnoredItemKeys();
389
 
390
    /**
391
    Add the BAD type inventory to existing stock.
392
    */
393
    void addBadInventory(1:i64 itemId, 2:i64 warehouseId, 3:i64 quantity) throws (1:InventoryServiceException cex);
394
 
395
    /**
396
    Returns all shipping locations
397
    */    
398
    list<Warehouse> getShippingLocations();
399
 
400
    /**
401
     * Fetches all the vendor item mappings present.
402
     */    
403
    list<VendorItemMapping> getAllVendorItemMappings();
404
 
405
    /**
406
     * Gets items' inventory for a warehouse
407
     * If warehouse is passed as zero, items' inventory across all warehouses is sent
408
     */
409
    map<i64, ItemInventory> getInventorySnapshot(1:i64 warehouseId);
410
 
411
    /**
412
    * Clear item availability cache.
413
    */
414
    void clearItemAvailabilityCache();
415
 
416
    void updateVendorString(1:i64 warehouseId, 2:string vendorString);
6096 amit.gupta 417
 
418
    void clearItemAvailabilityCacheForItem(1:i64 item_id);
6467 amar.kumar 419
 
7718 amar.kumar 420
    i64 getOurWarehouseIdForVendor(1:i64 vendorId, 2:i64 billingWarehouseId);
6484 amar.kumar 421
 
422
    map<i64, i64> getItemAvailabilitiesAtOurWarehouses(1:list<i64> item_ids);
6531 vikram.rag 423
 
424
    list<i64> getMonitoredWarehouseForVendors(1:list<i64> vendorIds);
425
 
426
    list<IgnoredInventoryUpdateItems> getIgnoredWarehouseidsAndItemids();
427
 
428
    bool insertItemtoIgnoreInventoryUpdatelist(1:i64 item_id,2:i64 warehouse_id);
429
 
430
    bool deleteItemFromIgnoredInventoryUpdateList(1:i64 item_id,2:i64 warehouse_id);
431
 
432
    i32 getAllIgnoredInventoryupdateItemsCount();
433
 
434
    list<i64> getIgnoredInventoryUpdateItemids(1:i32 offset,2:i32 limit);
435
 
6821 amar.kumar 436
    void updateItemStockPurchaseParams(1:i64 item_id, 2:i32 numOfDaysStock, 3:i64 minStockLevel);
437
 
438
    ItemStockPurchaseParams getItemStockPurchaseParams(1:i64 itemId);
439
 
440
    void addOosStatusForItem(1:map<i64, bool> oosStatusMap, 2: i64 date);
6832 amar.kumar 441
 
9665 rajveer 442
    list<OOSStatus> getOosStatusesForXDaysForItem(1:i64 itemId, 2:i32 sourceId, 3:i32 days);
6857 amar.kumar 443
 
10126 amar.kumar 444
    list<OOSStatus> getOosStatusesForXDays(1:i32 sourceId, 2:i32 days);
445
 
446
    list<VendorItemPricing> getAllVendorItemPricing(1:i64 itemId, 2:i64 vendorId);
447
 
6857 amar.kumar 448
    list<ItemStockPurchaseParams> getNonZeroItemStockPurchaseParams();
7149 amar.kumar 449
 
450
    /**
451
	Returns a list of inventory stock for items for which there are pending orders or have billable inventory.
452
	*/
453
	list<AvailableAndReservedStock> getBillableInventoryAndPendingOrders();
7281 kshitij.so 454
 
455
	string getWarehouseName(1:i64 warehouse_id);
456
 
457
	AmazonInventorySnapshot getAmazonInventoryForItem(1:i64 item_id);
458
 
459
	list<AmazonInventorySnapshot> getAllAmazonInventory();
460
 
10450 vikram.rag 461
	void addOrUpdateAmazonInventoryForItem(1:AmazonInventorySnapshot amazonInventorySnapshot,2:i64 time);
7281 kshitij.so 462
 
7972 amar.kumar 463
	string getLastNdaySaleForItem(1:i64 itemId, 2:i64 numberOfDays);
464
 
8282 kshitij.so 465
	void addOrUpdateAmazonFbaInventory(1:AmazonFbaInventorySnapshot amazonfbainventorysnapshot);
9482 vikram.rag 466
 
9762 amar.kumar 467
	void addUpdateHoldInventory(1:i64 itemId, 2:i64 warehouseId, 3:i64 holdQuantity, 4:i64 source)  throws (1:InventoryServiceException cex);
8182 amar.kumar 468
 
11173 vikram.rag 469
	list<AmazonFbaInventorySnapshot> getAmazonFbaItemInventory(1:i64 itemId);
8282 kshitij.so 470
 
9404 vikram.rag 471
	list<AmazonFbaInventorySnapshot> getAllAmazonFbaItemInventory();
8282 kshitij.so 472
 
9404 vikram.rag 473
	list<i64> getOursGoodWarehouseIdsForLocation(1:i64 state_id);
8363 vikram.rag 474
 
9404 vikram.rag 475
	i64 getHoldInventoryDetailForItemForWarehouseIdExceptSource(1:i64 id,2:i64 warehouse_id,3:i64 source);
8959 vikram.rag 476
 
9404 vikram.rag 477
	SnapdealInventoryItem getSnapdealInventoryForItem(1:i64 item_id);
478
 
479
	void addOrUpdateSnapdealInventoryForItem(1:SnapdealInventoryItem snapdealinventoryitem)
480
 
481
	double getNlcForWarehouse(1:i64 warehouse_id,2:i64 item_id)
482
 
9640 amar.kumar 483
	map<i32, i64> getHeldInventoryMapForItem(1:i64 item_id, 2:i64 warehouse_id)
484
 
9495 vikram.rag 485
	void addOrUpdateAllAmazonFbaInventory(list<AmazonFbaInventorySnapshot> allamazonfbainventorysnapshot)
9456 vikram.rag 486
 
9495 vikram.rag 487
	void addOrUpdateAllSnapdealInventory(list<SnapdealInventoryItem> allsnapdealinventorysnapshot)
9482 vikram.rag 488
 
9495 vikram.rag 489
	list<SnapdealInventoryItem> getSnapdealInventorySnapshot()
490
 
9761 amar.kumar 491
	list<HoldInventoryDetail> getHoldInventoryDetails(1:i64 itemId, 2:i64 warehouseId, 3:i64 source)
492
 
10450 vikram.rag 493
	void addOrUpdateFlipkartInventorySnapshot(1:list<FlipkartInventorySnapshot> flipkartInventorySnapshot,2:i64 time)
10050 vikram.rag 494
 
495
	list<FlipkartInventorySnapshot> getFlipkartInventorySnapshot()
496
 
10097 kshitij.so 497
	FlipkartInventorySnapshot getFlipkartlInventoryForItem(1:i64 item_id)
498
 
12280 amit.gupta 499
	map<i64,StateInfo> getStateMaster()
10485 vikram.rag 500
 
10547 vikram.rag 501
	void updateSnapdealStockAtEOD(list<SnapdealStockAtEOD> allsnapdealstock)
502
 
503
	void updateFlipkartStockAtEOD(list<FlipkartStockAtEOD> allflipkartstock)
504
 
12363 kshitij.so 505
	double getWanNlcForSource(1:i64 item_id,2:i64 source)
506
 
507
	list<AmazonFbaInventorySnapshot> getAllAvailableAmazonFbaItemInventory();
508
 
17990 kshitij.so 509
	bool updateItemAvailabilityForItemIds(1:list<i64> itemIds)
510
 
19247 kshitij.so 511
	list<i64> addVendorItemPricingInBulk(1:list<VendorItemPricing> vendorItemPricingList)
512
 
513
	void addInventoryInBulk (1:list<BulkAddInventory> bulkInventoryList) throws (1:InventoryServiceException cex);
19413 amit.gupta 514
 
515
	list<ItemLocationAvailability> getItemLocationAvailabilityCache(1:list<ItemLocationAvailability> itemLocations)
516
	list<ItemLocationAvailability> getItemLocationAvailabilityCacheByItemId(1:list<i64> itemIds)
517
	string getItemPincodeAvailability(1:list<i64> itemIds, 2:string pincode)
518
 
12363 kshitij.so 519
}