| Line 690... |
Line 690... |
| 690 |
__generate_return_advice(order, warehouse, provider, filename)
|
690 |
__generate_return_advice(order, warehouse, provider, filename)
|
| 691 |
mail(from_user, from_pwd, to_addr, subject, message, get_attachment_part(filename))
|
691 |
mail(from_user, from_pwd, to_addr, subject, message, get_attachment_part(filename))
|
| 692 |
order.pickupRequestNo = pickup_number
|
692 |
order.pickupRequestNo = pickup_number
|
| 693 |
order.status = OrderStatus.DOA_RETURN_AUTHORIZED
|
693 |
order.status = OrderStatus.DOA_RETURN_AUTHORIZED
|
| 694 |
order.statusDescription = "DOA pick up authorized"
|
694 |
order.statusDescription = "DOA pick up authorized"
|
| - |
|
695 |
order.doa_auth_timestamp = datetime.datetime.now()
|
| 695 |
session.commit()
|
696 |
session.commit()
|
| 696 |
return True
|
697 |
return True
|
| 697 |
except Exception as e:
|
698 |
except Exception as e:
|
| 698 |
print sys.exc_info()[0]
|
699 |
print sys.exc_info()[0]
|
| 699 |
return False
|
700 |
return False
|
| 700 |
finally:
|
701 |
finally:
|
| 701 |
if os.path.exists(filename):
|
702 |
if os.path.exists(filename):
|
| 702 |
os.remove(filename)
|
703 |
os.remove(filename)
|
| 703 |
|
704 |
|
| - |
|
705 |
def mark_doas_as_picked_up(provider_id, pickup_details):
|
| - |
|
706 |
for pickupNo, doa_pickup_timestamp in pickup_details.iteritems():
|
| - |
|
707 |
order = Order.query.filter_by(pickupRequestNo=pickupNo, logistics_provider_id = provider_id).first()
|
| - |
|
708 |
if order == None or order.status != OrderStatus.DOA_RETURN_AUTHORIZED:
|
| - |
|
709 |
#raise TransactionServiceException(102, "No order found for the awb: " + awb)
|
| - |
|
710 |
continue
|
| - |
|
711 |
order.status = OrderStatus.DOA_RETURN_IN_TRANSIT
|
| - |
|
712 |
order.statusDescription = "DOA picked up by Courier Company"
|
| - |
|
713 |
order.doa_pickup_timestamp = doa_pickup_timestamp
|
| - |
|
714 |
session.commit()
|
| - |
|
715 |
|
| - |
|
716 |
current_time = datetime.datetime.now()
|
| - |
|
717 |
to_datetime = datetime.datetime(current_time.year, current_time.month, current_time.day)
|
| - |
|
718 |
from_datetime = to_datetime - datetime.timedelta(2)
|
| - |
|
719 |
orders_not_picked_up = Order.query.filter_by(logistics_provider_id = provider_id).filter_by(status=OrderStatus.DOA_RETURN_AUTHORIZED).filter(Order.doa_auth_timestamp >= from_datetime).filter(Order.doa_auth_timestamp <= to_datetime).all()
|
| - |
|
720 |
return orders_not_picked_up
|
| - |
|
721 |
|
| 704 |
def receive_return(order_id):
|
722 |
def receive_return(order_id):
|
| 705 |
order = get_order(order_id)
|
723 |
order = get_order(order_id)
|
| 706 |
if order.status in [OrderStatus.DOA_RETURN_AUTHORIZED, OrderStatus.DOA_RETURN_IN_TRANSIT]:
|
724 |
if order.status in [OrderStatus.DOA_RETURN_AUTHORIZED, OrderStatus.DOA_RETURN_IN_TRANSIT]:
|
| 707 |
order.status = OrderStatus.DOA_RECEIVED
|
725 |
order.status = OrderStatus.DOA_RECEIVED
|
| 708 |
order.statusDescription = "DOA package received"
|
726 |
order.statusDescription = "DOA package received"
|
| - |
|
727 |
order.received_return_timestamp = datetime.datetime.now()
|
| 709 |
session.commit()
|
728 |
session.commit()
|
| 710 |
elif order.status == OrderStatus.SALES_RETURN_IN_TRANSIT :
|
729 |
elif order.status == OrderStatus.SALES_RETURN_IN_TRANSIT :
|
| 711 |
order.status = OrderStatus.SALES_RET_RECEIVED
|
730 |
order.status = OrderStatus.SALES_RET_RECEIVED
|
| 712 |
order.statusDescription = "Sales return received"
|
731 |
order.statusDescription = "Sales return received"
|
| - |
|
732 |
order.received_return_timestamp = datetime.datetime.now()
|
| 713 |
session.commit()
|
733 |
session.commit()
|
| 714 |
else:
|
734 |
else:
|
| 715 |
return False
|
735 |
return False
|
| 716 |
return True
|
736 |
return True
|
| 717 |
|
737 |
|
| Line 764... |
Line 784... |
| 764 |
order.statusDescription = "Order Reshipped"
|
784 |
order.statusDescription = "Order Reshipped"
|
| 765 |
session.commit()
|
785 |
session.commit()
|
| 766 |
else:
|
786 |
else:
|
| 767 |
raise TransactionServiceException(112, "This order can't be reshipped")
|
787 |
raise TransactionServiceException(112, "This order can't be reshipped")
|
| 768 |
|
788 |
|
| - |
|
789 |
order.reship_timestamp = datetime.datetime.now()
|
| 769 |
order.new_order_id = new_order.id
|
790 |
order.new_order_id = new_order.id
|
| 770 |
session.commit()
|
791 |
session.commit()
|
| 771 |
|
792 |
|
| 772 |
return new_order.id
|
793 |
return new_order.id
|
| 773 |
|
794 |
|
| Line 813... |
Line 834... |
| 813 |
order.status = status_transition[order.status]
|
834 |
order.status = status_transition[order.status]
|
| 814 |
order.statusDescription = "Refunded"
|
835 |
order.statusDescription = "Refunded"
|
| 815 |
else:
|
836 |
else:
|
| 816 |
raise TransactionServiceException(114, "This order can't be refunded")
|
837 |
raise TransactionServiceException(114, "This order can't be refunded")
|
| 817 |
|
838 |
|
| - |
|
839 |
order.refund_timestamp = datetime.datetime.now()
|
| 818 |
session.commit()
|
840 |
session.commit()
|
| 819 |
return True
|
841 |
return True
|
| 820 |
|
842 |
|
| 821 |
def __clone_order(order, should_copy_billing_info):
|
843 |
def __clone_order(order, should_copy_billing_info):
|
| 822 |
current_time = datetime.datetime.now()
|
844 |
current_time = datetime.datetime.now()
|