| Line 136... |
Line 136... |
| 136 |
if delivery_estimate is None:
|
136 |
if delivery_estimate is None:
|
| 137 |
raise LogisticsServiceException(104, "Unable to fetch delivery estimate for this pincode.")
|
137 |
raise LogisticsServiceException(104, "Unable to fetch delivery estimate for this pincode.")
|
| 138 |
|
138 |
|
| 139 |
warehouse_loc = delivery_estimate.warehouse_location
|
139 |
warehouse_loc = delivery_estimate.warehouse_location
|
| 140 |
try:
|
140 |
try:
|
| 141 |
#Get the id and location of actual warehouse that'll be used to fulfill this order.
|
141 |
#Get the id and location of actual warehouse that'll be used to fulfil this order.
|
| 142 |
warehouse_loc, warehouse_id, items_in_inventory = client.getItemAvailabilityAtLocation(warehouse_loc, itemId)
|
142 |
warehouse_loc, warehouse_id, items_in_inventory, expected_delay = client.getItemAvailabilityAtLocation(warehouse_loc, itemId)
|
| 143 |
except Exception as ex:
|
143 |
except Exception as ex:
|
| 144 |
raise LogisticsServiceException(103, "Unable to fetch inventory information about this item.")
|
144 |
raise LogisticsServiceException(103, "Unable to fetch inventory information about this item.")
|
| 145 |
|
145 |
|
| 146 |
# We are revising the estimated based on the actual warehouse that will be assigned to this order.
|
146 |
# We are revising the estimated based on the actual warehouse that will be assigned to this order.
|
| 147 |
# This warehouse may be located in a different zone that the one we allocated for this pincode.
|
147 |
# This warehouse may be located in a different zone that the one we allocated for this pincode.
|
| Line 149... |
Line 149... |
| 149 |
if delivery_estimate is None:
|
149 |
if delivery_estimate is None:
|
| 150 |
raise LogisticsServiceException(105, "Unable to fetch delivery estimate for pincode: " + destination_pin + " and revised location: " + str(warehouse_loc))
|
150 |
raise LogisticsServiceException(105, "Unable to fetch delivery estimate for pincode: " + destination_pin + " and revised location: " + str(warehouse_loc))
|
| 151 |
|
151 |
|
| 152 |
delivery_time = 24*delivery_estimate.delivery_time
|
152 |
delivery_time = 24*delivery_estimate.delivery_time
|
| 153 |
|
153 |
|
| - |
|
154 |
#Always add the expected delay
|
| - |
|
155 |
delivery_time = delivery_time + 24*expected_delay
|
| - |
|
156 |
|
| 154 |
# Increase the estimate if the actual stock is less than the threshold
|
157 |
# Increase the estimate if the actual stock is less than the threshold
|
| 155 |
if items_in_inventory < self.stock_threshold :
|
158 |
if items_in_inventory < self.stock_threshold :
|
| 156 |
delivery_time = delivery_time + self.time_to_procure
|
159 |
delivery_time = delivery_time + self.time_to_procure
|
| 157 |
|
160 |
|
| 158 |
#Further increase the estimate if it's late in the day
|
161 |
#Further increase the estimate if it's late in the day
|