| Line 64... |
Line 64... |
| 64 |
AmazonOrder, StoreOrderDetail, EdcBank, StoreOrderCollection, \
|
64 |
AmazonOrder, StoreOrderDetail, EdcBank, StoreOrderCollection, \
|
| 65 |
HotspotServiceMatrix, SnapdealOrder, FlipkartOrder, DataInsuranceDetailForOrder, \
|
65 |
HotspotServiceMatrix, SnapdealOrder, FlipkartOrder, DataInsuranceDetailForOrder, \
|
| 66 |
AmazonFbaOrderReturns, FlipkartAdvantageOrder, InvoiceCounterGenerator, \
|
66 |
AmazonFbaOrderReturns, FlipkartAdvantageOrder, InvoiceCounterGenerator, \
|
| 67 |
TransactionShipmentSequence, HsOrder, Creditor, UserSanction, CreditHistory, \
|
67 |
TransactionShipmentSequence, HsOrder, Creditor, UserSanction, CreditHistory, \
|
| 68 |
LoanHistory, ShipmentLogisticsCostDetail, ReturnOrderInfo, ReturnTransaction, \
|
68 |
LoanHistory, ShipmentLogisticsCostDetail, ReturnOrderInfo, ReturnTransaction, \
|
| 69 |
ReturnPickupRequest, SellerWarehouse, Seller, Organisation, \
|
69 |
ReturnPickupRequest, SellerWarehouse, Seller, Organisation,\
|
| 70 |
WarehouseAddressMapping, WarehouseAddressMaster
|
70 |
WarehouseAddressMapping, WarehouseAddressMaster
|
| 71 |
from shop2020.model.v1.order.impl.model.BaseOrder import BaseOrder
|
71 |
from shop2020.model.v1.order.impl.model.BaseOrder import BaseOrder
|
| 72 |
from shop2020.model.v1.order.impl.model.DTHRechargeOrder import DTHRechargeOrder
|
72 |
from shop2020.model.v1.order.impl.model.DTHRechargeOrder import DTHRechargeOrder
|
| 73 |
from shop2020.model.v1.order.impl.model.MobileRechargeOrder import \
|
73 |
from shop2020.model.v1.order.impl.model.MobileRechargeOrder import \
|
| 74 |
MobileRechargeOrder
|
74 |
MobileRechargeOrder
|
| Line 3718... |
Line 3718... |
| 3718 |
return True
|
3718 |
return True
|
| 3719 |
|
3719 |
|
| 3720 |
|
3720 |
|
| 3721 |
if order.cod:
|
3721 |
if order.cod:
|
| 3722 |
logging.info("Refunding COD order with status " + str(order.status))
|
3722 |
logging.info("Refunding COD order with status " + str(order.status))
|
| 3723 |
status_transition = { OrderStatus.LOST_IN_TRANSIT : OrderStatus.LOST_IN_TRANSIT_REFUNDED,
|
3723 |
status_transition = refund_status_transition
|
| 3724 |
OrderStatus.RTO_RECEIVED_PRESTINE : OrderStatus.RTO_REFUNDED,
|
- |
|
| 3725 |
OrderStatus.RTO_RECEIVED_DAMAGED : OrderStatus.RTO_DAMAGED_REFUNDED,
|
- |
|
| 3726 |
OrderStatus.RTO_LOST_IN_TRANSIT : OrderStatus.RTO_LOST_IN_TRANSIT_REFUNDED,
|
- |
|
| 3727 |
OrderStatus.DOA_CERT_INVALID : OrderStatus.DOA_INVALID_REFUNDED,
|
- |
|
| 3728 |
OrderStatus.DOA_CERT_VALID : OrderStatus.DOA_VALID_REFUNDED,
|
- |
|
| 3729 |
OrderStatus.DOA_RECEIVED_DAMAGED : OrderStatus.DOA_REFUNDED_RCVD_DAMAGED,
|
- |
|
| 3730 |
OrderStatus.DOA_LOST_IN_TRANSIT : OrderStatus.DOA_REFUNDED_LOST_IN_TRANSIT,
|
- |
|
| 3731 |
OrderStatus.RET_PRODUCT_UNUSABLE : OrderStatus.RET_PRODUCT_UNUSABLE_REFUNDED,
|
- |
|
| 3732 |
OrderStatus.RET_PRODUCT_USABLE : OrderStatus.RET_PRODUCT_USABLE_REFUNDED,
|
- |
|
| 3733 |
OrderStatus.RET_RECEIVED_DAMAGED : OrderStatus.RET_REFUNDED_RCVD_DAMAGED,
|
- |
|
| 3734 |
OrderStatus.RET_LOST_IN_TRANSIT : OrderStatus.RET_REFUNDED_LOST_IN_TRANSIT,
|
- |
|
| 3735 |
OrderStatus.COD_VERIFICATION_PENDING : OrderStatus.COD_VERIFICATION_FAILED,
|
- |
|
| 3736 |
OrderStatus.SUBMITTED_FOR_PROCESSING : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
- |
|
| 3737 |
OrderStatus.INVENTORY_LOW : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
- |
|
| 3738 |
OrderStatus.LOW_INV_PO_RAISED : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
- |
|
| 3739 |
OrderStatus.LOW_INV_REVERSAL_IN_PROCESS : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
- |
|
| 3740 |
OrderStatus.LOW_INV_NOT_AVAILABLE_AT_HOTSPOT : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
- |
|
| 3741 |
OrderStatus.ACCEPTED : OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY,
|
- |
|
| 3742 |
OrderStatus.BILLED : OrderStatus.CANCELLED_ON_CUSTOMER_REQUEST,
|
- |
|
| 3743 |
OrderStatus.CANCEL_REQUEST_CONFIRMED : OrderStatus.CANCELLED_ON_CUSTOMER_REQUEST
|
- |
|
| 3744 |
}
|
- |
|
| 3745 |
if order.status not in status_transition.keys():
|
3724 |
if order.status not in status_transition.keys():
|
| 3746 |
raise TransactionServiceException(114, "This order can't be refunded")
|
3725 |
raise TransactionServiceException(114, "This order can't be refunded")
|
| 3747 |
|
3726 |
|
| 3748 |
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]:
|
3727 |
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]:
|
| 3749 |
__update_inventory_reservation(order)
|
3728 |
__update_inventory_reservation(order)
|
| Line 4618... |
Line 4597... |
| 4618 |
if order.courier_delivery_time:
|
4597 |
if order.courier_delivery_time:
|
| 4619 |
order.courier_delivery_time = order.courier_delivery_time + datetime.timedelta(days=adjust_delivery_time(order.courier_delivery_time, further_delay))
|
4598 |
order.courier_delivery_time = order.courier_delivery_time + datetime.timedelta(days=adjust_delivery_time(order.courier_delivery_time, further_delay))
|
| 4620 |
else:
|
4599 |
else:
|
| 4621 |
order.courier_delivery_time = order.expected_delivery_time + datetime.timedelta(days=adjust_delivery_time(order.expected_delivery_time, further_delay))
|
4600 |
order.courier_delivery_time = order.expected_delivery_time + datetime.timedelta(days=adjust_delivery_time(order.expected_delivery_time, further_delay))
|
| 4622 |
session.commit()
|
4601 |
session.commit()
|
| - |
|
4602 |
|
| - |
|
4603 |
exist = TransactionRequiringExtraProcessing.query.filter_by(transaction_id = order.transaction_id).first()
|
| 4623 |
|
4604 |
|
| - |
|
4605 |
if not exist:
|
| - |
|
4606 |
|
| 4624 |
try:
|
4607 |
try:
|
| 4625 |
transaction_requiring_extra_processing = TransactionRequiringExtraProcessing()
|
4608 |
transaction_requiring_extra_processing = TransactionRequiringExtraProcessing()
|
| 4626 |
transaction_requiring_extra_processing.category = 'DELAYED_DELIVERY'
|
4609 |
transaction_requiring_extra_processing.category = 'DELAYED_DELIVERY'
|
| 4627 |
transaction_requiring_extra_processing.transaction_id = order.transaction_id
|
4610 |
transaction_requiring_extra_processing.transaction_id = order.transaction_id
|
| 4628 |
session.commit()
|
4611 |
session.commit()
|
| 4629 |
except Exception as e:
|
4612 |
except Exception as e:
|
| 4630 |
print 'Could not persist transaction id: ' + str(order.transaction_id) + ' for further processing due to: ' + str(e)
|
4613 |
print 'Could not persist transaction id: ' + str(order.transaction_id) + ' for further processing due to: ' + str(e)
|
| 4631 |
|
- |
|
| 4632 |
return True
|
4614 |
return True
|
| 4633 |
except:
|
4615 |
except:
|
| 4634 |
print sys.exc_info()[0]
|
4616 |
print sys.exc_info()[0]
|
| 4635 |
return False
|
4617 |
return False
|
| 4636 |
|
4618 |
|
| Line 4922... |
Line 4904... |
| 4922 |
- transactionId
|
4904 |
- transactionId
|
| 4923 |
"""
|
4905 |
"""
|
| 4924 |
transaction = get_transaction(transactionId)
|
4906 |
transaction = get_transaction(transactionId)
|
| 4925 |
transaction.status = TransactionStatus.FAILED
|
4907 |
transaction.status = TransactionStatus.FAILED
|
| 4926 |
for order in transaction.orders:
|
4908 |
for order in transaction.orders:
|
| - |
|
4909 |
if order.status in refund_status_transition.keys():
|
| 4927 |
refund_order(order.id, refundedBy, reason)
|
4910 |
refund_order(order.id, refundedBy, reason)
|
| 4928 |
session.commit()
|
4911 |
session.commit()
|
| 4929 |
|
4912 |
|
| 4930 |
def mark_order_cancellation_request_denied(orderId):
|
4913 |
def mark_order_cancellation_request_denied(orderId):
|
| 4931 |
"""
|
4914 |
"""
|
| 4932 |
If we decide to not to cancel order, we will move the order to previous status.
|
4915 |
If we decide to not to cancel order, we will move the order to previous status.
|
| Line 10961... |
Line 10944... |
| 10961 |
#seller would be returned on basis warehouse and company
|
10944 |
#seller would be returned on basis warehouse and company
|
| 10962 |
orgId=2
|
10945 |
orgId=2
|
| 10963 |
(sellerId,) = session.query(Seller.id).join((SellerWarehouse, Seller.id==SellerWarehouse.seller_id)).filter(Seller.organisation_id==orgId).filter(SellerWarehouse.warehouse_id==warehouse_id).first()
|
10946 |
(sellerId,) = session.query(Seller.id).join((SellerWarehouse, Seller.id==SellerWarehouse.seller_id)).filter(Seller.organisation_id==orgId).filter(SellerWarehouse.warehouse_id==warehouse_id).first()
|
| 10964 |
return sellerId
|
10947 |
return sellerId
|
| 10965 |
|
10948 |
|
| - |
|
10949 |
def add_shipment_delay(shipmentDelayDetail):
|
| - |
|
10950 |
returnList = []
|
| - |
|
10951 |
for delayObj in shipmentDelayDetail:
|
| - |
|
10952 |
print delayObj.orderId
|
| - |
|
10953 |
print delayObj.delayReason
|
| - |
|
10954 |
print delayObj.delayReasonText
|
| - |
|
10955 |
print delayObj.delay
|
| - |
|
10956 |
order = get_order(delayObj.orderId)
|
| - |
|
10957 |
if order.status not in [OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.ACCEPTED]:
|
| - |
|
10958 |
returnList.append(delayObj.orderId)
|
| - |
|
10959 |
continue
|
| - |
|
10960 |
try:
|
| - |
|
10961 |
result = add_delay_reason(delayObj.orderId, delayObj.delayReason, delayObj.delay, delayObj.delayReasonText)
|
| - |
|
10962 |
except:
|
| - |
|
10963 |
returnList.append(delayObj.orderId)
|
| - |
|
10964 |
continue
|
| - |
|
10965 |
if not result:
|
| - |
|
10966 |
returnList.append(delayObj.orderId)
|
| - |
|
10967 |
return returnList
|
| - |
|
10968 |
|
| - |
|
10969 |
|
| 10966 |
|
10970 |
|
| 10967 |
#Buyer can be anyone based on logic
|
10971 |
#Buyer can be anyone based on logic
|
| 10968 |
def __get_buyer(warehouse_id):
|
10972 |
def __get_buyer(warehouse_id):
|
| 10969 |
#As of now we have hardcoded the company and
|
10973 |
#As of now we have hardcoded the company and
|
| 10970 |
#seller would be returned on basis warehouse and company
|
10974 |
#seller would be returned on basis warehouse and company
|