| 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.get_by(airwaybill_no=awb)
|
263 |
order = Order.query.filter_by(airwaybill_no=awb, logistics_provider_id = provider_id).all()
|
| 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)
|
| 269 |
session.commit()
|
269 |
session.commit()
|
| 270 |
#FIXME: Add a check for shipping timestamp to be of yesterday
|
270 |
#FIXME: Add a check for shipping timestamp to be of yesterday
|
| - |
|
271 |
current_time = datetime.datetime.now()
|
| - |
|
272 |
to_datetime = datetime.datetime(current_time.year, current_time.month, current_time.day)
|
| - |
|
273 |
from_datetime = to_datetime - datetime.timedelta(1)
|
| 271 |
orders_not_picked_up = Order.query.filter_by(logistics_provider_id = provider_id, status=OrderStatus.SHIPPED_FROM_WH).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()
|
| 272 |
return orders_not_picked_up
|
275 |
return orders_not_picked_up
|
| 273 |
|
276 |
|
| - |
|
277 |
def mark_orders_as_delivered(provider_id, delivered_orders):
|
| - |
|
278 |
for awb, detail in delivered_orders.iteritems():
|
| - |
|
279 |
order = Order.query.filter_by(airwaybill_no=awb, logistics_provider_id = provider_id).all()
|
| - |
|
280 |
if order == None:
|
| - |
|
281 |
raise TransactionServiceException(103, "No order found for the awb:" + awb)
|
| - |
|
282 |
order.status = OrderStatus.DELIVERY_SUCCESS
|
| - |
|
283 |
order.statusDescription = "Order delivered"
|
| - |
|
284 |
order.delivery_timestamp, order.receiver = detail.split('|')
|
| - |
|
285 |
session.commit()
|
| - |
|
286 |
|
| 274 |
def get_alerts(order_id, all):
|
287 |
def get_alerts(order_id, all):
|
| 275 |
query = Alerts.query.filter_by(order_id=order_id)
|
288 |
query = Alerts.query.filter_by(order_id=order_id)
|
| 276 |
if not all:
|
289 |
if not all:
|
| 277 |
query = query.filter_by(valid=True)
|
290 |
query = query.filter_by(valid=True)
|
| 278 |
return query.all()
|
291 |
return query.all()
|