| Line 1911... |
Line 1911... |
| 1911 |
logging.info("Accepting order no: " + str(orderId))
|
1911 |
logging.info("Accepting order no: " + str(orderId))
|
| 1912 |
order = get_order(orderId)
|
1912 |
order = get_order(orderId)
|
| 1913 |
|
1913 |
|
| 1914 |
ordersList = []
|
1914 |
ordersList = []
|
| 1915 |
ordersList.append(order)
|
1915 |
ordersList.append(order)
|
| 1916 |
logisticsProviderFinalCheck(ordersList)
|
1916 |
updatedOrders = logisticsProviderFinalCheck(ordersList)
|
| 1917 |
order = get_order(orderId)
|
1917 |
order = updatedOrders[0]
|
| 1918 |
logistics_client = LogisticsClient().get_client()
|
1918 |
logistics_client = LogisticsClient().get_client()
|
| 1919 |
provider = logistics_client.getProvider(order.logistics_provider_id)
|
1919 |
provider = logistics_client.getProvider(order.logistics_provider_id)
|
| 1920 |
providerLimits = logistics_client.getProviderLimitDetailsForPincode(provider.id, order.customer_pincode)
|
1920 |
providerLimits = logistics_client.getProviderLimitDetailsForPincode(provider.id, order.customer_pincode)
|
| 1921 |
|
1921 |
|
| 1922 |
if order.total_weight is None or order.total_weight == 0:
|
1922 |
if order.total_weight is None or order.total_weight == 0:
|
| Line 1929... |
Line 1929... |
| 1929 |
if order.total_amount > provider.maxCodLimit:
|
1929 |
if order.total_amount > provider.maxCodLimit:
|
| 1930 |
raise TransactionServiceException(210, "Logistics Partner "+provider.name+ " Max Cod Amount Collection Limit Violated i.e. "+ str(provider.maxCodLimit)+" Suggestion: Split Order!!!")
|
1930 |
raise TransactionServiceException(210, "Logistics Partner "+provider.name+ " Max Cod Amount Collection Limit Violated i.e. "+ str(provider.maxCodLimit)+" Suggestion: Split Order!!!")
|
| 1931 |
|
1931 |
|
| 1932 |
if order.logistics_provider_id!=4:
|
1932 |
if order.logistics_provider_id!=4:
|
| 1933 |
|
1933 |
|
| 1934 |
providerCodLimit = float(providerLimits.get("websiteCodLimit"))
|
1934 |
providerCodLimit = float(providerLimits.get("providerCodLimit"))
|
| 1935 |
providerPrepaidLimit = float(providerLimits.get("providerPrepaidLimit"))
|
1935 |
providerPrepaidLimit = float(providerLimits.get("providerPrepaidLimit"))
|
| 1936 |
|
1936 |
|
| 1937 |
if order.cod:
|
1937 |
if order.cod:
|
| 1938 |
if order.total_amount > providerCodLimit:
|
1938 |
if order.total_amount > providerCodLimit:
|
| 1939 |
raise TransactionServiceException(212, "Provider Maximum COD Limit Violated for Customer Pincode i.e. "+str(providerCodLimit)+" Suggestion: Split Order!!!")
|
1939 |
raise TransactionServiceException(212, "Provider Maximum COD Limit Violated for Customer Pincode i.e. "+str(providerCodLimit)+" Suggestion: Split Order!!!")
|
| Line 8313... |
Line 8313... |
| 8313 |
for orderObj in ordersList:
|
8313 |
for orderObj in ordersList:
|
| 8314 |
totalOrderQuantity = totalOrderQuantity + long(orderObj.lineitems[0].quantity)
|
8314 |
totalOrderQuantity = totalOrderQuantity + long(orderObj.lineitems[0].quantity)
|
| 8315 |
|
8315 |
|
| 8316 |
print orders
|
8316 |
print orders
|
| 8317 |
|
8317 |
|
| 8318 |
logisticsProviderFinalCheck(ordersList)
|
8318 |
updatedOrders = logisticsProviderFinalCheck(ordersList)
|
| 8319 |
|
- |
|
| 8320 |
ordersList = get_order_list(orders)
|
- |
|
| 8321 |
|
8319 |
|
| 8322 |
user_client = UserClient().get_client()
|
8320 |
user_client = UserClient().get_client()
|
| 8323 |
isPrivateDealUser = user_client.isPrivateDealUser(ordersList[0].customer_id)
|
8321 |
isPrivateDealUser = user_client.isPrivateDealUser(updatedOrders[0].customer_id)
|
| 8324 |
privateDealUser = None
|
8322 |
privateDealUser = None
|
| 8325 |
if isPrivateDealUser:
|
8323 |
if isPrivateDealUser:
|
| 8326 |
privateDealUser = user_client.getPrivateDealUser(ordersList[0].customer_id)
|
8324 |
privateDealUser = user_client.getPrivateDealUser(updatedOrders[0].customer_id)
|
| 8327 |
logistics_client = LogisticsClient().get_client()
|
8325 |
logistics_client = LogisticsClient().get_client()
|
| 8328 |
singleOrder = ordersList[0]
|
- |
|
| 8329 |
provider = logistics_client.getProvider(singleOrder.logistics_provider_id)
|
8326 |
provider = logistics_client.getProvider(updatedOrders[0].logistics_provider_id)
|
| 8330 |
providerLimits = logistics_client.getProviderLimitDetailsForPincode(provider.id, ordersList[0].customer_pincode)
|
8327 |
providerLimits = logistics_client.getProviderLimitDetailsForPincode(provider.id, updatedOrders[0].customer_pincode)
|
| 8331 |
print 'Accpet Order Process Started'
|
8328 |
print 'Accpet Order Process Started'
|
| 8332 |
|
8329 |
|
| 8333 |
'''
|
8330 |
'''
|
| 8334 |
Check For Pre Conditions
|
8331 |
Check For Pre Conditions
|
| 8335 |
'''
|
8332 |
'''
|
| 8336 |
for order in ordersList:
|
8333 |
for order in updatedOrders:
|
| 8337 |
if order.total_weight is None or order.total_weight ==0:
|
8334 |
if order.total_weight is None or order.total_weight ==0:
|
| 8338 |
raise TransactionServiceException(208, "Weight Value Not Defined for order:- "+ str(order.id)+". Contact Category Team.")
|
8335 |
raise TransactionServiceException(208, "Weight Value Not Defined for order:- "+ str(order.id)+". Contact Category Team.")
|
| 8339 |
totalWeight = totalWeight + order.total_weight
|
8336 |
totalWeight = totalWeight + order.total_weight
|
| 8340 |
#if order.cod:
|
8337 |
#if order.cod:
|
| 8341 |
totalOrdersAmount = totalOrdersAmount + order.total_amount
|
8338 |
totalOrdersAmount = totalOrdersAmount + order.total_amount
|
| Line 8366... |
Line 8363... |
| 8366 |
|
8363 |
|
| 8367 |
if not order.cod:
|
8364 |
if not order.cod:
|
| 8368 |
if totalOrdersAmount > providerPrepaidLimit:
|
8365 |
if totalOrdersAmount > providerPrepaidLimit:
|
| 8369 |
raise TransactionServiceException(212, "Logistics Partner "+provider.name+ " Max Prepaid Amount Limit Violated Rs." +str(providerPrepaidLimit))
|
8366 |
raise TransactionServiceException(212, "Logistics Partner "+provider.name+ " Max Prepaid Amount Limit Violated Rs." +str(providerPrepaidLimit))
|
| 8370 |
|
8367 |
|
| 8371 |
for order in ordersList:
|
8368 |
for order in updatedOrders:
|
| 8372 |
if order.status in [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.CAPTURE_IN_PROCESS]:
|
8369 |
if order.status in [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.CAPTURE_IN_PROCESS]:
|
| 8373 |
if not order.cod:
|
8370 |
if not order.cod:
|
| 8374 |
if order.transaction.status == TransactionStatus.AUTHORIZED and order.transaction.payment_option != capitalFloatPayMethod:
|
8371 |
if order.transaction.status == TransactionStatus.AUTHORIZED and order.transaction.payment_option != capitalFloatPayMethod:
|
| 8375 |
__capture_txn(order)
|
8372 |
__capture_txn(order)
|
| 8376 |
break
|
8373 |
break
|
| Line 8381... |
Line 8378... |
| 8381 |
except:
|
8378 |
except:
|
| 8382 |
raise TransactionServiceException(212, "Unable to connect to Inventory System")
|
8379 |
raise TransactionServiceException(212, "Unable to connect to Inventory System")
|
| 8383 |
#conn = getDbConnection("localhost","root","shop2020","inventory")
|
8380 |
#conn = getDbConnection("localhost","root","shop2020","inventory")
|
| 8384 |
print 'Connected to Inventory DB'
|
8381 |
print 'Connected to Inventory DB'
|
| 8385 |
|
8382 |
|
| 8386 |
for order in ordersList:
|
8383 |
for order in updatedOrders:
|
| 8387 |
if order.status in [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.CAPTURE_IN_PROCESS]:
|
8384 |
if order.status in [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.CAPTURE_IN_PROCESS]:
|
| 8388 |
order.status = OrderStatus.ACCEPTED
|
8385 |
order.status = OrderStatus.ACCEPTED
|
| 8389 |
order.statusDescription = "Order Accepted"
|
8386 |
order.statusDescription = "Order Accepted"
|
| 8390 |
order.accepted_timestamp = datetime.datetime.now()
|
8387 |
order.accepted_timestamp = datetime.datetime.now()
|
| 8391 |
if order.source == 6 or order.source == 7 or order.source == 8:
|
8388 |
if order.source == 6 or order.source == 7 or order.source == 8:
|
| Line 8523... |
Line 8520... |
| 8523 |
logistics_client = LogisticsClient().get_client()
|
8520 |
logistics_client = LogisticsClient().get_client()
|
| 8524 |
awbNumber = logistics_client.getNewEmptyAwb(provider.id, deltype, totalOrderQuantity)
|
8521 |
awbNumber = logistics_client.getNewEmptyAwb(provider.id, deltype, totalOrderQuantity)
|
| 8525 |
'''
|
8522 |
'''
|
| 8526 |
|
8523 |
|
| 8527 |
txnSeqRequired = 0
|
8524 |
txnSeqRequired = 0
|
| 8528 |
txnShipSeq = TransactionShipmentSequence.query.filter(TransactionShipmentSequence.transactionId==ordersList[0].transaction_id).order_by(desc(TransactionShipmentSequence.id)).first()
|
8525 |
txnShipSeq = TransactionShipmentSequence.query.filter(TransactionShipmentSequence.transactionId==updatedOrders[0].transaction_id).order_by(desc(TransactionShipmentSequence.id)).first()
|
| 8529 |
if txnShipSeq is None:
|
8526 |
if txnShipSeq is None:
|
| 8530 |
txnShipSeq = TransactionShipmentSequence()
|
8527 |
txnShipSeq = TransactionShipmentSequence()
|
| 8531 |
txnShipSeq.transactionId = ordersList[0].transaction_id
|
8528 |
txnShipSeq.transactionId = updatedOrders[0].transaction_id
|
| 8532 |
txnShipSeq.createdTimestamp = datetime.datetime.now()
|
8529 |
txnShipSeq.createdTimestamp = datetime.datetime.now()
|
| 8533 |
txnShipSeq.sequence = 1
|
8530 |
txnShipSeq.sequence = 1
|
| 8534 |
txnSeqRequired = 1
|
8531 |
txnSeqRequired = 1
|
| 8535 |
else:
|
8532 |
else:
|
| 8536 |
txnShipSeqNew = TransactionShipmentSequence()
|
8533 |
txnShipSeqNew = TransactionShipmentSequence()
|
| 8537 |
txnShipSeqNew.transactionId = txnShipSeq.transactionId
|
8534 |
txnShipSeqNew.transactionId = txnShipSeq.transactionId
|
| 8538 |
txnShipSeqNew.createdTimestamp = datetime.datetime.now()
|
8535 |
txnShipSeqNew.createdTimestamp = datetime.datetime.now()
|
| 8539 |
txnShipSeqNew.sequence = txnShipSeq.sequence + 1
|
8536 |
txnShipSeqNew.sequence = txnShipSeq.sequence + 1
|
| 8540 |
txnSeqRequired = txnShipSeq.sequence + 1
|
8537 |
txnSeqRequired = txnShipSeq.sequence + 1
|
| 8541 |
|
8538 |
|
| 8542 |
for order in ordersList:
|
8539 |
for order in updatedOrders:
|
| 8543 |
#update_order_AWB(order.id, awbNumber)
|
8540 |
#update_order_AWB(order.id, awbNumber)
|
| 8544 |
order.logisticsTransactionId = str(order.transaction_id)+"-"+str(txnSeqRequired)
|
8541 |
order.logisticsTransactionId = str(order.transaction_id)+"-"+str(txnSeqRequired)
|
| 8545 |
|
8542 |
|
| 8546 |
session.commit()
|
8543 |
session.commit()
|
| 8547 |
|
8544 |
|
| 8548 |
singleOrder = ordersList[0]
|
8545 |
singleOrder = updatedOrders[0]
|
| 8549 |
if singleOrder.orderType == OrderType.B2B:
|
8546 |
if singleOrder.orderType == OrderType.B2B:
|
| 8550 |
user_client = UserClient().get_client()
|
8547 |
user_client = UserClient().get_client()
|
| 8551 |
if user_client.isPrivateDealUser(singleOrder.customer_id):
|
8548 |
if user_client.isPrivateDealUser(singleOrder.customer_id):
|
| 8552 |
billing_address = user_client.getBillingAddressForUser(singleOrder.customer_id)
|
8549 |
billing_address = user_client.getBillingAddressForUser(singleOrder.customer_id)
|
| 8553 |
if billing_address is not None:
|
8550 |
if billing_address is not None:
|
| Line 9845... |
Line 9842... |
| 9845 |
|
9842 |
|
| 9846 |
ordersList[0].lineitems[0].logisticsCost = ordersList[0].lineitems[0].logisticsCost + (round(logisticsCost,2)-logisticsCostInOrders)
|
9843 |
ordersList[0].lineitems[0].logisticsCost = ordersList[0].lineitems[0].logisticsCost + (round(logisticsCost,2)-logisticsCostInOrders)
|
| 9847 |
if codCollectionCharges>0:
|
9844 |
if codCollectionCharges>0:
|
| 9848 |
ordersList[0].lineitems[0].codCollectionCharges = ordersList[0].lineitems[0].codCollectionCharges + (round(codCollectionCharges,2)-codCollectionChargesInOrders)
|
9845 |
ordersList[0].lineitems[0].codCollectionCharges = ordersList[0].lineitems[0].codCollectionCharges + (round(codCollectionCharges,2)-codCollectionChargesInOrders)
|
| 9849 |
session.commit()
|
9846 |
session.commit()
|
| - |
|
9847 |
|
| - |
|
9848 |
return ordersList
|
| 9850 |
|
9849 |
|
| 9851 |
if __name__ == '__main__':
|
9850 |
if __name__ == '__main__':
|
| 9852 |
print get_orders_by_mobile_number("9650889334")
|
9851 |
print get_orders_by_mobile_number("9650889334")
|