details: https://code.openbravo.com/erp/devel/pi/rev/41e10f964f97 changeset: 26216:41e10f964f97 user: Unai Martirena <unai.martirena <at> openbravo.com> date: Mon Mar 16 17:07:49 2015 +0100 summary: Fixes bug 29252: Payment method in add payment does not display inactive values
The whereClause of fin_payment_method combo in add payment has been changed to not display never payment methods that are inactive. Also the default values of Add Payment window that are opened from all windows has been changed to not set as default a Payment Method that is inactive, even if it is marked as default in the financial account or if is the default payment method of the Business Partner. A change has also been done in OB.APRM.AddPayment.paymentMethodMulticurrency javascript function. In Add Payment window, while clearing Payment Method combo manually, the Financial Account was also being cleared. This was causing a problem when opening from Financial Account, because in this case novalues were displayed on both combos any more. It has been fixed to not to clear the Financial Account combo in this case as always is going to be the same, so it is no necessary to clear it. details: https://code.openbravo.com/erp/devel/pi/rev/df7e81f69e35 changeset: 26217:df7e81f69e35 user: Sandra Huguet <sandra.huguet <at> openbravo.com> date: Mon Mar 23 12:56:19 2015 +0100 summary: related to issue 29252 update Copyright diffstat: modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUISEL_SELECTOR.xml | 2 +- modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDefaultValuesHandler.java | 39 ++++++++- modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/TransactionAddPaymentDefaultValues.java | 16 ++- modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-addPayment.js | 7 +- 4 files changed, 49 insertions(+), 15 deletions(-) diffs (167 lines): diff -r 53a25921251d -r df7e81f69e35 modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUISEL_SELECTOR.xml --- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUISEL_SELECTOR.xml Mon Mar 23 12:52:19 2015 +0100 +++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUISEL_SELECTOR.xml Mon Mar 23 12:56:19 2015 +0100 @@ -186,7 +186,7 @@ <!--BA4FDCB15ACB47AD81BE3985E13032EE--> <NAME><![CDATA[Payment Method]]></NAME> <!--BA4FDCB15ACB47AD81BE3985E13032EE--> <AD_REFERENCE_ID><![CDATA[E664E415582A483DBBC91DEF256FB9E6]]></AD_REFERENCE_ID> <!--BA4FDCB15ACB47AD81BE3985E13032EE--> <AD_TABLE_ID><![CDATA[0B44DF7A2A854784BF34AD49C58647D7]]></AD_TABLE_ID> -<!--BA4FDCB15ACB47AD81BE3985E13032EE--> <WHERECLAUSE><![CDATA[exists (select 1 from FinancialMgmtFinAccPaymentMethod fpm where fpm.paymentMethod = e and (case when @issotrx@ = 'true' then fpm.payinAllow else fpm.payoutAllow end) = true and (fpm.account.id = @fin_financial_account_id@ or @inpwindowId@ <> '94EAA455D2644E04AB25D93BE5157B6D'))]]></WHERECLAUSE> +<!--BA4FDCB15ACB47AD81BE3985E13032EE--> <WHERECLAUSE><![CDATA[exists (select 1 from FinancialMgmtFinAccPaymentMethod fpm where fpm.paymentMethod = e and (case when @issotrx@ = 'true' then fpm.payinAllow else fpm.payoutAllow end) = true and (fpm.account.id = @fin_financial_account_id@ or @inpwindowId@ <> '94EAA455D2644E04AB25D93BE5157B6D') and fpm.active = true)]]></WHERECLAUSE> <!--BA4FDCB15ACB47AD81BE3985E13032EE--> <OBCLKER_TEMPLATE_ID><![CDATA[9314DE8599AD44E7BFC4CC50699042AB]]></OBCLKER_TEMPLATE_ID> <!--BA4FDCB15ACB47AD81BE3985E13032EE--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> <!--BA4FDCB15ACB47AD81BE3985E13032EE--> <SUGGESTIONTEXTMATCHSTYLE><![CDATA[substring]]></SUGGESTIONTEXTMATCHSTYLE> diff -r 53a25921251d -r df7e81f69e35 modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDefaultValuesHandler.java --- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDefaultValuesHandler.java Mon Mar 23 12:52:19 2015 +0100 +++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDefaultValuesHandler.java Mon Mar 23 12:56:19 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): ______________________________________. ************************************************************************ @@ -27,17 +27,21 @@ import org.apache.commons.lang.StringUtils; import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; +import org.hibernate.criterion.Restrictions; import org.openbravo.advpaymentmngt.dao.AdvPaymentMngtDao; import org.openbravo.advpaymentmngt.utility.FIN_Utility; import org.openbravo.dal.core.OBContext; import org.openbravo.dal.security.OrganizationStructureProvider; +import org.openbravo.dal.service.OBCriteria; import org.openbravo.dal.service.OBDal; import org.openbravo.model.common.businesspartner.BusinessPartner; import org.openbravo.model.common.enterprise.Organization; import org.openbravo.model.financialmgmt.payment.FIN_FinancialAccount; import org.openbravo.model.financialmgmt.payment.FIN_Payment; +import org.openbravo.model.financialmgmt.payment.FIN_PaymentMethod; import org.openbravo.model.financialmgmt.payment.FIN_PaymentSchedule; import org.openbravo.model.financialmgmt.payment.FIN_PaymentScheduleDetail; +import org.openbravo.model.financialmgmt.payment.FinAccPaymentMethod; @RequestScoped // Public class to allow extend the functionality, for example Add Payment popup opening from menu @@ -316,6 +320,8 @@ */ public String getDefaultPaymentMethod(Map<String, String> requestMap) throws JSONException { String strContext = requestMap.get("context"); + String strFinPaymentMethodId = null; + String strFinancialAccountId = null; if (strContext == null) { return ""; } @@ -323,16 +329,28 @@ if (context.has("inpfinPaymentmethodId") && context.get("inpfinPaymentmethodId") != JSONObject.NULL && StringUtils.isNotEmpty(context.getString("inpfinPaymentmethodId"))) { - return context.getString("inpfinPaymentmethodId"); + strFinPaymentMethodId = context.getString("inpfinPaymentmethodId"); + } + strFinancialAccountId = getDefaultFinancialAccount(requestMap); + if (strFinPaymentMethodId != null && strFinancialAccountId != null) { + if (getFinancialAccountPaymentMethod(strFinPaymentMethodId, strFinancialAccountId) != null) { + return strFinPaymentMethodId; + } } String strBPartnerId = getDefaultReceivedFrom(requestMap); if (StringUtils.isNotEmpty(strBPartnerId)) { BusinessPartner businessPartner = OBDal.getInstance().get(BusinessPartner.class, strBPartnerId); boolean isSOTrx = "Y".equals(getDefaultIsSOTrx(requestMap)); - if (isSOTrx && businessPartner.getPaymentMethod() != null) { + if (isSOTrx + && businessPartner.getPaymentMethod() != null + && getFinancialAccountPaymentMethod(businessPartner.getPaymentMethod().getId(), + strFinancialAccountId) != null) { return businessPartner.getPaymentMethod().getId(); - } else if (!isSOTrx && businessPartner.getPOPaymentMethod() != null) { + } else if (!isSOTrx + && businessPartner.getPOPaymentMethod() != null + && getFinancialAccountPaymentMethod(businessPartner.getPOPaymentMethod().getId(), + strFinancialAccountId) != null) { return businessPartner.getPOPaymentMethod().getId(); } } @@ -404,4 +422,17 @@ } } + private FinAccPaymentMethod getFinancialAccountPaymentMethod(String paymentMethodId, + String financialAccountId) { + OBCriteria<FinAccPaymentMethod> obc = OBDal.getInstance().createCriteria( + FinAccPaymentMethod.class); + obc.setFilterOnReadableOrganization(false); + obc.setMaxResults(1); + obc.add(Restrictions.eq(FinAccPaymentMethod.PROPERTY_ACCOUNT, + OBDal.getInstance().get(FIN_FinancialAccount.class, financialAccountId))); + obc.add(Restrictions.eq(FinAccPaymentMethod.PROPERTY_PAYMENTMETHOD, + OBDal.getInstance().get(FIN_PaymentMethod.class, paymentMethodId))); + return (FinAccPaymentMethod) obc.uniqueResult(); + } + } diff -r 53a25921251d -r df7e81f69e35 modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/TransactionAddPaymentDefaultValues.java --- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/TransactionAddPaymentDefaultValues.java Mon Mar 23 12:52:19 2015 +0100 +++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/TransactionAddPaymentDefaultValues.java Mon Mar 23 12:56:19 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): ______________________________________. ************************************************************************ @@ -170,16 +170,18 @@ FinAccPaymentMethod anyFinAccPaymentMethod = null; for (FinAccPaymentMethod finAccPaymentMethod : getFinancialAccount(requestMap) .getFinancialMgmtFinAccPaymentMethodList()) { - if (finAccPaymentMethod.isDefault()) { + if (finAccPaymentMethod.isActive()) { + if (finAccPaymentMethod.isDefault()) { + if ((isReceipt && finAccPaymentMethod.isPayinAllow()) + || (!isReceipt && finAccPaymentMethod.isPayoutAllow())) { + return finAccPaymentMethod.getPaymentMethod().getId(); + } + } if ((isReceipt && finAccPaymentMethod.isPayinAllow()) || (!isReceipt && finAccPaymentMethod.isPayoutAllow())) { - return finAccPaymentMethod.getPaymentMethod().getId(); + anyFinAccPaymentMethod = finAccPaymentMethod; } } - if ((isReceipt && finAccPaymentMethod.isPayinAllow()) - || (!isReceipt && finAccPaymentMethod.isPayoutAllow())) { - anyFinAccPaymentMethod = finAccPaymentMethod; - } } return anyFinAccPaymentMethod != null ? anyFinAccPaymentMethod.getPaymentMethod().getId() : ""; } diff -r 53a25921251d -r df7e81f69e35 modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-addPayment.js --- a/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-addPayment.js Mon Mar 23 12:52:19 2015 +0100 +++ b/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-addPayment.js Mon Mar 23 12:56:19 2015 +0100 @@ -161,7 +161,8 @@ isSOTrx = form.getItem('issotrx').getValue(), currencyId = form.getItem('c_currency_id').getValue(), paymentDate = form.getItem('payment_date').getValue(), - orgId = form.getItem('ad_org_id').getValue(); + orgId = form.getItem('ad_org_id').getValue(), + trxtype = (form.getItem('trxtype')) ? form.getItem('trxtype').getValue() : ""; callback = function (response, data, request) { var isShown = false; @@ -173,9 +174,9 @@ form.getItem('c_currency_id').valueMap[data.currencyId] = data.currencyIdIdentifier; } isShown = data.isPayIsMulticurrency && currencyId !== data.currencyToId && currencyId !== undefined; - if (data.isWrongFinancialAccount) { + if (data.isWrongFinancialAccount && trxtype === "") { form.getItem('fin_financial_account_id').setValue(''); - } else { + } else if (!data.isWrongFinancialAccount){ if (!form.getItem('c_currency_to_id').valueMap) { form.getItem('c_currency_to_id').valueMap = {}; } ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Openbravo-commits mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openbravo-commits
