details:   https://code.openbravo.com/erp/devel/pi/rev/408e578e3673
changeset: 28593:408e578e3673
user:      Atul Gaware <atul.gaware <at> openbravo.com>
date:      Thu Feb 11 16:16:57 2016 +0530
summary:   Fixes Issue 0032157: Not possible to sort by unit price in Return 
from
Customer p&e

In case of the Return From Customer for a numeric value of unit Price COALESCE
was being use with '' which should have been 0 instead, COALESCE for order no
was missing for RTC, additonal ReturnReasonLeftClause2 added to replace
EntityAlias.name in the transformeredHQL Query.

diffstat:

 
src/org/openbravo/common/datasource/ReturnToFromCustomerVendorHQLTransformer.java
 |  13 ++++++---
 1 files changed, 9 insertions(+), 4 deletions(-)

diffs (47 lines):

diff -r 670d9903e705 -r 408e578e3673 
src/org/openbravo/common/datasource/ReturnToFromCustomerVendorHQLTransformer.java
--- 
a/src/org/openbravo/common/datasource/ReturnToFromCustomerVendorHQLTransformer.java
 Thu Feb 11 15:57:36 2016 +0100
+++ 
b/src/org/openbravo/common/datasource/ReturnToFromCustomerVendorHQLTransformer.java
 Thu Feb 11 16:16:57 2016 +0530
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2014 Openbravo SLU
+ * All portions are Copyright (C) 2014-2016 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -32,12 +32,13 @@
   private static final String returnToVendorTabId = 
"5A5CCFC8359B4D79BA705DC487FE8173";
 
   private static final String rtv_unitPriceLeftClause = "(case when (select 
e.salesOrderLine.salesOrder.priceList.priceIncludesTax from 
ProcurementPOInvoiceMatch as e where e.goodsShipmentLine = iol) = true then  
coalesce((select ol.unitPrice from OrderLine as ol where ol.salesOrder.id = 
:salesOrderId and ol.goodsShipmentLine = iol), (select 
e.salesOrderLine.grossUnitPrice from ProcurementPOInvoiceMatch as e where 
e.goodsShipmentLine = iol)) else   coalesce((select ol.unitPrice from OrderLine 
as ol where ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine = iol), 
(select e.salesOrderLine.unitPrice from ProcurementPOInvoiceMatch as e where 
e.goodsShipmentLine = iol)) end)";
-  private static final String rtv_orderNoLeftClause = " coalesce ((select 
e.salesOrderLine.salesOrder.documentNo from ProcurementPOInvoiceMatch as e 
where e.goodsShipmentLine = iol), '0')";
-  private static final String rfc_unitPriceLeftClause = "(case when 
(iol.salesOrderLine.salesOrder.priceList.priceIncludesTax) = true then  
coalesce((select ol.unitPrice from OrderLine as ol where ol.salesOrder.id = 
:salesOrderId and ol.goodsShipmentLine = iol), 
(iol.salesOrderLine.grossUnitPrice)) else   coalesce((select ol.unitPrice from 
OrderLine as ol where ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine 
= iol), (coalesce(iol.salesOrderLine.unitPrice,''))) end)";
-  private static final String rfc_orderNoLeftClause = " (select 
e.salesOrderLine.salesOrder.documentNo from MaterialMgmtShipmentInOutLine as e 
where e.id = iol)";
+  private static final String rtv_orderNoLeftClause = " coalesce ((select 
e.salesOrderLine.salesOrder.documentNo from ProcurementPOInvoiceMatch as e 
where e.goodsShipmentLine = iol), '')";
+  private static final String rfc_unitPriceLeftClause = "(case when 
(iol.salesOrderLine.salesOrder.priceList.priceIncludesTax) = true then  
coalesce((select ol.unitPrice from OrderLine as ol where ol.salesOrder.id = 
:salesOrderId and ol.goodsShipmentLine = iol), 
(iol.salesOrderLine.grossUnitPrice)) else   coalesce((select ol.unitPrice from 
OrderLine as ol where ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine 
= iol), (coalesce(iol.salesOrderLine.unitPrice,0))) end)";
+  private static final String rfc_orderNoLeftClause = " coalesce((select 
e.salesOrderLine.salesOrder.documentNo from MaterialMgmtShipmentInOutLine as e 
where e.id = iol), '')";
   private static final String returnedLeftClause = " coalesce((select 
ol.orderedQuantity from OrderLine as ol where ol.salesOrder.id = :salesOrderId 
and ol.goodsShipmentLine = iol),0)";
   private static final String returnedOthersLeftClause = " coalesce((select 
sum(ol.orderedQuantity) from OrderLine as ol left join ol.salesOrder as o where 
ol.goodsShipmentLine = iol and o.processed = true and o.documentStatus <> 
'VO'), 0)";
   private static final String returnReasonLeftClause = " coalesce((select 
ol.returnReason.id from OrderLine as ol where ol.salesOrder.id = :salesOrderId 
and ol.goodsShipmentLine = iol), '')";
+  private static final String returnReasonLeftClause2 = " coalesce((select 
ol.returnReason.name from OrderLine as ol where ol.salesOrder.id = 
:salesOrderId and ol.goodsShipmentLine = iol), '')";
   private static final String returnReasonCountQuery = " select count(distinct 
e.name) from ReturnReason as e where exists (select distinct ol.returnReason 
from OrderLine as ol where ol.returnReason = e and ol.salesOrder.id = 
:salesOrderId  and ol.goodsShipmentLine is not null) ";
   private static final String returnReasonDataQuery = " select distinct e, 
e.name from ReturnReason as e where exists (select distinct ol.returnReason 
from OrderLine as ol where ol.returnReason = e and ol.salesOrder.id = 
:salesOrderId and ol.goodsShipmentLine is not null) ";
   private static final String unitPriceProperty = "unitPrice";
@@ -118,6 +119,8 @@
     } else {
       transformedHqlQuery = 
transformedHqlQuery.replace("@returnReasonLeftClause@.id",
           returnReasonLeftClause);
+      transformedHqlQuery = 
transformedHqlQuery.replace("@returnReasonLeftClause@.name",
+          returnReasonLeftClause2);
     }
     return transformedHqlQuery;
   }
@@ -148,6 +151,8 @@
     } else {
       transformedHqlQuery = 
transformedHqlQuery.replace("@returnReasonLeftClause@.id",
           returnReasonLeftClause);
+      transformedHqlQuery = 
transformedHqlQuery.replace("@returnReasonLeftClause@.name",
+          returnReasonLeftClause2);
     }
     return transformedHqlQuery;
   }

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to