| Line 119... |
Line 119... |
| 119 |
try:
|
119 |
try:
|
| 120 |
provider_pincodes = serviceable_location_cache[serviceable_location.provider_id]
|
120 |
provider_pincodes = serviceable_location_cache[serviceable_location.provider_id]
|
| 121 |
except:
|
121 |
except:
|
| 122 |
provider_pincodes = {}
|
122 |
provider_pincodes = {}
|
| 123 |
serviceable_location_cache[serviceable_location.provider_id] = provider_pincodes
|
123 |
serviceable_location_cache[serviceable_location.provider_id] = provider_pincodes
|
| 124 |
provider_pincodes[serviceable_location.dest_pincode] = serviceable_location.dest_code, serviceable_location.exp, serviceable_location.cod, serviceable_location.otgAvailable, serviceable_location.websiteCodLimit, serviceable_location.storeCodLimit, serviceable_location.providerPrepaidLimit
|
124 |
provider_pincodes[serviceable_location.dest_pincode] = serviceable_location.dest_code, serviceable_location.exp, serviceable_location.cod, serviceable_location.otgAvailable, serviceable_location.websiteCodLimit, serviceable_location.storeCodLimit, serviceable_location.providerPrepaidLimit, serviceable_location.providerCodLimit
|
| 125 |
|
125 |
|
| 126 |
def __cache_warehouse_allocation_table():
|
126 |
def __cache_warehouse_allocation_table():
|
| 127 |
warehouse_allocations = WarehouseAllocation.query.all()
|
127 |
warehouse_allocations = WarehouseAllocation.query.all()
|
| 128 |
for warehouse_allocation in warehouse_allocations:
|
128 |
for warehouse_allocation in warehouse_allocations:
|
| 129 |
warehouse_allocation_cache[warehouse_allocation.pincode]=warehouse_allocation.primary_warehouse_location
|
129 |
warehouse_allocation_cache[warehouse_allocation.pincode]=warehouse_allocation.primary_warehouse_location
|
| Line 557... |
Line 557... |
| 557 |
session.commit()
|
557 |
session.commit()
|
| 558 |
return awb.awb_number
|
558 |
return awb.awb_number
|
| 559 |
except:
|
559 |
except:
|
| 560 |
raise LogisticsServiceException(103, "Unable to get an AWB for the given Provider: " + str(providerId))
|
560 |
raise LogisticsServiceException(103, "Unable to get an AWB for the given Provider: " + str(providerId))
|
| 561 |
|
561 |
|
| 562 |
def get_costing_and_delivery_estimate_for_pincode(pincode, transactionAmount, isCod, weight, billingWarehouseId):
|
562 |
def get_costing_and_delivery_estimate_for_pincode(pincode, transactionAmount, isCod, weight, billingWarehouseId, isCompleteTxn):
|
| - |
|
563 |
print pincode, transactionAmount, isCod, weight, billingWarehouseId
|
| 563 |
deliveryEstimate = {}
|
564 |
deliveryEstimate = {}
|
| 564 |
logsiticsCosting = {}
|
565 |
logsiticsCosting = {}
|
| 565 |
providerCostingMap = {}
|
566 |
providerCostingMap = {}
|
| 566 |
serviceability = {}
|
567 |
serviceability = {}
|
| 567 |
|
568 |
|
| 568 |
for providerId in serviceable_location_cache.keys():
|
569 |
for providerId in serviceable_location_cache.keys():
|
| 569 |
if serviceable_location_cache.has_key(providerId) and serviceable_location_cache.get(providerId).has_key(pincode):
|
570 |
if serviceable_location_cache.has_key(providerId) and serviceable_location_cache.get(providerId).has_key(pincode):
|
| 570 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit = serviceable_location_cache.get(providerId).get(pincode)
|
571 |
dest_code, exp, iscod, otgAvailable, websiteCodLimit, storeCodLimit, providerPrepaidLimit, providerCodLimit = serviceable_location_cache.get(providerId).get(pincode)
|
| 571 |
if isCod and iscod:
|
572 |
if isCod and iscod:
|
| - |
|
573 |
if not isCompleteTxn:
|
| - |
|
574 |
if transactionAmount <= providerCodLimit:
|
| - |
|
575 |
serviceability[providerId] = serviceable_location_cache.get(providerId).get(pincode)
|
| - |
|
576 |
else:
|
| - |
|
577 |
continue
|
| - |
|
578 |
else:
|
| 572 |
serviceability[providerId] = serviceable_location_cache.get(providerId).get(pincode)
|
579 |
serviceability[providerId] = serviceable_location_cache.get(providerId).get(pincode)
|
| 573 |
elif isCod and not iscod:
|
580 |
elif isCod and not iscod:
|
| 574 |
continue
|
581 |
continue
|
| 575 |
else:
|
582 |
else:
|
| - |
|
583 |
if not isCompleteTxn:
|
| - |
|
584 |
if transactionAmount <= providerPrepaidLimit:
|
| - |
|
585 |
serviceability[providerId] = serviceable_location_cache.get(providerId).get(pincode)
|
| - |
|
586 |
else:
|
| - |
|
587 |
continue
|
| - |
|
588 |
else:
|
| 576 |
serviceability[providerId] = serviceable_location_cache.get(providerId).get(pincode)
|
589 |
serviceability[providerId] = serviceable_location_cache.get(providerId).get(pincode)
|
| 577 |
|
590 |
|
| 578 |
warehouse_location = warehouse_location_cache.get(billingWarehouseId)
|
591 |
warehouse_location = warehouse_location_cache.get(billingWarehouseId)
|
| 579 |
if warehouse_location is None:
|
592 |
if warehouse_location is None:
|
| 580 |
warehouse_location = 0
|
593 |
warehouse_location = 0
|
| 581 |
|
594 |
|
| Line 606... |
Line 619... |
| 606 |
additionalCostMultiplier = additionalWeight/logisticsCostObj.additionalUnitWeight
|
619 |
additionalCostMultiplier = additionalWeight/logisticsCostObj.additionalUnitWeight
|
| 607 |
additionalCost = additionalCostMultiplier*logisticsCostObj.additionalUnitLogisticsCost
|
620 |
additionalCost = additionalCostMultiplier*logisticsCostObj.additionalUnitLogisticsCost
|
| 608 |
logisticsCost = logisticsCost + additionalCost
|
621 |
logisticsCost = logisticsCost + additionalCost
|
| 609 |
if isCod:
|
622 |
if isCod:
|
| 610 |
if logisticsCostObj.codCollectionFactor:
|
623 |
if logisticsCostObj.codCollectionFactor:
|
| 611 |
codCollectionCharges = max(logisticsCostObj.minimumCodCollectionCharges, transactionAmount*logisticsCostObj.codCollectionFactor)
|
624 |
codCollectionCharges = max(logisticsCostObj.minimumCodCollectionCharges, (transactionAmount*logisticsCostObj.codCollectionFactor)/100)
|
| 612 |
logisticsCost = logisticsCost + max(logisticsCostObj.minimumCodCollectionCharges, transactionAmount*logisticsCostObj.codCollectionFactor)
|
625 |
logisticsCost = logisticsCost + max(logisticsCostObj.minimumCodCollectionCharges, (transactionAmount*logisticsCostObj.codCollectionFactor)/100)
|
| 613 |
else:
|
626 |
else:
|
| 614 |
codCollectionCharges = logisticsCostObj.minimumCodCollectionCharges
|
627 |
codCollectionCharges = logisticsCostObj.minimumCodCollectionCharges
|
| 615 |
logisticsCost = logisticsCost + logisticsCostObj.minimumCodCollectionCharges
|
628 |
logisticsCost = logisticsCost + logisticsCostObj.minimumCodCollectionCharges
|
| 616 |
|
629 |
|
| 617 |
if logsiticsCosting.has_key(logisticsCost):
|
630 |
if logsiticsCosting.has_key(round(logisticsCost,0)):
|
| 618 |
costingList = logsiticsCosting.get(logisticsCost)
|
631 |
costingList = logsiticsCosting.get(round(logisticsCost,0))
|
| 619 |
costingList.append(providerId)
|
632 |
costingList.append(providerId)
|
| 620 |
logsiticsCosting[logisticsCost] = costingList
|
633 |
logsiticsCosting[round(logisticsCost,0)] = costingList
|
| 621 |
else:
|
634 |
else:
|
| 622 |
costingList = []
|
635 |
costingList = []
|
| 623 |
costingList.append(providerId)
|
636 |
costingList.append(providerId)
|
| 624 |
logsiticsCosting[logisticsCost] = costingList
|
637 |
logsiticsCosting[round(logisticsCost,0)] = costingList
|
| 625 |
|
638 |
|
| 626 |
providerCostingMap[providerId] = [logisticsCost,codCollectionCharges]
|
639 |
providerCostingMap[providerId] = [logisticsCost,codCollectionCharges]
|
| 627 |
else:
|
640 |
else:
|
| 628 |
noCostFoundCount = noCostFoundCount +1
|
641 |
noCostFoundCount = noCostFoundCount +1
|
| 629 |
continue
|
642 |
continue
|
| 630 |
else:
|
643 |
else:
|
| 631 |
raise LogisticsServiceException(101, "No provider assigned for pincode: " + str(pincode))
|
644 |
print "No provider assigned for pincode: " + str(pincode)
|
| - |
|
645 |
return None
|
| 632 |
|
646 |
|
| 633 |
|
647 |
|
| 634 |
if noCostFoundCount == len(serviceability):
|
648 |
if noCostFoundCount == len(serviceability):
|
| 635 |
raise LogisticsServiceException(101, "No Costing Found for this pincode: " + str(pincode) +" for any of the provider")
|
649 |
print "No Costing Found for this pincode: " + str(pincode) +" for any of the provider"
|
| - |
|
650 |
return None
|
| 636 |
|
651 |
|
| 637 |
allSla = sorted(deliveryEstimate.keys())
|
652 |
allSla = sorted(deliveryEstimate.keys())
|
| 638 |
if len(allSla)==1:
|
653 |
if len(allSla)==1:
|
| 639 |
allEligibleProviders = deliveryEstimate.get(allSla[0])
|
654 |
allEligibleProviders = deliveryEstimate.get(allSla[0])
|
| 640 |
if len(allEligibleProviders)==1:
|
655 |
if len(allEligibleProviders)==1:
|
| 641 |
costingDetails = providerCostingMap.get(allEligibleProviders[0])
|
- |
|
| 642 |
delEstCostObj = DeliveryEstimateAndCosting()
|
- |
|
| 643 |
delEstCostObj.logistics_provider_id = allEligibleProviders[0]
|
- |
|
| 644 |
delEstCostObj.pincode = pincode
|
- |
|
| 645 |
delEstCostObj.deliveryTime = delivery_estimate_cache[pincode, allEligibleProviders[0], warehouse_location][0]
|
- |
|
| 646 |
delEstCostObj.delivery_delay = delivery_estimate_cache[pincode, allEligibleProviders[0], warehouse_location][1]
|
- |
|
| 647 |
delEstCostObj.codAllowed = serviceability[allEligibleProviders[0]][2]
|
- |
|
| 648 |
delEstCostObj.otgAvailable = serviceability[allEligibleProviders[0]][3]
|
- |
|
| 649 |
delEstCostObj.logisticsCost = costingDetails[0]-costingDetails[1]
|
- |
|
| 650 |
delEstCostObj.codCollectionCharges = costingDetails[1]
|
- |
|
| 651 |
return delEstCostObj
|
- |
|
| 652 |
else:
|
- |
|
| 653 |
costingListOrder = []
|
- |
|
| 654 |
for providerId in allEligibleProviders:
|
- |
|
| 655 |
costingDetails = providerCostingMap.get(allEligibleProviders[0])
|
- |
|
| 656 |
if costingDetails[0] not in costingListOrder:
|
- |
|
| 657 |
costingListOrder.append(costingDetails[0])
|
- |
|
| 658 |
|
- |
|
| 659 |
if DELHIVERY in allEligibleProviders:
|
- |
|
| 660 |
delihiveryCosting = providerCostingMap.get(DELHIVERY)
|
- |
|
| 661 |
considerCost = min(min(costingListOrder)+10, delihiveryCosting[0])
|
- |
|
| 662 |
if considerCost == delihiveryCosting[0]:
|
- |
|
| 663 |
delEstCostObj = DeliveryEstimateAndCosting()
|
- |
|
| 664 |
delEstCostObj.logistics_provider_id = DELHIVERY
|
- |
|
| 665 |
delEstCostObj.pincode = pincode
|
- |
|
| 666 |
delEstCostObj.deliveryTime = delivery_estimate_cache[pincode, DELHIVERY, warehouse_location][0]
|
- |
|
| 667 |
delEstCostObj.delivery_delay = delivery_estimate_cache[pincode, DELHIVERY, warehouse_location][1]
|
- |
|
| 668 |
delEstCostObj.codAllowed = serviceability[DELHIVERY][2]
|
- |
|
| 669 |
delEstCostObj.otgAvailable = serviceability[DELHIVERY][3]
|
- |
|
| 670 |
delEstCostObj.logisticsCost = delihiveryCosting[0]-delihiveryCosting[1]
|
- |
|
| 671 |
delEstCostObj.codCollectionCharges = delihiveryCosting[1]
|
- |
|
| 672 |
return delEstCostObj
|
- |
|
| 673 |
else:
|
- |
|
| 674 |
considerCost = considerCost -10
|
- |
|
| 675 |
eligibleProviders = logsiticsCosting.get(considerCost)
|
- |
|
| 676 |
costingDetails = providerCostingMap.get(eligibleProviders[0])
|
- |
|
| 677 |
delEstCostObj = DeliveryEstimateAndCosting()
|
- |
|
| 678 |
delEstCostObj.logistics_provider_id = eligibleProviders[0]
|
- |
|
| 679 |
delEstCostObj.pincode = pincode
|
- |
|
| 680 |
delEstCostObj.deliveryTime = delivery_estimate_cache[pincode, eligibleProviders[0], warehouse_location][0]
|
- |
|
| 681 |
delEstCostObj.delivery_delay = delivery_estimate_cache[pincode, eligibleProviders[0], warehouse_location][1]
|
- |
|
| 682 |
delEstCostObj.codAllowed = serviceability[eligibleProviders[0]][2]
|
- |
|
| 683 |
delEstCostObj.otgAvailable = serviceability[eligibleProviders[0]][3]
|
- |
|
| 684 |
delEstCostObj.logisticsCost = costingDetails[0]-costingDetails[1]
|
- |
|
| 685 |
delEstCostObj.codCollectionCharges = costingDetails[1]
|
- |
|
| 686 |
return delEstCostObj
|
- |
|
| 687 |
else:
|
656 |
try:
|
| 688 |
costingListOrder = sorted(costingListOrder)
|
- |
|
| 689 |
eligibleProviders = logsiticsCosting.get(costingListOrder[0])
|
- |
|
| 690 |
costingDetails = providerCostingMap.get(eligibleProviders[0])
|
- |
|
| 691 |
delEstCostObj = DeliveryEstimateAndCosting()
|
- |
|
| 692 |
delEstCostObj.logistics_provider_id = eligibleProviders[0]
|
- |
|
| 693 |
delEstCostObj.pincode = pincode
|
- |
|
| 694 |
delEstCostObj.deliveryTime = delivery_estimate_cache[pincode, eligibleProviders[0], warehouse_location][0]
|
- |
|
| 695 |
delEstCostObj.delivery_delay = delivery_estimate_cache[pincode, eligibleProviders[0], warehouse_location][1]
|
- |
|
| 696 |
delEstCostObj.codAllowed = serviceability[eligibleProviders[0]][2]
|
- |
|
| 697 |
delEstCostObj.otgAvailable = serviceability[eligibleProviders[0]][3]
|
- |
|
| 698 |
delEstCostObj.logisticsCost = costingDetails[0]-costingDetails[1]
|
- |
|
| 699 |
delEstCostObj.codCollectionCharges = costingDetails[1]
|
- |
|
| 700 |
return delEstCostObj
|
- |
|
| 701 |
|
- |
|
| 702 |
else:
|
- |
|
| 703 |
if allSla[1]-allSla[0]!=1:
|
- |
|
| 704 |
allEligibleProviders = deliveryEstimate.get(allSla[0])
|
- |
|
| 705 |
if len(allEligibleProviders)==1:
|
- |
|
| 706 |
costingDetails = providerCostingMap.get(allEligibleProviders[0])
|
657 |
costingDetails = providerCostingMap.get(allEligibleProviders[0])
|
| 707 |
delEstCostObj = DeliveryEstimateAndCosting()
|
658 |
delEstCostObj = DeliveryEstimateAndCosting()
|
| 708 |
delEstCostObj.logistics_provider_id = allEligibleProviders[0]
|
659 |
delEstCostObj.logistics_provider_id = allEligibleProviders[0]
|
| 709 |
delEstCostObj.pincode = pincode
|
660 |
delEstCostObj.pincode = pincode
|
| 710 |
delEstCostObj.deliveryTime = delivery_estimate_cache[pincode, allEligibleProviders[0], warehouse_location][0]
|
661 |
delEstCostObj.deliveryTime = delivery_estimate_cache[pincode, allEligibleProviders[0], warehouse_location][0]
|
| Line 712... |
Line 663... |
| 712 |
delEstCostObj.codAllowed = serviceability[allEligibleProviders[0]][2]
|
663 |
delEstCostObj.codAllowed = serviceability[allEligibleProviders[0]][2]
|
| 713 |
delEstCostObj.otgAvailable = serviceability[allEligibleProviders[0]][3]
|
664 |
delEstCostObj.otgAvailable = serviceability[allEligibleProviders[0]][3]
|
| 714 |
delEstCostObj.logisticsCost = costingDetails[0]-costingDetails[1]
|
665 |
delEstCostObj.logisticsCost = costingDetails[0]-costingDetails[1]
|
| 715 |
delEstCostObj.codCollectionCharges = costingDetails[1]
|
666 |
delEstCostObj.codCollectionCharges = costingDetails[1]
|
| 716 |
return delEstCostObj
|
667 |
return delEstCostObj
|
| 717 |
else:
|
668 |
except:
|
| 718 |
costingListOrder = []
|
- |
|
| 719 |
for providerId in allEligibleProviders:
|
- |
|
| 720 |
costingDetails = providerCostingMap.get(allEligibleProviders[0])
|
- |
|
| 721 |
if costingDetails[0] not in costingListOrder:
|
- |
|
| 722 |
costingListOrder.append(costingDetails[0])
|
- |
|
| 723 |
|
- |
|
| 724 |
if DELHIVERY in allEligibleProviders:
|
- |
|
| 725 |
delihiveryCosting = providerCostingMap.get(DELHIVERY)
|
- |
|
| 726 |
considerCost = min(min(costingListOrder)+10, delihiveryCosting[0])
|
- |
|
| 727 |
if considerCost == delihiveryCosting[0]:
|
- |
|
| 728 |
delEstCostObj = DeliveryEstimateAndCosting()
|
- |
|
| 729 |
delEstCostObj.logistics_provider_id = DELHIVERY
|
- |
|
| 730 |
delEstCostObj.pincode = pincode
|
- |
|
| 731 |
delEstCostObj.deliveryTime = delivery_estimate_cache[pincode, DELHIVERY, warehouse_location][0]
|
- |
|
| 732 |
delEstCostObj.delivery_delay = delivery_estimate_cache[pincode, DELHIVERY, warehouse_location][1]
|
- |
|
| 733 |
delEstCostObj.codAllowed = serviceability[DELHIVERY][2]
|
- |
|
| 734 |
delEstCostObj.otgAvailable = serviceability[DELHIVERY][3]
|
- |
|
| 735 |
delEstCostObj.logisticsCost = delihiveryCosting[0]-delihiveryCosting[1]
|
- |
|
| 736 |
delEstCostObj.codCollectionCharges = delihiveryCosting[1]
|
- |
|
| 737 |
return delEstCostObj
|
- |
|
| 738 |
else:
|
669 |
return None
|
| 739 |
considerCost = considerCost -10
|
- |
|
| 740 |
eligibleProviders = logsiticsCosting.get(considerCost)
|
- |
|
| 741 |
costingDetails = providerCostingMap.get(eligibleProviders[0])
|
- |
|
| 742 |
delEstCostObj = DeliveryEstimateAndCosting()
|
- |
|
| 743 |
delEstCostObj.logistics_provider_id = eligibleProviders[0]
|
- |
|
| 744 |
delEstCostObj.pincode = pincode
|
- |
|
| 745 |
delEstCostObj.deliveryTime = delivery_estimate_cache[pincode, eligibleProviders[0], warehouse_location][0]
|
- |
|
| 746 |
delEstCostObj.delivery_delay = delivery_estimate_cache[pincode, eligibleProviders[0], warehouse_location][1]
|
- |
|
| 747 |
delEstCostObj.codAllowed = serviceability[eligibleProviders[0]][2]
|
- |
|
| 748 |
delEstCostObj.otgAvailable = serviceability[eligibleProviders[0]][3]
|
- |
|
| 749 |
delEstCostObj.logisticsCost = costingDetails[0]-costingDetails[1]
|
- |
|
| 750 |
delEstCostObj.codCollectionCharges = costingDetails[1]
|
- |
|
| 751 |
return delEstCostObj
|
- |
|
| 752 |
else:
|
- |
|
| 753 |
costingListOrder = sorted(costingListOrder)
|
- |
|
| 754 |
eligibleProviders = logsiticsCosting.get(costingListOrder[0])
|
- |
|
| 755 |
costingDetails = providerCostingMap.get(eligibleProviders[0])
|
- |
|
| 756 |
delEstCostObj = DeliveryEstimateAndCosting()
|
- |
|
| 757 |
delEstCostObj.logistics_provider_id = eligibleProviders[0]
|
- |
|
| 758 |
delEstCostObj.pincode = pincode
|
- |
|
| 759 |
delEstCostObj.deliveryTime = delivery_estimate_cache[pincode, eligibleProviders[0], warehouse_location][0]
|
- |
|
| 760 |
delEstCostObj.delivery_delay = delivery_estimate_cache[pincode, eligibleProviders[0], warehouse_location][1]
|
- |
|
| 761 |
delEstCostObj.codAllowed = serviceability[eligibleProviders[0]][2]
|
- |
|
| 762 |
delEstCostObj.otgAvailable = serviceability[eligibleProviders[0]][3]
|
- |
|
| 763 |
delEstCostObj.logisticsCost = costingDetails[0]-costingDetails[1]
|
- |
|
| 764 |
delEstCostObj.codCollectionCharges = costingDetails[1]
|
- |
|
| 765 |
return delEstCostObj
|
- |
|
| 766 |
|
- |
|
| 767 |
else:
|
670 |
else:
|
| 768 |
allEligibleProviders = deliveryEstimate.get(allSla[0])
|
- |
|
| 769 |
secondBestEligibleProviders = deliveryEstimate.get(allSla[1])
|
- |
|
| 770 |
for providerId in secondBestEligibleProviders:
|
- |
|
| 771 |
allEligibleProviders.append(providerId)
|
- |
|
| 772 |
|
- |
|
| 773 |
costingListOrder = []
|
671 |
costingListOrder = []
|
| 774 |
for providerId in allEligibleProviders:
|
672 |
for providerId in allEligibleProviders:
|
| 775 |
costingDetails = providerCostingMap.get(allEligibleProviders[0])
|
673 |
costingDetails = providerCostingMap.get(providerId)
|
| 776 |
if costingDetails[0] not in costingListOrder:
|
674 |
if costingDetails and costingDetails[0] not in costingListOrder:
|
| 777 |
costingListOrder.append(costingDetails[0])
|
675 |
costingListOrder.append(round(costingDetails[0],0))
|
| 778 |
|
676 |
|
| 779 |
if DELHIVERY in allEligibleProviders:
|
677 |
costingListOrder = sorted(costingListOrder)
|
| 780 |
delihiveryCosting = providerCostingMap.get(DELHIVERY)
|
678 |
eligibleProviders = logsiticsCosting.get(costingListOrder[0])
|
| 781 |
considerCost = min(min(costingListOrder)+10, delihiveryCosting[0])
|
- |
|
| 782 |
if considerCost == delihiveryCosting[0]:
|
679 |
for providerId in eligibleProviders:
|
| 783 |
delEstCostObj = DeliveryEstimateAndCosting()
|
- |
|
| 784 |
delEstCostObj.logistics_provider_id = DELHIVERY
|
- |
|
| 785 |
delEstCostObj.pincode = pincode
|
- |
|
| 786 |
delEstCostObj.deliveryTime = delivery_estimate_cache[pincode, DELHIVERY, warehouse_location][0]
|
- |
|
| 787 |
delEstCostObj.delivery_delay = delivery_estimate_cache[pincode, DELHIVERY, warehouse_location][1]
|
- |
|
| 788 |
delEstCostObj.codAllowed = serviceability[DELHIVERY][2]
|
- |
|
| 789 |
delEstCostObj.otgAvailable = serviceability[DELHIVERY][3]
|
- |
|
| 790 |
delEstCostObj.logisticsCost = delihiveryCosting[0]-delihiveryCosting[1]
|
- |
|
| 791 |
delEstCostObj.codCollectionCharges = delihiveryCosting[1]
|
- |
|
| 792 |
return delEstCostObj
|
- |
|
| 793 |
else:
|
- |
|
| 794 |
considerCost = considerCost -10
|
680 |
if providerCostingMap.has_key(providerId):
|
| 795 |
eligibleProviders = logsiticsCosting.get(considerCost)
|
- |
|
| 796 |
costingDetails = providerCostingMap.get(eligibleProviders[0])
|
681 |
costingDetails = providerCostingMap.get(providerId)
|
| 797 |
delEstCostObj = DeliveryEstimateAndCosting()
|
682 |
delEstCostObj = DeliveryEstimateAndCosting()
|
| 798 |
delEstCostObj.logistics_provider_id = eligibleProviders[0]
|
683 |
delEstCostObj.logistics_provider_id = providerId
|
| 799 |
delEstCostObj.pincode = pincode
|
684 |
delEstCostObj.pincode = pincode
|
| 800 |
delEstCostObj.deliveryTime = delivery_estimate_cache[pincode, eligibleProviders[0], warehouse_location][0]
|
685 |
delEstCostObj.deliveryTime = delivery_estimate_cache[pincode, providerId, warehouse_location][0]
|
| 801 |
delEstCostObj.delivery_delay = delivery_estimate_cache[pincode, eligibleProviders[0], warehouse_location][1]
|
686 |
delEstCostObj.delivery_delay = delivery_estimate_cache[pincode, providerId, warehouse_location][1]
|
| 802 |
delEstCostObj.codAllowed = serviceability[eligibleProviders[0]][2]
|
687 |
delEstCostObj.codAllowed = serviceability[providerId][2]
|
| 803 |
delEstCostObj.otgAvailable = serviceability[eligibleProviders[0]][3]
|
688 |
delEstCostObj.otgAvailable = serviceability[providerId][3]
|
| 804 |
delEstCostObj.logisticsCost = costingDetails[0]-costingDetails[1]
|
689 |
delEstCostObj.logisticsCost = costingDetails[0]-costingDetails[1]
|
| 805 |
delEstCostObj.codCollectionCharges = costingDetails[1]
|
690 |
delEstCostObj.codCollectionCharges = costingDetails[1]
|
| 806 |
return delEstCostObj
|
691 |
return delEstCostObj
|
| - |
|
692 |
else:
|
| - |
|
693 |
continue
|
| - |
|
694 |
return None
|
| - |
|
695 |
else:
|
| - |
|
696 |
allEligibleProviders = []
|
| - |
|
697 |
virtualDelayCostMap = {}
|
| - |
|
698 |
virtualCommercialsCostMap = {}
|
| - |
|
699 |
for sla in allSla:
|
| - |
|
700 |
if sla-allSla[0]<=1:
|
| - |
|
701 |
consideredProviders = deliveryEstimate.get(sla)
|
| - |
|
702 |
for providerId in consideredProviders:
|
| - |
|
703 |
if isCod and providerId in [7,46]:
|
| - |
|
704 |
virtualCommercialsCostMap[providerId] = 10
|
| - |
|
705 |
if providerId not in allEligibleProviders:
|
| - |
|
706 |
allEligibleProviders.append(providerId)
|
| - |
|
707 |
virtualDelayCostMap[providerId] = 0
|
| - |
|
708 |
elif sla-allSla[0]==2:
|
| - |
|
709 |
consideredProviders = deliveryEstimate.get(sla)
|
| - |
|
710 |
for providerId in consideredProviders:
|
| - |
|
711 |
if isCod and providerId in [7,46]:
|
| - |
|
712 |
virtualCommercialsCostMap[providerId] = 10
|
| - |
|
713 |
if providerId not in allEligibleProviders:
|
| - |
|
714 |
allEligibleProviders.append(providerId)
|
| - |
|
715 |
virtualDelayCostMap[providerId] = 20+round((0.3*transactionAmount)/100,0)
|
| - |
|
716 |
elif sla-allSla[0]==3:
|
| - |
|
717 |
consideredProviders = deliveryEstimate.get(sla)
|
| - |
|
718 |
for providerId in consideredProviders:
|
| - |
|
719 |
if isCod and providerId in [7,46]:
|
| - |
|
720 |
virtualCommercialsCostMap[providerId] = 10
|
| - |
|
721 |
if providerId not in allEligibleProviders:
|
| - |
|
722 |
allEligibleProviders.append(providerId)
|
| - |
|
723 |
virtualDelayCostMap[providerId] = 40+round((0.6*transactionAmount)/100,0)
|
| - |
|
724 |
|
| - |
|
725 |
costingListOrder = []
|
| - |
|
726 |
costingListMap = {}
|
| - |
|
727 |
for providerId in allEligibleProviders:
|
| - |
|
728 |
costingDetails = providerCostingMap.get(providerId)
|
| - |
|
729 |
if costingDetails:
|
| - |
|
730 |
cost = round(costingDetails[0],0)
|
| - |
|
731 |
if virtualDelayCostMap.has_key(providerId):
|
| - |
|
732 |
cost = cost + virtualDelayCostMap.get(providerId)
|
| - |
|
733 |
if virtualCommercialsCostMap.has_key(providerId):
|
| - |
|
734 |
cost = cost + virtualCommercialsCostMap.get(providerId)
|
| - |
|
735 |
if costingListMap.has_key(cost):
|
| - |
|
736 |
providers = costingListMap.get(cost)
|
| - |
|
737 |
providers.append(providerId)
|
| - |
|
738 |
costingListMap[cost] = providers
|
| 807 |
else:
|
739 |
else:
|
| - |
|
740 |
providers = []
|
| - |
|
741 |
providers.append(providerId)
|
| - |
|
742 |
costingListMap[cost] = providers
|
| - |
|
743 |
if cost not in costingListOrder:
|
| - |
|
744 |
costingListOrder.append(cost)
|
| - |
|
745 |
|
| 808 |
costingListOrder = sorted(costingListOrder)
|
746 |
costingListOrder = sorted(costingListOrder)
|
| - |
|
747 |
|
| - |
|
748 |
print costingListMap
|
| 809 |
eligibleProviders = logsiticsCosting.get(costingListOrder[0])
|
749 |
eligibleProviders = costingListMap.get(costingListOrder[0])
|
| - |
|
750 |
for providerId in eligibleProviders:
|
| - |
|
751 |
if providerCostingMap.has_key(providerId):
|
| 810 |
costingDetails = providerCostingMap.get(eligibleProviders[0])
|
752 |
costingDetails = providerCostingMap.get(providerId)
|
| 811 |
delEstCostObj = DeliveryEstimateAndCosting()
|
753 |
delEstCostObj = DeliveryEstimateAndCosting()
|
| 812 |
delEstCostObj.logistics_provider_id = eligibleProviders[0]
|
754 |
delEstCostObj.logistics_provider_id = providerId
|
| 813 |
delEstCostObj.pincode = pincode
|
755 |
delEstCostObj.pincode = pincode
|
| 814 |
delEstCostObj.deliveryTime = delivery_estimate_cache[pincode, eligibleProviders[0], warehouse_location][0]
|
756 |
delEstCostObj.deliveryTime = delivery_estimate_cache[pincode, providerId, warehouse_location][0]
|
| 815 |
delEstCostObj.delivery_delay = delivery_estimate_cache[pincode, eligibleProviders[0], warehouse_location][1]
|
757 |
delEstCostObj.delivery_delay = delivery_estimate_cache[pincode, providerId, warehouse_location][1]
|
| 816 |
delEstCostObj.codAllowed = serviceability[eligibleProviders[0]][2]
|
758 |
delEstCostObj.codAllowed = serviceability[providerId][2]
|
| 817 |
delEstCostObj.otgAvailable = serviceability[eligibleProviders[0]][3]
|
759 |
delEstCostObj.otgAvailable = serviceability[providerId][3]
|
| 818 |
delEstCostObj.logisticsCost = costingDetails[0]-costingDetails[1]
|
760 |
delEstCostObj.logisticsCost = costingDetails[0]-costingDetails[1]
|
| 819 |
delEstCostObj.codCollectionCharges = costingDetails[1]
|
761 |
delEstCostObj.codCollectionCharges = costingDetails[1]
|
| 820 |
return delEstCostObj
|
762 |
return delEstCostObj
|
| - |
|
763 |
else:
|
| - |
|
764 |
continue
|
| - |
|
765 |
return None
|
| 821 |
|
766 |
|