Subversion Repositories SmartDukaan

Rev

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