| Line 258... |
Line 258... |
| 258 |
except:
|
258 |
except:
|
| 259 |
return False
|
259 |
return False
|
| 260 |
|
260 |
|
| 261 |
def mark_orders_as_picked_up(provider_id, pickup_details):
|
261 |
def mark_orders_as_picked_up(provider_id, pickup_details):
|
| 262 |
for awb, pickup_timestamp in pickup_details.iteritems():
|
262 |
for awb, pickup_timestamp in pickup_details.iteritems():
|
| 263 |
order = Order.query.filter_by(airwaybill_no=awb, logistics_provider_id = provider_id).all()
|
263 |
order = Order.query.filter_by(airwaybill_no=awb, logistics_provider_id = provider_id).first()
|
| 264 |
if order == None:
|
264 |
if order == None:
|
| 265 |
raise TransactionServiceException(102, "No order found for the awb: " + awb)
|
265 |
raise TransactionServiceException(102, "No order found for the awb: " + awb)
|
| 266 |
order.status = OrderStatus.SHIPPED_TO_LOGST
|
266 |
order.status = OrderStatus.SHIPPED_TO_LOGST
|
| 267 |
order.statusDescription = "Order picked up by Courier Company"
|
267 |
order.statusDescription = "Order picked up by Courier Company"
|
| 268 |
order.pickup_timestamp = to_py_date(pickup_timestamp)
|
268 |
order.pickup_timestamp = to_py_date(pickup_timestamp)
|
| Line 274... |
Line 274... |
| 274 |
orders_not_picked_up = Order.query.filter_by(logistics_provider_id = provider_id).filter_by(status=OrderStatus.SHIPPED_FROM_WH).filter(Order.shipping_timestamp >= from_datetime).filter(Order.shipping_timestamp <= to_datetime).all()
|
274 |
orders_not_picked_up = Order.query.filter_by(logistics_provider_id = provider_id).filter_by(status=OrderStatus.SHIPPED_FROM_WH).filter(Order.shipping_timestamp >= from_datetime).filter(Order.shipping_timestamp <= to_datetime).all()
|
| 275 |
return orders_not_picked_up
|
275 |
return orders_not_picked_up
|
| 276 |
|
276 |
|
| 277 |
def mark_orders_as_delivered(provider_id, delivered_orders):
|
277 |
def mark_orders_as_delivered(provider_id, delivered_orders):
|
| 278 |
for awb, detail in delivered_orders.iteritems():
|
278 |
for awb, detail in delivered_orders.iteritems():
|
| 279 |
order = Order.query.filter_by(airwaybill_no=awb, logistics_provider_id = provider_id).all()
|
279 |
order = Order.query.filter_by(airwaybill_no=awb, logistics_provider_id = provider_id).first()
|
| 280 |
if order == None:
|
280 |
if order == None:
|
| 281 |
raise TransactionServiceException(103, "No order found for the awb:" + awb)
|
281 |
raise TransactionServiceException(103, "No order found for the awb:" + awb)
|
| 282 |
order.status = OrderStatus.DELIVERY_SUCCESS
|
282 |
order.status = OrderStatus.DELIVERY_SUCCESS
|
| 283 |
order.statusDescription = "Order delivered"
|
283 |
order.statusDescription = "Order delivered"
|
| 284 |
order.delivery_timestamp, order.receiver = detail.split('|')
|
284 |
order.delivery_timestamp, order.receiver = detail.split('|')
|
| 285 |
session.commit()
|
285 |
session.commit()
|
| 286 |
|
286 |
|
| - |
|
287 |
def mark_orders_as_failed(provider_id, returned_orders):
|
| - |
|
288 |
for awb, detail in returned_orders.iteritems():
|
| - |
|
289 |
order = Order.query.filter_by(airwaybill_no=awb, logistics_provider_id = provider_id).first()
|
| - |
|
290 |
if order == None:
|
| - |
|
291 |
raise TransactionServiceException(103, "No order found for the awb:" + awb)
|
| - |
|
292 |
order.status = OrderStatus.FAILED
|
| - |
|
293 |
order.delivery_timestamp, reason = detail.split('|')
|
| - |
|
294 |
order.statusDescription = "Order Returned to Origin:" + reason
|
| - |
|
295 |
session.commit()
|
| - |
|
296 |
|
| 287 |
def get_alerts(order_id, all):
|
297 |
def get_alerts(order_id, all):
|
| 288 |
query = Alerts.query.filter_by(order_id=order_id)
|
298 |
query = Alerts.query.filter_by(order_id=order_id)
|
| 289 |
if not all:
|
299 |
if not all:
|
| 290 |
query = query.filter_by(valid=True)
|
300 |
query = query.filter_by(valid=True)
|
| 291 |
return query.all()
|
301 |
return query.all()
|