Fixes issue 30788: Add filter by document no. in Journal Entries Report
authorAlvaro Ferraz <alvaro.ferraz@openbravo.com>
Mon, 14 Sep 2015 13:53:36 +0200
changeset 27846 1f83e987ac49
parent 27845 d14b031058e5
child 27847 488b5488e994
Fixes issue 30788: Add filter by document no. in Journal Entries Report

Document No. field has been added to Journal Entries Report.
It will be shown only in case of Document selected has a document number property. Otherwise, it will be hidden and its value will be empty.
If it is filled with any value, report query will retrieve only records of this document with selected document number.
Query to filter by documentno will be dynamically generated from ReportGeneralLedgerJournal.java and insterted into ReportGeneralLedgerJournalData.java query.
src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.html
src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.java
src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.xml
src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal_data.xsql
--- a/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.html	Mon Nov 09 13:14:03 2015 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.html	Mon Sep 14 13:53:36 2015 +0200
@@ -119,6 +119,8 @@
         displayLogicElement('advancedFiltersrow3', true);
         displayLogicElement('advancedFiltersrow4', true);
         displayLogicElement('advancedFiltersrow5', true);
+        displayLogicElement('advancedFiltersrow6', true);
+        displayDocumentNo();
     }
     else{
         displayLogicElement('advancedFiltersrow0', false);
@@ -127,6 +129,40 @@
         displayLogicElement('advancedFiltersrow3', false);
         displayLogicElement('advancedFiltersrow4', false);
         displayLogicElement('advancedFiltersrow5', false);
+        displayLogicElement('advancedFiltersrow6', false);
+    }
+}
+
+function displayDocumentNo(){
+    switch (inpDocument.options[inpDocument.selectedIndex].value) {
+      case "APC":
+      case "API":
+      case "APP":
+      case "ARC":
+      case "ARI":
+      case "ARI_RM":
+      case "ARR":
+      case "BSF":
+      case "CAD":
+      case "DDB":
+      case "GLJ":
+      case "LDC":
+      case "REC":
+      case "REM_REM":
+        displayLogicElement('advancedFiltersrow2', true);
+        break;
+      case "AMZ":
+      case "CMC":
+      case "FAT":
+      case "LCC":
+      case "REM_REMCANCEL":
+      case "REM_REMRETURN":
+        displayLogicElement('advancedFiltersrow2', false);
+        paramDocumentNo.value = "";
+        break;
+      default:
+        displayLogicElement('advancedFiltersrow2', false);
+        paramDocumentNo.value = "";
     }    
 }
 
@@ -253,6 +289,7 @@
         updateMenuIcon('buttonMenu');
 
         setWindowElementFocus('firstElement');
+        displayDocumentNo();
         displayAdvancedFilters();
         selectDocument();
         openTabWhenPost();
@@ -550,14 +587,18 @@
             </tr>
             <tr id=advancedFiltersrow1>
              <td class="TitleCell"><span class="LabelText">Document</span></td>
-              <td class="Combo_ContentCell" colspan="2"> <select  name="inpDocument" id="inpDocument" class="Combo Combo_TwoCells_width">
+              <td class="Combo_ContentCell" colspan="2"> <select  name="inpDocument" id="inpDocument" class="Combo Combo_TwoCells_width" onchange="displayDocumentNo();">
                   <option value=""> <div id="reportDocument"></div></option>
                 </select></td>
                  <td class="TitleCell"><span class="LabelText">Initial Page Number</span></td>
               <td class="TextBox_ContentCell"> <input dojoType="openbravo:Textbox"  class="dojoValidateValid TextBox_OneCell_width" type="text" name="inpPageNo" id="paramPageNo" size="10" maxlength="10" value=""></input><script>djConfig.searchIds.push("paramPageNo");</script>
               </td>
             </tr>
-             <tr id=advancedFiltersrow2>              
+            <tr id=advancedFiltersrow2>
+               <td class="TitleCell"><span class="LabelText">Document No.</span></td>
+               <td class="TextBox_ContentCell"><input dojoType="openbravo:Textbox"  class="dojoValidateValid TextBox_OneCell_width" type="text" name="inpDocumentNo" id="paramDocumentNo" size="10" maxlength="10" value=""></input><script>djConfig.searchIds.push("paramPageNo");</script></td>
+            </tr>
+             <tr id=advancedFiltersrow3>
               <td class="TitleCell"><span class="LabelText">Initial Entry Number</span></td>
               <td class="TextBox_ContentCell">
                 <input dojoType="openbravo:Textbox" class="dojoValidateValid TextBox_OneCell_width" type="text" name="inpEntryNo"
@@ -569,14 +610,14 @@
             <td class="Radio_Check_ContentCell"><input TYPE="checkbox" id="paramShowRegular" name="inpShowRegular" value="Y"/></td>
             </tr>
             
-        <tr id=advancedFiltersrow3>      
+        <tr id=advancedFiltersrow4>
           <td class="TitleCell"><span class="LabelText">Show P&L Closing Entries</span></td>
           <td class="Radio_Check_ContentCell"><input TYPE="checkbox" id="paramShowReg" name="inpShowReg" value="Y"/></td>
           <td class="ContentCell"></td>
            <td class="TitleCell"><span class="LabelText">Show Opening Entries</span></td>
           <td class="Radio_Check_ContentCell"><input TYPE="checkbox" id="paramShowOpening" name="inpShowOpening" value="Y"/></td>
         </tr>
-        <tr id=advancedFiltersrow4>          
+        <tr id=advancedFiltersrow5>
           <td class="TitleCell"><span class="LabelText">Show Closing Entries</span></td>
           <td class="Radio_Check_ContentCell"><input TYPE="checkbox" id="paramShowClosing" name="inpShowClosing" value="Y"/></td>
           <td class="ContentCell"></td>
@@ -584,7 +625,7 @@
           <td class="Radio_Check_ContentCell"><input TYPE="checkbox" id="paramShowDescription" name="inpShowDescription" value="Y"/></td>
           <td class="ContentCell"></td>
         </tr>
-        <tr id=advancedFiltersrow5>
+        <tr id=advancedFiltersrow6>
           <td class="TitleCell"><span class="LabelText">Show Divide Up Entries</span></td>
           <td class="Radio_Check_ContentCell"><input TYPE="checkbox" id="paramShowDivideUp" name="inpShowDivideUp" value="Y"/></td>
           <td class="ContentCell"></td>
--- a/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.java	Mon Nov 09 13:14:03 2015 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.java	Mon Sep 14 13:53:36 2015 +0200
@@ -33,9 +33,12 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.StringUtils;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
+import org.hibernate.Query;
 import org.openbravo.base.secureApp.HttpSecureAppServlet;
 import org.openbravo.base.secureApp.VariablesHistory;
 import org.openbravo.base.secureApp.VariablesSecureApp;
@@ -54,6 +57,8 @@
 import org.openbravo.erpCommon.utility.OBError;
 import org.openbravo.erpCommon.utility.ToolBar;
 import org.openbravo.erpCommon.utility.Utility;
+import org.openbravo.model.ad.datamodel.Table;
+import org.openbravo.model.ad.system.Client;
 import org.openbravo.model.common.enterprise.DocumentType;
 import org.openbravo.model.financialmgmt.accounting.coa.AcctSchema;
 import org.openbravo.model.financialmgmt.accounting.coa.AcctSchemaTable;
@@ -93,6 +98,8 @@
           "");
       String strDocument = vars.getGlobalVariable("inpDocument",
           "ReportGeneralLedgerJournal|Document", "");
+      String strDocumentNo = vars.getGlobalVariable("inpDocumentNo",
+          "ReportGeneralLedgerJournal|DocumentNo", "");
       String strOrg = vars.getGlobalVariable("inpOrg", "ReportGeneralLedgerJournal|Org", "0");
       String strShowClosing = vars.getGlobalVariable("inpShowClosing",
           "ReportGeneralLedgerJournal|ShowClosing", "Y");
