| Line 933... |
Line 933... |
| 933 |
Parameters:
|
933 |
Parameters:
|
| 934 |
- order_id
|
934 |
- order_id
|
| 935 |
- refunded_by
|
935 |
- refunded_by
|
| 936 |
- reason
|
936 |
- reason
|
| 937 |
"""
|
937 |
"""
|
| 938 |
status_transition = {OrderStatus.SALES_RET_RECEIVED : OrderStatus.SALES_RET_REFUNDED,
|
- |
|
| 939 |
OrderStatus.DOA_CERT_INVALID : OrderStatus.DOA_INVALID_REFUNDED,
|
- |
|
| 940 |
OrderStatus.DOA_CERT_VALID : OrderStatus.DOA_VALID_REFUNDED,
|
- |
|
| 941 |
OrderStatus.INIT : OrderStatus.CANCELED,
|
- |
|
| 942 |
OrderStatus.SUBMITTED_FOR_PROCESSING : OrderStatus.REFUNDED,
|
- |
|
| 943 |
OrderStatus.INVENTORY_LOW : OrderStatus.REFUNDED
|
- |
|
| 944 |
}
|
- |
|
| - |
|
938 |
|
| 945 |
order = get_order(order_id)
|
939 |
order = get_order(order_id)
|
| 946 |
|
940 |
|
| 947 |
if order.status not in status_transition.keys():
|
- |
|
| 948 |
raise TransactionServiceException(114, "This order can't be refunded")
|
- |
|
| - |
|
941 |
|
| 949 |
|
942 |
|
| 950 |
if order.cod:
|
943 |
if order.cod:
|
| - |
|
944 |
status_transition = {OrderStatus.SALES_RET_RECEIVED : OrderStatus.SALES_RET_REFUNDED,
|
| - |
|
945 |
OrderStatus.DOA_CERT_INVALID : OrderStatus.DOA_INVALID_REFUNDED,
|
| - |
|
946 |
OrderStatus.DOA_CERT_VALID : OrderStatus.DOA_VALID_REFUNDED,
|
| - |
|
947 |
OrderStatus.INIT : OrderStatus.CANCELED,
|
| 951 |
if order.status in [OrderStatus.INIT, OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.INVENTORY_LOW]:
|
948 |
OrderStatus.SUBMITTED_FOR_PROCESSING : OrderStatus.CANCELED,
|
| - |
|
949 |
OrderStatus.INVENTORY_LOW : OrderStatus.CANCELED,
|
| - |
|
950 |
OrderStatus.ACCEPTED : OrderStatus.CANCELED,
|
| - |
|
951 |
OrderStatus.BILLED : OrderStatus.CANCELED,
|
| - |
|
952 |
}
|
| - |
|
953 |
if order.status not in status_transition.keys():
|
| - |
|
954 |
raise TransactionServiceException(114, "This order can't be refunded")
|
| - |
|
955 |
|
| - |
|
956 |
if order.status <= OrderStatus.BILLED:
|
| 952 |
__update_inventory_reservation(order)
|
957 |
__update_inventory_reservation(order)
|
| 953 |
order.statusDescription = "Order Cancelled"
|
958 |
order.statusDescription = "Order Cancelled"
|
| 954 |
elif order.status in [OrderStatus.SALES_RET_RECEIVED, OrderStatus.DOA_CERT_INVALID, OrderStatus.DOA_CERT_VALID] :
|
959 |
elif order.status in [OrderStatus.SALES_RET_RECEIVED, OrderStatus.DOA_CERT_INVALID, OrderStatus.DOA_CERT_VALID] :
|
| 955 |
__create_return_order(order)
|
960 |
__create_return_order(order)
|
| 956 |
__create_refund(order)
|
961 |
__create_refund(order)
|
| 957 |
order.statusDescription = "Order Refunded"
|
962 |
order.statusDescription = "Order Refunded"
|
| 958 |
else:
|
963 |
else:
|
| - |
|
964 |
status_transition = {OrderStatus.SALES_RET_RECEIVED : OrderStatus.SALES_RET_REFUNDED,
|
| - |
|
965 |
OrderStatus.DOA_CERT_INVALID : OrderStatus.DOA_INVALID_REFUNDED,
|
| - |
|
966 |
OrderStatus.DOA_CERT_VALID : OrderStatus.DOA_VALID_REFUNDED,
|
| - |
|
967 |
OrderStatus.SUBMITTED_FOR_PROCESSING : OrderStatus.REFUNDED,
|
| - |
|
968 |
OrderStatus.INVENTORY_LOW : OrderStatus.REFUNDED
|
| - |
|
969 |
}
|
| - |
|
970 |
if order.status not in status_transition.keys():
|
| - |
|
971 |
raise TransactionServiceException(114, "This order can't be refunded")
|
| - |
|
972 |
|
| 959 |
if order.status in [OrderStatus.SALES_RET_RECEIVED, OrderStatus.DOA_CERT_INVALID, OrderStatus.DOA_CERT_VALID] :
|
973 |
if order.status in [OrderStatus.SALES_RET_RECEIVED, OrderStatus.DOA_CERT_INVALID, OrderStatus.DOA_CERT_VALID] :
|
| 960 |
__create_return_order(order)
|
974 |
__create_return_order(order)
|
| 961 |
__create_refund(order)
|
975 |
__create_refund(order)
|
| 962 |
order.statusDescription = "Order Refunded"
|
976 |
order.statusDescription = "Order Refunded"
|
| 963 |
elif order.status in [OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.INVENTORY_LOW]:
|
977 |
elif order.status in [OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.INVENTORY_LOW]:
|