| 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 82... |
Line 82... |
| 82 |
from shop2020.model.v1.order.impl.model.ServiceProvider import ServiceProvider
|
82 |
from shop2020.model.v1.order.impl.model.ServiceProvider import ServiceProvider
|
| 83 |
from shop2020.model.v1.order.impl.model.TelecomCircle import TelecomCircle
|
83 |
from shop2020.model.v1.order.impl.model.TelecomCircle import TelecomCircle
|
| 84 |
from shop2020.model.v1.order.impl.model.UserWallet import UserWallet
|
84 |
from shop2020.model.v1.order.impl.model.UserWallet import UserWallet
|
| 85 |
from shop2020.model.v1.order.impl.model.UserWalletHistory import \
|
85 |
from shop2020.model.v1.order.impl.model.UserWalletHistory import \
|
| 86 |
UserWalletHistory
|
86 |
UserWalletHistory
|
| - |
|
87 |
from shop2020.model.v1.user.impl.Converters import to_t_address
|
| 87 |
from shop2020.thriftpy.alert.ttypes import MonitoredEntity, EntityType
|
88 |
from shop2020.thriftpy.alert.ttypes import MonitoredEntity, EntityType
|
| 88 |
from shop2020.thriftpy.crm.ttypes import *
|
89 |
from shop2020.thriftpy.crm.ttypes import *
|
| 89 |
from shop2020.thriftpy.logistics.ttypes import DeliveryType, PickUpType
|
90 |
from shop2020.thriftpy.logistics.ttypes import DeliveryType, PickUpType
|
| 90 |
from shop2020.thriftpy.model.v1.catalog.ttypes import ItemType, ItemCondition
|
91 |
from shop2020.thriftpy.model.v1.catalog.ttypes import ItemType, ItemCondition
|
| 91 |
from shop2020.thriftpy.model.v1.inventory.ttypes import BillingType, \
|
92 |
from shop2020.thriftpy.model.v1.inventory.ttypes import BillingType, \
|
| Line 98... |
Line 99... |
| 98 |
AmazonFCWarehouseLocation, RechargeMode, CreditTxnType, \
|
99 |
AmazonFCWarehouseLocation, RechargeMode, CreditTxnType, \
|
| 99 |
CreditHistory as TCreditHistory, LoanHistory as TLoanHistory, \
|
100 |
CreditHistory as TCreditHistory, LoanHistory as TLoanHistory, \
|
| 100 |
ShipmentLogisticsCostDetail as TShipmentLogisticsCostDetail, \
|
101 |
ShipmentLogisticsCostDetail as TShipmentLogisticsCostDetail, \
|
| 101 |
ReturnTransactionStatus, ReturnAction, ReturnTxnResolutionStatus, \
|
102 |
ReturnTransactionStatus, ReturnAction, ReturnTxnResolutionStatus, \
|
| 102 |
ReplacementShippingType, ReturnTxnPickupStatus, ReceivedReturnType, \
|
103 |
ReplacementShippingType, ReturnTxnPickupStatus, ReceivedReturnType, \
|
| 103 |
ReturnPickupType, RefundType, SellerInfo
|
104 |
ReturnPickupType, RefundType, SellerInfo, BuyerInfo
|
| 104 |
from shop2020.thriftpy.model.v1.user.ttypes import VoucherType, CouponCategory, \
|
105 |
from shop2020.thriftpy.model.v1.user.ttypes import VoucherType, CouponCategory, \
|
| 105 |
User, Sex
|
106 |
User, Sex
|
| 106 |
from shop2020.thriftpy.payments.ttypes import PaymentException
|
107 |
from shop2020.thriftpy.payments.ttypes import PaymentException
|
| 107 |
from shop2020.thriftpy.utils.ttypes import UserSmsInfo, SmsType
|
108 |
from shop2020.thriftpy.utils.ttypes import UserSmsInfo, SmsType
|
| 108 |
from shop2020.thriftpy.warehouse.ttypes import ScanType, \
|
109 |
from shop2020.thriftpy.warehouse.ttypes import ScanType, \
|
| Line 110... |
Line 111... |
| 110 |
from shop2020.utils.EmailAttachmentSender import mail, get_attachment_part, \
|
111 |
from shop2020.utils.EmailAttachmentSender import mail, get_attachment_part, \
|
| 111 |
mail_html
|
112 |
mail_html
|
| 112 |
from shop2020.utils.Utils import to_py_date, to_java_date, \
|
113 |
from shop2020.utils.Utils import to_py_date, to_java_date, \
|
| 113 |
getSyncOperatorsForRecharge
|
114 |
getSyncOperatorsForRecharge
|
| 114 |
from suds.client import Client
|
115 |
from suds.client import Client
|
| 115 |
from shop2020.model.v1.user.impl.Converters import to_t_address
|
- |
|
| 116 |
|
116 |
|
| 117 |
|
117 |
|
| 118 |
#Start:- Added By Manish Sharma for Creating a new Ticket: Category- RTO Refund on 21-Jun-2013
|
118 |
#Start:- Added By Manish Sharma for Creating a new Ticket: Category- RTO Refund on 21-Jun-2013
|
| 119 |
#End:- Added By Manish Sharma for Creating a new Ticket: Category- RTO Refund on 21-Jun-2013
|
119 |
#End:- Added By Manish Sharma for Creating a new Ticket: Category- RTO Refund on 21-Jun-2013
|
| 120 |
#Start:- Added By Manish Sharma for Creating a new Ticket: Category- RTO Refund on 21-Jun-2013
|
120 |
#Start:- Added By Manish Sharma for Creating a new Ticket: Category- RTO Refund on 21-Jun-2013
|
| 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 = refund_status_transition
|
3723 |
status_transition = { OrderStatus.LOST_IN_TRANSIT : OrderStatus.LOST_IN_TRANSIT_REFUNDED,
|
| - |
|
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 |
}
|
| 3724 |
if order.status not in status_transition.keys():
|
3745 |
if order.status not in status_transition.keys():
|
| 3725 |
raise TransactionServiceException(114, "This order can't be refunded")
|
3746 |
raise TransactionServiceException(114, "This order can't be refunded")
|
| 3726 |
|
3747 |
|
| 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]:
|
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]:
|
| 3728 |
__update_inventory_reservation(order)
|
3749 |
__update_inventory_reservation(order)
|
| Line 4901... |
Line 4922... |
| 4901 |
- transactionId
|
4922 |
- transactionId
|
| 4902 |
"""
|
4923 |
"""
|
| 4903 |
transaction = get_transaction(transactionId)
|
4924 |
transaction = get_transaction(transactionId)
|
| 4904 |
transaction.status = TransactionStatus.FAILED
|
4925 |
transaction.status = TransactionStatus.FAILED
|
| 4905 |
for order in transaction.orders:
|
4926 |
for order in transaction.orders:
|
| 4906 |
if order.status in refund_status_transition.keys():
|
- |
|
| 4907 |
refund_order(order.id, refundedBy, reason)
|
4927 |
refund_order(order.id, refundedBy, reason)
|
| 4908 |
session.commit()
|
4928 |
session.commit()
|
| 4909 |
|
4929 |
|
| 4910 |
def mark_order_cancellation_request_denied(orderId):
|
4930 |
def mark_order_cancellation_request_denied(orderId):
|
| 4911 |
"""
|
4931 |
"""
|
| 4912 |
If we decide to not to cancel order, we will move the order to previous status.
|
4932 |
If we decide to not to cancel order, we will move the order to previous status.
|
| Line 10910... |
Line 10930... |
| 10910 |
seller = Seller.get_by(id=sellerId)
|
10930 |
seller = Seller.get_by(id=sellerId)
|
| 10911 |
if seller is None:
|
10931 |
if seller is None:
|
| 10912 |
return None
|
10932 |
return None
|
| 10913 |
else:
|
10933 |
else:
|
| 10914 |
sellerInfo.tin = seller.tin
|
10934 |
sellerInfo.tin = seller.tin
|
| - |
|
10935 |
sellerInfo.stateId = seller.state_id
|
| 10915 |
org = Organisation.get_by(id=seller.organisation_id)
|
10936 |
org = Organisation.get_by(id=seller.organisation_id)
|
| 10916 |
if org is None:
|
10937 |
if org is None:
|
| 10917 |
return None
|
10938 |
return None
|
| 10918 |
else:
|
10939 |
else:
|
| 10919 |
sellerInfo.organisationName = org.name
|
10940 |
sellerInfo.organisationName = org.name
|
| Line 10939... |
Line 10960... |
| 10939 |
#As of now we have hardcoded the company and
|
10960 |
#As of now we have hardcoded the company and
|
| 10940 |
#seller would be returned on basis warehouse and company
|
10961 |
#seller would be returned on basis warehouse and company
|
| 10941 |
orgId=1
|
10962 |
orgId=1
|
| 10942 |
(sellerId,) = session.query(Seller.id).join((SellerWarehouse, Seller.id==SellerWarehouse.seller_id)).filter(Seller.organisation_id==orgId).filter(SellerWarehouse.warehouse_id==warehouse_id).first()
|
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()
|
| 10943 |
return sellerId
|
10964 |
return sellerId
|
| - |
|
10965 |
|
| - |
|
10966 |
|
| - |
|
10967 |
#Buyer can be anyone based on logic
|
| - |
|
10968 |
def __get_buyer(warehouse_id):
|
| - |
|
10969 |
#As of now we have hardcoded the company and
|
| - |
|
10970 |
#seller would be returned on basis warehouse and company
|
| 10944 |
|
10971 |
orgId=1
|
| - |
|
10972 |
buyerId=None
|
| - |
|
10973 |
result = session.query(Seller.id).join((SellerWarehouse, Seller.id==SellerWarehouse.seller_id)).filter(Seller.organisation_id==orgId).filter(SellerWarehouse.warehouse_id==warehouse_id).first()
|
| - |
|
10974 |
if result:
|
| - |
|
10975 |
buyerId = result[0]
|
| - |
|
10976 |
return buyerId
|
| 10945 |
|
10977 |
|
| - |
|
10978 |
def get_buyer_by_warehouse(warehouse_id):
|
| - |
|
10979 |
buyerId = __get_buyer(warehouse_id)
|
| - |
|
10980 |
if buyerId is None:
|
| - |
|
10981 |
return None
|
| - |
|
10982 |
sellerInfo = get_seller_info(buyerId)
|
| - |
|
10983 |
buyerInfo = BuyerInfo()
|
| - |
|
10984 |
buyerInfo.cinNumber = sellerInfo.cinNumber
|
| - |
|
10985 |
buyerInfo.organisationName = sellerInfo.organisationName
|
| - |
|
10986 |
buyerInfo.regId = sellerInfo.regId
|
| - |
|
10987 |
buyerInfo.tin = sellerInfo.tin
|
| - |
|
10988 |
buyerInfo.registeredAddress = sellerInfo.registeredAddress
|
| - |
|
10989 |
buyerInfo.buyerId = buyerId
|
| - |
|
10990 |
buyerInfo.stateId = sellerInfo.state_id
|
| - |
|
10991 |
addressMapping = session.query(WarehouseAddressMaster).join((WarehouseAddressMapping,WarehouseAddressMapping.address_id==WarehouseAddressMaster.id)).filter(WarehouseAddressMapping.warehouse_id==warehouse_id).first()
|
| - |
|
10992 |
if addressMapping is not None:
|
| - |
|
10993 |
buyerInfo.addressId = addressMapping.address_id
|
| - |
|
10994 |
buyerInfo.address = addressMapping
|
| - |
|
10995 |
else:
|
| - |
|
10996 |
return None
|
| 10946 |
if __name__ == '__main__':
|
10997 |
if __name__ == '__main__':
|
| 10947 |
print get_orders_by_mobile_number("9650889334")
|
10998 |
print get_orders_by_mobile_number("9650889334")
|