@@ -143,10 +150,11 @@
       strcelementvaluetodes = (strcelementvaluetodes.equals("null")) ? "" : strcelementvaluetodes;
       vars.setSessionValue("inpElementValueIdFrom_DES", strcelementvaluefromdes);
       vars.setSessionValue("inpElementValueIdTo_DES", strcelementvaluetodes);
-      printPageDataSheet(response, vars, strDateFrom, strDateTo, strDocument, strOrg, strTable,
-          strRecord, "", strcAcctSchemaId, strShowClosing, strShowReg, strShowOpening, strPageNo,
-          strEntryNo, strShowDescription, strShowRegular, strShowDivideUp, "", "",
-          strcelementvaluefrom, strcelementvalueto, strcelementvaluefromdes, strcelementvaluetodes);
+      printPageDataSheet(response, vars, strDateFrom, strDateTo, strDocument, strDocumentNo,
+          strOrg, strTable, strRecord, "", strcAcctSchemaId, strShowClosing, strShowReg,
+          strShowOpening, strPageNo, strEntryNo, strShowDescription, strShowRegular,
+          strShowDivideUp, "", "", strcelementvaluefrom, strcelementvalueto,
+          strcelementvaluefromdes, strcelementvaluetodes);
     } else if (vars.commandIn("DIRECT")) {
       String strTable = vars.getGlobalVariable("inpTable", "ReportGeneralLedgerJournal|Table");
       String strRecord = vars.getGlobalVariable("inpRecord", "ReportGeneralLedgerJournal|Record");
@@ -172,15 +180,15 @@
       }
       setHistoryCommand(request, "DIRECT");
       vars.setSessionValue("ReportGeneralLedgerJournal.initRecordNumber", "0");
-      printPageDataSheet(response, vars, "", "", "", "", strTable, strRecord, "", strcAcctSchemaId,
-          "", "", "", "1", "1", "", "Y", "", schemas, strPosted, "", "", "", "");
+      printPageDataSheet(response, vars, "", "", "", "", "", strTable, strRecord, "",
+          strcAcctSchemaId, "", "", "", "1", "1", "", "Y", "", schemas, strPosted, "", "", "", "");
     } else if (vars.commandIn("DIRECT2")) {
       String strFactAcctGroupId = vars.getGlobalVariable("inpFactAcctGroupId",
           "ReportGeneralLedgerJournal|FactAcctGroupId");
       setHistoryCommand(request, "DIRECT2");
       vars.setSessionValue("ReportGeneralLedgerJournal.initRecordNumber", "0");
-      printPageDataSheet(response, vars, "", "", "", "", "", "", strFactAcctGroupId, "", "", "",
-          "", "1", "1", "", "Y", "", "", "", "", "", "", "");
+      printPageDataSheet(response, vars, "", "", "", "", "", "", "", strFactAcctGroupId, "", "",
+          "", "", "1", "1", "", "Y", "", "", "", "", "", "", "");
     } else if (vars.commandIn("FIND")) {
       String strcAcctSchemaId = vars.getRequestGlobalVariable("inpcAcctSchemaId",
           "ReportGeneralLedger|cAcctSchemaId");
@@ -190,6 +198,8 @@
           "ReportGeneralLedgerJournal|DateTo");
       String strDocument = vars.getRequestGlobalVariable("inpDocument",
           "ReportGeneralLedgerJournal|Document");
+      String strDocumentNo = vars.getRequestGlobalVariable("inpDocumentNo",
+          "ReportGeneralLedgerJournal|DocumentNo");
       String strOrg = vars.getGlobalVariable("inpOrg", "ReportGeneralLedgerJournal|Org", "0");
       String strShowClosing = vars.getRequestGlobalVariable("inpShowClosing",
           "ReportGeneralLedgerJournal|ShowClosing");
@@ -254,10 +264,10 @@
             strcelementvalueto);
       vars.setSessionValue("inpElementValueIdFrom_DES", strcelementvaluefromdes);
       vars.setSessionValue("inpElementValueIdTo_DES", strcelementvaluetodes);
-      printPageDataSheet(response, vars, strDateFrom, strDateTo, strDocument, strOrg, "", "", "",
-          strcAcctSchemaId, strShowClosing, strShowReg, strShowOpening, strPageNo, strEntryNo,
-          strShowDescription, strShowRegular, strShowDivideUp, "", "", strcelementvaluefrom,
-          strcelementvalueto, strcelementvaluefromdes, strcelementvaluetodes);
+      printPageDataSheet(response, vars, strDateFrom, strDateTo, strDocument, strDocumentNo,
+          strOrg, "", "", "", strcAcctSchemaId, strShowClosing, strShowReg, strShowOpening,
+          strPageNo, strEntryNo, strShowDescription, strShowRegular, strShowDivideUp, "", "",
+          strcelementvaluefrom, strcelementvalueto, strcelementvaluefromdes, strcelementvaluetodes);
     } else if (vars.commandIn("PDF", "XLS")) {
       if (log4j.isDebugEnabled())
         log4j.debug("PDF");
@@ -269,6 +279,8 @@
           "ReportGeneralLedgerJournal|DateTo");
       String strDocument = vars.getRequestGlobalVariable("inpDocument",
           "ReportGeneralLedgerJournal|Document");
+      String strDocumentNo = vars.getRequestGlobalVariable("inpDocumentNo",
+          "ReportGeneralLedgerJournal|DocumentNo");
       String strOrg = vars.getGlobalVariable("inpOrg", "ReportGeneralLedgerJournal|Org", "0");
       String strShowClosing = vars.getRequestGlobalVariable("inpShowClosing",
           "ReportGeneralLedgerJournal|ShowClosing");
@@ -341,10 +353,10 @@
           "ReportGeneralLedgerJournal|C_ElementValue_IDFROM");
       String strcelementvalueto = vars.getRequestGlobalVariable("inpcElementValueIdTo",
           "ReportGeneralLedgerJournal|C_ElementValue_IDTO");
-      printPagePDF(request, response, vars, strDateFrom, strDateTo, strDocument, strOrg, strTable,
-          strRecord, strFactAcctGroupId, strcAcctSchemaId, strShowClosing, strShowReg,
-          strShowOpening, strPageNo, strEntryNo, "Y".equals(strShowDescription) ? "Y" : "",
-          strShowRegular, strShowDivideUp, strcelementvaluefrom, strcelementvalueto);
+      printPagePDF(request, response, vars, strDateFrom, strDateTo, strDocument, strDocumentNo,
+          strOrg, strTable, strRecord, strFactAcctGroupId, strcAcctSchemaId, strShowClosing,
+          strShowReg, strShowOpening, strPageNo, strEntryNo, "Y".equals(strShowDescription) ? "Y"
+              : "", strShowRegular, strShowDivideUp, strcelementvaluefrom, strcelementvalueto);
     } else if (vars.commandIn("PREVIOUS_RELATION")) {
       String strInitRecord = vars.getSessionValue("ReportGeneralLedgerJournal.initRecordNumber");
       String strPreviousRecordRange = vars.getSessionValue(PREVIOUS_RANGE);
@@ -404,13 +416,13 @@
   }
 
   private void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars,
-      String strDateFrom, String strDateTo, String strDocument, String strOrg, String strTable,
-      String strRecord, String strFactAcctGroupId, String strcAcctSchemaId, String strShowClosing,
-      String strShowReg, String strShowOpening, String strPageNo, String strEntryNo,
-      String strShowDescription, String strShowRegular, String strShowDivideUp, String accShemas,
-      String strPosted, String strcelementvaluefrom, String strcelementvalueto,
-      String strcelementvaluefromdes, String strcelementvaluetodes) throws IOException,
-      ServletException {
+      String strDateFrom, String strDateTo, String strDocument, String strDocumentNo,
+      String strOrg, String strTable, String strRecord, String strFactAcctGroupId,
+      String strcAcctSchemaId, String strShowClosing, String strShowReg, String strShowOpening,
+      String strPageNo, String strEntryNo, String strShowDescription, String strShowRegular,
+      String strShowDivideUp, String accShemas, String strPosted, String strcelementvaluefrom,
+      String strcelementvalueto, String strcelementvaluefromdes, String strcelementvaluetodes)
+      throws IOException, ServletException {
     String strAllaccounts = "Y";
     if (strcelementvaluefrom != null && !strcelementvaluefrom.equals(""))
       strAllaccounts = "N";
@@ -447,8 +459,8 @@
             Utility.getContext(this, vars, "#User_Client", "ReportGeneralLedger"),
             Utility.getContext(this, vars, "#AccessibleOrgTree", "ReportGeneralLedger"),
             strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"), strDocument,
-            strcAcctSchemaId, strOrgFamily, strCheck, strAllaccounts, strcelementvaluefrom,
-            strcelementvalueto);
+            getDocumentNo(vars.getClient(), strDocument, strDocumentNo), strcAcctSchemaId,
+            strOrgFamily, strCheck, strAllaccounts, strcelementvaluefrom, strcelementvalueto);
         String strInitAcctEntries = vars.getSessionValue(PREVIOUS_ACCTENTRIES);
         int acctEntries = (strInitAcctEntries.equals("") ? 0 : Integer.parseInt(strInitAcctEntries
             .split(",")[0]));
@@ -503,15 +515,17 @@
             Utility.getContext(this, vars, "#User_Client", "ReportGeneralLedger"),
             Utility.getContext(this, vars, "#AccessibleOrgTree", "ReportGeneralLedger"),
             strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"), strDocument,
