Subversion Repositories SmartDukaan

Rev

Rev 19523 | Rev 19541 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 19523 Rev 19537
Line 611... Line 611...
611
            process_credit_transaction(transaction.id, singleOrder.customer_id, 1, creditTxns)
611
            process_credit_transaction(transaction.id, singleOrder.customer_id, 1, creditTxns)
612
            
612
            
613
        for billingWarehouseId, orders in billingWarehouseIdMap.items():
613
        for billingWarehouseId, orders in billingWarehouseIdMap.items():
614
            logistics_client = LogisticsClient().get_client()
614
            logistics_client = LogisticsClient().get_client()
615
            transactionAmount , transactionWeight = billingWarehouseTxnMap.get(billingWarehouseId)
615
            transactionAmount , transactionWeight = billingWarehouseTxnMap.get(billingWarehouseId)
-
 
616
            costingAndDeliveryEstimateObj = None
-
 
617
            try:
616
            costingAndDeliveryEstimateObj = logistics_client.getCostingAndDeliveryEstimateForPincode(orders[0].customer_pincode, transactionAmount, False, transactionWeight, billingWarehouseId, False)
618
                costingAndDeliveryEstimateObj = logistics_client.getCostingAndDeliveryEstimateForPincode(orders[0].customer_pincode, transactionAmount, False, transactionWeight, billingWarehouseId, False)
-
 
619
            except:
617
            if costingAndDeliveryEstimateObj is None:
620
                try:
618
                subOrderAmountsList = sorted(subOrderAmountsMap.keys())
621
                    subOrderAmountsList = sorted(subOrderAmountsMap.keys())
619
                maxUnitPriceOrder = subOrderAmountsMap.get(subOrderAmountsList[len(subOrderAmountsList)-1])
622
                    maxUnitPriceOrder = subOrderAmountsMap.get(subOrderAmountsList[len(subOrderAmountsList)-1])
620
                costingAndDeliveryEstimateObj = logistics_client.getCostingAndDeliveryEstimateForPincode(orders[0].customer_pincode, maxUnitPriceOrder.lineitems[0].unit_price, False, maxUnitPriceOrder.lineitems[0].unit_weight, billingWarehouseId, False)
623
                    costingAndDeliveryEstimateObj = logistics_client.getCostingAndDeliveryEstimateForPincode(orders[0].customer_pincode, maxUnitPriceOrder.lineitems[0].unit_price, False, maxUnitPriceOrder.lineitems[0].unit_weight, billingWarehouseId, False)
621
            if costingAndDeliveryEstimateObj is None:
624
                except:
622
                raise TransactionServiceException(108, "No Logistics Provider Assigned")
625
                    raise TransactionServiceException(108, "No Logistics Provider Assigned")
-
 
626
            
623
            logisticsCost = costingAndDeliveryEstimateObj.logisticsCost
627
            logisticsCost = costingAndDeliveryEstimateObj.logisticsCost
624
            logisticsCostInOrders = 0
628
            logisticsCostInOrders = 0
625
            current_time = datetime.datetime.now()
629
            current_time = datetime.datetime.now()
626
            #delivery_delay
630
            #delivery_delay
627
            for order in orders:
631
            for order in orders:
Line 811... Line 815...
811
                __create_recharge_voucher_tracker(order, voucherAmount, VoucherType.SPICEDECK_MOBILE)
815
                __create_recharge_voucher_tracker(order, voucherAmount, VoucherType.SPICEDECK_MOBILE)
812
 
816
 
813
        for billingWarehouseId, orders in billingWarehouseIdMap.items():
817
        for billingWarehouseId, orders in billingWarehouseIdMap.items():
814
            logistics_client = LogisticsClient().get_client()
818
            logistics_client = LogisticsClient().get_client()
815
            transactionAmount , transactionWeight = billingWarehouseTxnMap.get(billingWarehouseId)
819
            transactionAmount , transactionWeight = billingWarehouseTxnMap.get(billingWarehouseId)
-
 
820
            costingAndDeliveryEstimateObj = None
-
 
821
            try:
816
            costingAndDeliveryEstimateObj = logistics_client.getCostingAndDeliveryEstimateForPincode(orders[0].customer_pincode, transactionAmount, True, transactionWeight, billingWarehouseId, False)
