| Line 371... |
Line 371... |
| 371 |
def print_rto_orders_report(filename, returned_orders):
|
371 |
def print_rto_orders_report(filename, returned_orders):
|
| 372 |
writer = csv.writer(open(filename, "wb"), delimiter=',', quoting=csv.QUOTE_NONE)
|
372 |
writer = csv.writer(open(filename, "wb"), delimiter=',', quoting=csv.QUOTE_NONE)
|
| 373 |
writer.writerow(['AWB No', 'Return date', 'Reason'])
|
373 |
writer.writerow(['AWB No', 'Return date', 'Reason'])
|
| 374 |
for awb, date_reason in returned_orders.iteritems():
|
374 |
for awb, date_reason in returned_orders.iteritems():
|
| 375 |
date, reason = date_reason.split('|')
|
375 |
date, reason = date_reason.split('|')
|
| - |
|
376 |
if reason is not None:
|
| - |
|
377 |
reason = reason.replace(","," ")
|
| 376 |
writer.writerow([awb, date, reason])
|
378 |
writer.writerow([awb, date, reason])
|
| 377 |
|
379 |
|
| 378 |
def print_undelivered_orders_report(filename, orders):
|
380 |
def print_undelivered_orders_report(filename, orders):
|
| 379 |
writer = csv.writer(open(filename, "wb"), delimiter=',', quoting=csv.QUOTE_NONE)
|
381 |
writer = csv.writer(open(filename, "wb"), delimiter=',', quoting=csv.QUOTE_NONE)
|
| 380 |
writer.writerow(['Order Id', 'AWB No', 'Status', 'Status Description', 'Shipping timestamp', 'Pickup timestamp'])
|
382 |
writer.writerow(['Order Id', 'AWB No', 'Status', 'Status Description', 'Shipping timestamp', 'Pickup timestamp'])
|
| 381 |
for order in orders:
|
383 |
for order in orders:
|
| - |
|
384 |
statusDescription = ''
|
| - |
|
385 |
if order.statusDescription is not None:
|
| - |
|
386 |
statusDescription = order.statusDescription.replace(","," ")
|
| 382 |
writer.writerow([order.id, order.airwaybill_no, order.status, order.statusDescription, to_py_date(order.shipping_timestamp), to_py_date(order.pickup_timestamp)])
|
387 |
writer.writerow([order.id, order.airwaybill_no, order.status, statusDescription, to_py_date(order.shipping_timestamp), to_py_date(order.pickup_timestamp)])
|
| 383 |
|
388 |
|
| 384 |
def get_py_datetime(datestring, timestring):
|
389 |
def get_py_datetime(datestring, timestring):
|
| 385 |
# This should be a command line argument.
|
390 |
# This should be a command line argument.
|
| 386 |
# Refer http://docs.python.org/library/time.html#time.strftime to
|
391 |
# Refer http://docs.python.org/library/time.html#time.strftime to
|
| 387 |
# get a complete list of format specifiers available for date time.
|
392 |
# get a complete list of format specifiers available for date time.
|
| Line 423... |
Line 428... |
| 423 |
|
428 |
|
| 424 |
provider = get_provider_by_name(options.provider)
|
429 |
provider = get_provider_by_name(options.provider)
|
| 425 |
|
430 |
|
| 426 |
if options.pickup_report:
|
431 |
if options.pickup_report:
|
| 427 |
process_pickup_records(provider)
|
432 |
process_pickup_records(provider)
|
| 428 |
process_dao_pickup_orders(provider)
|
433 |
#process_dao_pickup_orders(provider)
|
| 429 |
process_return_pickup_orders(provider)
|
434 |
#process_return_pickup_orders(provider)
|
| 430 |
if options.delivery_report:
|
435 |
if options.delivery_report:
|
| 431 |
process_delivery_report(provider)
|
436 |
process_delivery_report(provider)
|
| 432 |
|
437 |
|
| 433 |
if __name__ == '__main__':
|
438 |
if __name__ == '__main__':
|
| 434 |
main()
|
439 |
main()
|