| Line 110... |
Line 110... |
| 110 |
return self.get_logistics_estimation_with_type(itemId, destination_pin, type)
|
110 |
return self.get_logistics_estimation_with_type(itemId, destination_pin, type)
|
| 111 |
finally:
|
111 |
finally:
|
| 112 |
close_session()
|
112 |
close_session()
|
| 113 |
|
113 |
|
| 114 |
def get_logistics_estimation_with_type(self, itemId, destination_pin, type):
|
114 |
def get_logistics_estimation_with_type(self, itemId, destination_pin, type):
|
| 115 |
if not destination_pin:
|
- |
|
| 116 |
destination_pin = self.default_pincode
|
- |
|
| 117 |
try:
|
115 |
try:
|
| - |
|
116 |
#Get the id and location of actual warehouse that'll be used to fulfil this order.
|
| 118 |
client = CatalogClient().get_client()
|
117 |
client = CatalogClient().get_client()
|
| 119 |
item = client.getItem(itemId)
|
118 |
fulfilmentWarehouseId, expected_delay, billingWarehouseId, sellingPrice = client.getItemAvailabilityAtLocation(itemId)
|
| 120 |
except Exception as ex:
|
119 |
except Exception as ex:
|
| 121 |
raise LogisticsServiceException(103, "Unable to fetch inventory information about this item.")
|
120 |
raise LogisticsServiceException(103, "Unable to fetch inventory information about this item.")
|
| 122 |
|
121 |
|
| 123 |
delivery_estimate = get_logistics_estimation(destination_pin, item.sellingPrice, None, type)
|
122 |
delivery_estimate = get_logistics_estimation(destination_pin, sellingPrice, None, type)
|
| 124 |
if delivery_estimate is None:
|
123 |
if delivery_estimate is None:
|
| 125 |
raise LogisticsServiceException(104, "Unable to fetch delivery estimate for this pincode.")
|
124 |
raise LogisticsServiceException(104, "Unable to fetch delivery estimate for this pincode.")
|
| 126 |
|
- |
|
| 127 |
warehouse_loc = delivery_estimate.warehouse_location
|
- |
|
| 128 |
try:
|
125 |
|
| 129 |
#Get the id and location of actual warehouse that'll be used to fulfil this order.
|
- |
|
| 130 |
warehouse_loc, fulfilmentWarehouseId, items_in_inventory, expected_delay, billingWarehouseId = client.getItemAvailabilityAtLocation(warehouse_loc, itemId)
|
- |
|
| 131 |
except Exception as ex:
|
- |
|
| 132 |
raise LogisticsServiceException(103, "Unable to fetch inventory information about this item.")
|
- |
|
| 133 |
|
- |
|
| 134 |
|
- |
|
| 135 |
|
126 |
|
| 136 |
## Commented below part as we have only Delhi as warehouse city. If we will add some more warehouses in different cities, this could be useful.
|
127 |
## Commented below part as we have only Delhi as warehouse city. If we will add some more warehouses in different cities, this could be useful.
|
| 137 |
# We are revising the estimates based on the actual warehouse that this order will be assigned to.
|
128 |
# We are revising the estimates based on the actual warehouse that this order will be assigned to.
|
| 138 |
# This warehouse may be located in a zone which is different from the one we allocated for this pincode.
|
129 |
# This warehouse may be located in a zone which is different from the one we allocated for this pincode.
|
| 139 |
#delivery_estimate = get_logistics_estimation(destination_pin, item.sellingPrice, warehouse_loc, type)
|
130 |
#delivery_estimate = get_logistics_estimation(destination_pin, item.sellingPrice, warehouse_loc, type)
|