details:   https://code.openbravo.com/erp/devel/pi/rev/49c0de1828a4
changeset: 13895:49c0de1828a4
user:      Mikel Irurita <mikel.irurita <at> openbravo.com>
date:      Fri Sep 30 12:03:19 2011 +0200
summary:   Fixes issue 18637: Improve message when trying to create invoice 
using automatic PM not available

diffstat:

 src-db/database/sourcedata/AD_MESSAGE.xml                        |   2 +-
 src/org/openbravo/erpCommon/ad_callouts/SE_Invoice_BPartner.java |  26 
++++++---
 2 files changed, 18 insertions(+), 10 deletions(-)

diffs (99 lines):

diff -r 29c7f8e120e0 -r 49c0de1828a4 src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/sourcedata/AD_MESSAGE.xml Fri Sep 30 11:48:16 2011 +0200
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml Fri Sep 30 12:03:19 2011 +0200
@@ -18084,7 +18084,7 @@
 <!--B506C3346CDB44EEB33592003DCA14B2-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--B506C3346CDB44EEB33592003DCA14B2-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--B506C3346CDB44EEB33592003DCA14B2-->  
<VALUE><![CDATA[PaymentmethodNotbelongsFinAccount]]></VALUE>
-<!--B506C3346CDB44EEB33592003DCA14B2-->  <MSGTEXT><![CDATA[Automatic actions 
could not be performed: selected payment method does not belong to the business 
partner default financial account.]]></MSGTEXT>
+<!--B506C3346CDB44EEB33592003DCA14B2-->  <MSGTEXT><![CDATA[Automatic actions 
could not be performed: selected payment method does not belong to the business 
partner default financial account or the default financial account is not 
accessible for the invoice's organization.]]></MSGTEXT>
 <!--B506C3346CDB44EEB33592003DCA14B2-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
 <!--B506C3346CDB44EEB33592003DCA14B2-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--B506C3346CDB44EEB33592003DCA14B2--></AD_MESSAGE>
diff -r 29c7f8e120e0 -r 49c0de1828a4 
src/org/openbravo/erpCommon/ad_callouts/SE_Invoice_BPartner.java
--- a/src/org/openbravo/erpCommon/ad_callouts/SE_Invoice_BPartner.java  Fri Sep 
30 11:48:16 2011 +0200
+++ b/src/org/openbravo/erpCommon/ad_callouts/SE_Invoice_BPartner.java  Fri Sep 
30 12:03:19 2011 +0200
@@ -68,13 +68,15 @@
       String strIsSOTrx = Utility.getContext(this, vars, "isSOTrx", 
strWindowId);
       String strTabId = vars.getStringParameter("inpTabId");
       String strfinPaymentmethodId = 
vars.getStringParameter("inpfinPaymentmethodId");
+      String strOrgId = vars.getStringParameter("inpadOrgId");
 
       try {
         if ("inpfinPaymentmethodId".equals(strChanged)) { // Payment Method 
changed
-          printPagePaymentMethod(response, vars, strBPartner, strIsSOTrx, 
strfinPaymentmethodId);
+          printPagePaymentMethod(response, vars, strBPartner, strIsSOTrx, 
strfinPaymentmethodId,
+              strOrgId);
         } else {
           printPage(response, vars, strBPartner, strDocType, strIsSOTrx, 
strWindowId, strLocation,
-              strContact, strProjectId, strTabId);
+              strContact, strProjectId, strTabId, strOrgId);
         }
       } catch (ServletException ex) {
         pageErrorCallOut(response);
@@ -85,7 +87,8 @@
 
   private void printPage(HttpServletResponse response, VariablesSecureApp 
vars, String strBPartner,
       String strDocType, String strIsSOTrx, String strWindowId, String 
strLocation,
-      String strContact, String strProjectId, String strTabId) throws 
IOException, ServletException {
+      String strContact, String strProjectId, String strTabId, String 
strOrgId) throws IOException,
+      ServletException {
     if (log4j.isDebugEnabled())
       log4j.debug("Output: dataSheet");
     XmlDocument xmlDocument = xmlEngine.readXmlTemplate(
@@ -243,7 +246,7 @@
           && strIsSOTrx.equals("Y")) {
         String creditLimitExceed = "" + 
Double.parseDouble(data[0].creditavailable) * -1;
         String automationPaymentMethod = isAutomaticCombination(vars, 
strBPartner, strIsSOTrx,
-            strFinPaymentMethodId);
+            strFinPaymentMethodId, strOrgId);
         resultado.append(", new Array('MESSAGE', \""
             + Utility.messageBD(this, "CreditLimitOver", vars.getLanguage()) + 
creditLimitExceed
             + "<br/>" + automationPaymentMethod + "\")");
@@ -261,13 +264,14 @@
   }
 
   private void printPagePaymentMethod(HttpServletResponse response, 
VariablesSecureApp vars,
-      String strBPartnerId, String strIsSOTrx, String strfinPaymentmethodId) 
throws IOException,
-      ServletException {
+      String strBPartnerId, String strIsSOTrx, String strfinPaymentmethodId, 
String strOrgId)
+      throws IOException, ServletException {
     XmlDocument xmlDocument = xmlEngine.readXmlTemplate(
         "org/openbravo/erpCommon/ad_callouts/CallOut").createXmlDocument();
     StringBuilder result = new StringBuilder();
 
-    String message = isAutomaticCombination(vars, strBPartnerId, strIsSOTrx, 
strfinPaymentmethodId);
+    String message = isAutomaticCombination(vars, strBPartnerId, strIsSOTrx, 
strfinPaymentmethodId,
+        strOrgId);
 
     result.append("var calloutName='SE_Invoice_BPartner';\n\n");
     result.append("var respuesta = new Array(new Array(\"MESSAGE\", ");
@@ -298,7 +302,7 @@
    *         financial account of the given business partner.
    */
   private String isAutomaticCombination(VariablesSecureApp vars, String 
strBPartnerId,
-      String strIsSOTrx, String strfinPaymentmethodId) {
+      String strIsSOTrx, String strfinPaymentmethodId, String strOrgId) {
     BusinessPartner bpartner = OBDal.getInstance().get(BusinessPartner.class, 
strBPartnerId);
     FIN_PaymentMethod selectedPaymentMethod = 
OBDal.getInstance().get(FIN_PaymentMethod.class,
         strfinPaymentmethodId);
@@ -308,14 +312,18 @@
       FIN_FinancialAccount account = null;
       String message = "";
 
-      if (bpartner != null && selectedPaymentMethod != null) {
+      if (bpartner != null && selectedPaymentMethod != null && 
!"".equals(strOrgId)) {
         account = (isSales) ? bpartner.getAccount() : 
bpartner.getPOFinancialAccount();
         if (account != null) {
           OBCriteria<FinAccPaymentMethod> obc = 
OBDal.getInstance().createCriteria(
               FinAccPaymentMethod.class);
+          obc.setFilterOnReadableOrganization(false);
           obc.add(Restrictions.eq(FinAccPaymentMethod.PROPERTY_ACCOUNT, 
account));
           obc.add(Restrictions
               .eq(FinAccPaymentMethod.PROPERTY_PAYMENTMETHOD, 
selectedPaymentMethod));
+          obc.add(Restrictions.in(FinAccPaymentMethod.PROPERTY_ORGANIZATION + 
".id", OBContext
+              
.getOBContext().getOrganizationStructureProvider().getNaturalTree(strOrgId)));
+
           if (obc.list() == null || obc.list().size() == 0) {
             message = Utility.messageBD(this, 
"PaymentmethodNotbelongsFinAccount",
                 vars.getLanguage());

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to