-            strcAcctSchemaId, strOrgFamily, strCheck, strAllaccounts, strcelementvaluefrom,
-            strcelementvalueto, vars.getLanguage(), initRecordNumber, intRecordRangeUsed);
+            getDocumentNo(vars.getClient(), strDocument, strDocumentNo), strcAcctSchemaId,
+            strOrgFamily, strCheck, strAllaccounts, strcelementvaluefrom, strcelementvalueto,
+            vars.getLanguage(), initRecordNumber, intRecordRangeUsed);
         if (data != null && data.length > 0)
           strPosition = ReportGeneralLedgerJournalData.selectCount(this,
               Utility.getContext(this, vars, "#User_Client", "ReportGeneralLedger"),
               Utility.getContext(this, vars, "#AccessibleOrgTree", "ReportGeneralLedger"),
               strDateFrom, DateTimeData.nDaysAfter(this, strDateTo, "1"), strDocument,
-              strcAcctSchemaId, strOrgFamily, strCheck, strAllaccounts, strcelementvaluefrom,
-              strcelementvalueto, data[0].dateacct, data[0].identifier);
+              getDocumentNo(vars.getClient(), strDocument, strDocumentNo), strcAcctSchemaId,
+              strOrgFamily, strCheck, strAllaccounts, strcelementvaluefrom, strcelementvalueto,
+              data[0].dateacct, data[0].identifier);
       } else {
         data = ReportGeneralLedgerJournalData.selectDirect(this,
             "Y".equals(strShowDescription) ? "'Y'" : "'N'",
@@ -654,6 +668,7 @@
     vars.setSessionValue("ReportGeneralLedgerJournal|Record", strRecord);
     vars.setSessionValue("ReportGeneralLedgerJournal|Table", strTable);
     xmlDocument.setParameter("inpPageNo", strPageNo);
+    xmlDocument.setParameter("inpDocumentNo", strDocumentNo);
     xmlDocument.setParameter("inpEntryNo", strEntryNo);
     // If none of the "show" flags is active, then regular is checked
     xmlDocument.setParameter("showRegular", ("".equals(strShowRegular)) ? "N" : strShowRegular);
@@ -686,11 +701,11 @@
 
   private void printPagePDF(HttpServletRequest request, HttpServletResponse response,
       VariablesSecureApp vars, String strDateFrom, String strDateTo, String strDocument,
-      String strOrg, String strTable, String strRecord, String strFactAcctGroupId,
-      String strcAcctSchemaId, String strShowClosing, String strShowReg, String strShowOpening,
-      String strPageNo, String strEntryNo, String strShowDescription, String strShowRegular,
-      String strShowDivideUp, String strcelementvaluefrom, String strcelementvalueto) 
-      throws IOException, ServletException {
+      String strDocumentNo, String strOrg, String strTable, String strRecord,
+      String strFactAcctGroupId, String strcAcctSchemaId, String strShowClosing, String strShowReg,
+      String strShowOpening, String strPageNo, String strEntryNo, String strShowDescription,
+      String strShowRegular, String strShowDivideUp, String strcelementvaluefrom,
+      String strcelementvalueto) throws IOException, ServletException {
 
     ReportGeneralLedgerJournalData[] data = null;
 
@@ -711,7 +726,8 @@
       data = ReportGeneralLedgerJournalData.select(this, "Y".equals(strShowDescription) ? "'Y'"
           : "'N'", Utility.getContext(this, vars, "#User_Client", "ReportGeneralLedger"), Utility
           .getContext(this, vars, "#AccessibleOrgTree", "ReportGeneralLedger"), strDateFrom,
-          DateTimeData.nDaysAfter(this, strDateTo, "1"), strDocument, strcAcctSchemaId,
+          DateTimeData.nDaysAfter(this, strDateTo, "1"), strDocument,
+          getDocumentNo(vars.getClient(), strDocument, strDocumentNo), strcAcctSchemaId,
           strOrgFamily, strCheck, strAllaccounts, strcelementvaluefrom, strcelementvalueto, vars
               .getLanguage());
     } else
@@ -894,6 +910,35 @@
 
   }
 
+  private String getDocumentNo(String strClient, String strDocument, String strDocumentNo) {
+    if (StringUtils.isEmpty(strDocument) || StringUtils.isEmpty(strDocumentNo)) {
+      return null;
+    } else {
+      String documentNo = StringEscapeUtils.escapeSql(strDocumentNo);
+      documentNo = documentNo.replaceAll(";", "");
+      String string = "( SELECT 1 FROM ";
+
+      StringBuffer where = new StringBuffer();
+      where.append(" select t." + Table.PROPERTY_DBTABLENAME);
+      where.append(" from " + DocumentType.ENTITY_NAME + " as d");
+      where.append(" join d." + DocumentType.PROPERTY_TABLE + " as t");
+      where.append(" where d." + DocumentType.PROPERTY_DOCUMENTCATEGORY + " = :document");
+      where.append(" and d." + DocumentType.PROPERTY_CLIENT + " = :client");
+      where.append(" group by d." + DocumentType.PROPERTY_DOCUMENTCATEGORY);
+      where.append(" , t." + Table.PROPERTY_DBTABLENAME);
+      Query qry = OBDal.getInstance().getSession().createQuery(where.toString());
+      qry.setMaxResults(1);
+      qry.setParameter("document", strDocument);
+      qry.setParameter("client", OBDal.getInstance().get(Client.class, strClient));
+      String tablename = (String) qry.uniqueResult();
+
+      string += tablename;
+      string += " dt WHERE record_id = dt." + tablename + "_id";
+      string += " AND dt.documentno = '" + documentNo + "' )";
+      return string;
+    }
+  }
+
   @Override
   public String getServletInfo() {
     return "Servlet ReportGeneralLedgerJournal. This Servlet was made by Pablo Sarobe modified by everybody";
--- a/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.xml	Mon Nov 09 13:14:03 2015 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.xml	Mon Sep 14 13:53:36 2015 +0200
@@ -12,7 +12,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-2014 Openbravo SLU
+* All portions are Copyright (C) 2001-2015 Openbravo SLU
 * All Rights Reserved.
 * Contributor(s):  ______________________________________.
 ************************************************************************
@@ -47,6 +47,7 @@
   <PARAMETER id="inpParamschemas" name="cAcctschemas" attribute="value" default=""/>
   <PARAMETER id="posted" name="posted" attribute="value" default=""/>
   <PARAMETER id="paramPageNo" name="inpPageNo" attribute="value" default="1"/>
+  <PARAMETER id="paramDocumentNo" name="inpDocumentNo" attribute="value" default=""/>
   <PARAMETER id="paramEntryNo" name="inpEntryNo" attribute="value" default="1"/>
   <PARAMETER id="fieldCheck" name="check" default="Y"/>
   <PARAMETER id="paramShowRegular" name="showRegular" boolean="checked" withId="fieldCheck"/>
--- a/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal_data.xsql	Mon Nov 09 13:14:03 2015 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal_data.xsql	Mon Sep 14 13:53:36 2015 +0200
@@ -12,7 +12,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-2014 Openbravo SLU
+ * All portions are Copyright (C) 2001-2015 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -70,6 +70,7 @@
     <Parameter name="parDateFrom" optional="true" after="AND 1=1"><![CDATA[ AND f.dateacct >= TO_DATE(?)]]></Parameter>
     <Parameter name="parDateTo" optional="true" after="AND 1=1"><![CDATA[ AND f.dateacct < TO_DATE(?)]]></Parameter>
     <Parameter name="docbasetype" optional="true" after="AND 1=1"><![CDATA[ AND f.DOCBASETYPE = ?]]></Parameter>
+    <Parameter name="documentNo" optional="true" after="AND 1=1" type="argument"><![CDATA[ AND EXISTS ]]></Parameter>
     <Parameter name="acctschema" optional="true" after="AND 1=1"><![CDATA[ AND f.C_ACCTSCHEMA_ID = ?]]></Parameter>
     <Parameter name="orgFamily" type="replace" optional="true" after="AND f.AD_ORG_ID IN(" text="'2'"/>
     <Parameter name="checks" type="replace" optional="true" after="AND F.FactAcctType IN (" text="'C','N','O','R','D'"/>    
@@ -81,6 +82,7 @@
     <Parameter name="parDateFrom" optional="true" after="AND 3=3"><![CDATA[ AND dateacct >= TO_DATE(?)]]></Parameter>
     <Parameter name="parDateTo" optional="true" after="AND 3=3"><![CDATA[ AND dateacct < TO_DATE(?)]]></Parameter>
     <Parameter name="docbasetype" optional="true" after="AND 3=3"><![CDATA[ AND DOCBASETYPE = ?]]></Parameter>
+    <Parameter name="documentNo" optional="true" after="AND 3=3" type="argument"><![CDATA[ AND EXISTS ]]></Parameter>
     <Parameter name="acctschema" optional="true" after="AND 3=3"><![CDATA[ AND C_ACCTSCHEMA_ID = ?]]></Parameter>
     <Parameter name="orgFamily" type="replace" optional="true" after="AND AD_ORG_ID IN(" text="'4'"/>
     <Parameter name="checks" type="replace" optional="true" after="AND FactAcctType IN (" text="'C','N','O','R','D'"/>
@@ -137,6 +139,7 @@
     <Parameter name="parDateFrom" optional="true" after="AND 1=1"><![CDATA[ AND f.dateacct >= TO_DATE(?)]]></Parameter>
     <Parameter name="parDateTo" optional="true" after="AND 1=1"><![CDATA[ AND f.dateacct < TO_DATE(?)]]></Parameter>
     <Parameter name="docbasetype" optional="true" after="AND 1=1"><![CDATA[ AND f.DOCBASETYPE = ?]]></Parameter>
+    <Parameter name="documentNo" optional="true" after="AND 1=1" type="argument"><![CDATA[ AND EXISTS ]]></Parameter>
     <Parameter name="acctschema" optional="true" after="AND 1=1"><![CDATA[ AND f.C_ACCTSCHEMA_ID = ?]]></Parameter>
     <Parameter name="orgFamily" type="replace" optional="true" after="AND f.AD_ORG_ID IN(" text="'2'"/>
     <Parameter name="checks" type="replace" optional="true" after="AND F.FactAcctType IN (" text="'C','N','O','R','D'"/>
@@ -148,6 +151,7 @@
     <Parameter name="parDateFrom" optional="true" after="AND 3=3"><![CDATA[ AND dateacct >= TO_DATE(?)]]></Parameter>
     <Parameter name="parDateTo" optional="true" after="AND 3=3"><![CDATA[ AND dateacct < TO_DATE(?)]]></Parameter>
     <Parameter name="docbasetype" optional="true" after="AND 3=3"><![CDATA[ AND DOCBASETYPE = ?]]></Parameter>
+    <Parameter name="documentNo" optional="true" after="AND 3=3" type="argument"><![CDATA[ AND EXISTS ]]></Parameter>
     <Parameter name="acctschema" optional="true" after="AND 3=3"><![CDATA[ AND C_ACCTSCHEMA_ID = ?]]></Parameter>
     <Parameter name="orgFamily" type="replace" optional="true" after="AND AD_ORG_ID IN(" text="'4'"/>
     <Parameter name="checks" type="replace" optional="true" after="AND FactAcctType IN (" text="'C','N','O','R','D'"/>
@@ -193,6 +197,7 @@
     <Parameter name="parDateFrom" optional="true" after="AND 1=1"><![CDATA[ AND f.dateacct >= TO_DATE(?)]]></Parameter>
     <Parameter name="parDateTo" optional="true" after="AND 1=1"><![CDATA[ AND f.dateacct < TO_DATE(?)]]></Parameter>
     <Parameter name="docbasetype" optional="true" after="AND 1=1"><![CDATA[ AND f.DOCBASETYPE = ?]]></Parameter>
+    <Parameter name="documentNo" optional="true" after="AND 1=1" type="argument"><![CDATA[ AND EXISTS ]]></Parameter>
     <Parameter name="acctschema" optional="true" after="AND 1=1"><![CDATA[ AND f.C_ACCTSCHEMA_ID = ?]]></Parameter>
     <Parameter name="orgFamily" type="replace" optional="true" after="AND f.AD_ORG_ID IN(" text="'2'"/>
     <Parameter name="checks" type="replace" optional="true" after="AND F.FactAcctType IN (" text="'C','N','O','R','D'"/>
@@ -204,6 +209,7 @@
     <Parameter name="parDateFrom" optional="true" after="AND 3=3"><![CDATA[ AND dateacct >= TO_DATE(?)]]></Parameter>
     <Parameter name="parDateTo" optional="true" after="AND 3=3"><![CDATA[ AND dateacct < TO_DATE(?)]]></Parameter>
     <Parameter name="docbasetype" optional="true" after="AND 3=3"><![CDATA[ AND DOCBASETYPE = ?]]></Parameter>
+    <Parameter name="documentNo" optional="true" after="AND 3=3" type="argument"><![CDATA[ AND EXISTS ]]></Parameter>
     <Parameter name="acctschema" optional="true" after="AND 3=3"><![CDATA[ AND C_ACCTSCHEMA_ID = ?]]></Parameter>
     <Parameter name="orgFamily" type="replace" optional="true" after="AND AD_ORG_ID IN(" text="'4'"/>
     <Parameter name="checks" type="replace" optional="true" after="AND FactAcctType IN (" text="'C','N','O','R','D'"/>