| Line 490... |
Line 490... |
| 490 |
def change_transaction_status(transaction_id, new_status, description, pickUp, orderType, source):
|
490 |
def change_transaction_status(transaction_id, new_status, description, pickUp, orderType, source):
|
| 491 |
logging.info("########change transaction status called" + str(transaction_id))
|
491 |
logging.info("########change transaction status called" + str(transaction_id))
|
| 492 |
transaction = get_transaction(transaction_id)
|
492 |
transaction = get_transaction(transaction_id)
|
| 493 |
|
493 |
|
| 494 |
if new_status in (TransactionStatus.AUTHORIZED, TransactionStatus.FLAGGED, TransactionStatus.COD_IN_PROCESS):
|
494 |
if new_status in (TransactionStatus.AUTHORIZED, TransactionStatus.FLAGGED, TransactionStatus.COD_IN_PROCESS):
|
| 495 |
|
- |
|
| 496 |
|
- |
|
| 497 |
wallet_amount_used = 0.0
|
495 |
wallet_amount_used = 0.0
|
| 498 |
for order in transaction.orders:
|
496 |
for order in transaction.orders:
|
| 499 |
wallet_amount_used = wallet_amount_used + order.wallet_amount
|
497 |
wallet_amount_used = wallet_amount_used + order.wallet_amount
|
| 500 |
if wallet_amount_used > 0:
|
498 |
if wallet_amount_used > 0:
|
| 501 |
user_wallet = get_user_wallet(transaction.orders[0].customer_id)
|
499 |
user_wallet = get_user_wallet(transaction.orders[0].customer_id)
|
| Line 644... |
Line 642... |
| 644 |
item_pricing = inventory_client.getItemPricing(item_id, -1)
|
642 |
item_pricing = inventory_client.getItemPricing(item_id, -1)
|
| 645 |
order.lineitems[0].transfer_price = item_pricing.transferPrice
|
643 |
order.lineitems[0].transfer_price = item_pricing.transferPrice
|
| 646 |
order.lineitems[0].nlc = item_pricing.nlc
|
644 |
order.lineitems[0].nlc = item_pricing.nlc
|
| 647 |
except:
|
645 |
except:
|
| 648 |
print "Not able to get transfer price. Skipping"
|
646 |
print "Not able to get transfer price. Skipping"
|
| 649 |
|
- |
|
| 650 |
elif new_status == TransactionStatus.COD_IN_PROCESS:
|
- |
|
| 651 |
expectedDelayMap = {}
|
- |
|
| 652 |
billingWarehouseIdMap = {}
|
- |
|
| 653 |
billingWarehouseTxnMap = {}
|
- |
|
| 654 |
subOrderAmountsMap = {}
|
- |
|
| 655 |
for order in transaction.orders:
|
- |
|
| 656 |
order.status = OrderStatus.COD_VERIFICATION_PENDING
|
- |
|
| 657 |
order.statusDescription = "Verification Pending"
|
- |
|
| 658 |
order.cod = True
|
- |
|
| 659 |
#OrderType cant be changed
|
- |
|
| 660 |
#order.orderType = orderType
|
- |
|
| 661 |
#After we got payment success, we will set logistics info also
|
- |
|
| 662 |
logistics_client = LogisticsClient().get_client()
|
- |
|
| 663 |
#FIXME line item is only one now. If multiple will come, need to fix.
|
- |
|
| 664 |
item_id = order.lineitems[0].item_id
|
- |
|
| 665 |
|
- |
|
| 666 |
try:
|
- |
|
| 667 |
#Get the id and location of actual warehouse that'll be used to fulfil this order.
|
- |
|
| 668 |
inventory_client = InventoryClient().get_client()
|
- |
|
| 669 |
fulfilmentWhId, expected_delay, billingWarehouseId, sellingPrice, totalAvailability, weight = inventory_client.getItemAvailabilityAtLocation(item_id, 1, -1)
|
- |
|
| 670 |
except Exception as ex:
|
- |
|
| 671 |
raise TransactionServiceException(103, "Unable to fetch inventory information about this item.")
|
- |
|
| 672 |
|
- |
|
| 673 |
expectedDelayMap[item_id] = expected_delay
|
- |
|
| 674 |
if billingWarehouseIdMap.has_key(billingWarehouseId):
|
- |
|
| 675 |
ordersList = billingWarehouseIdMap.get(billingWarehouseId)
|
- |
|
| 676 |
ordersList.append(order)
|
- |
|
| 677 |
billingWarehouseIdMap[billingWarehouseId] = ordersList
|
- |
|
| 678 |
else:
|
- |
|
| 679 |
ordersList = []
|
- |
|
| 680 |
ordersList.append(order)
|
- |
|
| 681 |
billingWarehouseIdMap[billingWarehouseId] = ordersList
|
- |
|
| 682 |
|
- |
|
| 683 |
if billingWarehouseTxnMap.has_key(billingWarehouseId):
|
- |
|
| 684 |
transactionAmount , transactionWeight = billingWarehouseTxnMap.get(billingWarehouseId)
|
- |
|
| 685 |
transactionAmount = transactionAmount+order.total_amount
|
- |
|
| 686 |
transactionWeight = transactionWeight+order.total_weight
|
- |
|
| 687 |
billingWarehouseTxnMap[billingWarehouseId] = transactionAmount , transactionWeight
|
- |
|
| 688 |
else:
|
- |
|
| 689 |
billingWarehouseTxnMap[billingWarehouseId] = order.total_amount , order.total_weight
|
- |
|
| 690 |
|
- |
|
| 691 |
subOrderAmountsMap[long(order.lineitems[0].unit_price)] = order
|
- |
|
| 692 |
|
- |
|
| 693 |
order.fulfilmentWarehouseId = fulfilmentWhId
|
- |
|
| 694 |
order.warehouse_id = billingWarehouseId
|
- |
|
| 695 |
|
- |
|
| 696 |
if order.productCondition != ProductCondition.BAD:
|
- |
|
| 697 |
inventory_client.reserveItemInWarehouse(item_id, order.fulfilmentWarehouseId, sourceId, order.id, to_java_date(order.created_timestamp), to_java_date(order.promised_shipping_time), order.lineitems[0].quantity)
|
- |
|
| 698 |
|
- |
|
| 699 |
try:
|
- |
|
| 700 |
item_pricing = inventory_client.getItemPricing(item_id, -1)
|
- |
|
| 701 |
order.lineitems[0].transfer_price = item_pricing.transferPrice
|
- |
|
| 702 |
order.lineitems[0].nlc = item_pricing.nlc
|
- |
|
| 703 |
except:
|
- |
|
| 704 |
print "Not able to get transfer price. Skipping"
|
- |
|
| 705 |
|
647 |
|
| 706 |
session.commit()
|
648 |
session.commit()
|
| 707 |
|
- |
|
| 708 |
if new_status in (TransactionStatus.AUTHORIZED, TransactionStatus.FLAGGED, TransactionStatus.COD_IN_PROCESS):
|
- |
|
| 709 |
try:
|
- |
|
| 710 |
if order.source == OrderSource.WEBSITE:
|
- |
|
| 711 |
if new_status == TransactionStatus.COD_IN_PROCESS:
|
- |
|
| 712 |
transaction_requiring_extra_processing = TransactionRequiringExtraProcessing()
|
- |
|
| 713 |
transaction_requiring_extra_processing.category = 'COD_VERIFICATION'
|
- |
|
| 714 |
transaction_requiring_extra_processing.transaction_id = transaction_id
|
- |
|
| 715 |
session.commit()
|
- |
|
| 716 |
elif new_status == TransactionStatus.FLAGGED:
|
- |
|
| 717 |
transaction_requiring_extra_processing = TransactionRequiringExtraProcessing()
|
- |
|
| 718 |
transaction_requiring_extra_processing.category = 'PAYMENT_FLAGGED'
|
- |
|
| 719 |
transaction_requiring_extra_processing.transaction_id = transaction_id
|
- |
|
| 720 |
session.commit()
|
- |
|
| 721 |
else:
|
- |
|
| 722 |
order.otg = False
|
- |
|
| 723 |
session.commit()
|
- |
|
| 724 |
except Exception as e:
|
- |
|
| 725 |
print "Error inserting transaction Id: " + str(transaction_id) + " due to " + str(e)
|
- |
|
| 726 |
|
- |
|
| 727 |
return True
|
649 |
return True
|
| 728 |
|
650 |
|
| 729 |
def __create_recharge_voucher_tracker(order, amount, voucherType):
|
651 |
def __create_recharge_voucher_tracker(order, amount, voucherType):
|
| 730 |
rvt = RechargeVoucherTracker()
|
652 |
rvt = RechargeVoucherTracker()
|
| 731 |
rvt.order = order
|
653 |
rvt.order = order
|
| Line 4151... |
Line 4073... |
| 4151 |
userClient, isFofo = __is_Fofo(userClient, order.customer_id)
|
4073 |
userClient, isFofo = __is_Fofo(userClient, order.customer_id)
|
| 4152 |
if isFofo:
|
4074 |
if isFofo:
|
| 4153 |
stateId = warehouse.stateId
|
4075 |
stateId = warehouse.stateId
|
| 4154 |
if warehouse.id == warehouse.billingWarehouseId:
|
4076 |
if warehouse.id == warehouse.billingWarehouseId:
|
| 4155 |
itemAvailabilityLocation = inventoryClient.getItemAvailabilityAtLocation(lineitem.item_id, sourceId, stateId)
|
4077 |
itemAvailabilityLocation = inventoryClient.getItemAvailabilityAtLocation(lineitem.item_id, sourceId, stateId)
|
| - |
|
4078 |
if warehouse.billingWarehouseId == itemAvailabilityLocation[2]:
|
| 4156 |
vendor_warehouse_id=itemAvailabilityLocation[0]
|
4079 |
billing_warehouse_id=itemAvailabilityLocation[2]
|
| 4157 |
billing_warehouse_id=itemAvailabilityLocation[2]
|
4080 |
vendor_warehouse_id=itemAvailabilityLocation[0]
|
| - |
|
4081 |
else:
|
| - |
|
4082 |
vendor_warehouse_id = 8489
|
| 4158 |
else:
|
4083 |
else:
|
| 4159 |
vendor_warehouse_id = warehouse_id
|
4084 |
vendor_warehouse_id = warehouse_id
|
| 4160 |
billing_warehouse_id=warehouse.billingWarehouseId
|
4085 |
billing_warehouse_id=warehouse.billingWarehouseId
|
| 4161 |
|
4086 |
|
| 4162 |
#if vendorWarehouse is None or vendorWarehouse.billingWarehouseId != warehouse.id:
|
4087 |
#if vendorWarehouse is None or vendorWarehouse.billingWarehouseId != warehouse.id:
|
| Line 11379... |
Line 11304... |
| 11379 |
|
11304 |
|
| 11380 |
|
11305 |
|
| 11381 |
if __name__ == '__main__':
|
11306 |
if __name__ == '__main__':
|
| 11382 |
DataService.initialize(db_hostname="192.168.190.112")
|
11307 |
DataService.initialize(db_hostname="192.168.190.112")
|
| 11383 |
#transaction_ids=[1030084,1030087,1030090,1030093,1030096,1030099,1030102,1030105,1030108,1030111,1030114,1030117,1030120,1030123,1030144,1030147,1030153]
|
11308 |
#transaction_ids=[1030084,1030087,1030090,1030093,1030096,1030099,1030102,1030105,1030108,1030111,1030114,1030117,1030120,1030123,1030144,1030147,1030153]
|
| 11384 |
transaction_ids=[1043579, 1043580, 1043581, 1043582, 1043584, 1043588, 1043589]
|
11309 |
#transaction_ids=[1043579, 1043580, 1043581, 1043582, 1043584, 1043588, 1043589]
|
| 11385 |
#transaction_ids=[1043577]
|
11310 |
#transaction_ids=[1043577]
|
| 11386 |
for transaction_id in transaction_ids:
|
11311 |
#for transaction_id in transaction_ids:
|
| 11387 |
process_failed_payment(TransactionStatus.AUTHORIZED, transaction_id, "Transaction Authorised", 1, PickUpType.SELF)
|
11312 |
# process_failed_payment(TransactionStatus.AUTHORIZED, transaction_id, "Transaction Authorised", 1, PickUpType.SELF)
|
| - |
|
11313 |
#
|
| - |
|
11314 |
##################################################################################################################################
|
| - |
|
11315 |
refund_order(1588409, "backend-team", "As per Customer's Request")
|
| - |
|
11316 |
|
| 11388 |
|
11317 |
|
| 11389 |
|
11318 |
|
| 11390 |
# mark_order_for_selfpickup_temp(transaction_ids)
|
11319 |
# mark_order_for_selfpickup_temp(transaction_ids)
|
| 11391 |
# get_billed_orders_for_manifest_gen(7441, 2, True)
|
11320 |
# get_billed_orders_for_manifest_gen(7441, 2, True)
|
| 11392 |
# ordersmap = {'911319502886601':1544266,'911319502890314':1544266,'x911319502903141':1544269,'x911319502916655':1544269,'x911319502950985':1544269,'x911319502836309':1544269,'x911319502972369':1544269,'x911319502950860':1544269,'x911319502918313':1544269,
|
11321 |
# ordersmap = {'911319502886601':1544266,'911319502890314':1544266,'x911319502903141':1544269,'x911319502916655':1544269,'x911319502950985':1544269,'x911319502836309':1544269,'x911319502972369':1544269,'x911319502950860':1544269,'x911319502918313':1544269,
|
| 11393 |
# 'x911319502943436':1544269,'x911319502928056':1544269,'x911319502838263':1544269,'911319502794144':1544269,'x911319502821616':1544269,'x911319502974746':1544269,'x911319502821442':1544269,'x911319502903984':1544269,'x911319502820980':1544269,
|
11322 |
# 'x911319502943436':1544269,'x911319502928056':1544269,'x911319502838263':1544269,'911319502794144':1544269,'x911319502821616':1544269,'x911319502974746':1544269,'x911319502821442':1544269,'x911319502903984':1544269,'x911319502820980':1544269,
|