Subversion Repositories SmartDukaan

Rev

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