details: https://code.openbravo.com/erp/devel/main/rev/0a2625ff68a7 changeset: 27530:0a2625ff68a7 user: Atul Gaware <atul.gaware <at> openbravo.com> date: Thu Sep 03 15:00:55 2015 +0530 summary: Fixes Issue 30736:Delivery method is not populated from Business Partner in Goods Shipment
Callout on Business Partner in Goods Shipment is modified to set Delivery Method, Delivery Terms from business partner if exist other than default values details: https://code.openbravo.com/erp/devel/main/rev/5f4c2906f294 changeset: 27531:5f4c2906f294 user: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com> date: Fri Sep 04 10:26:47 2015 +0200 summary: Related to issue 30641: Reload payment method only if it is active Reload payment method when changing business partner in the selector only if business partner default payment method is active for the current financial account. Also ReceivedFromPaymentMethodActionHandler performance has been improved. details: https://code.openbravo.com/erp/devel/main/rev/1d78ee2328c6 changeset: 27532:1d78ee2328c6 user: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com> date: Wed Sep 02 19:55:07 2015 +0200 summary: Fixes issue 30712: Payment Method not filled in Add Payment Payment Method was not filled when running Add Payment and business partner has no default Financial Account. When calling from getDefaultPaymentMethod to getFinancialAccountPaymentMethod in AddPaymentDefaultValuesHandler class with a null financialAccountId (in case of opening Add Payment from windows without Financial Account information like Purchase/Sales Order/Invoice and Business Partner does not have a default Financial Account setted), a NPE was raised and Payment Method was not filled in Add Payment. Now, in Purchase/Sales Order/Invoice windows, where is no financial account information in the context, document payment method will be taken if it is active for any financial account, if not, business partner default payment method will be taken instead (if it is active for any financial account and document organization has access to it). In those windows, Financial Account selector will show Business Partner default account if selected Payment Method belongs to it, or any Financial Account which Payment Method belongs to instead. In case of opening Add Payment from Payment In/Out windows, where exists Financial Account information in the context, Payment Method and Financial Account will be taken from the document. details: https://code.openbravo.com/erp/devel/main/rev/ddf0351fd69a changeset: 27533:ddf0351fd69a user: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com> date: Tue Sep 01 15:08:49 2015 +0200 summary: Fixes issue 30719: Deposit To in Add Payment does not filter correctly Deposit To in Add Payment should only show financial accounts where selected payment method is active. details: https://code.openbravo.com/erp/devel/main/rev/dc8f878ff592 changeset: 27534:dc8f878ff592 user: RM packaging bot <staff.rm <at> openbravo.com> date: Fri Sep 04 13:44:36 2015 +0000 summary: CI: merge back from main details: https://code.openbravo.com/erp/devel/main/rev/fcdcb8232dfb changeset: 27535:fcdcb8232dfb user: Víctor Martínez Romanos <victor.martinez <at> openbravo.com> date: Thu Sep 03 17:13:57 2015 +0200 summary: Fixed bug 30685 Fixed bug 30686 Fixed bug 30751: Several Payment Proposal issues This changeset includes the fixes for several issues related to the Payment Proposal flow: # 30685: Error when reactivating payment proposal related with a closed order Cause: The payment schedule detail was deleted as part of the reactivation process, however DAL wasn't aware of it: when trying to delete the associated payment proposal line, DAL tried first to set proposal line's PSD to null, creating a database constraint violation in the flush. # 30686: It is not possible to process payment related with a closed order and generated from payment proposal window. Cause: The payment detail associated to the closed order remained in the system and it couldn't be deleted neither manually nor automatically because it was linked to the payment proposal line # 30751: Lines deleted each time you reactivate a payment proposal Cause: The code in charge of deleting the payment proposal lines was deleting only the lines linked to the last set of processed payment schedule details, instead of doing for all of them. This code worked fine when the payment was reactivated from the Payment window, but not when it was called from the Payment Proposal window, wrongly removing payment proposal lines. The solution for all these issues is the following: 1. The payment proposal is set to processed=N before calling the payment process. This avoids the need of running flushes in the payment process to unprocess and process the payment proposal. That fixes the flush issues and increases the general performance of the process. 2. The code in charge of deleting the linked payment proposal lines is executed: 2.1 when a PSD is deleted because the amount is 0 (for example in the scenario where we close the order), or 2.2 when we are reactivating a payment (deleting lines only) and we don't come from payment proposal reactivation process. Now when calling the payment process from the Payment proposal, we pass a new parameter comingFrom to the payment process. 2.3 In Add Payment, when we are removing a line (for example while reactivating a payment deleting the lines) details: https://code.openbravo.com/erp/devel/main/rev/f3ddf66cdf4b changeset: 27536:f3ddf66cdf4b user: RM packaging bot <staff.rm <at> openbravo.com> date: Mon Sep 07 19:01:05 2015 +0000 summary: CI: update AD_MODULE to version 27535 diffstat: modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MODULE.xml | 2 +- modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml | 4 +- modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUISEL_SELECTOR.xml | 2 +- modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentActionHandler.java | 2 + modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/ReceivedFromPaymentMethodActionHandler.java | 49 ++-- modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDefaultValuesHandler.java | 112 +++++++-- modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java | 67 ++++- modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProposalProcess.java | 9 +- modules/org.openbravo.apachejdbcconnectionpool/src-db/database/sourcedata/AD_MODULE.xml | 2 +- modules/org.openbravo.apachejdbcconnectionpool/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml | 2 +- modules/org.openbravo.base.weld/src-db/database/sourcedata/AD_MODULE.xml | 2 +- modules/org.openbravo.base.weld/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml | 2 +- modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MODULE.xml | 2 +- modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml | 8 +- modules/org.openbravo.client.htmlwidget/src-db/database/sourcedata/AD_MODULE.xml | 2 +- modules/org.openbravo.client.htmlwidget/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml | 2 +- modules/org.openbravo.client.kernel/src-db/database/sourcedata/AD_MODULE.xml | 2 +- modules/org.openbravo.client.kernel/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml | 6 +- modules/org.openbravo.client.myob/src-db/database/sourcedata/AD_MODULE.xml | 2 +- modules/org.openbravo.client.myob/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml | 4 +- modules/org.openbravo.client.querylist/src-db/database/sourcedata/AD_MODULE.xml | 2 +- modules/org.openbravo.client.querylist/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml | 2 +- modules/org.openbravo.client.widgets/src-db/database/sourcedata/AD_MODULE.xml | 2 +- modules/org.openbravo.client.widgets/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml | 2 +- modules/org.openbravo.financial.paymentreport/src-db/database/sourcedata/AD_MODULE.xml | 2 +- modules/org.openbravo.financial.paymentreport/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml | 2 +- modules/org.openbravo.reports.ordersawaitingdelivery/src-db/database/sourcedata/AD_MODULE.xml | 2 +- modules/org.openbravo.reports.ordersawaitingdelivery/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml | 2 +- modules/org.openbravo.service.datasource/src-db/database/sourcedata/AD_MODULE.xml | 2 +- modules/org.openbravo.service.datasource/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml | 10 +- modules/org.openbravo.service.integration.google/src-db/database/sourcedata/AD_MODULE.xml | 2 +- modules/org.openbravo.service.integration.google/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml | 4 +- modules/org.openbravo.service.integration.openid/src-db/database/sourcedata/AD_MODULE.xml | 2 +- modules/org.openbravo.service.integration.openid/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml | 2 +- modules/org.openbravo.service.json/src-db/database/sourcedata/AD_MODULE.xml | 2 +- modules/org.openbravo.service.json/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml | 2 +- modules/org.openbravo.userinterface.selector/src-db/database/sourcedata/AD_MODULE.xml | 2 +- modules/org.openbravo.userinterface.selector/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml | 12 +- modules/org.openbravo.userinterface.skin.250to300Comp/src-db/database/sourcedata/AD_MODULE.xml | 2 +- modules/org.openbravo.userinterface.skin.250to300Comp/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml | 2 +- modules/org.openbravo.userinterface.smartclient/src-db/database/sourcedata/AD_MODULE.xml | 2 +- modules/org.openbravo.userinterface.smartclient/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml | 6 +- modules/org.openbravo.utility.cleanup.log/src-db/database/sourcedata/AD_MODULE.xml | 2 +- modules/org.openbravo.utility.cleanup.log/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml | 2 +- modules/org.openbravo.v3.datasets/src-db/database/sourcedata/AD_MODULE.xml | 2 +- modules/org.openbravo.v3.datasets/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml | 6 +- modules/org.openbravo.v3.framework/src-db/database/sourcedata/AD_MODULE.xml | 2 +- modules/org.openbravo.v3.framework/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml | 24 +- modules/org.openbravo.v3/src-db/database/sourcedata/AD_MODULE.xml | 2 +- modules/org.openbravo.v3/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml | 22 +- src-db/database/sourcedata/AD_MODULE.xml | 4 +- src/org/openbravo/erpCommon/ad_callouts/SL_InOut_BPartner.java | 23 +- 52 files changed, 270 insertions(+), 170 deletions(-) diffs (truncated from 1398 to 300 lines): diff -r d824566905ac -r f3ddf66cdf4b modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MODULE.xml --- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MODULE.xml Tue Sep 01 11:09:05 2015 +0200 +++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MODULE.xml Mon Sep 07 19:01:05 2015 +0000 @@ -6,7 +6,7 @@ <!--A918E3331C404B889D69AA9BFAFB23AC--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID> <!--A918E3331C404B889D69AA9BFAFB23AC--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> <!--A918E3331C404B889D69AA9BFAFB23AC--> <NAME><![CDATA[Advanced Payables and Receivables Mngmt]]></NAME> -<!--A918E3331C404B889D69AA9BFAFB23AC--> <VERSION><![CDATA[3.0.27515]]></VERSION> +<!--A918E3331C404B889D69AA9BFAFB23AC--> <VERSION><![CDATA[3.0.27535]]></VERSION> <!--A918E3331C404B889D69AA9BFAFB23AC--> <DESCRIPTION><![CDATA[Managing your finances with an ERP does not have to be difficult. Enjoy a radically improved user experience that combines the power of an enterprise grade financial application with the simplicity and ease of a web 2.0 personal accounting service.]]></DESCRIPTION> <!--A918E3331C404B889D69AA9BFAFB23AC--> <HELP><![CDATA[Advanced Payables and Receivables Management simplifies and automates the business processes around the management of financial accounts, from the receipt and issue of payment, to the reconciliation of those events with bank statements. If you would like to help shape this module you are welcome to take part in the forum discussions or register feature requests or issues in the corresponding (Forum and Bug Tracking) sections in the Advanced Payables and Receivable project in the OB Forge.]]></HELP> diff -r d824566905ac -r f3ddf66cdf4b modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml --- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml Tue Sep 01 11:09:05 2015 +0200 +++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml Mon Sep 07 19:01:05 2015 +0000 @@ -7,7 +7,7 @@ <!--89326AE95DAD449D85DFAB2C5B1C6683--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> <!--89326AE95DAD449D85DFAB2C5B1C6683--> <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID> <!--89326AE95DAD449D85DFAB2C5B1C6683--> <AD_DEPENDENT_MODULE_ID><![CDATA[5EB4F15C80684ACA904756BDC12ADBE5]]></AD_DEPENDENT_MODULE_ID> -<!--89326AE95DAD449D85DFAB2C5B1C6683--> <STARTVERSION><![CDATA[2.1.27515]]></STARTVERSION> +<!--89326AE95DAD449D85DFAB2C5B1C6683--> <STARTVERSION><![CDATA[2.1.27535]]></STARTVERSION> <!--89326AE95DAD449D85DFAB2C5B1C6683--> <ISINCLUDED><![CDATA[N]]></ISINCLUDED> <!--89326AE95DAD449D85DFAB2C5B1C6683--> <DEPENDANT_MODULE_NAME><![CDATA[User Interface Selector]]></DEPENDANT_MODULE_NAME> <!--89326AE95DAD449D85DFAB2C5B1C6683--> <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT> @@ -21,7 +21,7 @@ <!--B97FC854C6DD41E692161585645A900F--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> <!--B97FC854C6DD41E692161585645A900F--> <AD_MODULE_ID><![CDATA[A918E3331C404B889D69AA9BFAFB23AC]]></AD_MODULE_ID> <!--B97FC854C6DD41E692161585645A900F--> <AD_DEPENDENT_MODULE_ID><![CDATA[0]]></AD_DEPENDENT_MODULE_ID> -<!--B97FC854C6DD41E692161585645A900F--> <STARTVERSION><![CDATA[3.0.27515]]></STARTVERSION> +<!--B97FC854C6DD41E692161585645A900F--> <STARTVERSION><![CDATA[3.0.27535]]></STARTVERSION> <!--B97FC854C6DD41E692161585645A900F--> <ISINCLUDED><![CDATA[N]]></ISINCLUDED> <!--B97FC854C6DD41E692161585645A900F--> <DEPENDANT_MODULE_NAME><![CDATA[core]]></DEPENDANT_MODULE_NAME> <!--B97FC854C6DD41E692161585645A900F--> <DEPENDENCY_ENFORCEMENT><![CDATA[MAJOR]]></DEPENDENCY_ENFORCEMENT> diff -r d824566905ac -r f3ddf66cdf4b modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUISEL_SELECTOR.xml --- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUISEL_SELECTOR.xml Tue Sep 01 11:09:05 2015 +0200 +++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUISEL_SELECTOR.xml Mon Sep 07 19:01:05 2015 +0000 @@ -55,7 +55,7 @@ <!--5D29D4DFCF4440B8BF89420419A0DBFE--> <NAME><![CDATA[Financial Account]]></NAME> <!--5D29D4DFCF4440B8BF89420419A0DBFE--> <AD_REFERENCE_ID><![CDATA[7F1A079A842545DF966D7EFD4BC5CFCE]]></AD_REFERENCE_ID> <!--5D29D4DFCF4440B8BF89420419A0DBFE--> <AD_TABLE_ID><![CDATA[B129E53BC0E747879F7BA17F0AECEC32]]></AD_TABLE_ID> -<!--5D29D4DFCF4440B8BF89420419A0DBFE--> <WHERECLAUSE><![CDATA[@fin_paymentmethod_id@ is null or exists (select 1 from FinancialMgmtFinAccPaymentMethod fpm join fpm.account as fa where fpm.paymentMethod.id = @fin_paymentmethod_id@ and fa = e and (case when @issotrx@ = 'true' then fpm.payinAllow else fpm.payoutAllow end) = true and (@c_currency_id@ = fa.currency.id or (case when @issotrx@ = 'true' then fpm.payinIsMulticurrency else fpm.payoutIsMulticurrency end) = true))]]></WHERECLAUSE> +<!--5D29D4DFCF4440B8BF89420419A0DBFE--> <WHERECLAUSE><![CDATA[@fin_paymentmethod_id@ is null or exists (select 1 from FinancialMgmtFinAccPaymentMethod fpm join fpm.account as fa where fpm.paymentMethod.id = @fin_paymentmethod_id@ and fa = e and (case when @issotrx@ = 'true' then fpm.payinAllow else fpm.payoutAllow end) = true and (@c_currency_id@ = fa.currency.id or (case when @issotrx@ = 'true' then fpm.payinIsMulticurrency else fpm.payoutIsMulticurrency end) = true) and fpm.active = true)]]></WHERECLAUSE> <!--5D29D4DFCF4440B8BF89420419A0DBFE--> <OBCLKER_TEMPLATE_ID><![CDATA[9314DE8599AD44E7BFC4CC50699042AB]]></OBCLKER_TEMPLATE_ID> <!--5D29D4DFCF4440B8BF89420419A0DBFE--> <ISACTIVE><![CDATA[Y]]></ISACTIVE> <!--5D29D4DFCF4440B8BF89420419A0DBFE--> <SUGGESTIONTEXTMATCHSTYLE><![CDATA[startsWith]]></SUGGESTIONTEXTMATCHSTYLE> diff -r d824566905ac -r f3ddf66cdf4b modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentActionHandler.java --- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentActionHandler.java Tue Sep 01 11:09:05 2015 +0200 +++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentActionHandler.java Mon Sep 07 19:01:05 2015 +0000 @@ -509,6 +509,8 @@ } } + FIN_PaymentProcess.removePaymentProposalLines(psd); + pd.getFINPaymentScheduleDetailList().remove(psd); OBDal.getInstance().save(pd); OBDal.getInstance().remove(psd); diff -r d824566905ac -r f3ddf66cdf4b modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/ReceivedFromPaymentMethodActionHandler.java --- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/ReceivedFromPaymentMethodActionHandler.java Tue Sep 01 11:09:05 2015 +0200 +++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/ReceivedFromPaymentMethodActionHandler.java Mon Sep 07 19:01:05 2015 +0000 @@ -21,10 +21,11 @@ import java.util.Map; -import org.apache.commons.lang.StringUtils; import org.codehaus.jettison.json.JSONObject; +import org.hibernate.criterion.Restrictions; import org.openbravo.base.exception.OBException; import org.openbravo.client.kernel.BaseActionHandler; +import org.openbravo.dal.service.OBCriteria; import org.openbravo.dal.service.OBDal; import org.openbravo.model.common.businesspartner.BusinessPartner; import org.openbravo.model.financialmgmt.payment.FIN_FinancialAccount; @@ -40,9 +41,9 @@ JSONObject result = new JSONObject(); FIN_FinancialAccount financialAccount = OBDal.getInstance().get(FIN_FinancialAccount.class, jsonData.getString("financialAccount")); - boolean contains = false; - String paymentMethod = null; - String paymentMethodName = null; + FIN_PaymentMethod paymentMethod = null; + String paymentMethodId = ""; + String paymentMethodName = ""; if (financialAccount != null) { if (jsonData.has("receivedFrom") && jsonData.get("receivedFrom") != JSONObject.NULL) { @@ -50,35 +51,31 @@ BusinessPartner businessPartner = OBDal.getInstance().get(BusinessPartner.class, receivedFrom); if (jsonData.getString("isSOTrx").toString().equals("true")) { - paymentMethod = businessPartner.getPaymentMethod() != null ? businessPartner - .getPaymentMethod().getId() : ""; + paymentMethod = businessPartner.getPaymentMethod(); } else { - paymentMethod = businessPartner.getPOPaymentMethod() != null ? businessPartner - .getPOPaymentMethod().getId() : ""; + paymentMethod = businessPartner.getPOPaymentMethod(); } - for (FinAccPaymentMethod finAccPaymentMethod : financialAccount - .getFinancialMgmtFinAccPaymentMethodList()) { - if (StringUtils.equals(finAccPaymentMethod.getPaymentMethod().getId(), paymentMethod)) { - contains = true; - break; - } else { - contains = false; + + if (paymentMethod != null) { + OBCriteria<FinAccPaymentMethod> criteria = OBDal.getInstance().createCriteria( + FinAccPaymentMethod.class); + criteria.add(Restrictions.eq(FinAccPaymentMethod.PROPERTY_ACCOUNT, financialAccount)); + criteria + .add(Restrictions.eq(FinAccPaymentMethod.PROPERTY_PAYMENTMETHOD, paymentMethod)); + criteria.setFilterOnReadableOrganization(false); + criteria.setFilterOnActive(true); + criteria.setMaxResults(1); + FinAccPaymentMethod finAccPaymentMethod = (FinAccPaymentMethod) criteria.uniqueResult(); + + if (finAccPaymentMethod != null) { + paymentMethodId = finAccPaymentMethod.getPaymentMethod().getId(); + paymentMethodName = finAccPaymentMethod.getPaymentMethod().getName(); } } } - } else { - contains = false; } - if (!contains) { - paymentMethod = ""; - paymentMethodName = ""; - } else { - paymentMethodName = OBDal.getInstance().get(FIN_PaymentMethod.class, paymentMethod) - .getName(); - } - - result.put("paymentMethodId", paymentMethod); + result.put("paymentMethodId", paymentMethodId); result.put("paymentMethodName", paymentMethodName); return result; } catch (Exception e) { diff -r d824566905ac -r f3ddf66cdf4b modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDefaultValuesHandler.java --- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDefaultValuesHandler.java Tue Sep 01 11:09:05 2015 +0200 +++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDefaultValuesHandler.java Mon Sep 07 19:01:05 2015 +0000 @@ -282,32 +282,64 @@ && StringUtils.isNotEmpty(context.getString("Fin_Financial_Account_ID"))) { return context.getString("Fin_Financial_Account_ID"); } - String strBPartnerId = getDefaultReceivedFrom(requestMap); - if (StringUtils.isNotEmpty(strBPartnerId)) { - BusinessPartner businessPartner = OBDal.getInstance().get(BusinessPartner.class, - strBPartnerId); - boolean isSOTrx = "Y".equals(getDefaultIsSOTrx(requestMap)); - if (context.has("inpadClientId") && context.has("inpadOrgId")) { - final OrganizationStructureProvider osp = OBContext.getOBContext() - .getOrganizationStructureProvider(context.getString("inpadClientId")); - if (isSOTrx && businessPartner.getAccount() != null) { - if (osp.isInNaturalTree(businessPartner.getAccount().getOrganization(), OBDal - .getInstance().get(Organization.class, context.getString("inpadOrgId")))) { - return businessPartner.getAccount().getId(); - } else { - return ""; - } + String paymentMethodId = getDefaultPaymentMethod(requestMap); + if (StringUtils.isNotEmpty(paymentMethodId) && context.has("inpadClientId") + && context.has("inpadOrgId")) { - } else if (!isSOTrx && businessPartner.getPOFinancialAccount() != null) { - if (osp.isInNaturalTree(businessPartner.getPOFinancialAccount().getOrganization(), OBDal - .getInstance().get(Organization.class, context.getString("inpadOrgId")))) { - return businessPartner.getPOFinancialAccount().getId(); - } else { - return ""; - } + final OrganizationStructureProvider osp = OBContext.getOBContext() + .getOrganizationStructureProvider(context.getString("inpadClientId")); + 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.getAccount() != null + && getFinancialAccountPaymentMethod(paymentMethodId, businessPartner.getAccount() + .getId()) != null + && osp.isInNaturalTree(businessPartner.getAccount().getOrganization(), OBDal + .getInstance().get(Organization.class, context.getString("inpadOrgId")))) { + return businessPartner.getAccount().getId(); + } + + else if (!isSOTrx + && businessPartner.getPOFinancialAccount() != null + && getFinancialAccountPaymentMethod(paymentMethodId, businessPartner + .getPOFinancialAccount().getId()) != null + && osp.isInNaturalTree(businessPartner.getPOFinancialAccount().getOrganization(), OBDal + .getInstance().get(Organization.class, context.getString("inpadOrgId")))) { + return businessPartner.getPOFinancialAccount().getId(); } } + + FinAccPaymentMethod fpm = getFinancialAccountPaymentMethod(paymentMethodId, null); + if (fpm != null + && osp.isInNaturalTree(fpm.getAccount().getOrganization(), + OBDal.getInstance().get(Organization.class, context.getString("inpadOrgId")))) { + return fpm.getAccount().getId(); + } + } + + return null; + } + + private String getContextFinancialAccount(Map<String, String> requestMap) throws JSONException { + String strContext = requestMap.get("context"); + if (strContext == null) { + return null; + } + JSONObject context = new JSONObject(strContext); + if (context.has("inpfinFinancialAccountId") + && context.get("inpfinFinancialAccountId") != JSONObject.NULL + && StringUtils.isNotEmpty(context.getString("inpfinFinancialAccountId"))) { + return context.getString("inpfinFinancialAccountId"); + } else if (context.has("Fin_Financial_Account_ID") + && context.get("Fin_Financial_Account_ID") != JSONObject.NULL + && StringUtils.isNotEmpty(context.getString("Fin_Financial_Account_ID"))) { + return context.getString("Fin_Financial_Account_ID"); } return null; } @@ -331,26 +363,38 @@ && StringUtils.isNotEmpty(context.getString("inpfinPaymentmethodId"))) { strFinPaymentMethodId = context.getString("inpfinPaymentmethodId"); } - strFinancialAccountId = getDefaultFinancialAccount(requestMap); - if (strFinPaymentMethodId != null && strFinancialAccountId != null) { - if (getFinancialAccountPaymentMethod(strFinPaymentMethodId, strFinancialAccountId) != null) { - return strFinPaymentMethodId; - } + + strFinancialAccountId = getContextFinancialAccount(requestMap); + if (strFinPaymentMethodId != null + && getFinancialAccountPaymentMethod(strFinPaymentMethodId, strFinancialAccountId) != null) { + return strFinPaymentMethodId; } + String strBPartnerId = getDefaultReceivedFrom(requestMap); - if (StringUtils.isNotEmpty(strBPartnerId)) { + if (StringUtils.isNotEmpty(strBPartnerId) && context.has("inpadClientId") + && context.has("inpadOrgId")) { + + final OrganizationStructureProvider osp = OBContext.getOBContext() + .getOrganizationStructureProvider(context.getString("inpadClientId")); BusinessPartner businessPartner = OBDal.getInstance().get(BusinessPartner.class, strBPartnerId); boolean isSOTrx = "Y".equals(getDefaultIsSOTrx(requestMap)); + if (isSOTrx && businessPartner.getPaymentMethod() != null && getFinancialAccountPaymentMethod(businessPartner.getPaymentMethod().getId(), - strFinancialAccountId) != null) { + strFinancialAccountId) != null + && osp.isInNaturalTree(businessPartner.getPaymentMethod().getOrganization(), OBDal + .getInstance().get(Organization.class, context.getString("inpadOrgId")))) { return businessPartner.getPaymentMethod().getId(); - } else if (!isSOTrx + } + + else if (!isSOTrx && businessPartner.getPOPaymentMethod() != null && getFinancialAccountPaymentMethod(businessPartner.getPOPaymentMethod().getId(), - strFinancialAccountId) != null) { + strFinancialAccountId) != null + && osp.isInNaturalTree(businessPartner.getPOPaymentMethod().getOrganization(), OBDal + .getInstance().get(Organization.class, context.getString("inpadOrgId")))) { return businessPartner.getPOPaymentMethod().getId(); } } @@ -428,8 +472,10 @@ FinAccPaymentMethod.class); obc.setFilterOnReadableOrganization(false); obc.setMaxResults(1); - obc.add(Restrictions.eq(FinAccPaymentMethod.PROPERTY_ACCOUNT, - OBDal.getInstance().get(FIN_FinancialAccount.class, financialAccountId))); + if (!StringUtils.isEmpty(financialAccountId)) { + 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 d824566905ac -r f3ddf66cdf4b modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java --- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java Tue Sep 01 11:09:05 2015 +0200 +++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java Mon Sep 07 19:01:05 2015 +0000 @@ -29,6 +29,7 @@ import java.util.Set; import java.util.TreeSet; +import org.apache.commons.lang.StringUtils; import org.hibernate.criterion.Restrictions; ------------------------------------------------------------------------------ _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits