| Line 344... |
Line 344... |
| 344 |
transaction.payment_option = t_transaction.payment_option
|
344 |
transaction.payment_option = t_transaction.payment_option
|
| 345 |
if t_transaction.totalShippingCost:
|
345 |
if t_transaction.totalShippingCost:
|
| 346 |
transaction.totalShippingCost = t_transaction.totalShippingCost
|
346 |
transaction.totalShippingCost = t_transaction.totalShippingCost
|
| 347 |
if t_transaction.totalCodCharges:
|
347 |
if t_transaction.totalCodCharges:
|
| 348 |
transaction.totalCodCharges = t_transaction.totalCodCharges
|
348 |
transaction.totalCodCharges = t_transaction.totalCodCharges
|
| - |
|
349 |
|
| - |
|
350 |
user_client = UserClient().get_client()
|
| - |
|
351 |
user_client.getCounterByUserId(t_transaction.customer_id)
|
| 349 |
|
352 |
|
| 350 |
totalAmount = 0
|
353 |
totalAmount = 0
|
| 351 |
wallet_amount = 0.0
|
354 |
wallet_amount = 0.0
|
| 352 |
for t_order in t_orders:
|
355 |
for t_order in t_orders:
|
| 353 |
order = create_order(t_order)
|
356 |
order = create_order(t_order)
|
| Line 478... |
Line 481... |
| 478 |
transaction = get_transaction(transaction_id)
|
481 |
transaction = get_transaction(transaction_id)
|
| 479 |
|
482 |
|
| 480 |
return transaction.status
|
483 |
return transaction.status
|
| 481 |
|
484 |
|
| 482 |
def change_transaction_status(transaction_id, new_status, description, pickUp, orderType, source):
|
485 |
def change_transaction_status(transaction_id, new_status, description, pickUp, orderType, source):
|
| - |
|
486 |
logging.info("########change transaction status called")
|
| 483 |
transaction = get_transaction(transaction_id)
|
487 |
transaction = get_transaction(transaction_id)
|
| 484 |
|
488 |
|
| 485 |
if new_status in (TransactionStatus.AUTHORIZED, TransactionStatus.FLAGGED, TransactionStatus.COD_IN_PROCESS):
|
489 |
if new_status in (TransactionStatus.AUTHORIZED, TransactionStatus.FLAGGED, TransactionStatus.COD_IN_PROCESS):
|
| 486 |
wallet_amount_used = 0.0
|
490 |
wallet_amount_used = 0.0
|
| 487 |
for order in transaction.orders:
|
491 |
for order in transaction.orders:
|
| Line 490... |
Line 494... |
| 490 |
user_wallet = get_user_wallet(transaction.orders[0].customer_id)
|
494 |
user_wallet = get_user_wallet(transaction.orders[0].customer_id)
|
| 491 |
if user_wallet and user_wallet.amount < wallet_amount_used:
|
495 |
if user_wallet and user_wallet.amount < wallet_amount_used:
|
| 492 |
if new_status == TransactionStatus.AUTHORIZED:
|
496 |
if new_status == TransactionStatus.AUTHORIZED:
|
| 493 |
try:
|
497 |
try:
|
| 494 |
captured_amount = __capture_txn(transaction_id)
|
498 |
captured_amount = __capture_txn(transaction_id)
|
| 495 |
add_amount_in_wallet(transaction.customer_id, captured_amount, transaction_id, WalletReferenceType.PURCHASE, False, "Amount added against failed Purchase", commit_session=True)
|
- |
|
| 496 |
except:
|
499 |
except:
|
| - |
|
500 |
#TODO:
|
| - |
|
501 |
##add_amount_in_wallet(transaction.customer_id, captured_amount, transaction_id, WalletReferenceType.PURCHASE, False, "Amount added against failed Purchase", commit_session=True)
|
| 497 |
pass
|
502 |
pass
|
| 498 |
return False
|
503 |
return False
|
| 499 |
payment_client = PaymentClient().get_client()
|
504 |
payment_client = PaymentClient().get_client()
|
| 500 |
payments = payment_client.getPaymentForTxnId(order.transaction_id)
|
505 |
payments = payment_client.getPaymentForTxnId(order.transaction_id)
|
| 501 |
wallet_payment_exist = False
|
506 |
wallet_payment_exist = False
|
| 502 |
for payment in payments:
|
507 |
for payment in payments:
|
| 503 |
if payment.gatewayId == walletGatewayId:
|
508 |
if payment.gatewayId == walletGatewayId:
|
| 504 |
wallet_payment_exist = True
|
509 |
wallet_payment_exist = True
|
| - |
|
510 |
logging.info("########Updating wallet")
|
| 505 |
payment_client.updatePaymentDetails(payment.paymentId, "", "", "SUCCESS", "Payment Received", "", "", "", "", PaymentStatus.SUCCESS, "", None);
|
511 |
payment_client.updatePaymentDetails(payment.paymentId, "", "", "SUCCESS", "Payment Received", "", "", "", "", PaymentStatus.SUCCESS, "", None);
|
| 506 |
if not wallet_payment_exist:
|
512 |
if not wallet_payment_exist:
|
| 507 |
return False
|
513 |
return False
|
| 508 |
consume_wallet(transaction.orders[0].customer_id, wallet_amount_used, transaction_id, WalletReferenceType.PURCHASE, "Against Order purchase")
|
514 |
consume_wallet(transaction.orders[0].customer_id, wallet_amount_used, transaction_id, WalletReferenceType.PURCHASE, "Against Order purchase")
|
| 509 |
|
515 |
|
| Line 9099... |
Line 9105... |
| 9099 |
print e.message
|
9105 |
print e.message
|
| 9100 |
if warehouseDbConnection.open:
|
9106 |
if warehouseDbConnection.open:
|
| 9101 |
warehouseDbConnection.close()
|
9107 |
warehouseDbConnection.close()
|
| 9102 |
raise TransactionServiceException(110, 'Transfer price missing for itemId: ' + str(item_id) + ' and vendor: ' + str(warehouse.vendor.id))
|
9108 |
raise TransactionServiceException(110, 'Transfer price missing for itemId: ' + str(item_id) + ' and vendor: ' + str(warehouse.vendor.id))
|
| 9103 |
|
9109 |
|
| 9104 |
if order.orderType == OrderType.B2B:
|
9110 |
# if order.orderType == OrderType.B2B:
|
| 9105 |
tinNumber = Attribute.query.filter(Attribute.orderId == order.id).filter(Attribute.name == "tinNumber").first()
|
9111 |
# tinNumber = Attribute.query.filter(Attribute.orderId == order.id).filter(Attribute.name == "tinNumber").first()
|
| 9106 |
if tinNumber is None:
|
9112 |
# if tinNumber is None:
|
| 9107 |
if warehouseDbConnection.open:
|
9113 |
# if warehouseDbConnection.open:
|
| 9108 |
warehouseDbConnection.close()
|
9114 |
# warehouseDbConnection.close()
|
| 9109 |
raise TransactionServiceException(308, "Tin Number is Missing for B2B Order. Please contact engineering Team" + str(orderId))
|
9115 |
# raise TransactionServiceException(308, "Tin Number is Missing for B2B Order. Please contact engineering Team" + str(orderId))
|
| 9110 |
if newTaxType != 0:
|
9116 |
# if newTaxType != 0:
|
| 9111 |
order.orderType = OrderType.B2C
|
9117 |
# order.orderType = OrderType.B2C
|
| 9112 |
|
9118 |
|
| 9113 |
if billingType == BillingType.OURS:
|
9119 |
if billingType == BillingType.OURS:
|
| 9114 |
if order.productCondition == ProductCondition.GOOD:
|
9120 |
if order.productCondition == ProductCondition.GOOD:
|
| 9115 |
# Fetching GOOD w/h corresponding to the virtual one here
|
9121 |
# Fetching GOOD w/h corresponding to the virtual one here
|
| 9116 |
if not warehouse.billingWarehouseId:
|
9122 |
if not warehouse.billingWarehouseId:
|
| Line 11613... |
Line 11619... |
| 11613 |
transaction = get_transaction(transaction_id)
|
11619 |
transaction = get_transaction(transaction_id)
|
| 11614 |
user_client = UserClient().get_client()
|
11620 |
user_client = UserClient().get_client()
|
| 11615 |
counter = user_client.getCounterByUserId(transaction.customer_id)
|
11621 |
counter = user_client.getCounterByUserId(transaction.customer_id)
|
| 11616 |
address = user_client.getAddressById(counter.address)
|
11622 |
address = user_client.getAddressById(counter.address)
|
| 11617 |
for order in transaction.orders:
|
11623 |
for order in transaction.orders:
|
| 11618 |
oa = Attribute()
|
11624 |
#oa = Attribute()
|
| 11619 |
oa.value = counter.tin
|
11625 |
#oa.value = counter.tin
|
| 11620 |
oa.name='tinNumber'
|
11626 |
#oa.name='tinNumber'
|
| 11621 |
oa.orderId = order.id
|
11627 |
#soa.orderId = order.id
|
| 11622 |
|
11628 |
|
| 11623 |
order.customer_name = address.name
|
11629 |
order.customer_name = address.name
|
| 11624 |
order.customer_pincode = address.pin
|
11630 |
order.customer_pincode = address.pin
|
| 11625 |
order.customer_address1 = address.line1
|
11631 |
order.customer_address1 = address.line1
|
| 11626 |
order.customer_address2 = address.line2
|
11632 |
order.customer_address2 = address.line2
|