| Line 15... |
Line 15... |
| 15 |
def initialize():
|
15 |
def initialize():
|
| 16 |
log_entry("initialize@DataAccessor", "Initializing data service")
|
16 |
log_entry("initialize@DataAccessor", "Initializing data service")
|
| 17 |
DataService.initialize()
|
17 |
DataService.initialize()
|
| 18 |
|
18 |
|
| 19 |
def get_provider(provider_id):
|
19 |
def get_provider(provider_id):
|
| 20 |
return Provider.get_by(id=provider_id)
|
20 |
provider = Provider.get_by(id=provider_id)
|
| - |
|
21 |
return provider
|
| 21 |
|
22 |
|
| 22 |
def get_providers():
|
23 |
def get_providers():
|
| 23 |
return Provider.query.all()
|
24 |
providers = Provider.query.all()
|
| - |
|
25 |
return providers
|
| 24 |
|
26 |
|
| 25 |
def get_logistics_estimation(destination_pin):
|
27 |
def get_logistics_estimation(destination_pin):
|
| 26 |
try:
|
28 |
try:
|
| 27 |
warehouse_location = WarehouseAllocation.get_by(pincode = destination_pin).primary_warehouse_location
|
29 |
warehouse_location = WarehouseAllocation.get_by(pincode = destination_pin).primary_warehouse_location
|
| 28 |
except:
|
30 |
except:
|
| 29 |
raise LogisticsServiceException(101, "No Warehouse assigned to this pincode.")
|
31 |
raise LogisticsServiceException(101, "No Warehouse assigned to this pincode.")
|
| 30 |
|
32 |
|
| 31 |
query = DeliveryEstimate.query.filter_by(warehouse_location = warehouse_location)
|
33 |
query = DeliveryEstimate.query.filter_by(warehouse_location = warehouse_location)
|
| 32 |
query = query.filter_by(destination_pin = destination_pin)
|
34 |
query = query.filter_by(destination_pin = destination_pin)
|
| 33 |
query = query.order_by(DeliveryEstimate.delivery_time)
|
35 |
query = query.order_by(DeliveryEstimate.delivery_time)
|
| 34 |
try:
|
36 |
try:
|
| 35 |
return query.first()
|
37 |
return query.first()
|
| 36 |
except:
|
38 |
except:
|
| 37 |
raise LogisticsServiceException(103, "No Logistics partner listed for this destination pincode and the primary warehouse")
|
39 |
raise LogisticsServiceException(103, "No Logistics partner listed for this destination pincode and the primary warehouse")
|
| 38 |
|
40 |
|
| 39 |
def add_empty_AWBs(numbers, provider_id, type):
|
41 |
def add_empty_AWBs(numbers, provider_id, type):
|
| 40 |
for number in numbers:
|
42 |
for number in numbers:
|
| 41 |
query = Awb.query.filter_by(awb_number = number, provider_id = provider_id)
|
43 |
query = Awb.query.filter_by(awb_number = number, provider_id = provider_id)
|
| 42 |
try:
|
44 |
try:
|
| 43 |
query.one()
|
45 |
query.one()
|
| Line 66... |
Line 68... |
| 66 |
raise LogisticsServiceException(103, "Unable to get an AWB for the given Provider: " + str(provider_id))
|
68 |
raise LogisticsServiceException(103, "Unable to get an AWB for the given Provider: " + str(provider_id))
|
| 67 |
|
69 |
|
| 68 |
def get_shipment_info(awb_number, provider_id):
|
70 |
def get_shipment_info(awb_number, provider_id):
|
| 69 |
awb = Awb.get_by(awb_number = awb_number, provider_id = provider_id)
|
71 |
awb = Awb.get_by(awb_number = awb_number, provider_id = provider_id)
|
| 70 |
query = AwbUpdate.query.filter_by(awb = awb)
|
72 |
query = AwbUpdate.query.filter_by(awb = awb)
|
| 71 |
return query.all()
|
- |
|
| 72 |
|
73 |
info = query.all()
|
| - |
|
74 |
return info
|
| - |
|
75 |
|
| - |
|
76 |
def close_session():
|
| - |
|
77 |
if session.is_active:
|
| - |
|
78 |
print "session is active. closing it."
|
| - |
|
79 |
session.close()
|
| - |
|
80 |
|
| 73 |
|
81 |
|