Fixes issue 20706: To clone sales order is missing the list price value
authorJavier Etxarri <javier.echarri@openbravo.com>
Fri, 08 Jun 2012 09:57:26 +0200
changeset 16790 6d03521c95b4
parent 16789 59873e199061
child 16791 dbb3d43517a8
Fixes issue 20706: To clone sales order is missing the list price value
modules/org.openbravo.client.application/src/org/openbravo/client/application/businesslogic/CloneOrderActionHandler.java
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/businesslogic/CloneOrderActionHandler.java	Thu Jun 07 18:00:36 2012 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/businesslogic/CloneOrderActionHandler.java	Fri Jun 08 09:57:26 2012 +0200
@@ -79,7 +79,10 @@
         objCloneOrdLine.setReservedQuantity(new BigDecimal("0"));
         objCloneOrdLine.setDeliveredQuantity(new BigDecimal("0"));
         objCloneOrdLine.setInvoicedQuantity(new BigDecimal("0"));
-        objCloneOrdLine.setListPrice(bdPriceList);
+        if (!"".equals(bdPriceList) || bdPriceList != null
+            || !bdPriceList.equals(BigDecimal.ZERO.setScale(bdPriceList.scale()))) {
+          objCloneOrdLine.setListPrice(bdPriceList);
+        }
         objCloneOrder.getOrderLineList().add(objCloneOrdLine);
         objCloneOrdLine.setSalesOrder(objCloneOrder);
       }
@@ -98,7 +101,7 @@
 
   private String getPriceListVersion(String priceList, String clientId) {
     try {
-      String whereClause = " as plv , PricingPriceList pl where pl.id=plv.id and plv.active='Y' and "
+      String whereClause = " as plv left outer join plv.priceList pl where plv.active='Y' and plv.active='Y' and "
           + " pl.id = :priceList and plv.client.id = :clientId order by plv.validFromDate desc";
 
       OBQuery<PriceListVersion> ppriceListVersion = OBDal.getInstance().createQuery(
@@ -135,7 +138,7 @@
   public static BigDecimal getLineNetAmt(String strOrderId) {
 
     BigDecimal bdLineNetAmt = new BigDecimal("0");
-    final String readLineNetAmtHql = " select (ol.lineNetAmount + ol.freightAmount + ol.chargeAmount) as LineNetAmt from OrderLine ol where ol.salesOrder.id=?";
+    final String readLineNetAmtHql = " select (coalesce(ol.lineNetAmount,0) + coalesce(ol.freightAmount,0) + coalesce(ol.chargeAmount,0)) as LineNetAmt from OrderLine ol where ol.salesOrder.id=?";
     final Query readLineNetAmtQry = OBDal.getInstance().getSession().createQuery(readLineNetAmtHql);
     readLineNetAmtQry.setString(0, strOrderId);