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]);
        }

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to