Attached Files | aprm_15785 [^] (19,346 bytes) 2011-01-28 01:16 [Show Content] [Hide Content]# HG changeset patch
# Parent 0d47d0acf43eb41de618b5aba07e8c104a28e59d
Fixes issue 15785: Filter payment methods by payment in/out flags when populating combos
diff --git a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/AddPaymentFromInvoice.java b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/AddPaymentFromInvoice.java
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/AddPaymentFromInvoice.java
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/AddPaymentFromInvoice.java
@@ -104,25 +104,30 @@
String strFinancialAccountId = vars.getRequestGlobalVariable("inpFinancialAccount", "");
String strPaymentMethodId = vars.getRequestGlobalVariable("inpPaymentMethod", "");
String strOrgId = vars.getRequestGlobalVariable("inpadOrgId", "");
- refreshPaymentMethodCombo(response, strPaymentMethodId, strFinancialAccountId, strOrgId);
+ boolean isReceipt = vars.getRequiredStringParameter("isReceipt").equals("Y");
+ refreshPaymentMethodCombo(response, strPaymentMethodId, strFinancialAccountId, strOrgId, isReceipt);
} else if (vars.commandIn("FINANCIALACCOUNT")) {
String strFinancialAccountId = vars.getRequestGlobalVariable("inpFinancialAccount", "");
String strPaymentMethodId = vars.getRequiredStringParameter("inpPaymentMethod");
String strOrgId = vars.getRequestGlobalVariable("inpadOrgId", "");
String strCurrencyId = vars.getRequestGlobalVariable("inpCurrencyId", "");
+ boolean isReceipt = vars.getRequiredStringParameter("isReceipt").equals("Y");
refreshFinancialAccountCombo(response, strPaymentMethodId, strFinancialAccountId, strOrgId,
- strCurrencyId);
+ strCurrencyId, isReceipt);
} else if (vars.commandIn("FILLFINANCIALACCOUNT")) {
String strFinancialAccountId = vars.getRequestGlobalVariable("inpFinancialAccount", "");
String strOrgId = vars.getRequestGlobalVariable("inpadOrgId", "");
String strCurrencyId = vars.getRequestGlobalVariable("inpCurrencyId", "");
- refreshFinancialAccountCombo(response, "", strFinancialAccountId, strOrgId, strCurrencyId);
+ boolean isReceipt = vars.getRequiredStringParameter("isReceipt").equals("Y");
+ refreshFinancialAccountCombo(response, "", strFinancialAccountId, strOrgId, strCurrencyId,
+ isReceipt);
} else if (vars.commandIn("FILLPAYMENTMETHOD")) {
String strPaymentMethodId = vars.getRequiredStringParameter("inpPaymentMethod");
String strOrgId = vars.getRequestGlobalVariable("inpadOrgId", "");
- refreshPaymentMethodCombo(response, strPaymentMethodId, "", strOrgId);
+ boolean isReceipt = vars.getRequiredStringParameter("isReceipt").equals("Y");
+ refreshPaymentMethodCombo(response, strPaymentMethodId, "", strOrgId, isReceipt);
} else if (vars.commandIn("SAVE")) {
String strAction = vars.getRequiredStringParameter("inpActionDocument");
@@ -282,12 +287,12 @@
// Payment Method combobox
String paymentMethodComboHtml = FIN_Utility.getPaymentMethodList(strPaymentMethodId, "",
- strOrgId, true, true);
+ strOrgId, true, true, isReceipt);
xmlDocument.setParameter("sectionDetailPaymentMethod", paymentMethodComboHtml);
// Financial Account combobox
String finAccountComboHtml = FIN_Utility.getFinancialAccountList(strPaymentMethodId,
- strFinancialAccountId, strOrgId, true, strCurrencyId);
+ strFinancialAccountId, strOrgId, true, strCurrencyId, isReceipt);
xmlDocument.setParameter("sectionDetailFinancialAccount", finAccountComboHtml);
// Currency
@@ -376,11 +381,12 @@
}
private void refreshPaymentMethodCombo(HttpServletResponse response, String srtPaymentMethod,
- String strFinancialAccountId, String strOrgId) throws IOException, ServletException {
+ String strFinancialAccountId, String strOrgId, boolean isReceipt)
+ throws IOException, ServletException {
log4j.debug("Callout: Financial Account has changed to" + strFinancialAccountId);
String paymentMethodComboHtml = FIN_Utility.getPaymentMethodList(srtPaymentMethod,
- strFinancialAccountId, strOrgId, true, true);
+ strFinancialAccountId, strOrgId, true, true, isReceipt);
response.setContentType("text/html; charset=UTF-8");
PrintWriter out = response.getWriter();
@@ -390,12 +396,13 @@
}
private void refreshFinancialAccountCombo(HttpServletResponse response,
- String strPaymentMethodId, String strFinancialAccountId, String strOrgId, String strCurrencyId)
+ String strPaymentMethodId, String strFinancialAccountId, String strOrgId,
+ String strCurrencyId, boolean isReceipt)
throws IOException, ServletException {
log4j.debug("Callout: Payment Method has changed to " + strPaymentMethodId);
String finAccountComboHtml = FIN_Utility.getFinancialAccountList(strPaymentMethodId,
- strFinancialAccountId, strOrgId, true, strCurrencyId);
+ strFinancialAccountId, strOrgId, true, strCurrencyId, isReceipt);
response.setContentType("text/html; charset=UTF-8");
PrintWriter out = response.getWriter();
diff --git a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/AddPaymentFromTransaction.java b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/AddPaymentFromTransaction.java
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/AddPaymentFromTransaction.java
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/AddPaymentFromTransaction.java
@@ -96,7 +96,8 @@
final String strBusinessPartnerId = vars.getRequestGlobalVariable("inpcBpartnerId", "");
final String strFinancialAccountId = vars.getRequiredStringParameter("inpFinancialAccountId",
IsIDFilter.instance);
- refreshPaymentMethod(response, strBusinessPartnerId, strFinancialAccountId);
+ boolean isReceipt = vars.getRequiredStringParameter("isReceipt").equals("Y");
+ refreshPaymentMethod(response, strBusinessPartnerId, strFinancialAccountId, isReceipt);
} else if (vars.commandIn("LOADCREDIT")) {
final String strBusinessPartnerId = vars.getRequiredStringParameter("inpcBpartnerId");
@@ -294,7 +295,7 @@
// Payment Method combobox
String paymentMethodComboHtml = FIN_Utility.getPaymentMethodList(defaultPaymentMethod,
- strFinancialAccountId, financialAccount.getOrganization().getId(), true, true);
+ strFinancialAccountId, financialAccount.getOrganization().getId(), true, true, isReceipt);
xmlDocument.setParameter("sectionDetailPaymentMethod", paymentMethodComboHtml);
xmlDocument.setParameter("dateDisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
@@ -360,7 +361,7 @@
}
private void refreshPaymentMethod(HttpServletResponse response, String strBusinessPartnerId,
- String strFinancialAccountId) throws IOException, ServletException {
+ String strFinancialAccountId, boolean isReceipt) throws IOException, ServletException {
log4j.debug("Callout: Business Partner has changed to" + strBusinessPartnerId);
String paymentMethodComboHtml = "";
@@ -370,7 +371,7 @@
BusinessPartner bp = OBDal.getInstance().get(BusinessPartner.class, strBusinessPartnerId);
paymentMethodComboHtml = FIN_Utility.getPaymentMethodList(
(bp.getPaymentMethod() != null) ? bp.getPaymentMethod().getId() : null,
- strFinancialAccountId, account.getOrganization().getId(), true, true);
+ strFinancialAccountId, account.getOrganization().getId(), true, true, isReceipt);
}
response.setContentType("text/html; charset=UTF-8");
diff --git a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_forms/BatchPaymentExecution.java b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_forms/BatchPaymentExecution.java
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_forms/BatchPaymentExecution.java
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_forms/BatchPaymentExecution.java
@@ -110,15 +110,19 @@
} else if (vars.commandIn("CALLOUTPAYMENTMETHOD")) {
String strPaymentMethodId = vars.getRequestGlobalVariable("inpPaymentMethod", "");
String strOrgId = vars.getRequestGlobalVariable("inpOrgId", "");
- reloadPaymentMethodCombo(response, strPaymentMethodId, "", strOrgId);
+ boolean isReceipt = "Y".equals(vars.getGlobalVariable("inpIsReceipt",
+ "BatchPaymentExecution|IsReceipt", ""));
+ reloadPaymentMethodCombo(response, strPaymentMethodId, "", strOrgId, isReceipt);
} else if (vars.commandIn("CALLOUTFINANCIALACCOUNT")) {
String strFinancialAccountId = vars.getRequestGlobalVariable("inpFinancialAccount", "");
String strPaymentMethodId = vars.getRequiredStringParameter("inpPaymentMethod");
String strOrgId = vars.getRequestGlobalVariable("inpOrgId", "");
String strCurrencyId = vars.getRequestGlobalVariable("inpCurrencyId", "");
+ boolean isReceipt = "Y".equals(vars.getGlobalVariable("inpIsReceipt",
+ "BatchPaymentExecution|IsReceipt", ""));
reloadFinancialAccountCombo(response, strPaymentMethodId, strFinancialAccountId, strOrgId,
- strCurrencyId);
+ strCurrencyId, isReceipt );
} else
pageError(response);
@@ -188,14 +192,15 @@
xmlDocument.setParameter("grid_Default", "0");
// Payment Method combobox
+ final boolean isReceipt = "Y".equals(strIsReceipt);
String paymentMethodComboHtml = FIN_Utility.getPaymentMethodList(strPaymentMethodId, "",
- newOrg, true, true);
+ newOrg, true, true, isReceipt);
xmlDocument.setParameter("sectionDetailPaymentMethod", paymentMethodComboHtml);
// Financial Account combobox
// Currency - not filtered
String finAccountComboHtml = FIN_Utility.getFinancialAccountList(strPaymentMethodId,
- strFinancialAccountId, newOrg, true, "");
+ strFinancialAccountId, newOrg, true, "", isReceipt);
xmlDocument.setParameter("sectionDetailFinancialAccount", finAccountComboHtml);
OBError myMessage = vars.getMessage(adFormId);
@@ -436,11 +441,12 @@
}
private void reloadPaymentMethodCombo(HttpServletResponse response, String srtPaymentMethod,
- String strFinancialAccountId, String strOrgId) throws IOException, ServletException {
+ String strFinancialAccountId, String strOrgId, boolean isReceipt)
+ throws IOException, ServletException {
log4j.debug("Callout: Financial Account has changed to");
String paymentMethodComboHtml = FIN_Utility.getPaymentMethodList(srtPaymentMethod,
- strFinancialAccountId, strOrgId, true, true);
+ strFinancialAccountId, strOrgId, true, true, isReceipt);
response.setContentType("text/html; charset=UTF-8");
PrintWriter out = response.getWriter();
@@ -450,12 +456,12 @@
}
private void reloadFinancialAccountCombo(HttpServletResponse response, String strPaymentMethodId,
- String strFinancialAccountId, String strOrgId, String strCurrencyId) throws IOException,
+ String strFinancialAccountId, String strOrgId, String strCurrencyId, boolean isReceipt) throws IOException,
ServletException {
log4j.debug("Callout: Payment Method has changed to " + strPaymentMethodId);
String finAccountComboHtml = FIN_Utility.getFinancialAccountList(strPaymentMethodId,
- strFinancialAccountId, strOrgId, true, strCurrencyId);
+ strFinancialAccountId, strOrgId, true, strCurrencyId, isReceipt);
response.setContentType("text/html; charset=UTF-8");
PrintWriter out = response.getWriter();
diff --git a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/dao/AdvPaymentMngtDao.java b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/dao/AdvPaymentMngtDao.java
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/dao/AdvPaymentMngtDao.java
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/dao/AdvPaymentMngtDao.java
@@ -875,7 +875,7 @@
}
public List<FIN_PaymentMethod> getFilteredPaymentMethods(String strFinancialAccountId,
- String strOrgId, boolean excludePaymentMethodWithoutAccount) {
+ String strOrgId, boolean excludePaymentMethodWithoutAccount, boolean isInPayment) {
final OBCriteria<FIN_PaymentMethod> obc = OBDal.getInstance().createCriteria(
FIN_PaymentMethod.class);
obc.add(Expression.in("organization.id", OBContext.getOBContext()
@@ -886,7 +886,12 @@
if (strFinancialAccountId != null && !strFinancialAccountId.isEmpty()) {
for (FinAccPaymentMethod finAccPayMethod : getObject(FIN_FinancialAccount.class,
strFinancialAccountId).getFinancialMgmtFinAccPaymentMethodList()) {
- payMethods.add(finAccPayMethod.getPaymentMethod().getId());
+ if( isInPayment && finAccPayMethod.isPayinAllow() ) {
+ payMethods.add(finAccPayMethod.getPaymentMethod().getId());
+ } else if (!isInPayment && finAccPayMethod.isPayoutAllow() ) {
+ payMethods.add(finAccPayMethod.getPaymentMethod().getId());
+ }
+ // else not valid for this type of payment
}
if (payMethods.isEmpty()) {
return (new ArrayList<FIN_PaymentMethod>());
@@ -909,13 +914,18 @@
}
obc.add(Expression.in("id", payMethods));
}
+ if(isInPayment) {
+ obc.add(Expression.eq(FIN_PaymentMethod.PROPERTY_PAYINALLOW, true));
+ } else {
+ obc.add(Expression.eq(FIN_PaymentMethod.PROPERTY_PAYINALLOW, true));
+ }
}
return obc.list();
}
public List<FIN_FinancialAccount> getFilteredFinancialAccounts(String strPaymentMethodId,
- String strOrgId, String strCurrencyId) {
+ String strOrgId, String strCurrencyId, boolean isInPayment) {
final OBCriteria<FIN_FinancialAccount> obc = OBDal.getInstance().createCriteria(
FIN_FinancialAccount.class);
obc.add(Expression.in("organization.id", OBContext.getOBContext()
@@ -931,7 +941,12 @@
if (strPaymentMethodId != null && !strPaymentMethodId.isEmpty()) {
for (FinAccPaymentMethod finAccPayMethod : getObject(FIN_PaymentMethod.class,
strPaymentMethodId).getFinancialMgmtFinAccPaymentMethodList()) {
- finAccs.add(finAccPayMethod.getAccount().getId());
+ if( isInPayment && finAccPayMethod.isPayinAllow() ) {
+ finAccs.add(finAccPayMethod.getAccount().getId());
+ } else if (!isInPayment && finAccPayMethod.isPayoutAllow() ) {
+ finAccs.add(finAccPayMethod.getAccount().getId());
+ }
+ // else not valid for this type of payment
}
if (finAccs.isEmpty()) {
return (new ArrayList<FIN_FinancialAccount>());
diff --git a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_Utility.java b/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
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_Utility.java
@@ -361,14 +361,18 @@
* if the strPaymentMethodId is empty or null then depending on this parameter the list
* will include payment methods with no Financial Accounts associated or only show the
* Payment Methods that belongs to at least on Financial Account
+ * @param isInPayment
+ * specifies the type of payment to get payment methods for. If true, will return
+ * payment methods with Payment In enabled, if false will return payment methods with
+ * Payment Out enabled.
* @return a String with the html code with the options to fill the drop-down of Payment Methods.
*/
public static String getPaymentMethodList(String strPaymentMethodId,
String strFinancialAccountId, String strOrgId, boolean isMandatory,
- boolean excludePaymentMethodWithoutAccount) {
+ boolean excludePaymentMethodWithoutAccount, boolean isInPayment) {
dao = new AdvPaymentMngtDao();
List<FIN_PaymentMethod> paymentMethods = dao.getFilteredPaymentMethods(strFinancialAccountId,
- strOrgId, excludePaymentMethodWithoutAccount);
+ strOrgId, excludePaymentMethodWithoutAccount, isInPayment);
String options = getOptionsList(paymentMethods, strPaymentMethodId, isMandatory);
return options;
}
@@ -387,13 +391,18 @@
* the Organization id the record belongs to.
* @param strCurrencyId
* optional Currency id to filter the Financial Accounts.
+ * @param isInPayment
+ * specifies the type of payment to that is being made. If true, will return
+ * accounts with payment methods that have Payment In enabled, if false will return accounts
+ * with payment methods that have Payment Out enabled.
* @return a String with the html code with the options to fill the drop-down of Financial
* Accounts.
*/
public static String getFinancialAccountList(String strPaymentMethodId,
- String strFinancialAccountId, String strOrgId, boolean isMandatory, String strCurrencyId) {
+ String strFinancialAccountId, String strOrgId, boolean isMandatory, String strCurrencyId,
+ boolean isInPayment) {
List<FIN_FinancialAccount> financialAccounts = dao.getFilteredFinancialAccounts(
- strPaymentMethodId, strOrgId, strCurrencyId);
+ strPaymentMethodId, strOrgId, strCurrencyId, isInPayment);
String options = getOptionsList(financialAccounts, strFinancialAccountId, isMandatory);
return options;
}
diff --git a/src/org/openbravo/erpCommon/ad_callouts/SE_PaymentMethod_FinAccount.java b/src/org/openbravo/erpCommon/ad_callouts/SE_PaymentMethod_FinAccount.java
--- a/src/org/openbravo/erpCommon/ad_callouts/SE_PaymentMethod_FinAccount.java
+++ b/src/org/openbravo/erpCommon/ad_callouts/SE_PaymentMethod_FinAccount.java
@@ -43,6 +43,8 @@
String tabId = info.getTabId();
boolean isVendorTab = "224".equals(tabId);
+ String finIsReceipt= info.getStringParameter("inpfinIsreceipt",null );
+ boolean isPaymentOut=isVendorTab || "N".equals(finIsReceipt);
String srtOrgId = info.getStringParameter("inpadOrgId", IsIDFilter.instance);
FIN_PaymentMethod paymentMethod = OBDal.getInstance().get(FIN_PaymentMethod.class,
@@ -71,6 +73,11 @@
obc.add(Expression.eq(FinAccPaymentMethod.PROPERTY_PAYMENTMETHOD, paymentMethod));
obc.add(Expression.in("organization.id", OBContext.getOBContext()
.getOrganizationStructureProvider().getNaturalTree(srtOrgId)));
+ if(isPaymentOut) {
+ obc.add(Expression.eq(FinAccPaymentMethod.PROPERTY_PAYOUTALLOW, true));
+ } else {
+ obc.add(Expression.eq(FinAccPaymentMethod.PROPERTY_PAYINALLOW, true));
+ }
for (FinAccPaymentMethod accPm : obc.list()) {
if (srtSelectedFinancialAccount.equals(accPm.getAccount().getId())) {
|