| Line 544... |
Line 544... |
| 544 |
# order.orderType = orderType
|
544 |
# order.orderType = orderType
|
| 545 |
#After we got payment success, we will set logistics info also
|
545 |
#After we got payment success, we will set logistics info also
|
| 546 |
logistics_client = LogisticsClient().get_client()
|
546 |
logistics_client = LogisticsClient().get_client()
|
| 547 |
#FIXME line item is only one now. If multiple will come, need to fix.
|
547 |
#FIXME line item is only one now. If multiple will come, need to fix.
|
| 548 |
item_id = order.lineitems[0].item_id
|
548 |
item_id = order.lineitems[0].item_id
|
| 549 |
if pickUp == PickUpType.RUNNER or pickUp == PickUpType.SELF or order.source!=OrderSource.WEBSITE:
|
549 |
if pickUp == PickUpType.RUNNER or pickUp == PickUpType.SELF:
|
| 550 |
logistics_info = logistics_client.getLogisticsInfo(order.customer_pincode, item_id, DeliveryType.PREPAID, pickUp)
|
550 |
logistics_info = logistics_client.getLogisticsInfo(order.customer_pincode, item_id, DeliveryType.PREPAID, pickUp)
|
| 551 |
current_time = datetime.datetime.now()
|
551 |
current_time = datetime.datetime.now()
|
| 552 |
logistics_info.deliveryTime = adjust_delivery_time(current_time, logistics_info.deliveryTime)
|
552 |
logistics_info.deliveryTime = adjust_delivery_time(current_time, logistics_info.deliveryTime)
|
| 553 |
logistics_info.shippingTime = adjust_delivery_time(current_time, logistics_info.shippingTime)
|
553 |
logistics_info.shippingTime = adjust_delivery_time(current_time, logistics_info.shippingTime)
|
| 554 |
logistics_info.deliveryDelay = adjust_delivery_time(current_time, (logistics_info.shippingTime+logistics_info.deliveryDelay))
|
554 |
logistics_info.deliveryDelay = adjust_delivery_time(current_time, (logistics_info.shippingTime+logistics_info.deliveryDelay))
|
| Line 556... |
Line 556... |
| 556 |
order.otg = logistics_info.otgAvailable
|
556 |
order.otg = logistics_info.otgAvailable
|
| 557 |
order.warehouse_id = logistics_info.warehouseId
|
557 |
order.warehouse_id = logistics_info.warehouseId
|
| 558 |
order.fulfilmentWarehouseId = logistics_info.fulfilmentWarehouseId
|
558 |
order.fulfilmentWarehouseId = logistics_info.fulfilmentWarehouseId
|
| 559 |
order.logistics_provider_id = logistics_info.providerId
|
559 |
order.logistics_provider_id = logistics_info.providerId
|
| 560 |
|
560 |
|
| 561 |
|
- |
|
| 562 |
if order.source != OrderSource.AMAZON or order.source != OrderSource.JUNGLEE:
|
- |
|
| 563 |
order.courier_delivery_time = (current_time + datetime.timedelta(days=logistics_info.deliveryDelay)).replace(hour=PREPAID_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
561 |
order.courier_delivery_time = (current_time + datetime.timedelta(days=logistics_info.deliveryDelay)).replace(hour=PREPAID_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
| 564 |
order.expected_shipping_time = (current_time + datetime.timedelta(days=logistics_info.shippingTime)).replace(hour=PREPAID_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
562 |
order.expected_shipping_time = (current_time + datetime.timedelta(days=logistics_info.shippingTime)).replace(hour=PREPAID_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
| 565 |
order.promised_shipping_time = order.expected_shipping_time
|
563 |
order.promised_shipping_time = order.expected_shipping_time
|
| 566 |
order.expected_delivery_time = (current_time + datetime.timedelta(days=logistics_info.deliveryTime)).replace(hour=PREPAID_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
564 |
order.expected_delivery_time = (current_time + datetime.timedelta(days=logistics_info.deliveryTime)).replace(hour=PREPAID_SHIPPING_CUTOFF_TIME, minute=0, second=0)
|
| 567 |
order.promised_delivery_time = order.expected_delivery_time
|
565 |
order.promised_delivery_time = order.expected_delivery_time
|
| 568 |
|
566 |
|
| 569 |
inventory_client = InventoryClient().get_client()
|
567 |
inventory_client = InventoryClient().get_client()
|
| 570 |
fulfilmentWarehouseId = logistics_info.fulfilmentWarehouseId
|
568 |
fulfilmentWarehouseId = logistics_info.fulfilmentWarehouseId
|
| 571 |
if OrderType.B2B == order.orderType:
|
569 |
# if OrderType.B2B == order.orderType:
|
| 572 |
#get state
|
570 |
# #get state
|
| 573 |
stateMaster = fetchStateMaster()
|
571 |
# stateMaster = fetchStateMaster()
|
| 574 |
stateId = -1
|
572 |
# stateId = -1
|
| 575 |
for k, v in stateMaster.iteritems():
|
573 |
# for k, v in stateMaster.iteritems():
|
| 576 |
if v.stateName == order.customer_state:
|
574 |
# if v.stateName == order.customer_state:
|
| 577 |
stateId = k
|
575 |
# stateId = k
|
| 578 |
break
|
576 |
# break
|
| 579 |
if stateId == -1:
|
577 |
# if stateId == -1:
|
| 580 |
raise TransactionServiceException(108, "No such State")
|
578 |
# raise TransactionServiceException(108, "No such State")
|
| 581 |
if not inventory_client.isAlive():
|
579 |
# if not inventory_client.isAlive():
|
| 582 |
inventory_client = InventoryClient().get_client()
|
580 |
# inventory_client = InventoryClient().get_client()
|
| 583 |
ffWarehouse = inventory_client.getWarehouse(order.fulfilmentWarehouseId)
|
581 |
# ffWarehouse = inventory_client.getWarehouse(order.fulfilmentWarehouseId)
|
| 584 |
if stateId!= ffWarehouse.stateId:
|
582 |
# if stateId!= ffWarehouse.stateId:
|
| 585 |
goodWhIds = inventory_client.getOursGoodWarehouseIdsForLocation(stateId)
|
583 |
# goodWhIds = inventory_client.getOursGoodWarehouseIdsForLocation(stateId)
|
| 586 |
if goodWhIds is None or len(goodWhIds) == 0:
|
584 |
# if goodWhIds is None or len(goodWhIds) == 0:
|
| 587 |
raise TransactionServiceException(108, "No availability from this location")
|
585 |
# raise TransactionServiceException(108, "No availability from this location")
|
| 588 |
fulfilmentWarehouseId = goodWhIds[0]
|
586 |
# fulfilmentWarehouseId = goodWhIds[0]
|
| 589 |
for goodWhId in goodWhIds:
|
587 |
# for goodWhId in goodWhIds:
|
| 590 |
availability = inventory_client.getItemAvailibilityAtWarehouse(goodWhId, order.lineitems[0].item_id)
|
588 |
# availability = inventory_client.getItemAvailibilityAtWarehouse(goodWhId, order.lineitems[0].item_id)
|
| 591 |
if availability > 0:
|
589 |
# if availability > 0:
|
| 592 |
fulfilmentWarehouseId = goodWhId
|
590 |
# fulfilmentWarehouseId = goodWhId
|
| 593 |
break
|
591 |
# break
|
| 594 |
|
592 |
#
|
| 595 |
order.fulfilmentWarehouseId = fulfilmentWarehouseId
|
593 |
# order.fulfilmentWarehouseId = fulfilmentWarehouseId
|
| 596 |
fulfillmentWh = inventory_client.getWarehouse(fulfilmentWarehouseId)
|
594 |
# fulfillmentWh = inventory_client.getWarehouse(fulfilmentWarehouseId)
|
| 597 |
order.warehouse_id = fulfillmentWh.billingWarehouseId
|
595 |
# order.warehouse_id = fulfillmentWh.billingWarehouseId
|
| 598 |
|
596 |
|
| 599 |
if order.pickupStoreId:
|
597 |
if order.pickupStoreId:
|
| 600 |
order.otg = False
|
598 |
order.otg = False
|
| 601 |
|
599 |
|
| 602 |
if order.productCondition != ProductCondition.BAD:
|
600 |
if order.productCondition != ProductCondition.BAD:
|
| Line 631... |
Line 629... |
| 631 |
subOrderAmountsMap[long(order.lineitems[0].unit_price)] = order
|
629 |
subOrderAmountsMap[long(order.lineitems[0].unit_price)] = order
|
| 632 |
|
630 |
|
| 633 |
order.fulfilmentWarehouseId = fulfilmentWhId
|
631 |
order.fulfilmentWarehouseId = fulfilmentWhId
|
| 634 |
order.warehouse_id = billingWarehouseId
|
632 |
order.warehouse_id = billingWarehouseId
|
| 635 |
|
633 |
|
| 636 |
fulfilmentWarehouseId = fulfilmentWhId
|
634 |
# fulfilmentWarehouseId = fulfilmentWhId
|
| 637 |
if OrderType.B2B == order.orderType:
|
635 |
# if OrderType.B2B == order.orderType:
|
| 638 |
#get state
|
636 |
# #get state
|
| 639 |
stateMaster = fetchStateMaster()
|
637 |
# stateMaster = fetchStateMaster()
|
| 640 |
stateId = -1
|
638 |
# stateId = -1
|
| 641 |
for k, v in stateMaster.iteritems():
|
639 |
# for k, v in stateMaster.iteritems():
|
| 642 |
if v.stateName == order.customer_state:
|
640 |
# if v.stateName == order.customer_state:
|
| 643 |
stateId = k
|
641 |
# stateId = k
|
| 644 |
break
|
642 |
# break
|
| 645 |
if stateId == -1:
|
643 |
# if stateId == -1:
|
| 646 |
raise TransactionServiceException(108, "No such State")
|
644 |
# raise TransactionServiceException(108, "No such State")
|
| 647 |
if not inventory_client.isAlive():
|
645 |
# if not inventory_client.isAlive():
|
| 648 |
inventory_client = InventoryClient().get_client()
|
646 |
# inventory_client = InventoryClient().get_client()
|
| 649 |
ffWarehouse = inventory_client.getWarehouse(order.fulfilmentWarehouseId)
|
647 |
# ffWarehouse = inventory_client.getWarehouse(order.fulfilmentWarehouseId)
|
| 650 |
if stateId!= ffWarehouse.stateId:
|
648 |
# if stateId!= ffWarehouse.stateId:
|
| 651 |
goodWhIds = inventory_client.getOursGoodWarehouseIdsForLocation(stateId)
|
649 |
# goodWhIds = inventory_client.getOursGoodWarehouseIdsForLocation(stateId)
|
| 652 |
if goodWhIds is None or len(goodWhIds) == 0:
|
650 |
# if goodWhIds is None or len(goodWhIds) == 0:
|
| 653 |
raise TransactionServiceException(108, "No availability from this location")
|
651 |
# raise TransactionServiceException(108, "No availability from this location")
|
| 654 |
fulfilmentWarehouseId = goodWhIds[0]
|
652 |
# fulfilmentWarehouseId = goodWhIds[0]
|
| 655 |
for goodWhId in goodWhIds:
|
653 |
# for goodWhId in goodWhIds:
|
| 656 |
availability = inventory_client.getItemAvailibilityAtWarehouse(goodWhId, order.lineitems[0].item_id)
|
654 |
# availability = inventory_client.getItemAvailibilityAtWarehouse(goodWhId, order.lineitems[0].item_id)
|
| 657 |
if availability > 0:
|
655 |
# if availability > 0:
|
| 658 |
fulfilmentWarehouseId = goodWhId
|
656 |
# fulfilmentWarehouseId = goodWhId
|
| 659 |
break
|
657 |
# break
|
| 660 |
|
658 |
#
|
| 661 |
order.fulfilmentWarehouseId = fulfilmentWarehouseId
|
659 |
# order.fulfilmentWarehouseId = fulfilmentWarehouseId
|
| 662 |
fulfillmentWh = inventory_client.getWarehouse(fulfilmentWarehouseId)
|
660 |
# fulfillmentWh = inventory_client.getWarehouse(fulfilmentWarehouseId)
|
| 663 |
order.warehouse_id = fulfillmentWh.billingWarehouseId
|
661 |
# order.warehouse_id = fulfillmentWh.billingWarehouseId
|
| 664 |
|
662 |
|
| 665 |
if order.pickupStoreId:
|
663 |
if order.pickupStoreId:
|
| 666 |
order.otg = False
|
664 |
order.otg = False
|
| 667 |
|
665 |
|
| 668 |
if order.productCondition != ProductCondition.BAD:
|
666 |
if order.productCondition != ProductCondition.BAD:
|
| Line 842... |
Line 840... |
| 842 |
subOrderAmountsMap[long(order.lineitems[0].unit_price)] = order
|
840 |
subOrderAmountsMap[long(order.lineitems[0].unit_price)] = order
|
| 843 |
|
841 |
|
| 844 |
order.fulfilmentWarehouseId = fulfilmentWhId
|
842 |
order.fulfilmentWarehouseId = fulfilmentWhId
|
| 845 |
order.warehouse_id = billingWarehouseId
|
843 |
order.warehouse_id = billingWarehouseId
|
| 846 |
|
844 |
|
| 847 |
fulfilmentWarehouseId = fulfilmentWhId
|
845 |
# fulfilmentWarehouseId = fulfilmentWhId
|
| 848 |
if OrderType.B2B == order.orderType:
|
846 |
# if OrderType.B2B == order.orderType:
|
| 849 |
#get state
|
847 |
# #get state
|
| 850 |
stateMaster = fetchStateMaster()
|
848 |
# stateMaster = fetchStateMaster()
|
| 851 |
stateId = -1
|
849 |
# stateId = -1
|
| 852 |
for k, v in stateMaster.iteritems():
|
850 |
# for k, v in stateMaster.iteritems():
|
| 853 |
if v.stateName == order.customer_state:
|
851 |
# if v.stateName == order.customer_state:
|
| 854 |
stateId = k
|
852 |
# stateId = k
|
| 855 |
break
|
853 |
# break
|
| 856 |
if stateId == -1:
|
854 |
# if stateId == -1:
|
| 857 |
raise TransactionServiceException(108, "No such State")
|
855 |
# raise TransactionServiceException(108, "No such State")
|
| 858 |
if not inventory_client.isAlive():
|
856 |
# if not inventory_client.isAlive():
|
| 859 |
inventory_client = InventoryClient().get_client()
|
857 |
# inventory_client = InventoryClient().get_client()
|
| 860 |
ffWarehouse = inventory_client.getWarehouse(order.fulfilmentWarehouseId)
|
858 |
# ffWarehouse = inventory_client.getWarehouse(order.fulfilmentWarehouseId)
|
| 861 |
if stateId!= ffWarehouse.stateId:
|
859 |
# if stateId!= ffWarehouse.stateId:
|
| 862 |
goodWhIds = inventory_client.getOursGoodWarehouseIdsForLocation(stateId)
|
860 |
# goodWhIds = inventory_client.getOursGoodWarehouseIdsForLocation(stateId)
|
| 863 |
if goodWhIds is None or len(goodWhIds) == 0:
|
861 |
# if goodWhIds is None or len(goodWhIds) == 0:
|
| 864 |
raise TransactionServiceException(108, "No availability from this location")
|
862 |
# raise TransactionServiceException(108, "No availability from this location")
|
| 865 |
fulfilmentWarehouseId = goodWhIds[0]
|
863 |
# fulfilmentWarehouseId = goodWhIds[0]
|
| 866 |
for goodWhId in goodWhIds:
|
864 |
# for goodWhId in goodWhIds:
|
| 867 |
availability = inventory_client.getItemAvailibilityAtWarehouse(goodWhId, order.lineitems[0].item_id)
|
865 |
# availability = inventory_client.getItemAvailibilityAtWarehouse(goodWhId, order.lineitems[0].item_id)
|
| 868 |
if availability > 0:
|
866 |
# if availability > 0:
|
| 869 |
fulfilmentWarehouseId = goodWhId
|
867 |
# fulfilmentWarehouseId = goodWhId
|
| 870 |
break
|
868 |
# break
|
| 871 |
|
869 |
#
|
| 872 |
order.fulfilmentWarehouseId = fulfilmentWarehouseId
|
870 |
# order.fulfilmentWarehouseId = fulfilmentWarehouseId
|
| 873 |
fulfillmentWh = inventory_client.getWarehouse(fulfilmentWarehouseId)
|
871 |
# fulfillmentWh = inventory_client.getWarehouse(fulfilmentWarehouseId)
|
| 874 |
order.warehouse_id = fulfillmentWh.billingWarehouseId
|
872 |
# order.warehouse_id = fulfillmentWh.billingWarehouseId
|
| 875 |
|
873 |
|
| 876 |
if order.pickupStoreId:
|
874 |
if order.pickupStoreId:
|
| 877 |
order.otg = False
|
875 |
order.otg = False
|
| 878 |
|
876 |
|
| 879 |
if order.productCondition != ProductCondition.BAD:
|
877 |
if order.productCondition != ProductCondition.BAD:
|
| Line 4757... |
Line 4755... |
| 4757 |
logistics_client = LogisticsClient().get_client()
|
4755 |
logistics_client = LogisticsClient().get_client()
|
| 4758 |
provider = logistics_client.getProvider(logisticsProviderId)
|
4756 |
provider = logistics_client.getProvider(logisticsProviderId)
|
| 4759 |
|
4757 |
|
| 4760 |
if provider.groupShipmentAllowed:
|
4758 |
if provider.groupShipmentAllowed:
|
| 4761 |
for order in orders:
|
4759 |
for order in orders:
|
| 4762 |
totalOrdersAmount = totalOrdersAmount + (order.total_amount+order.shippingCost-order.gvAmount)
|
4760 |
totalOrdersAmount = totalOrdersAmount + order.net_payable_amount
|
| 4763 |
|
4761 |
|
| 4764 |
if abs(amount - (totalOrdersAmount)) > 0.5:
|
4762 |
if abs(amount - (totalOrdersAmount)) > 0.5:
|
| 4765 |
unprocessed_awbs[awb] = "Payment of Rs. " + str(amount) + " has been received against the total value of Rs. " + str(totalOrdersAmount) + " for Master Order Id: " + orders[0].logisticsTransactionId
|
4763 |
unprocessed_awbs[awb] = "Payment of Rs. " + str(amount) + " has been received against the total value of Rs. " + str(totalOrdersAmount) + " for Master Order Id: " + orders[0].logisticsTransactionId
|
| 4766 |
continue
|
4764 |
continue
|
| 4767 |
try:
|
4765 |
try:
|