Subversion Repositories SmartDukaan

Rev

Rev 7808 | Rev 7972 | 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
 
6
enum WarehouseLocation {
7808 anupam.sin 7
	Delhi = 0,
8
	Mumbai = 1,
5945 mandeep.dh 9
	Bangalore = 2,
10
	Kolkata = 3
11
}
12
 
13
struct Vendor {
14
	1:i64 id,
15
	2:string name
16
}
17
 
18
enum BillingType {
19
	OURS = 0,
6725 rajveer 20
	EXTERNAL = 1,
21
	OURS_EXTERNAL = 2
5945 mandeep.dh 22
}
23
 
24
enum WarehouseType {
25
    OURS = 0,
7410 amar.kumar 26
    THIRD_PARTY = 1,
27
    OURS_THIRDPARTY = 2
5945 mandeep.dh 28
}
29
 
30
enum InventoryType {
31
    GOOD = 0,
32
    BAD = 1,
33
    VIRTUAL = 2
34
}
35
 
36
enum HolidayType {
37
	WEEKLY = 0,
38
	MONTHLY = 1,
39
	SPECIFIC = 2
40
}
41
 
42
/* 
43
Warehouse fields details
44
location: it is full address
45
vendorString: some key for the warehouse
46
*/
47
struct Warehouse {
48
	1:i64 id,
49
	2:string displayName,
50
	3:string location,
51
	5:i64 addedOn,
52
	6:i64 lastCheckedOn,
53
	7:string tinNumber,
54
	8:string pincode,
55
	9:string vendorString,
56
	10:WarehouseLocation logisticsLocation,
57
	12:BillingType billingType,
58
	13:WarehouseType warehouseType,
59
	14:InventoryType inventoryType,
60
	15:Vendor vendor,
61
	16:i64 shippingWarehouseId,
62
	17:i64 billingWarehouseId,
63
	18:bool isAvailabilityMonitored,
7330 amit.gupta 64
	19:i64 transferDelayInHours,
65
	20:i64 stateId
5945 mandeep.dh 66
}
67
 
68
/* */
69
struct ItemInventory{
70
	1:i64 id,
71
	2:map<i64,i64> availability,
72
	3:map<i64,i64> reserved
73
}
74
 
75
struct ItemInventoryHistory{
76
	1:i64 item_id,
77
	2:i64 warehouse_id,
78
	3:i64 timestamp,
79
	4:i64 availability
80
}
81
 
82
struct VendorItemPricing{
83
	1:i64 vendorId,
84
	2:i64 itemId,
85
	3:double transferPrice,
86
	4:double mop,
6747 amar.kumar 87
	5:double dealerPrice,
88
	6:double nlc
5945 mandeep.dh 89
}
90
 
91
struct VendorItemMapping{
92
	1:i64 vendorId,
93
	2:string itemKey,
94
	3:i64 itemId
95
}
96
 
97
struct AvailableAndReservedStock {
98
	1:i64 itemId,
99
	2:i64 available,
100
	3:i64 reserved,
101
	4:i64 minimumStock
102
}
103
 
6531 vikram.rag 104
struct IgnoredInventoryUpdateItems {
105
	1:i64 itemId,
106
	2:i64 warehouseId
6821 amar.kumar 107
}
108
 
109
struct ItemStockPurchaseParams{
110
	1:i64 item_id,
111
	2:i32 numOfDaysStock,
112
	3:i64 minStockLevel
113
}
114
 
5945 mandeep.dh 115
exception InventoryServiceException{
116
	1:i64 id,
117
	2:string message
118
}
119
 
6821 amar.kumar 120
struct OOSStatus {
121
	1:i64 item_id
122
	2:i64 date
123
	3:bool is_oos
124
	4:i64 num_orders
125
}
7281 kshitij.so 126
 
127
struct AmazonInventorySnapshot {
128
    1:i64 item_id
129
    2:i64 availability
130
    3:i64 reserved
131
} 
132
 
5945 mandeep.dh 133
service InventoryService extends GenericService.GenericService{
134
 
135
	i64 addWarehouse(1:Warehouse warehouse) throws (1:InventoryServiceException cex),
136
 
137
	/**
138
	add a new vendor
139
	*/
140
	i64 addVendor(1:Vendor vendor) throws (1:InventoryServiceException cex),
141
 
142
	/**
143
	Stores the incremental warehouse updates of items.
144
	*/
145
	void updateInventoryHistory(1:i64 warehouse_id, 2:string timestamp, 3:map<string, i64> availability) throws (1:InventoryServiceException cex),
146
 
147
	/**
148
	Stores the final inventory stocks of items.
149
	*/
150
	void updateInventory(1:i64 warehouse_id, 2:string timestamp, 3:map<string, i64> availability) throws (1:InventoryServiceException cex),
151
 
152
	/**
153
	Add the inventory to existing stock.
154
	*/
155
	void addInventory(1:i64 itemId, 2:i64 warehouseId, 3:i64 quantity) throws (1:InventoryServiceException cex),
156
 
157
	//all delete methods
158
	void retireWarehouse(1:i64 warehouse_id) throws (1:InventoryServiceException cex),
159
 
160
	ItemInventory getItemInventoryByItemId(1:i64 item_id) throws (1:InventoryServiceException cex),
161
	i64 getItemAvailibilityAtWarehouse(1:i64 warehouse_id, 2:i64 item_id) throws (1:InventoryServiceException cex),
162
 
163
	/**
164
	Determines the warehouse that should be used to fulfil an order for the given item.
165
	It first checks all the warehouses which are in the logistics location given by the
166
	warehouse_loc parameter. If none of the warehouses there have any inventory, then the
167
	preferred warehouse for the item is used. 
168
 
169
	Returns an ordered list of size 4 with following elements in the given order:
170
	1. Id of the fulfillment warehouse which was finally picked up.
171
	2. Expected delay added by the category manager.
172
	3. Id of the billing warehouse which was finally picked up.
173
	 */
5978 rajveer 174
	list<i64> getItemAvailabilityAtLocation(1:i64 itemId, 2:i64 sourceId) throws (1:InventoryServiceException isex),
5945 mandeep.dh 175
 
176
	list<Warehouse> getAllWarehouses(1:bool isActive) throws (1:InventoryServiceException cex),
177
 
178
	/**
179
	 Returns the warehouse with the given id.
180
	*/
181
	Warehouse getWarehouse(1:i64 warehouse_id) throws (1:InventoryServiceException cex),
182
	list<i64> getAllItemsForWarehouse(1:i64 warehouse_id) throws (1:InventoryServiceException cex),
183
 
184
	/**
5966 rajveer 185
	Depending on reservation in the table, verify if we can bill this order or not.
186
	*/
187
	bool isOrderBillable(1:i64 itemId, 2:i64 warehouseId, 3:i64 sourceId, 4:i64 orderId),
188
 
189
	/**
5945 mandeep.dh 190
	 Increases the reservation count for an item in a warehouse. Should always succeed normally.
191
	*/
5966 rajveer 192
	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 193
 
194
	/**
7968 amar.kumar 195
	 Updates the reservation for Order
196
	*/
197
	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),
198
 
199
	/**
5945 mandeep.dh 200
	 Decreases the reservation count for an item in a warehouse. Should always succeed normally.
201
	*/
5966 rajveer 202
	bool reduceReservationCount(1:i64 itemId, 2:i64 warehouseId, 3:i64 sourceId, 4:i64 orderId, 5:double quantity) throws (1:InventoryServiceException cex),
5945 mandeep.dh 203
 
204
	/**
205
	Returns the pricing information of an item associated with the vendor of the given warehouse.
206
	Raises an exception if either the item, vendor or the associated pricing information can't be found.
207
	*/
208
	VendorItemPricing getItemPricing(1:i64 itemId, 2:i64 vendorId) throws (1:InventoryServiceException cex),
209
 
210
	/**
211
	Returns the list of vendor pricing information of an item.
212
	Raises an exception if item not found corresponding to itemId
213
	*/
214
	list<VendorItemPricing> getAllItemPricing(1:i64 itemId) throws (1:InventoryServiceException cex),
215
 
216
 
217
	/**
218
	Adds vendor prices corresponding to the item. If pricing already exists then updates the prices. 
219
	Raises an exception if either the item or vendor can't be found corresponding to their ids.
220
	*/
221
	void addVendorItemPricing(1:VendorItemPricing vendorItemPricing) throws (1:InventoryServiceException cex),
222
 
223
	/**
224
	Returns a vendor given its id
225
	*/
226
	Vendor getVendor(1:i64 vendorId), 
227
 
228
    /**
229
    Return list of all vendors
230
    */
231
    list<Vendor> getAllVendors(), 
232
 
233
	/**
234
	Adds VendorItemMapping. Updates VendorItemMapping if exists corresponding to the item key.  
235
	*/
236
	void addVendorItemMapping(1:string key, 2:VendorItemMapping vendorItemMapping) throws (1:InventoryServiceException cex),
237
 
238
	/**
239
	Returns the list of vendor item mapping corresponding to itemId passed as parameter.
240
	Raises an exception if item not found corresponding to itemId
241
	*/
242
	list<VendorItemMapping> getVendorItemMappings(1:i64 itemId) throws (1:InventoryServiceException cex),
243
 
244
	/**
245
	Returns a list of inventory stock for items for which there are pending orders for the given vendor.
246
	*/
247
	list<AvailableAndReservedStock> getPendingOrdersInventory(1:i64 vendorid),
248
 
249
	/**
250
	 This method returns all warehouses for a given warehosueType, inventoryType, vendor, billingWarehouse and shippingWarehouse.
251
	 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
252
	 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
253
     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
254
     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
255
	 */
256
	list<Warehouse> getWarehouses(1:WarehouseType warehouseType, 2:InventoryType inventoryType, 3:i64 vendorId, 4:i64 billingWarehouseId, 5:i64 shippingWarehouseId);
