| Line 160... |
Line 160... |
| 160 |
CreditTxnType.LOAN_CANCELLED : -1,
|
160 |
CreditTxnType.LOAN_CANCELLED : -1,
|
| 161 |
CreditTxnType.PAID : -1,
|
161 |
CreditTxnType.PAID : -1,
|
| 162 |
CreditTxnType.CORRECTION : -1
|
162 |
CreditTxnType.CORRECTION : -1
|
| 163 |
}
|
163 |
}
|
| 164 |
|
164 |
|
| - |
|
165 |
refund_status_transition = { OrderStatus.LOST_IN_TRANSIT : OrderStatus.LOST_IN_TRANSIT_REFUNDED,
|
| - |
|
166 |
OrderStatus.RTO_RECEIVED_PRESTINE : OrderStatus.RTO_REFUNDED,
|
| - |
|
167 |
OrderStatus.RTO_RECEIVED_DAMAGED : OrderStatus.RTO_DAMAGED_REFUNDED,
|
| - |
|
168 |
OrderStatus.RTO_LOST_IN_TRANSIT : OrderStatus.RTO_LOST_IN_TRANSIT_REFUNDED,
|
| - |
|
169 |
OrderStatus.DOA_CERT_INVALID : OrderStatus.DOA_INVALID_REFUNDED,
|
| - |
|
170 |
OrderStatus.DOA_CERT_VALID : OrderStatus.DOA_VALID_REFUNDED,
|
| - |
|
171 |
OrderStatus.DOA_RECEIVED_DAMAGED : OrderStatus.DOA_REFUNDED_RCVD_DAMAGED,
|
| - |
|
172 |
OrderStatus.DOA_LOST_IN_TRANSIT : OrderStatus.DOA_REFUNDED_LOST_IN_TRANSIT,
|
| - |
|
173 |
OrderStatus.RET_PRODUCT_UNUSABLE : OrderStatus.RET_PRODUCT_UNUSABLE_REFUNDED,
|
| - |
|
174 |
OrderStatus.RET_PRODUCT_USABLE : OrderStatus.RET_PRODUCT_USABLE_REFUNDED,
|
| - |
|
175 |
OrderStatus.RET_RECEIVED_DAMAGED : OrderStatus.RET_REFUNDED_RCVD_DAMAGED,
|
| - |
|
176 |
OrderStatus.RET_LOST_IN_TRANSIT : OrderStatus.RET_REFUNDED_LOST_IN_TRANSIT,
|
| - |
|
177 |
OrderStatus.COD_VERIFICATION_PENDING : OrderStatus.COD_VERIFICATION_FAILED,
|
| - |
|
178 |
OrderStatus.SUBMITTED_FOR_PROCESSING : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
| - |
|
179 |
OrderStatus.INVENTORY_LOW : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
| - |
|
180 |
OrderStatus.LOW_INV_PO_RAISED : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
| - |
|
181 |
OrderStatus.LOW_INV_REVERSAL_IN_PROCESS : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
| - |
|
182 |
OrderStatus.LOW_INV_NOT_AVAILABLE_AT_HOTSPOT : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
| - |
|
183 |
OrderStatus.ACCEPTED : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
| - |
|
184 |
OrderStatus.BILLED : OrderStatus.CANCELLED_ON_CUSTOMER_REQUEST,
|
| - |
|
185 |
OrderStatus.CANCEL_REQUEST_CONFIRMED : OrderStatus.CANCELLED_ON_CUSTOMER_REQUEST
|
| - |
|
186 |
}
|
| - |
|
187 |
|
| 165 |
creditorTicketSizeMap = {}
|
188 |
creditorTicketSizeMap = {}
|
| 166 |
creditorDueDateMap = {}
|
189 |
creditorDueDateMap = {}
|
| 167 |
|
190 |
|
| 168 |
stateIdMap = {}
|
191 |
stateIdMap = {}
|
| 169 |
def fetchStateMaster():
|
192 |
def fetchStateMaster():
|
| Line 3768... |
Line 3791... |
| 3768 |
return True
|
3791 |
return True
|
| 3769 |
|
3792 |
|
| 3770 |
|
3793 |
|
| 3771 |
if order.cod:
|
3794 |
if order.cod:
|
| 3772 |
logging.info("Refunding COD order with status " + str(order.status))
|
3795 |
logging.info("Refunding COD order with status " + str(order.status))
|
| 3773 |
status_transition = { OrderStatus.LOST_IN_TRANSIT : OrderStatus.LOST_IN_TRANSIT_REFUNDED,
|
3796 |
status_transition = refund_status_transition
|
| 3774 |
OrderStatus.RTO_RECEIVED_PRESTINE : OrderStatus.RTO_REFUNDED,
|
- |
|
| 3775 |
OrderStatus.RTO_RECEIVED_DAMAGED : OrderStatus.RTO_DAMAGED_REFUNDED,
|
- |
|
| 3776 |
OrderStatus.RTO_LOST_IN_TRANSIT : OrderStatus.RTO_LOST_IN_TRANSIT_REFUNDED,
|
- |
|
| 3777 |
OrderStatus.DOA_CERT_INVALID : OrderStatus.DOA_INVALID_REFUNDED,
|
- |
|
| 3778 |
OrderStatus.DOA_CERT_VALID : OrderStatus.DOA_VALID_REFUNDED,
|
- |
|
| 3779 |
OrderStatus.DOA_RECEIVED_DAMAGED : OrderStatus.DOA_REFUNDED_RCVD_DAMAGED,
|
- |
|
| 3780 |
OrderStatus.DOA_LOST_IN_TRANSIT : OrderStatus.DOA_REFUNDED_LOST_IN_TRANSIT,
|
- |
|
| 3781 |
OrderStatus.RET_PRODUCT_UNUSABLE : OrderStatus.RET_PRODUCT_UNUSABLE_REFUNDED,
|
- |
|
| 3782 |
OrderStatus.RET_PRODUCT_USABLE : OrderStatus.RET_PRODUCT_USABLE_REFUNDED,
|
- |
|
| 3783 |
OrderStatus.RET_RECEIVED_DAMAGED : OrderStatus.RET_REFUNDED_RCVD_DAMAGED,
|
- |
|
| 3784 |
OrderStatus.RET_LOST_IN_TRANSIT : OrderStatus.RET_REFUNDED_LOST_IN_TRANSIT,
|
- |
|
| 3785 |
OrderStatus.COD_VERIFICATION_PENDING : OrderStatus.COD_VERIFICATION_FAILED,
|
- |
|
| 3786 |
OrderStatus.SUBMITTED_FOR_PROCESSING : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
- |
|
| 3787 |
OrderStatus.INVENTORY_LOW : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
- |
|
| 3788 |
OrderStatus.LOW_INV_PO_RAISED : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
- |
|
| 3789 |
OrderStatus.LOW_INV_REVERSAL_IN_PROCESS : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
- |
|
| 3790 |
OrderStatus.LOW_INV_NOT_AVAILABLE_AT_HOTSPOT : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
- |
|
| 3791 |
OrderStatus.ACCEPTED : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
- |
|
| 3792 |
OrderStatus.BILLED : OrderStatus.CANCELLED_ON_CUSTOMER_REQUEST,
|
- |
|
| 3793 |
OrderStatus.CANCEL_REQUEST_CONFIRMED : OrderStatus.CANCELLED_ON_CUSTOMER_REQUEST
|
- |
|
| 3794 |
}
|
- |
|
| 3795 |
if order.status not in status_transition.keys():
|
3797 |
if order.status not in status_transition.keys():
|
| 3796 |
raise TransactionServiceException(114, "This order can't be refunded")
|
3798 |
raise TransactionServiceException(114, "This order can't be refunded")
|
| 3797 |
|
3799 |
|
| 3798 |
if order.status in [OrderStatus.COD_VERIFICATION_PENDING, OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.INVENTORY_LOW, OrderStatus.LOW_INV_PO_RAISED, OrderStatus.LOW_INV_REVERSAL_IN_PROCESS, OrderStatus.LOW_INV_NOT_AVAILABLE_AT_HOTSPOT, OrderStatus.ACCEPTED]:
|
3800 |
if order.status in [OrderStatus.COD_VERIFICATION_PENDING, OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.INVENTORY_LOW, OrderStatus.LOW_INV_PO_RAISED, OrderStatus.LOW_INV_REVERSAL_IN_PROCESS, OrderStatus.LOW_INV_NOT_AVAILABLE_AT_HOTSPOT, OrderStatus.ACCEPTED]:
|
| 3799 |
__update_inventory_reservation(order)
|
3801 |
__update_inventory_reservation(order)
|
| Line 4972... |
Line 4974... |
| 4972 |
- transactionId
|
4974 |
- transactionId
|
| 4973 |
"""
|
4975 |
"""
|
| 4974 |
transaction = get_transaction(transactionId)
|
4976 |
transaction = get_transaction(transactionId)
|
| 4975 |
transaction.status = TransactionStatus.FAILED
|
4977 |
transaction.status = TransactionStatus.FAILED
|
| 4976 |
for order in transaction.orders:
|
4978 |
for order in transaction.orders:
|
| - |
|
4979 |
if order.status in refund_status_transition.keys():
|
| 4977 |
refund_order(order.id, refundedBy, reason)
|
4980 |
refund_order(order.id, refundedBy, reason)
|
| 4978 |
session.commit()
|
4981 |
session.commit()
|
| 4979 |
|
4982 |
|
| 4980 |
def mark_order_cancellation_request_denied(orderId):
|
4983 |
def mark_order_cancellation_request_denied(orderId):
|
| 4981 |
"""
|
4984 |
"""
|
| 4982 |
If we decide to not to cancel order, we will move the order to previous status.
|
4985 |
If we decide to not to cancel order, we will move the order to previous status.
|