Subversion Repositories SmartDukaan

Rev

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