Subversion Repositories SmartDukaan

Rev

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