| Line 53... |
Line 53... |
| 53 |
warehouse_location = WarehouseAllocation.get_by(pincode = destination_pin).primary_warehouse_location
|
53 |
warehouse_location = WarehouseAllocation.get_by(pincode = destination_pin).primary_warehouse_location
|
| 54 |
except:
|
54 |
except:
|
| 55 |
print "Unexpected error:", sys.exc_info()[0]
|
55 |
print "Unexpected error:", sys.exc_info()[0]
|
| 56 |
raise LogisticsServiceException(101, "No Warehouse locations assigned to this pincode: " + destination_pin)
|
56 |
raise LogisticsServiceException(101, "No Warehouse locations assigned to this pincode: " + destination_pin)
|
| 57 |
|
57 |
|
| 58 |
try:
|
- |
|
| 59 |
sld = ServiceableLocationDetails.get_by(dest_pincode = destination_pin)
|
58 |
provider = __get_logistics_provider_for_destination_pincode(type, destination_pin)
|
| 60 |
if type == DeliveryType.PREPAID and sld.exp:
|
- |
|
| 61 |
provider = sld.provider
|
- |
|
| 62 |
if type == DeliveryType.COD and sld.cod:
|
- |
|
| 63 |
provider = sld.provider
|
- |
|
| 64 |
except Exception as ex:
|
- |
|
| 65 |
print "Unexpected error:", sys.exc_info()[0]
|
- |
|
| 66 |
|
59 |
|
| 67 |
if not provider:
|
60 |
if not provider:
|
| 68 |
raise LogisticsServiceException(101, "No provider assigned for pincode: " + str(destination_pin) + \
|
61 |
raise LogisticsServiceException(101, "No provider assigned for pincode: " + str(destination_pin) + \
|
| 69 |
", and warehouse location: " + str(warehouse_location))
|
62 |
", and warehouse location: " + str(warehouse_location))
|
| 70 |
|
63 |
|
| Line 87... |
Line 80... |
| 87 |
try:
|
80 |
try:
|
| 88 |
return query.first()
|
81 |
return query.first()
|
| 89 |
except Exception as ex:
|
82 |
except Exception as ex:
|
| 90 |
print ex
|
83 |
print ex
|
| 91 |
raise LogisticsServiceException(103, "No Logistics partner listed for this destination pincode and the primary warehouse")
|
84 |
raise LogisticsServiceException(103, "No Logistics partner listed for this destination pincode and the primary warehouse")
|
| - |
|
85 |
|
| - |
|
86 |
'''
|
| - |
|
87 |
Cache the return values of the function for one day
|
| - |
|
88 |
'''
|
| - |
|
89 |
@memoized(86400)
|
| - |
|
90 |
def __get_logistics_provider_for_destination_pincode(type, destination_pin):
|
| - |
|
91 |
try:
|
| - |
|
92 |
sld = ServiceableLocationDetails.get_by(dest_pincode = destination_pin)
|
| - |
|
93 |
if type == DeliveryType.PREPAID and sld.exp:
|
| - |
|
94 |
provider = sld.provider
|
| - |
|
95 |
if type == DeliveryType.COD and sld.cod:
|
| - |
|
96 |
provider = sld.provider
|
| - |
|
97 |
except Exception as ex:
|
| - |
|
98 |
print "Unexpected error:", sys.exc_info()[0]
|
| - |
|
99 |
return provider
|
| 92 |
|
100 |
|
| 93 |
def add_empty_AWBs(numbers, provider_id, type):
|
101 |
def add_empty_AWBs(numbers, provider_id, type):
|
| 94 |
for number in numbers:
|
102 |
for number in numbers:
|
| 95 |
query = Awb.query.filter_by(awb_number = number, provider_id = provider_id)
|
103 |
query = Awb.query.filter_by(awb_number = number, provider_id = provider_id)
|
| 96 |
try:
|
104 |
try:
|