details:   https://code.openbravo.com/erp/devel/main/rev/415240d522f2
changeset: 13693:415240d522f2
user:      Mikel Irurita <mikel.irurita <at> openbravo.com>
date:      Tue Sep 20 13:33:32 2011 +0200
summary:   Fixes issue 18546: Posting financial invoice - Process Failed during 
execution

details:   https://code.openbravo.com/erp/devel/main/rev/d411c230fb19
changeset: 13694:d411c230fb19
user:      Mikel Irurita <mikel.irurita <at> openbravo.com>
date:      Tue Sep 20 19:50:12 2011 +0200
summary:   Related to issue 18546: improve message to InvalidAccount

details:   https://code.openbravo.com/erp/devel/main/rev/adb7ef6043dc
changeset: 13695:adb7ef6043dc
user:      Jon Alegría <jon.alegria <at> openbravo.com>
date:      Fri Sep 16 13:33:17 2011 +0200
summary:   Fixes issue 0018540: Amortizations can not be posted

diffstat:

 src/org/openbravo/erpCommon/ad_forms/AcctServer.java      |   5 +-
 src/org/openbravo/erpCommon/ad_forms/DocInvoice.java      |  27 ++++++++------
 src/org/openbravo/erpCommon/ad_forms/DocInvoice_data.xsql |  21 +++++++---
 3 files changed, 33 insertions(+), 20 deletions(-)

diffs (91 lines):

diff -r 53b25752950c -r adb7ef6043dc 
src/org/openbravo/erpCommon/ad_forms/AcctServer.java
--- a/src/org/openbravo/erpCommon/ad_forms/AcctServer.java      Mon Sep 26 
15:23:44 2011 +0000
+++ b/src/org/openbravo/erpCommon/ad_forms/AcctServer.java      Fri Sep 16 
13:33:17 2011 +0200
@@ -939,9 +939,10 @@
       if (GL_Category_ID != null && GL_Category_ID.equals("")) {
         AcctServerData[] data = 
AcctServerData.selectGLCategory(connectionProvider, AD_Client_ID,
             DocumentType);
-        if (data != null && data.length != 0)
+        if (data != null && data.length != 0) {
           GL_Category_ID = data[0].glCategoryId;
-         IsReversal = data[0].isreversal;
+          IsReversal = data[0].isreversal;
+        }
       }
       if (DocumentType != null && DocumentType.equals(""))
         log4j.warn("AcctServer - loadDocumentType - No DocType for GL Info");
diff -r 53b25752950c -r adb7ef6043dc 
src/org/openbravo/erpCommon/ad_forms/DocInvoice.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocInvoice.java      Mon Sep 26 
15:23:44 2011 +0000
+++ b/src/org/openbravo/erpCommon/ad_forms/DocInvoice.java      Fri Sep 16 
13:33:17 2011 +0200
@@ -757,21 +757,26 @@
       setStatus(STATUS_DocumentDisabled);
       return false;
     }
-    try {
-      data = DocInvoiceData.selectFinInvCount(conn, strRecordId);
-      if (data.length > 0) {
-        if (Integer.parseInt(data[0].fininvcount) == 0)
-          return true;
-        else if (Integer.parseInt(data[0].fininvcount) == 
Integer.parseInt(data[0].finacctcount))
-          return true;
-        else {
-          setStatus(STATUS_Error);
+    
+    AcctSchema acct = null;
+    for (int i = 0; i < m_as.length; i++) {
+      acct = m_as[i];
+      try {
+        data = DocInvoiceData.selectFinInvCount(conn, strRecordId, 
acct.m_C_AcctSchema_ID);
+        int countFinInv = Integer.parseInt(data[0].fininvcount);
+        int countGLItemAcct = Integer.parseInt(data[0].finacctcount);
+        // For any GL Item used in financial invoice lines debit/credit 
accounts must be defined
+        if (countFinInv != 0 && (countFinInv != countGLItemAcct)) {
+          log4jDocInvoice.debug("DocInvoice - getDocumentConfirmation - GL 
Item used in financial "
+              + "invoice lines debit/credit accounts must be defined.");
+          setStatus(STATUS_InvalidAccount);
           return false;
         }
+      } catch (ServletException e) {
+        log4jDocInvoice.error("Exception in getDocumentConfirmation method: " 
+ e);
       }
-    } catch (ServletException e) {
-      log4jDocInvoice.error("Exception in getDocumentConfirmation method: " + 
e);
     }
+    
     return true;
   }
 
diff -r 53b25752950c -r adb7ef6043dc 
src/org/openbravo/erpCommon/ad_forms/DocInvoice_data.xsql
--- a/src/org/openbravo/erpCommon/ad_forms/DocInvoice_data.xsql Mon Sep 26 
15:23:44 2011 +0000
+++ b/src/org/openbravo/erpCommon/ad_forms/DocInvoice_data.xsql Fri Sep 16 
13:33:17 2011 +0200
@@ -159,16 +159,23 @@
     <SqlMethodComment></SqlMethodComment>
     <Sql>
       <![CDATA[
-        SELECT (SELECT COUNT(*) FROM C_INVOICELINE WHERE 
FINANCIAL_INVOICE_LINE='Y'
-        AND C_INVOICE_ID=?) AS FININVCOUNT, 
-        (SELECT COUNT(*) FROM C_INVOICELINE invln LEFT JOIN C_GLITEM_ACCT 
glact ON 
-        invln.ACCOUNT_ID = glact.C_GLITEM_ID WHERE 
invln.FINANCIAL_INVOICE_LINE='Y' AND 
-        invln.C_INVOICE_ID=? AND 
-        glact.GLITEM_DEBIT_ACCT IS NOT NULL AND 
-        glact.GLITEM_CREDIT_ACCT IS NOT NULL) AS FINACCTCOUNT FROM DUAL
+        SELECT (SELECT count(distinct account_id)
+                FROM c_invoiceline
+                WHERE financial_invoice_line='Y'
+                      AND c_invoice_id = ?) AS FININVCOUNT,
+               (SELECT count(distinct glact.c_glitem_id)
+                FROM c_invoiceline invline JOIN c_glitem_acct glact ON 
(invline.account_id = glact.c_glitem_id)
+                     JOIN c_acctschema acctschema on (glact.c_acctschema_id = 
acctschema.c_acctschema_id)
+                WHERE invline.financial_invoice_line = 'Y' AND
+                      invline.c_invoice_id = ? AND
+                      acctschema.c_acctschema_id = ? AND
+                      glact.glitem_debit_acct IS NOT NULL AND 
+                      glact.glitem_credit_acct IS NOT NULL) AS FINACCTCOUNT
+        FROM DUAL
      ]]>
      </Sql>
      <Parameter name="invoiceId"/>
      <Parameter name="invoiceId"/>
+     <Parameter name="acctschemaId"/>
    </SqlMethod>
 </SqlClass>

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to