details: https://code.openbravo.com/erp/devel/pi/rev/1f83e987ac49 changeset: 27846:1f83e987ac49 user: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com> date: Mon Sep 14 13:53:36 2015 +0200 summary: 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. details: https://code.openbravo.com/erp/devel/pi/rev/488b5488e994 changeset: 27847:488b5488e994 user: Víctor Martínez Romanos <victor.martinez <at> openbravo.com> date: Tue Sep 15 14:02:13 2015 +0200 summary: Related to issue 30788: code review improvements Minor modifications: + Run query in admin mode + Usage of StringUtils.isBlank to control whitespace + Usage of StringBuffer to avoid String concatenation + Control any possible exception and return null to avoid breaking the report + Avoid unnecessary indentation (removed else) + Avoid the need of getting the Client object and using directly the id instead + Exists clause removed from subquery related to accounts from/to filter because it's useless and affects performance + Set the right param to djConfig.searchIds.push diffstat: src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.html | 51 +++- src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.java | 128 +++++++-- src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.xml | 3 +- src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal_data.xsql | 5 +- 4 files changed, 145 insertions(+), 42 deletions(-) diffs (truncated from 420 to 300 lines): diff -r d14b031058e5 -r 488b5488e994 src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.html --- 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 Tue Sep 15 14:02:13 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("paramDocumentNo");</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> diff -r d14b031058e5 -r 488b5488e994 src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.java --- 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 Tue Sep 15 14:02:13 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,7 @@ 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.common.enterprise.DocumentType; import org.openbravo.model.financialmgmt.accounting.coa.AcctSchema; import org.openbravo.model.financialmgmt.accounting.coa.AcctSchemaTable; @@ -93,6 +97,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 +149,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 +179,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 +197,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 +263,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 +278,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 +352,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 +415,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 +458,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 +514,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 +667,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 +700,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, ------------------------------------------------------------------------------ _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits
