Subversion Repositories SmartDukaan

Rev

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