[ 
https://issues.apache.org/jira/browse/OFBIZ-6988?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Nicolas Malin updated OFBIZ-6988:
---------------------------------
    Description: 
On the service *calcShipmentCostEstimate*, each estimated shipment cost are 
analysed to resolve who is enable to apply on the order.

During the breakQtys block analyse, OFBiz check if the estimate match the 
quantity  with their breaks and valid it if one is good
{code}
                    if (qv != null) {
                        useQty = true;
                        BigDecimal min = BigDecimal.ONE.movePointLeft(4);
                        BigDecimal max = BigDecimal.ONE.movePointLeft(4);

                        try {
                            min = qv.getBigDecimal("fromQuantity");
                            max = qv.getBigDecimal("thruQuantity");
                        } catch (Exception e) {
                        }
                        if (shippableQuantity.compareTo(min) >= 0 && 
(max.compareTo(BigDecimal.ZERO) == 0 || shippableQuantity.compareTo(max) <= 0)) 
{
                            qtyValid = true;
                        }
                        if (Debug.infoOn()) Debug.logInfo(" # QUANTITY SHIP min 
: " + min + ", max : " + max + ", value " + shippableQuantity + " qtyValid " + 
qtyValid, module);
                    }
                    if (pv != null) {
                        usePrice = true;
                        BigDecimal min = BigDecimal.ONE.movePointLeft(4);
                        BigDecimal max = BigDecimal.ONE.movePointLeft(4);

                        try {
                            min = pv.getBigDecimal("fromQuantity");
                            max = pv.getBigDecimal("thruQuantity");
                        } catch (Exception e) {
                        }
                        if (shippableTotal.compareTo(min) >= 0 && 
(max.compareTo(BigDecimal.ZERO) == 0 || shippableTotal.compareTo(max) <= 0)) {
                            priceValid = true;
                        }
                        if (Debug.infoOn()) Debug.logInfo(" # PRICE TOT SHIP 
min : " + min + ", max : " + max + ", value " + shippableTotal+ " qtyValid " + 
priceValid, module);
                    }
                    // Now check the tests.
                    if ((useWeight && weightValid)  || (useQty && qtyValid) || 
(usePrice && priceValid)) {
                        estimateList.add(thisEstimate);
                    }
{code}

I didn't understand why a estimate shippping cost that contains a break no 
valid can be apply on the order.

On a customer project I ave these rules:
||      ||Quantity Break Id||   Price Break Id|| Flat Price ||  Order Price 
Percent ||
|FR000|         |       0 - 1000 [FRP4]         | 25    |0|
|FR001|         0 - 500,000 [FRB01]|    1000 - 0 [FRP3]         |       |15|
|FR004|         2,000,000 - 0 [FRB04]|  1000 - 0 [FRP3]         |       |2|
|FR003|         1,000,001 - 1,999,999 [FRB03]|  1000 - 0 [FRP3]         |       
 |5|
|FR002|         500,001 - 1,000,000 [FRB02]|    1000 - 0 [FRP3]         |       
  |8|

The problem with the previous code that for a total price more than 300€ OFBiz 
give me a random rule between FR00[1-4] and it's wrong because I have also a 
break on total quantity shipped

I propose to change the check like this 
{code}
@@ -406,7 +410,9 @@
                         }
                     }
                     // Now check the tests.
-                    if ((useWeight && weightValid) || (useQty && qtyValid) || 
(usePrice && priceValid)) {
+                    if ((!useWeight || useWeight && weightValid) 
+                            && (!useQty || useQty && qtyValid)
+                            && (!usePrice || usePrice && priceValid)) {
                         estimateList.add(thisEstimate);
                     }
                 }
{code}

To ensure that is a break is define on the estimated shipping cost, we enable 
this last only all define break are valid.

Any suggest ?

  was:
On the service *calcShipmentCostEstimate*, each estimated shipment cost are 
analysed to resolve who is enable to apply on the order.

During the breakQtys block analyse, OFBiz check if the estimate match the 
quantity  with their breaks and valid it if one is good
{code}
                    if (qv != null) {
                        useQty = true;
                        BigDecimal min = BigDecimal.ONE.movePointLeft(4);
                        BigDecimal max = BigDecimal.ONE.movePointLeft(4);

                        try {
                            min = qv.getBigDecimal("fromQuantity");
                            max = qv.getBigDecimal("thruQuantity");
                        } catch (Exception e) {
                        }
                        if (shippableQuantity.compareTo(min) >= 0 && 
(max.compareTo(BigDecimal.ZERO) == 0 || shippableQuantity.compareTo(max) <= 0)) 
{
                            qtyValid = true;
                        }
                        if (Debug.infoOn()) Debug.logInfo(" # QUANTITY SHIP min 
: " + min + ", max : " + max + ", value " + shippableQuantity + " qtyValid " + 
qtyValid, module);
                    }
                    if (pv != null) {
                        usePrice = true;
                        BigDecimal min = BigDecimal.ONE.movePointLeft(4);
                        BigDecimal max = BigDecimal.ONE.movePointLeft(4);

                        try {
                            min = pv.getBigDecimal("fromQuantity");
                            max = pv.getBigDecimal("thruQuantity");
                        } catch (Exception e) {
                        }
                        if (shippableTotal.compareTo(min) >= 0 && 
(max.compareTo(BigDecimal.ZERO) == 0 || shippableTotal.compareTo(max) <= 0)) {
                            priceValid = true;
                        }
                        if (Debug.infoOn()) Debug.logInfo(" # PRICE TOT SHIP 
min : " + min + ", max : " + max + ", value " + shippableTotal+ " qtyValid " + 
priceValid, module);
                    }
                    // Now check the tests.
                    if ((useWeight && weightValid)  || (useQty && qtyValid) || 
(usePrice && priceValid)) {
                        estimateList.add(thisEstimate);
                    }
{code}

I didn't understand why a estimate shippping cost that contains a break no 
valid can be apply on the order.

On a customer project I ave these rules:
||      ||Quantity Break Id||   Price Break Id|| Flat Price ||  Order Price 
Percent ||
|FR000|         |       0 - 300 [FRP4]  | 15    |0|
|FR001|         0 - 30,000 [FRB01]|     300 - 0 [FRP3]  |       |5|
|FR004|         100,000 - 0 [FRB04]|    300 - 0 [FRP3]  |       |1|
|FR003|         50,001 - 99,999 [FRB03]|        300 - 0 [FRP3]  |        |2|
|FR002|         30,001 - 50,000 [FRB02]|        300 - 0 [FRP3]  |         |3|

The problem with the previous code that for a total price more than 300€ OFBiz 
give me a random rule between FR00[1-4] and it's wrong because I have also a 
break on total quantity shipped

I propose to change the check like this 
{code}
@@ -406,7 +410,9 @@
                         }
                     }
                     // Now check the tests.
-                    if ((useWeight && weightValid) || (useQty && qtyValid) || 
(usePrice && priceValid)) {
+                    if ((!useWeight || useWeight && weightValid) 
+                            && (!useQty || useQty && qtyValid)
+                            && (!usePrice || usePrice && priceValid)) {
                         estimateList.add(thisEstimate);
                     }
                 }
{code}

To ensure that is a break is define on the estimated shipping cost, we enable 
this last only all define break are valid.

Any suggest ?


> Estimated shipping cost resolution with breaks on price and quantity
> --------------------------------------------------------------------
>
>                 Key: OFBIZ-6988
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-6988
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: product
>    Affects Versions: Trunk
>            Reporter: Nicolas Malin
>            Assignee: Nicolas Malin
>            Priority: Minor
>              Labels: shipping
>
> On the service *calcShipmentCostEstimate*, each estimated shipment cost are 
> analysed to resolve who is enable to apply on the order.
> During the breakQtys block analyse, OFBiz check if the estimate match the 
> quantity  with their breaks and valid it if one is good
> {code}
>                     if (qv != null) {
>                         useQty = true;
>                         BigDecimal min = BigDecimal.ONE.movePointLeft(4);
>                         BigDecimal max = BigDecimal.ONE.movePointLeft(4);
>                         try {
>                             min = qv.getBigDecimal("fromQuantity");
>                             max = qv.getBigDecimal("thruQuantity");
>                         } catch (Exception e) {
>                         }
>                         if (shippableQuantity.compareTo(min) >= 0 && 
> (max.compareTo(BigDecimal.ZERO) == 0 || shippableQuantity.compareTo(max) <= 
> 0)) {
>                             qtyValid = true;
>                         }
>                         if (Debug.infoOn()) Debug.logInfo(" # QUANTITY SHIP 
> min : " + min + ", max : " + max + ", value " + shippableQuantity + " 
> qtyValid " + qtyValid, module);
>                     }
>                     if (pv != null) {
>                         usePrice = true;
>                         BigDecimal min = BigDecimal.ONE.movePointLeft(4);
>                         BigDecimal max = BigDecimal.ONE.movePointLeft(4);
>                         try {
>                             min = pv.getBigDecimal("fromQuantity");
>                             max = pv.getBigDecimal("thruQuantity");
>                         } catch (Exception e) {
>                         }
>                         if (shippableTotal.compareTo(min) >= 0 && 
> (max.compareTo(BigDecimal.ZERO) == 0 || shippableTotal.compareTo(max) <= 0)) {
>                             priceValid = true;
>                         }
>                         if (Debug.infoOn()) Debug.logInfo(" # PRICE TOT SHIP 
> min : " + min + ", max : " + max + ", value " + shippableTotal+ " qtyValid " 
> + priceValid, module);
>                     }
>                     // Now check the tests.
>                     if ((useWeight && weightValid)  || (useQty && qtyValid) 
> || (usePrice && priceValid)) {
>                         estimateList.add(thisEstimate);
>                     }
> {code}
> I didn't understand why a estimate shippping cost that contains a break no 
> valid can be apply on the order.
> On a customer project I ave these rules:
> ||    ||Quantity Break Id||   Price Break Id|| Flat Price ||  Order Price 
> Percent ||
> |FR000|       |       0 - 1000 [FRP4]         | 25    |0|
> |FR001|       0 - 500,000 [FRB01]|    1000 - 0 [FRP3]         |       |15|
> |FR004|       2,000,000 - 0 [FRB04]|  1000 - 0 [FRP3]         |       |2|
> |FR003|       1,000,001 - 1,999,999 [FRB03]|  1000 - 0 [FRP3]         |       
>  |5|
> |FR002|       500,001 - 1,000,000 [FRB02]|    1000 - 0 [FRP3]         |       
>   |8|
> The problem with the previous code that for a total price more than 300€ 
> OFBiz give me a random rule between FR00[1-4] and it's wrong because I have 
> also a break on total quantity shipped
> I propose to change the check like this 
> {code}
> @@ -406,7 +410,9 @@
>                          }
>                      }
>                      // Now check the tests.
> -                    if ((useWeight && weightValid) || (useQty && qtyValid) 
> || (usePrice && priceValid)) {
> +                    if ((!useWeight || useWeight && weightValid) 
> +                            && (!useQty || useQty && qtyValid)
> +                            && (!usePrice || usePrice && priceValid)) {
>                          estimateList.add(thisEstimate);
>                      }
>                  }
> {code}
> To ensure that is a break is define on the estimated shipping cost, we enable 
> this last only all define break are valid.
> Any suggest ?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to