Subversion Repositories SmartDukaan

Rev

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