Subversion Repositories SmartDukaan

Rev

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