| Line 486... |
Line 486... |
| 486 |
transaction = get_transaction(transaction_id)
|
486 |
transaction = get_transaction(transaction_id)
|
| 487 |
|
487 |
|
| 488 |
return transaction.status
|
488 |
return transaction.status
|
| 489 |
|
489 |
|
| 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")
|
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 |
|
495 |
|
| 496 |
|
496 |
|
| Line 721... |
Line 721... |
| 721 |
#order.orderType = orderType
|
721 |
#order.orderType = orderType
|
| 722 |
#After we got payment success, we will set logistics info also
|
722 |
#After we got payment success, we will set logistics info also
|
| 723 |
logistics_client = LogisticsClient().get_client()
|
723 |
logistics_client = LogisticsClient().get_client()
|
| 724 |
#FIXME line item is only one now. If multiple will come, need to fix.
|
724 |
#FIXME line item is only one now. If multiple will come, need to fix.
|
| 725 |
item_id = order.lineitems[0].item_id
|
725 |
item_id = order.lineitems[0].item_id
|
| 726 |
if order.pickupStoreId:
|
- |
|
| 727 |
# Need to send prepaid awb number for store pick up orders
|
- |
|
| 728 |
logistics_info = logistics_client.getLogisticsEstimation(item_id, order.customer_pincode, DeliveryType.COD)
|
- |
|
| 729 |
#//Start:- Added by Manish Sharma for FedEx Integration- Shipment Creation on 31-Jul-2013
|
- |
|
| 730 |
#prepaid_logistics_info = logistics_client.getLogisticsInfo(order.customer_pincode, item_id, DeliveryType.PREPAID, pickUp)
|
- |
|
| 731 |
#logistics_info.airway_billno = prepaid_logistics_info.airway_billno
|
- |
|
| 732 |
#logistics_info.providerId = prepaid_logistics_info.providerId
|
- |
|
| 733 |
#End:- Added by Manish Sharma for FedEx Integration- Shipment Creation on 31-Jul-2013
|
- |
|
| 734 |
# Will not provide OTG in pickup store
|
- |
|
| 735 |
order.otg = False
|
- |
|
| 736 |
|
- |
|
| 737 |
current_time = datetime.datetime.now()
|
- |
|
| 738 |
logistics_info.deliveryTime = adjust_delivery_time(current_time, logistics_info.deliveryTime)
|
- |
|
| 739 |
logistics_info.shippingTime = adjust_delivery_time(current_time, logistics_info.shippingTime)
|
- |
|
| 740 |
logistics_info.deliveryDelay = adjust_delivery_time(current_time, (logistics_info.shippingTime+logistics_info.deliveryDelay))
|
- |
|
| 741 |
|
- |
|
| 742 |
order.warehouse_id = logistics_info.warehouseId
|
- |
|
| 743 |
order.fulfilmentWarehouseId = logistics_info.fulfilmentWarehouseId
|
- |
|
| 744 |
order.logistics_provider_id = logistics_info.providerId
|
- |
|
| 745 |
#Start:- Added by Manish Sharma for FedEx Integration- Shipment Creation on 31-Jul-2013
|
- |
|
| 746 |
#order.airwaybill_no = logistics_info.airway_billno
|
- |
|
| 747 |
#order.tracking_id = order.airwaybill_no
|
- |
|
| 748 |
#End:- Added by Manish Sharma for FedEx Integration- Shipment Creation on 31-Jul-2013
|
- |
|
| 749 |
if order.source != OrderSource.AMAZON or order.source != OrderSource.JUNGLEE:
|
- |
|
| 750 |
order.courier_delivery_time = (current_time + datetime.timedelta(days=logistics_info.deliveryDelay)).replace(hour=COD_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
- |
|
| 751 |
order.expected_shipping_time = (current_time + datetime.timedelta(days=logistics_info.shippingTime)).replace(hour=COD_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
- |
|
| 752 |
order.promised_shipping_time = order.expected_shipping_time
|
- |
|
| 753 |
order.expected_delivery_time = (current_time + datetime.timedelta(days=logistics_info.deliveryTime)).replace(hour=COD_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
- |
|
| 754 |
order.promised_delivery_time = order.expected_delivery_time
|
- |
|
| 755 |
|
- |
|
| 756 |
inventory_client = InventoryClient().get_client()
|
- |
|
| 757 |
fulfilmentWarehouseId = logistics_info.fulfilmentWarehouseId
|
- |
|
| 758 |
if OrderType.B2B == order.orderType:
|
- |
|
| 759 |
#get state
|
- |
|
| 760 |
stateMaster = fetchStateMaster()
|
- |
|
| 761 |
stateId = -1
|
- |
|
| 762 |
for k, v in stateMaster.iteritems():
|
- |
|
| 763 |
if v.stateName == order.customer_state:
|
- |
|
| 764 |
stateId = k
|
- |
|
| 765 |
break
|
- |
|
| 766 |
if stateId == -1:
|
- |
|
| 767 |
raise TransactionServiceException(108, "No such State")
|
- |
|
| 768 |
if not inventory_client.isAlive():
|
- |
|
| 769 |
inventory_client = InventoryClient().get_client()
|
- |
|
| 770 |
ffWarehouse = inventory_client.getWarehouse(order.fulfilmentWarehouseId)
|
- |
|
| 771 |
if stateId!= ffWarehouse.stateId:
|
- |
|
| 772 |
goodWhIds = inventory_client.getOursGoodWarehouseIdsForLocation(stateId)
|
- |
|
| 773 |
|
726 |
|
| 774 |
if goodWhIds is None or len(goodWhIds) == 0:
|
727 |
try:
|
| 775 |
raise TransactionServiceException(108, "No availability from this location")
|
728 |
#Get the id and location of actual warehouse that'll be used to fulfil this order.
|
| 776 |
fulfilmentWarehouseId = goodWhIds[0]
|
729 |
inventory_client = InventoryClient().get_client()
|
| 777 |
for goodWhId in goodWhIds:
|
- |
|
| 778 |
availability = inventory_client.getItemAvailibilityAtWarehouse(goodWhId, order.lineitems[0].item_id)
|
730 |
fulfilmentWhId, expected_delay, billingWarehouseId, sellingPrice, totalAvailability, weight = inventory_client.getItemAvailabilityAtLocation(item_id, 1, -1)
|
| 779 |
if availability > 0:
|
731 |
except Exception as ex:
|
| 780 |
fulfilmentWarehouseId = goodWhId
|
732 |
raise TransactionServiceException(103, "Unable to fetch inventory information about this item.")
|
| 781 |
break
|
- |
|
| 782 |
|
733 |
|
| 783 |
order.fulfilmentWarehouseId = fulfilmentWarehouseId
|
734 |
expectedDelayMap[item_id] = expected_delay
|
| 784 |
fulfillmentWh = inventory_client.getWarehouse(fulfilmentWarehouseId)
|
735 |
if billingWarehouseIdMap.has_key(billingWarehouseId):
|
| 785 |
order.warehouse_id = fulfillmentWh.billingWarehouseId
|
736 |
ordersList = billingWarehouseIdMap.get(billingWarehouseId)
|
| 786 |
if order.productCondition != ProductCondition.BAD:
|
737 |
ordersList.append(order)
|
| 787 |
inventory_client.reserveItemInWarehouse(item_id, fulfilmentWarehouseId, sourceId, order.id, to_java_date(order.created_timestamp), to_java_date(order.promised_shipping_time), order.lineitems[0].quantity)
|
738 |
billingWarehouseIdMap[billingWarehouseId] = ordersList
|
| 788 |
|
- |
|
| 789 |
else:
|
739 |
else:
|
| - |
|
740 |
ordersList = []
|
| - |
|
741 |
ordersList.append(order)
|
| - |
|
742 |
billingWarehouseIdMap[billingWarehouseId] = ordersList
|
| - |
|
743 |
|
| - |
|
744 |
if billingWarehouseTxnMap.has_key(billingWarehouseId):
|
| - |
|
745 |
transactionAmount , transactionWeight = billingWarehouseTxnMap.get(billingWarehouseId)
|
| - |
|
746 |
transactionAmount = transactionAmount+order.total_amount
|
| - |
|
747 |
transactionWeight = transactionWeight+order.total_weight
|
| - |
|
748 |
billingWarehouseTxnMap[billingWarehouseId] = transactionAmount , transactionWeight
|
| - |
|
749 |
else:
|
| - |
|
750 |
billingWarehouseTxnMap[billingWarehouseId] = order.total_amount , order.total_weight
|
| 790 |
|
751 |
|
| 791 |
try:
|
- |
|
| 792 |
#Get the id and location of actual warehouse that'll be used to fulfil this order.
|
- |
|
| 793 |
inventory_client = InventoryClient().get_client()
|
752 |
subOrderAmountsMap[long(order.lineitems[0].unit_price)] = order
|
| 794 |
fulfilmentWhId, expected_delay, billingWarehouseId, sellingPrice, totalAvailability, weight = inventory_client.getItemAvailabilityAtLocation(item_id, 1, -1)
|
- |
|
| 795 |
except Exception as ex:
|
- |
|
| 796 |
raise TransactionServiceException(103, "Unable to fetch inventory information about this item.")
|
- |
|
| 797 |
|
753 |
|
| 798 |
expectedDelayMap[item_id] = expected_delay
|
- |
|
| 799 |
if billingWarehouseIdMap.has_key(billingWarehouseId):
|
- |
|
| 800 |
ordersList = billingWarehouseIdMap.get(billingWarehouseId)
|
- |
|
| 801 |
ordersList.append(order)
|
- |
|
| 802 |
billingWarehouseIdMap[billingWarehouseId] = ordersList
|
- |
|
| 803 |
else:
|
- |
|
| 804 |
ordersList = []
|
- |
|
| 805 |
ordersList.append(order)
|
- |
|
| 806 |
billingWarehouseIdMap[billingWarehouseId] = ordersList
|
- |
|
| 807 |
|
- |
|
| 808 |
if billingWarehouseTxnMap.has_key(billingWarehouseId):
|
- |
|
| 809 |
transactionAmount , transactionWeight = billingWarehouseTxnMap.get(billingWarehouseId)
|
- |
|
| 810 |
transactionAmount = transactionAmount+order.total_amount
|
- |
|
| 811 |
transactionWeight = transactionWeight+order.total_weight
|
- |
|
| 812 |
billingWarehouseTxnMap[billingWarehouseId] = transactionAmount , transactionWeight
|
- |
|
| 813 |
else:
|
- |
|
| 814 |
billingWarehouseTxnMap[billingWarehouseId] = order.total_amount , order.total_weight
|
- |
|
| 815 |
|
- |
|
| 816 |
subOrderAmountsMap[long(order.lineitems[0].unit_price)] = order
|
- |
|
| 817 |
|
- |
|
| 818 |
order.fulfilmentWarehouseId = fulfilmentWhId
|
754 |
order.fulfilmentWarehouseId = fulfilmentWhId
|
| 819 |
order.warehouse_id = billingWarehouseId
|
755 |
order.warehouse_id = billingWarehouseId
|
| 820 |
|
756 |
|
| 821 |
if order.pickupStoreId:
|
- |
|
| 822 |
order.otg = False
|
- |
|
| 823 |
|
- |
|
| 824 |
if order.productCondition != ProductCondition.BAD:
|
757 |
if order.productCondition != ProductCondition.BAD:
|
| 825 |
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)
|
758 |
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)
|
| 826 |
|
759 |
|
| 827 |
try:
|
760 |
try:
|
| 828 |
item_pricing = inventory_client.getItemPricing(item_id, -1)
|
761 |
item_pricing = inventory_client.getItemPricing(item_id, -1)
|
| 829 |
order.lineitems[0].transfer_price = item_pricing.transferPrice
|
762 |
order.lineitems[0].transfer_price = item_pricing.transferPrice
|
| 830 |
order.lineitems[0].nlc = item_pricing.nlc
|
763 |
order.lineitems[0].nlc = item_pricing.nlc
|
| 831 |
except:
|
764 |
except:
|
| 832 |
print "Not able to get transfer price. Skipping"
|
765 |
print "Not able to get transfer price. Skipping"
|
| 833 |
|
766 |
|
| 834 |
catalog_client = CatalogClient().get_client()
|
- |
|
| 835 |
voucherAmount = catalog_client.getVoucherAmount(item_id, VoucherType.SPICEDECK_MOBILE)
|
- |
|
| 836 |
if voucherAmount:
|
- |
|
| 837 |
__create_recharge_voucher_tracker(order, voucherAmount, VoucherType.SPICEDECK_MOBILE)
|
- |
|
| 838 |
|
- |
|
| 839 |
for billingWarehouseId, orders in billingWarehouseIdMap.items():
|
767 |
for billingWarehouseId, orders in billingWarehouseIdMap.items():
|
| 840 |
logistics_client = LogisticsClient().get_client()
|
768 |
logistics_client = LogisticsClient().get_client()
|
| 841 |
transactionAmount , transactionWeight = billingWarehouseTxnMap.get(billingWarehouseId)
|
769 |
transactionAmount , transactionWeight = billingWarehouseTxnMap.get(billingWarehouseId)
|
| 842 |
costingAndDeliveryEstimateObj = None
|
770 |
costingAndDeliveryEstimateObj = None
|
| 843 |
try:
|
771 |
try:
|