What is the basis of setting up priority in shipping estimates

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

What is the basis of setting up priority in shipping estimates

Vikas Mayur-3
Hi, I was looking at a method calcShipmentCostEstimate in ShipmentServices, Line 410 - 445. I have included this code snippet here for reference.

I was wondering about what is the basis of setting up this priority, Line 410 - 416. 


Vikas

        // Calculate priority based on available data.
        double PRIORITY_PARTY = 9;
        double PRIORITY_ROLE = 8;
        double PRIORITY_GEO = 4;
        double PRIORITY_WEIGHT = 1;
        double PRIORITY_QTY = 1;
        double PRIORITY_PRICE = 1;

        int estimateIndex = 0;

        if (estimateList.size() > 1) {
            TreeMap<Integer, GenericValue> estimatePriority = new TreeMap<Integer, GenericValue>();
            //int estimatePriority[] = new int[estimateList.size()];

            for (GenericValue currentEstimate: estimateList) {
                int prioritySum = 0;
                if (UtilValidate.isNotEmpty(currentEstimate.getString("partyId")))
                    prioritySum += PRIORITY_PARTY;
                if (UtilValidate.isNotEmpty(currentEstimate.getString("roleTypeId")))
                    prioritySum += PRIORITY_ROLE;
                if (UtilValidate.isNotEmpty(currentEstimate.getString("geoIdTo")))
                    prioritySum += PRIORITY_GEO;
                if (UtilValidate.isNotEmpty(currentEstimate.getString("weightBreakId")))
                    prioritySum += PRIORITY_WEIGHT;
                if (UtilValidate.isNotEmpty(currentEstimate.getString("quantityBreakId")))
                    prioritySum += PRIORITY_QTY;
                if (UtilValidate.isNotEmpty(currentEstimate.getString("priceBreakId")))
                    prioritySum += PRIORITY_PRICE;

                // there will be only one of each priority; latest will replace
                estimatePriority.put(Integer.valueOf(prioritySum), currentEstimate);
            }

            // locate the highest priority estimate; or the latest entered
            Object[] estimateArray = estimatePriority.values().toArray();
            estimateIndex = estimateList.indexOf(estimateArray[estimateArray.length - 1]);
        }


smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: What is the basis of setting up priority in shipping estimates

Jacques Le Roux
Administrator
I would be interested by this also. I did not look into details but I suppose, it's only to sort the shipment methods before showing them on UI, is that right ?

Thanks

Jacques
  ----- Original Message -----
  From: Vikas Mayur
  To: [hidden email]
  Sent: Saturday, December 13, 2008 9:54 AM
  Subject: What is the basis of setting up priority in shipping estimates


  Hi, I was looking at a method calcShipmentCostEstimate in ShipmentServices, Line 410 - 445. I have included this code snippet here for reference.


  I was wondering about what is the basis of setting up this priority, Line 410 - 416.




  Vikas



          // Calculate priority based on available data.
          double PRIORITY_PARTY = 9;
          double PRIORITY_ROLE = 8;
          double PRIORITY_GEO = 4;
          double PRIORITY_WEIGHT = 1;
          double PRIORITY_QTY = 1;
          double PRIORITY_PRICE = 1;


          int estimateIndex = 0;


          if (estimateList.size() > 1) {
              TreeMap<Integer, GenericValue> estimatePriority = new TreeMap<Integer, GenericValue>();
              //int estimatePriority[] = new int[estimateList.size()];


              for (GenericValue currentEstimate: estimateList) {
                  int prioritySum = 0;
                  if (UtilValidate.isNotEmpty(currentEstimate.getString("partyId")))
                      prioritySum += PRIORITY_PARTY;
                  if (UtilValidate.isNotEmpty(currentEstimate.getString("roleTypeId")))
                      prioritySum += PRIORITY_ROLE;
                  if (UtilValidate.isNotEmpty(currentEstimate.getString("geoIdTo")))
                      prioritySum += PRIORITY_GEO;
                  if (UtilValidate.isNotEmpty(currentEstimate.getString("weightBreakId")))
                      prioritySum += PRIORITY_WEIGHT;
                  if (UtilValidate.isNotEmpty(currentEstimate.getString("quantityBreakId")))
                      prioritySum += PRIORITY_QTY;
                  if (UtilValidate.isNotEmpty(currentEstimate.getString("priceBreakId")))
                      prioritySum += PRIORITY_PRICE;


                  // there will be only one of each priority; latest will replace
                  estimatePriority.put(Integer.valueOf(prioritySum), currentEstimate);
              }


              // locate the highest priority estimate; or the latest entered
              Object[] estimateArray = estimatePriority.values().toArray();
              estimateIndex = estimateList.indexOf(estimateArray[estimateArray.length - 1]);
          }