details:   https://code.openbravo.com/erp/devel/pi/rev/d8929499d9ff
changeset: 31104:d8929499d9ff
user:      Rafael Queralta Pozo <rqueralta <at> nauta.cu>
date:      Mon Jan 02 17:15:14 2017 -0500
summary:   Fixed issue 34345:Sales Dimensional Report is not showing SO with 0 
net amount

Having clause was changed to show Sales Order lines with 0 line net amount

details:   https://code.openbravo.com/erp/devel/pi/rev/a75ea21e11ec
changeset: 31105:a75ea21e11ec
user:      Mark <markmm82 <at> gmail.com>
date:      Mon Jan 16 13:15:25 2017 -0500
summary:   Related to issue 34345: Code review improvements

Some code review improvements to check the amounts are GREATER THAN (not equals)
and/or LESS THAN (not equals) the filters provided in the UI. If there is not 
any
amount filter defined then it is not necessary to include a "HAVING" clause to 
the
query.

Applied these changes to Sales and Purchase Orders reports.

diffstat:

 
src/org/openbravo/erpCommon/ad_reports/ReportPurchaseDimensionalAnalysesJR.java 
|  21 +++++----
 src/org/openbravo/erpCommon/ad_reports/ReportSalesDimensionalAnalyzeJR.java    
 |  17 ++++---
 2 files changed, 22 insertions(+), 16 deletions(-)

diffs (78 lines):

diff -r 9a02f5f50ace -r a75ea21e11ec 
src/org/openbravo/erpCommon/ad_reports/ReportPurchaseDimensionalAnalysesJR.java
--- 
a/src/org/openbravo/erpCommon/ad_reports/ReportPurchaseDimensionalAnalysesJR.java
   Mon Jan 16 09:46:35 2017 +0100
+++ 
b/src/org/openbravo/erpCommon/ad_reports/ReportPurchaseDimensionalAnalysesJR.java
   Mon Jan 16 13:15:25 2017 -0500
@@ -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) 2001-2015 Openbravo SLU 
+ * All portions are Copyright (C) 2001-2017 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -457,16 +457,19 @@
       strOrderby = " ORDER BY 1";
     }
     String strHaving = "";
-    if (!strMayor.equals("") && !strMenor.equals("")) {
-      strHaving = " HAVING (SUM(CONVAMOUNT) >= " + strMayor + " AND 
SUM(CONVAMOUNT) <= " + strMenor
+    if (!strMayor.isEmpty() && !strMenor.isEmpty()) {
+      // "Greater than" and "Less than" filters are defined
+      strHaving = " HAVING (SUM(CONVAMOUNT) > " + strMayor + " AND 
SUM(CONVAMOUNT) < " + strMenor
           + ")";
-    } else if (!strMayor.equals("") && strMenor.equals("")) {
-      strHaving = " HAVING (SUM(CONVAMOUNT) >= " + strMayor + ")";
-    } else if (strMayor.equals("") && !strMenor.equals("")) {
-      strHaving = " HAVING (SUM(CONVAMOUNT) <= " + strMenor + ")";
-    } else {
-      strHaving = " HAVING ((SUM(CONVAMOUNT) >= 0 OR SUM(CONVAMOUNTREF) >= 0) 
OR (SUM(CONVAMOUNT) <= 0 OR SUM(CONVAMOUNTREF) <= 0))";
+    } else if (!strMayor.isEmpty() && strMenor.isEmpty()) {
+      // Only "Greater than" filter is defined
+      strHaving = " HAVING (SUM(CONVAMOUNT) > " + strMayor + ")";
+    } else if (strMayor.isEmpty() && !strMenor.isEmpty()) {
+      // Only "Less than" filter is defined
+      strHaving = " HAVING (SUM(CONVAMOUNT) < " + strMenor + ")";
     }
+    // If "Greater than" and "Less than" filters are not defined it is not 
necessary to add the
+    // Having clause
     strOrderby = strHaving + strOrderby;
 
     // Checks if there is a conversion rate for each of the transactions of
diff -r 9a02f5f50ace -r a75ea21e11ec 
src/org/openbravo/erpCommon/ad_reports/ReportSalesDimensionalAnalyzeJR.java
--- 
a/src/org/openbravo/erpCommon/ad_reports/ReportSalesDimensionalAnalyzeJR.java   
    Mon Jan 16 09:46:35 2017 +0100
+++ 
b/src/org/openbravo/erpCommon/ad_reports/ReportSalesDimensionalAnalyzeJR.java   
    Mon Jan 16 13:15:25 2017 -0500
@@ -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) 2001-2015 Openbravo SLU 
+ * All portions are Copyright (C) 2001-2017 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -597,16 +597,19 @@
       strOrderby = " ORDER BY 1";
     }
     String strHaving = "";
-    if (!strMayor.equals("") && !strMenor.equals("")) {
+    if (!strMayor.isEmpty() && !strMenor.isEmpty()) {
+      // "Greater than" and "Less than" filters are defined
       strHaving = " HAVING (SUM(CONVAMOUNT) > " + strMayor + " AND 
SUM(CONVAMOUNT) < " + strMenor
           + ")";
-    } else if (!strMayor.equals("") && strMenor.equals("")) {
+    } else if (!strMayor.isEmpty() && strMenor.isEmpty()) {
+      // Only "Greater than" filter is defined
       strHaving = " HAVING (SUM(CONVAMOUNT) > " + strMayor + ")";
-    } else if (strMayor.equals("") && !strMenor.equals("")) {
+    } else if (strMayor.isEmpty() && !strMenor.isEmpty()) {
+      // Only "Less than" filter is defined
       strHaving = " HAVING (SUM(CONVAMOUNT) < " + strMenor + ")";
-    } else {
-      strHaving = " HAVING (SUM(CONVAMOUNT) <> 0 OR SUM(CONVAMOUNTREF) <> 0)";
-    }
+    } 
+    // If "Greater than" and "Less than" filters are not defined it is not 
necessary to add the
+    // Having clause
     strOrderby = strHaving + strOrderby;
 
     int limit = 0;

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to