| 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 |
*/
|
| 5978 |
rajveer |
146 |
list<i64> getItemAvailabilityAtLocation(1:i64 itemId, 2:i64 sourceId) throws (1:InventoryServiceException isex),
|
| 5945 |
mandeep.dh |
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 |
/**
|
| 5966 |
rajveer |
157 |
Depending on reservation in the table, verify if we can bill this order or not.
|
|
|
158 |
*/
|
|
|
159 |
bool isOrderBillable(1:i64 itemId, 2:i64 warehouseId, 3:i64 sourceId, 4:i64 orderId),
|
|
|
160 |
|
|
|
161 |
/**
|
| 5945 |
mandeep.dh |
162 |
Increases the reservation count for an item in a warehouse. Should always succeed normally.
|
|
|
163 |
*/
|
| 5966 |
rajveer |
164 |
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 |
165 |
|
|
|
166 |
/**
|
|
|
167 |
Decreases the reservation count for an item in a warehouse. Should always succeed normally.
|
|
|
168 |
*/
|
| 5966 |
rajveer |
169 |
bool reduceReservationCount(1:i64 itemId, 2:i64 warehouseId, 3:i64 sourceId, 4:i64 orderId, 5:double quantity) throws (1:InventoryServiceException cex),
|
| 5945 |
mandeep.dh |
170 |
|
|
|
171 |
/**
|
|
|
172 |
Returns the pricing information of an item associated with the vendor of the given warehouse.
|
|
|
173 |
Raises an exception if either the item, vendor or the associated pricing information can't be found.
|
|
|
174 |
*/
|
|
|
175 |
VendorItemPricing getItemPricing(1:i64 itemId, 2:i64 vendorId) throws (1:InventoryServiceException cex),
|
|
|
176 |
|
|
|
177 |
/**
|
|
|
178 |
Returns the list of vendor pricing information of an item.
|
|
|
179 |
Raises an exception if item not found corresponding to itemId
|
|
|
180 |
*/
|
|
|
181 |
list<VendorItemPricing> getAllItemPricing(1:i64 itemId) throws (1:InventoryServiceException cex),
|
|
|
182 |
|
|
|
183 |
|
|
|
184 |
/**
|
|
|
185 |
Adds vendor prices corresponding to the item. If pricing already exists then updates the prices.
|
|
|
186 |
Raises an exception if either the item or vendor can't be found corresponding to their ids.
|
|
|
187 |
*/
|
|
|
188 |
void addVendorItemPricing(1:VendorItemPricing vendorItemPricing) throws (1:InventoryServiceException cex),
|
|
|
189 |
|
|
|
190 |
/**
|
|
|
191 |
Returns a vendor given its id
|
|
|
192 |
*/
|
|
|
193 |
Vendor getVendor(1:i64 vendorId),
|
|
|
194 |
|
|
|
195 |
/**
|
|
|
196 |
Return list of all vendors
|
|
|
197 |
*/
|
|
|
198 |
list<Vendor> getAllVendors(),
|
|
|
199 |
|
|
|
200 |
/**
|
|
|
201 |
Adds VendorItemMapping. Updates VendorItemMapping if exists corresponding to the item key.
|
|
|
202 |
*/
|
|
|
203 |
void addVendorItemMapping(1:string key, 2:VendorItemMapping vendorItemMapping) throws (1:InventoryServiceException cex),
|
|
|
204 |
|
|
|
205 |
/**
|
|
|
206 |
Returns the list of vendor item mapping corresponding to itemId passed as parameter.
|
|
|
207 |
Raises an exception if item not found corresponding to itemId
|
|
|
208 |
*/
|
|
|
209 |
list<VendorItemMapping> getVendorItemMappings(1:i64 itemId) throws (1:InventoryServiceException cex),
|
|
|
210 |
|
|
|
211 |
/**
|
|
|
212 |
Returns a list of inventory stock for items for which there are pending orders for the given vendor.
|
|
|
213 |
*/
|
|
|
214 |
list<AvailableAndReservedStock> getPendingOrdersInventory(1:i64 vendorid),
|
|
|
215 |
|
|
|
216 |
/**
|
|
|
217 |
This method returns all warehouses for a given warehosueType, inventoryType, vendor, billingWarehouse and shippingWarehouse.
|
|
|
218 |
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
|
|
|
219 |
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
|
|
|
220 |
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
|
|
|
221 |
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
|
|
|
222 |
*/
|
|
|
223 |
list<Warehouse> getWarehouses(1:WarehouseType warehouseType, 2:InventoryType inventoryType, 3:i64 vendorId, 4:i64 billingWarehouseId, 5:i64 shippingWarehouseId);
|
|
|
224 |
|
|
|
225 |
/**
|
|
|
226 |
* Resets availability of an item to the quantity mentioned in a warehouse.
|
|
|
227 |
*/
|
|
|
228 |
void resetAvailability(1:string itemKey, 2:i64 vendorId, 3:i64 quantity, 4:i64 warehouseId) throws (1:InventoryServiceException cex);
|
|
|
229 |
|
|
|
230 |
/**
|
|
|
231 |
* Resets availability of a warehouse to zero.
|
|
|
232 |
*/
|
|
|
233 |
void resetAvailabilityForWarehouse(1:i64 warehouseId) throws (1:InventoryServiceException cex);
|
|
|
234 |
|
|
|
235 |
/**
|
|
|
236 |
* Returns the list of item keys which need to be processed for a given warehouse.
|
|
|
237 |
* This is currently used by Support application to send item keys whose inventory needs
|
|
|
238 |
* to be updated from PLB
|
|
|
239 |
*/
|
|
|
240 |
list<string> getItemKeysToBeProcessed(1:i64 warehouseId);
|
|
|
241 |
|
|
|
242 |
/**
|
|
|
243 |
* Marks/Deletes missed inventory updates for a given key and warehouse.
|
|
|
244 |
* This generally happens when updates from PLB are applied on the currentinventorysnapshot for an item
|
|
|
245 |
*/
|
|
|
246 |
void markMissedInventoryUpdatesAsProcessed(1:string itemKey, 2:i64 warehouseId);
|
|
|
247 |
|
|
|
248 |
/**
|
|
|
249 |
* Returns all the item key mappings that have been ignored until date. Value of map has the warehouse id
|
|
|
250 |
* and the timestamp from where alert was raised.
|
|
|
251 |
*/
|
|
|
252 |
map<string, map<i64, i64>> getIgnoredItemKeys();
|
|
|
253 |
|
|
|
254 |
/**
|
|
|
255 |
Add the BAD type inventory to existing stock.
|
|
|
256 |
*/
|
|
|
257 |
void addBadInventory(1:i64 itemId, 2:i64 warehouseId, 3:i64 quantity) throws (1:InventoryServiceException cex);
|
|
|
258 |
|
|
|
259 |
/**
|
|
|
260 |
Returns all shipping locations
|
|
|
261 |
*/
|
|
|
262 |
list<Warehouse> getShippingLocations();
|
|
|
263 |
|
|
|
264 |
/**
|
|
|
265 |
* Fetches all the vendor item mappings present.
|
|
|
266 |
*/
|
|
|
267 |
list<VendorItemMapping> getAllVendorItemMappings();
|
|
|
268 |
|
|
|
269 |
/**
|
|
|
270 |
* Gets items' inventory for a warehouse
|
|
|
271 |
* If warehouse is passed as zero, items' inventory across all warehouses is sent
|
|
|
272 |
*/
|
|
|
273 |
map<i64, ItemInventory> getInventorySnapshot(1:i64 warehouseId);
|
|
|
274 |
|
|
|
275 |
/**
|
|
|
276 |
* Clear item availability cache.
|
|
|
277 |
*/
|
|
|
278 |
void clearItemAvailabilityCache();
|
|
|
279 |
|
|
|
280 |
void updateVendorString(1:i64 warehouseId, 2:string vendorString);
|
|
|
281 |
}
|