details:   https://code.openbravo.com/erp/devel/pi/rev/a998052fc425
changeset: 31760:a998052fc425
user:      Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
date:      Thu Mar 30 10:25:21 2017 +0200
summary:   Related to issue 35560: Code review improvements

Backout fixes of issues 35560 & 28973 and fix issue 28973 properly:
DocGLJournal.isperiodOpen method was not correctly checking if 
DocGLJournalData.periodOpen retrieves no period.

diffstat:

 src/org/openbravo/erpCommon/ad_forms/DocGLJournal.java      |  21 ++++++++++++-
 src/org/openbravo/erpCommon/ad_forms/DocGLJournal_data.xsql |   4 +-
 2 files changed, 22 insertions(+), 3 deletions(-)

diffs (73 lines):

diff -r 47095a5a471d -r a998052fc425 
src/org/openbravo/erpCommon/ad_forms/DocGLJournal.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocGLJournal.java    Wed Mar 29 
22:04:32 2017 +0000
+++ b/src/org/openbravo/erpCommon/ad_forms/DocGLJournal.java    Thu Mar 30 
10:25:21 2017 +0200
@@ -11,7 +11,7 @@
  * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
  * created by ComPiere are Copyright (C) ComPiere, Inc.;   All Rights Reserved.
  * Contributor(s): Openbravo SLU
- * Contributions are Copyright (C) 2001-2015 Openbravo S.L.U.
+ * Contributions are Copyright (C) 2001-2017 Openbravo S.L.U.
  ******************************************************************************
  */
 package org.openbravo.erpCommon.ad_forms;
@@ -22,6 +22,7 @@
 
 import javax.servlet.ServletException;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.openbravo.base.secureApp.VariablesSecureApp;
 import org.openbravo.dal.core.OBContext;
@@ -73,6 +74,7 @@
     loadDocumentType(); // lines require doc type
     m_PostingType = data[0].getField("PostingType");
     m_IsOpening = data[0].getField("isopening");
+    C_Period_ID = isperiodOpen(conn, data[0].getField("period"));
     C_Currency_ID = data[0].getField("c_currency_id");
     try {
       C_AcctSchema_ID = DocGLJournalData.selectAcctSchema(conn, AD_Client_ID, 
Record_ID);
@@ -304,6 +306,23 @@
     return true;
   }
 
+  private String isperiodOpen(ConnectionProvider conn, String periodId) {
+    if ("".equals(periodId)) {
+      return "";
+    }
+    try {
+      DocGLJournalData[] data = DocGLJournalData.periodOpen(conn, periodId);
+      if (data != null && data.length > 0 && 
StringUtils.isNotEmpty(data[0].period)) {
+        return periodId;
+      } else {
+        return "";
+      }
+    } catch (ServletException e) {
+      e.printStackTrace();
+      return "";
+    }
+  }
+
   public String getServletInfo() {
     return "Servlet for the accounting";
   } // end of getServletInfo() method
diff -r 47095a5a471d -r a998052fc425 
src/org/openbravo/erpCommon/ad_forms/DocGLJournal_data.xsql
--- a/src/org/openbravo/erpCommon/ad_forms/DocGLJournal_data.xsql       Wed Mar 
29 22:04:32 2017 +0000
+++ b/src/org/openbravo/erpCommon/ad_forms/DocGLJournal_data.xsql       Thu Mar 
30 10:25:21 2017 +0200
@@ -29,7 +29,7 @@
         SELECT G.AD_CLIENT_ID, G.AD_ORG_ID, G.DOCUMENTNO, G.DATEACCT, 
G.DATEDOC,
         G.C_CURRENCY_ID, G.C_DOCTYPE_ID, G.POSTED, G.POSTINGTYPE, G.ISOPENING,
         G.C_CAMPAIGN_ID, G.C_PROJECT_ID, G.USER1_ID, G.USER2_ID, 
G.C_COSTCENTER_ID,
-        G.A_ASSET_ID, G.C_BPARTNER_ID, G.M_PRODUCT_ID, G.C_PERIOD_ID, 
+        G.A_ASSET_ID, G.C_BPARTNER_ID, G.M_PRODUCT_ID, G.C_PERIOD_ID AS PERIOD,
         '' AS FININVCOUNT,'' AS FINACCTCOUNT, G.MULTI_GL
         FROM GL_JOURNAL G
         WHERE AD_CLIENT_ID=?
@@ -56,7 +56,7 @@
       <SqlMethodComment></SqlMethodComment>
       <Sql>
       <![CDATA[
-      select max(c_period.c_period_id) as c_period_id
+      select max(c_period.c_period_id) as period
       from c_period, c_periodcontrol
       where c_period.c_period_id = c_periodcontrol.c_period_id
       and c_periodcontrol.docbasetype = 'GLJ'

------------------------------------------------------------------------------
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