822
                costingAndDeliveryEstimateObj = logistics_client.getCostingAndDeliveryEstimateForPincode(orders[0].customer_pincode, transactionAmount, True, transactionWeight, billingWarehouseId, False)
-
 
823
            except:
817
            if costingAndDeliveryEstimateObj is None:
824
                try:
818
                subOrderAmountsList = sorted(subOrderAmountsMap.keys())
825
                    subOrderAmountsList = sorted(subOrderAmountsMap.keys())
819
                maxUnitPriceOrder = subOrderAmountsMap.get(subOrderAmountsList[len(subOrderAmountsList)-1])
826
                    maxUnitPriceOrder = subOrderAmountsMap.get(subOrderAmountsList[len(subOrderAmountsList)-1])
820
                costingAndDeliveryEstimateObj = logistics_client.getCostingAndDeliveryEstimateForPincode(orders[0].customer_pincode, maxUnitPriceOrder.lineitems[0].unit_price, True, maxUnitPriceOrder.lineitems[0].unit_weight, billingWarehouseId, False)
827
                    costingAndDeliveryEstimateObj = logistics_client.getCostingAndDeliveryEstimateForPincode(orders[0].customer_pincode, maxUnitPriceOrder.lineitems[0].unit_price, True, maxUnitPriceOrder.lineitems[0].unit_weight, billingWarehouseId, False)
821
            if costingAndDeliveryEstimateObj is None:
828
                except:
822
                raise TransactionServiceException(108, "No Logistics Provider Assigned")
829
                    raise TransactionServiceException(108, "No Logistics Provider Assigned")
823
            
830
              
824
            current_time = datetime.datetime.now()
831
            current_time = datetime.datetime.now()
825
            logisticsCost = costingAndDeliveryEstimateObj.logisticsCost
832
            logisticsCost = costingAndDeliveryEstimateObj.logisticsCost
826
            logisticsCostInOrders = 0
833
            logisticsCostInOrders = 0
827
            codCollectionCharges = costingAndDeliveryEstimateObj.codCollectionCharges
834
            codCollectionCharges = costingAndDeliveryEstimateObj.codCollectionCharges
828
            codCollectionChargesInOrders = 0
835
            codCollectionChargesInOrders = 0
Line 9803... Line 9810...
9803
    for order in ordersList:
9810
    for order in ordersList:
9804
        shipmentAmount = shipmentAmount + order.total_amount
9811
        shipmentAmount = shipmentAmount + order.total_amount
9805
        shipmentWeight = shipmentWeight + order.total_weight
9812
        shipmentWeight = shipmentWeight + order.total_weight
9806
    
9813
    
9807
    logistics_client = LogisticsClient().get_client()
9814
    logistics_client = LogisticsClient().get_client()
-
 
9815
    costingAndDeliveryEstimateObj = None
-
 
9816
    try:
9808
    costingAndDeliveryEstimateObj = logistics_client.getCostingAndDeliveryEstimateForPincode(ordersList[0].customer_pincode, shipmentAmount, isCod, shipmentWeight, ordersList[0].warehouse_id, False)
9817
        costingAndDeliveryEstimateObj = logistics_client.getCostingAndDeliveryEstimateForPincode(ordersList[0].customer_pincode, shipmentAmount, isCod, shipmentWeight, ordersList[0].warehouse_id, False)
9809
    if costingAndDeliveryEstimateObj is None:
9818
    except:
9810
        raise TransactionServiceException(227, "No Provider Assigned for these orders. Please select less orders.")
9819
        raise TransactionServiceException(227, "No Provider Assigned for these orders. Please select less orders.")
-
 
9820
        
9811
    logisticsCost = costingAndDeliveryEstimateObj.logisticsCost
9821
    logisticsCost = costingAndDeliveryEstimateObj.logisticsCost
9812
    logisticsCostInOrders = 0
9822
    logisticsCostInOrders = 0
9813
    codCollectionCharges = costingAndDeliveryEstimateObj.codCollectionCharges
9823
    codCollectionCharges = costingAndDeliveryEstimateObj.codCollectionCharges
9814
    codCollectionChargesInOrders = 0 
9824
    codCollectionChargesInOrders = 0 
9815
    for order in ordersList:
9825
    for order in ordersList: