Subversion Repositories SmartDukaan

Rev

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