257
 
258
    /**
259
     * Resets availability of an item to the quantity mentioned in a warehouse.
260
     */
261
    void resetAvailability(1:string itemKey, 2:i64 vendorId, 3:i64 quantity, 4:i64 warehouseId) throws (1:InventoryServiceException cex);
262
 
263
    /**
264
     * Resets availability of a warehouse to zero.
265
     */
266
    void resetAvailabilityForWarehouse(1:i64 warehouseId) throws (1:InventoryServiceException cex);
267
 
268
    /**
269
     * Returns the list of item keys which need to be processed for a given warehouse.
270
     * This is currently used by Support application to send item keys whose inventory needs 
271
     * to be updated from PLB
272
     */
273
    list<string> getItemKeysToBeProcessed(1:i64 warehouseId);
274
 
275
    /**
276
     * Marks/Deletes missed inventory updates for a given key and warehouse.
277
     * This generally happens when updates from PLB are applied on the currentinventorysnapshot for an item
278
     */
279
    void markMissedInventoryUpdatesAsProcessed(1:string itemKey, 2:i64 warehouseId);
280
 
281
    /**
282
     * Returns all the item key mappings that have been ignored until date. Value of map has the warehouse id
283
     * and the timestamp from where alert was raised.
284
     */
285
    map<string, map<i64, i64>> getIgnoredItemKeys();
286
 
287
    /**
288
    Add the BAD type inventory to existing stock.
289
    */
290
    void addBadInventory(1:i64 itemId, 2:i64 warehouseId, 3:i64 quantity) throws (1:InventoryServiceException cex);
291
 
292
    /**
293
    Returns all shipping locations
294
    */    
295
    list<Warehouse> getShippingLocations();
296
 
297
    /**
298
     * Fetches all the vendor item mappings present.
299
     */    
300
    list<VendorItemMapping> getAllVendorItemMappings();
301
 
302
    /**
303
     * Gets items' inventory for a warehouse
304
     * If warehouse is passed as zero, items' inventory across all warehouses is sent
305
     */
306
    map<i64, ItemInventory> getInventorySnapshot(1:i64 warehouseId);
307
 
308
    /**
309
    * Clear item availability cache.
310
    */
311
    void clearItemAvailabilityCache();
312
 
313
    void updateVendorString(1:i64 warehouseId, 2:string vendorString);
6096 amit.gupta 314
 
315
    void clearItemAvailabilityCacheForItem(1:i64 item_id);
6467 amar.kumar 316
 
7718 amar.kumar 317
    i64 getOurWarehouseIdForVendor(1:i64 vendorId, 2:i64 billingWarehouseId);
6484 amar.kumar 318
 
319
    map<i64, i64> getItemAvailabilitiesAtOurWarehouses(1:list<i64> item_ids);
6531 vikram.rag 320
 
321
    list<i64> getMonitoredWarehouseForVendors(1:list<i64> vendorIds);
322
 
323
    list<IgnoredInventoryUpdateItems> getIgnoredWarehouseidsAndItemids();
324
 
325
    bool insertItemtoIgnoreInventoryUpdatelist(1:i64 item_id,2:i64 warehouse_id);
326
 
327
    bool deleteItemFromIgnoredInventoryUpdateList(1:i64 item_id,2:i64 warehouse_id);
328
 
329
    i32 getAllIgnoredInventoryupdateItemsCount();
330
 
331
    list<i64> getIgnoredInventoryUpdateItemids(1:i32 offset,2:i32 limit);
332
 
6821 amar.kumar 333
    void updateItemStockPurchaseParams(1:i64 item_id, 2:i32 numOfDaysStock, 3:i64 minStockLevel);
334
 
335
    ItemStockPurchaseParams getItemStockPurchaseParams(1:i64 itemId);
336
 
337
    void addOosStatusForItem(1:map<i64, bool> oosStatusMap, 2: i64 date);
6832 amar.kumar 338
 
339
    list<OOSStatus> getOosStatusesForXDaysForItem(1:i64 itemId, 2:i32 days);
6857 amar.kumar 340
 
341
    list<ItemStockPurchaseParams> getNonZeroItemStockPurchaseParams();
7149 amar.kumar 342
 
343
    /**
344
	Returns a list of inventory stock for items for which there are pending orders or have billable inventory.
345
	*/
346
	list<AvailableAndReservedStock> getBillableInventoryAndPendingOrders();
7281 kshitij.so 347
 
348
	string getWarehouseName(1:i64 warehouse_id);
349
 
350
	AmazonInventorySnapshot getAmazonInventoryForItem(1:i64 item_id);
351
 
352
	list<AmazonInventorySnapshot> getAllAmazonInventory();
353
 
354
	void addOrUpdateAmazonInventoryForItem(1:AmazonInventorySnapshot amazonInventorySnapshot);
355
 
5945 mandeep.dh 356
}