details: https://code.openbravo.com/erp/devel/pi/rev/0827ac596ad2 changeset: 28164:0827ac596ad2 user: Víctor Martínez Romanos <victor.martinez <at> openbravo.com> date: Wed Dec 23 13:42:24 2015 +0100 summary: Fixed bug 31649: Performance problems opening Balance Sheet and PL structure
selectYearsDouble query was consuming most of the time required for launching the window. Rewritten query to use EXISTS clause, to filter by AD_CLIENT_ID and to call AD_ORG_ISINNATURALTREE() function, which reduces the query cost from 126320.46 to 2527.97, and the time from 20 secs to 0,8 secs details: https://code.openbravo.com/erp/devel/pi/rev/2dfae5bc1ff6 changeset: 28165:2dfae5bc1ff6 user: Atul Gaware <atul.gaware <at> openbravo.com> date: Wed Dec 23 01:08:07 2015 +0530 summary: Fixes Issue 31697:Bank Statement Line description overwritten with GL Item's or payment's description when adding gl item or payment in add transaction of Match Statement Process. This issue is fixed in two area's 1. Add Transaction Process Definition window in Match Statement. 2. Transaction Tab of Financial Account window. Whenever there exists a description prior adding gl item or payment in above both cases description is appended with either gl item description or payment description. details: https://code.openbravo.com/erp/devel/pi/rev/ad230fc1c0f1 changeset: 28166:ad230fc1c0f1 user: Víctor Martínez Romanos <victor.martinez <at> openbravo.com> date: Wed Dec 23 18:48:11 2015 +0100 summary: Fixed bug 31697: code review improvements In case of removing a gl item from a transaction, the part of the transaction's description related to the GL Item (and everything else afterwards) will be deleted. The part of the transaction's description before the GL Item description will be always kept. The same behavior is applied when adding a new transaction from the Financial Account window and from the Match Statement --> Add transaction process In case of removing a payment, the behavior is similar to the GL Item described above. However, since the payment description doesn't follow a constant structure (like in the case of GL Item's description), it's very hard to detect the description on the fly. That means that the flow will only work just after saving the transaction or in the first change after loading the transaction, which are the common flows. If the user selects different payments without saving the record, the system will append the different payment's description to the transaction. The getFinAccTransactionDescription() method: 1. won't append multiple times the same description. 2. will add an extra empty line only when it's something to be appended 3. will work fine when the transaction already has a description with multiple lines 4. control any possible exception and returns the text to be append (if not blank), or the original description Applied jsbeautifier to ob-aprm-addTransaction.js details: https://code.openbravo.com/erp/devel/pi/rev/09cb07130e5b changeset: 28167:09cb07130e5b user: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com> date: Thu Dec 24 11:03:13 2015 +0100 summary: Related to issue 31697: Avoid append a null description diffstat: modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddTransactionOnChangePaymentActionHandler.java | 11 +- modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/GLItemTransactionActionHandler.java | 29 +++- modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_Utility.java | 38 ++++++ modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-addTransaction.js | 12 +- src/org/openbravo/erpCommon/ad_callouts/SE_GLItem_Transaction.java | 63 ++++----- src/org/openbravo/erpCommon/ad_callouts/SE_Payment_Transaction.java | 37 +++++- src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports_data.xsql | 21 +- 7 files changed, 145 insertions(+), 66 deletions(-) diffs (truncated from 391 to 300 lines): diff -r f26fa9fa4eba -r 09cb07130e5b modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddTransactionOnChangePaymentActionHandler.java --- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddTransactionOnChangePaymentActionHandler.java Wed Dec 23 11:48:21 2015 +0100 +++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddTransactionOnChangePaymentActionHandler.java Thu Dec 24 11:03:13 2015 +0100 @@ -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-2015 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************ @@ -23,6 +23,7 @@ import java.util.Map; import org.codehaus.jettison.json.JSONObject; +import org.openbravo.advpaymentmngt.utility.FIN_Utility; import org.openbravo.client.kernel.BaseActionHandler; import org.openbravo.dal.core.OBContext; import org.openbravo.dal.service.OBDal; @@ -46,8 +47,10 @@ try { OBContext.setAdminMode(true); final JSONObject jsonData = new JSONObject(data); + String description = jsonData.getString("strDescription"); if (jsonData.isNull("strPaymentId")) { - result.put("description", ""); + description = FIN_Utility.getFinAccTransactionDescription(description, "", ""); + result.put("description", description); result.put("depositamt", BigDecimal.ZERO); result.put("paymentamt", BigDecimal.ZERO); } else { @@ -65,7 +68,9 @@ result.put("cBpartnerId", payment.getBusinessPartner().getId()); } if (payment.getDescription() != null) { - result.put("description", payment.getDescription()); + description = FIN_Utility.getFinAccTransactionDescription(description, "", + payment.getDescription()); + result.put("description", description); } } } catch (Exception e) { diff -r f26fa9fa4eba -r 09cb07130e5b modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/GLItemTransactionActionHandler.java --- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/GLItemTransactionActionHandler.java Wed Dec 23 11:48:21 2015 +0100 +++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/GLItemTransactionActionHandler.java Thu Dec 24 11:03:13 2015 +0100 @@ -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-2015 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************ @@ -25,6 +25,7 @@ import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONObject; import org.openbravo.advpaymentmngt.utility.APRM_MatchingUtility; +import org.openbravo.advpaymentmngt.utility.FIN_Utility; import org.openbravo.client.kernel.BaseActionHandler; import org.openbravo.dal.core.OBContext; import org.openbravo.dal.service.OBDal; @@ -40,17 +41,25 @@ try { OBContext.setAdminMode(true); final JSONObject jsonData = new JSONObject(data); - final String strGLItemId = jsonData.getString("strGLItemId"); - - String description = ""; - if (StringUtils.isNotBlank(strGLItemId)) { - final GLItem glItem = OBDal.getInstance().get(GLItem.class, strGLItemId); - if (glItem != null) { - description = OBMessageUtils.messageBD("APRM_GLItem") + ": " + glItem.getName(); + String description = jsonData.getString("strDescription"); + final String glitemPrefix = OBMessageUtils.messageBD("APRM_GLItem"); + if (jsonData.isNull("strGLItemId")) { + description = FIN_Utility.getFinAccTransactionDescription(description, "\n" + glitemPrefix, + ""); + description = FIN_Utility.getFinAccTransactionDescription(description, glitemPrefix, ""); + result.put("description", description); + } else { + final String strGLItemId = jsonData.getString("strGLItemId"); + if (StringUtils.isNotBlank(strGLItemId)) { + final GLItem glItem = OBDal.getInstance().get(GLItem.class, strGLItemId); + if (glItem != null) { + String glItemDescription = glitemPrefix + ": " + glItem.getName(); + description = FIN_Utility.getFinAccTransactionDescription(description, glitemPrefix, + glItemDescription); + } } + result.put("description", description); } - - result.put("description", description); } catch (Exception e) { try { final JSONArray actions = APRM_MatchingUtility.createMessageInProcessView(e.getMessage(), diff -r f26fa9fa4eba -r 09cb07130e5b modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_Utility.java --- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_Utility.java Wed Dec 23 11:48:21 2015 +0100 +++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_Utility.java Thu Dec 24 11:03:13 2015 +0100 @@ -1583,4 +1583,42 @@ return (FinAccPaymentMethod) qry.uniqueResult(); } + + /** + * Appends existing Financial Account Transaction description with either GL Item Description or + * Payment description in a new line + * + * @param description + * @param descriptionToAppend + * @return returnDescription + */ + + public static String getFinAccTransactionDescription(String description, + String removeDescription, String appendDescription) { + try { + String returnDescription = description == null ? "" : description; + if (StringUtils.isBlank(removeDescription) + && StringUtils.contains(description, StringUtils.trim(appendDescription))) { + return description; + } + if (description != null && !description.equals("null") && !StringUtils.isBlank(description)) { + if (!StringUtils.isBlank(removeDescription) && description.indexOf(removeDescription) != -1) { + returnDescription = returnDescription + .substring(0, description.indexOf(removeDescription)) + + (StringUtils.isBlank(appendDescription) ? "" : appendDescription); + } else if (StringUtils.isNotBlank(appendDescription)) { + returnDescription = returnDescription + "\n" + appendDescription; + } + } else { + returnDescription = appendDescription; + } + return returnDescription; + } catch (Exception e) { + if (StringUtils.isNotBlank(appendDescription)) { + return appendDescription; + } else { + return description; + } + } + } } diff -r f26fa9fa4eba -r 09cb07130e5b modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-addTransaction.js --- a/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-addTransaction.js Wed Dec 23 11:48:21 2015 +0100 +++ b/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-addTransaction.js Thu Dec 24 11:03:13 2015 +0100 @@ -87,7 +87,8 @@ }; OB.APRM.AddTransaction.paymentOnChangeFunction = function (item, view, form, grid) { - var callback, strPaymentId = item.getValue(); + var callback, strPaymentId = item.getValue(), + strDescription = form.getItem('description').getValue(); callback = function (response, data, request) { form.getItem('description').setValue(data.description); @@ -97,19 +98,22 @@ }; OB.RemoteCallManager.call('org.openbravo.advpaymentmngt.actionHandler.AddTransactionOnChangePaymentActionHandler', { - strPaymentId: strPaymentId + strPaymentId: strPaymentId, + strDescription: strDescription }, {}, callback); }; OB.APRM.AddTransaction.glitemOnChangeFunction = function (item, view, form, grid) { - var callback, strGLItemId = item.getValue(); + var callback, strGLItemId = item.getValue(), + strDescription = form.getItem('description').getValue(); callback = function (response, data, request) { form.getItem('description').setValue(data.description); }; OB.RemoteCallManager.call('org.openbravo.advpaymentmngt.actionHandler.GLItemTransactionActionHandler', { - strGLItemId: strGLItemId + strGLItemId: strGLItemId, + strDescription: strDescription }, {}, callback); }; diff -r f26fa9fa4eba -r 09cb07130e5b src/org/openbravo/erpCommon/ad_callouts/SE_GLItem_Transaction.java --- a/src/org/openbravo/erpCommon/ad_callouts/SE_GLItem_Transaction.java Wed Dec 23 11:48:21 2015 +0100 +++ b/src/org/openbravo/erpCommon/ad_callouts/SE_GLItem_Transaction.java Thu Dec 24 11:03:13 2015 +0100 @@ -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) 2013 Openbravo SLU + * All portions are Copyright (C) 2013-2015 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************ @@ -20,11 +20,13 @@ import javax.servlet.ServletException; +import org.apache.commons.lang.StringUtils; +import org.openbravo.advpaymentmngt.utility.FIN_Utility; import org.openbravo.base.filter.IsIDFilter; +import org.openbravo.dal.core.OBContext; import org.openbravo.dal.service.OBDal; -import org.openbravo.erpCommon.utility.Utility; +import org.openbravo.erpCommon.utility.OBMessageUtils; import org.openbravo.model.financialmgmt.gl.GLItem; -import org.openbravo.model.financialmgmt.payment.FIN_FinaccTransaction; public class SE_GLItem_Transaction extends SimpleCallout { @@ -32,44 +34,35 @@ @Override protected void execute(CalloutInfo info) throws ServletException { + final String strGLItemId = info.getStringParameter("inpcGlitemId", IsIDFilter.instance); + String description = info.getStringParameter("inpdescription", null); + try { - final String strGLItemId = info.getStringParameter("inpcGlitemId", IsIDFilter.instance); - final String strTransactionId = info.getStringParameter("Fin_Finacc_Transaction_ID", - IsIDFilter.instance); - if ("".equals(strGLItemId)) { - info.addResult("inpdescription", ""); + OBContext.setAdminMode(true); + + final String glItemDescPrefix = OBMessageUtils.messageBD("APRM_GLItem"); + + // Delete only previous GL Item description + if (StringUtils.isBlank(strGLItemId)) { + description = FIN_Utility.getFinAccTransactionDescription(description, "\n" + + glItemDescPrefix, ""); + description = FIN_Utility + .getFinAccTransactionDescription(description, glItemDescPrefix, ""); } - GLItem glItem = OBDal.getInstance().get(GLItem.class, strGLItemId); - FIN_FinaccTransaction transaction = OBDal.getInstance().get(FIN_FinaccTransaction.class, - strTransactionId); - String description = ""; - if (transaction != null) { - GLItem oldGLItem = transaction.getGLItem(); - description = transaction.getDescription(); - String oldGlItemString = Utility.messageBD(this, "APRM_GLItem", info.vars.getLanguage()) - + ": " + oldGLItem.getName(); - String newGlItemString = Utility.messageBD(this, "APRM_GLItem", info.vars.getLanguage()) - + ": " + glItem.getName(); - if (description != null && !description.isEmpty()) { - description = description.indexOf(oldGlItemString) != -1 ? (description - .indexOf(oldGlItemString) == 0 ? "" : description.substring(0, - description.indexOf(oldGlItemString) - 1) - + "\n") - + newGlItemString - + description.substring( - oldGlItemString.length() + description.indexOf(oldGlItemString), - description.length()) : description; - } - description = (description == null || description.isEmpty()) ? newGlItemString - : description; - } else { - description = Utility.messageBD(this, "APRM_GLItem", info.vars.getLanguage()) + ": " - + glItem.getName(); - ; + + // Write description for selected GL Item + final GLItem glItem = OBDal.getInstance().get(GLItem.class, strGLItemId); + if (glItem != null) { + final String newGlItemDesc = glItemDescPrefix + ": " + glItem.getName(); + description = FIN_Utility.getFinAccTransactionDescription(description, glItemDescPrefix, + newGlItemDesc); } + info.addResult("inpdescription", description); } catch (Exception e) { return; + } finally { + OBContext.restorePreviousMode(); } } } diff -r f26fa9fa4eba -r 09cb07130e5b src/org/openbravo/erpCommon/ad_callouts/SE_Payment_Transaction.java --- a/src/org/openbravo/erpCommon/ad_callouts/SE_Payment_Transaction.java Wed Dec 23 11:48:21 2015 +0100 +++ b/src/org/openbravo/erpCommon/ad_callouts/SE_Payment_Transaction.java Thu Dec 24 11:03:13 2015 +0100 @@ -22,8 +22,12 @@ import javax.servlet.ServletException; +import org.apache.commons.lang.StringUtils; +import org.openbravo.advpaymentmngt.utility.FIN_Utility; import org.openbravo.base.filter.IsIDFilter; +import org.openbravo.dal.core.OBContext; import org.openbravo.dal.service.OBDal; +import org.openbravo.model.financialmgmt.payment.FIN_FinaccTransaction; import org.openbravo.model.financialmgmt.payment.FIN_Payment; public class SE_Payment_Transaction extends SimpleCallout { @@ -33,13 +37,37 @@ @Override protected void execute(CalloutInfo info) throws ServletException { try { + OBContext.setAdminMode(true); ------------------------------------------------------------------------------ _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits