Fixes bug 25979: Impossible to post a reconciliation
authorEduardo Argal Guibert <eduardo.argal@openbravo.com>
Mon, 14 Apr 2014 13:32:27 +0200
changeset 22911 d80d8cd8e39b
parent 22910 c41ba68ffe38
child 22912 f61bf8d6176d
Fixes bug 25979: Impossible to post a reconciliation
src/org/openbravo/erpCommon/utility/CashVATUtil.java
--- a/src/org/openbravo/erpCommon/utility/CashVATUtil.java	Mon Apr 14 09:28:56 2014 +0200
+++ b/src/org/openbravo/erpCommon/utility/CashVATUtil.java	Mon Apr 14 13:32:27 2014 +0200
@@ -359,24 +359,25 @@
         final TaxRate tax = itcv.getInvoiceTax().getTax();
         if (tax.isCashVAT()) {
           final BigDecimal taxAmt = itcv.getTaxAmount();
-          final DocTax m_tax = new DocTax(tax.getId(), tax.getName(), tax.getRate().toString(),
-              itcv.getInvoiceTax().getTaxableAmount().toString(), itcv.getTaxAmount().toString(),
-              tax.isNotTaxdeductable(), tax.isTaxdeductable());
-          final String invoicedocumentType = invoice.getDocumentType().getDocumentCategory();
-          final boolean isReversal = invoice.getDocumentType().isReversal();
-          // ARI, ARF, ARI_RM
-          if (invoicedocumentType.equals(AcctServer.DOCTYPE_ARInvoice)
-              || invoicedocumentType.equals(AcctServer.DOCTYPE_ARProForma)
-              || invoicedocumentType.equals(AcctServer.DOCTYPE_RMSalesInvoice)) {
-            if (isReversal) {
-              final FactLine factLine1 = fact.createLine(line,
-                  m_tax.getAccount(DocTax.ACCTTYPE_TaxDue_Trans, as, conn), cCurrencyID, "",
-                  taxAmt.toString(), Fact_Acct_Group_ID, nextSeqNo(SeqNo), documentType, conn);
-              factLine2 = fact.createLine(line, m_tax.getAccount(DocTax.ACCTTYPE_TaxDue, as, conn),
-                  cCurrencyID, taxAmt.toString(), "", Fact_Acct_Group_ID,
-                  nextSeqNo(factLine1.m_SeqNo), documentType, conn);
-            } else {
-              if (taxAmt.compareTo(BigDecimal.ZERO) != 0) {
+          if (taxAmt.compareTo(BigDecimal.ZERO) != 0) {
+            final DocTax m_tax = new DocTax(tax.getId(), tax.getName(), tax.getRate().toString(),
+                itcv.getInvoiceTax().getTaxableAmount().toString(), itcv.getTaxAmount().toString(),
+                tax.isNotTaxdeductable(), tax.isTaxdeductable());
+            final String invoicedocumentType = invoice.getDocumentType().getDocumentCategory();
+            final boolean isReversal = invoice.getDocumentType().isReversal();
+            // ARI, ARF, ARI_RM
+            if (invoicedocumentType.equals(AcctServer.DOCTYPE_ARInvoice)
+                || invoicedocumentType.equals(AcctServer.DOCTYPE_ARProForma)
+                || invoicedocumentType.equals(AcctServer.DOCTYPE_RMSalesInvoice)) {
+              if (isReversal) {
+                final FactLine factLine1 = fact.createLine(line,
+                    m_tax.getAccount(DocTax.ACCTTYPE_TaxDue_Trans, as, conn), cCurrencyID, "",
+                    taxAmt.toString(), Fact_Acct_Group_ID, nextSeqNo(SeqNo), documentType, conn);
+                factLine2 = fact.createLine(line,
+                    m_tax.getAccount(DocTax.ACCTTYPE_TaxDue, as, conn), cCurrencyID,
+                    taxAmt.toString(), "", Fact_Acct_Group_ID, nextSeqNo(factLine1.m_SeqNo),
+                    documentType, conn);
+              } else {
                 final FactLine factLine1 = fact
                     .createLine(line, m_tax.getAccount(DocTax.ACCTTYPE_TaxDue_Trans, as, conn),
                         cCurrencyID, taxAmt.toString(), "", Fact_Acct_Group_ID, nextSeqNo(SeqNo),
@@ -386,19 +387,38 @@
                     taxAmt.toString(), Fact_Acct_Group_ID, nextSeqNo(factLine1.m_SeqNo),
                     documentType, conn);
               }
+            }// ARC
+            else if (invoicedocumentType.equals(AcctServer.DOCTYPE_ARCredit)) {
+              final FactLine factLine1 = fact.createLine(line,
+                  m_tax.getAccount(DocTax.ACCTTYPE_TaxDue_Trans, as, conn), cCurrencyID, "",
+                  taxAmt.toString(), Fact_Acct_Group_ID, nextSeqNo(SeqNo), documentType, conn);
+              factLine2 = fact.createLine(line, m_tax.getAccount(DocTax.ACCTTYPE_TaxDue, as, conn),
+                  cCurrencyID, taxAmt.toString(), "", Fact_Acct_Group_ID,
+                  nextSeqNo(factLine1.m_SeqNo), documentType, conn);
             }
-          }// ARC
-          else if (invoicedocumentType.equals(AcctServer.DOCTYPE_ARCredit)) {
-            final FactLine factLine1 = fact.createLine(line,
-                m_tax.getAccount(DocTax.ACCTTYPE_TaxDue_Trans, as, conn), cCurrencyID, "",
-                taxAmt.toString(), Fact_Acct_Group_ID, nextSeqNo(SeqNo), documentType, conn);
-            factLine2 = fact.createLine(line, m_tax.getAccount(DocTax.ACCTTYPE_TaxDue, as, conn),
-                cCurrencyID, taxAmt.toString(), "", Fact_Acct_Group_ID,
-                nextSeqNo(factLine1.m_SeqNo), documentType, conn);
-          }
-          // API
-          else if (invoicedocumentType.equals(AcctServer.DOCTYPE_APInvoice)) {
-            if (isReversal) {
+            // API
+            else if (invoicedocumentType.equals(AcctServer.DOCTYPE_APInvoice)) {
+              if (isReversal) {
+                final FactLine factLine1 = fact
+                    .createLine(line, m_tax.getAccount(DocTax.ACCTTYPE_TaxCredit_Trans, as, conn),
+                        cCurrencyID, taxAmt.toString(), "", Fact_Acct_Group_ID, nextSeqNo(SeqNo),
+                        documentType, conn);
+                factLine2 = fact.createLine(line,
+                    m_tax.getAccount(DocTax.ACCTTYPE_TaxCredit, as, conn), cCurrencyID, "",
+                    taxAmt.toString(), Fact_Acct_Group_ID, nextSeqNo(factLine1.m_SeqNo),
+                    documentType, conn);
+              } else {
+                final FactLine factLine1 = fact.createLine(line,
+                    m_tax.getAccount(DocTax.ACCTTYPE_TaxCredit_Trans, as, conn), cCurrencyID, "",
+                    taxAmt.toString(), Fact_Acct_Group_ID, nextSeqNo(SeqNo), documentType, conn);
+                factLine2 = fact.createLine(line,
+                    m_tax.getAccount(DocTax.ACCTTYPE_TaxCredit, as, conn), cCurrencyID,
+                    taxAmt.toString(), "", Fact_Acct_Group_ID, nextSeqNo(factLine1.m_SeqNo),
+                    documentType, conn);
+              }
+            }
+            // APC
+            else if (invoicedocumentType.equals(AcctServer.DOCTYPE_APCredit)) {
               final FactLine factLine1 = fact.createLine(line,
                   m_tax.getAccount(DocTax.ACCTTYPE_TaxCredit_Trans, as, conn), cCurrencyID,
                   taxAmt.toString(), "", Fact_Acct_Group_ID, nextSeqNo(SeqNo), documentType, conn);
@@ -406,26 +426,8 @@
                   m_tax.getAccount(DocTax.ACCTTYPE_TaxCredit, as, conn), cCurrencyID, "",
                   taxAmt.toString(), Fact_Acct_Group_ID, nextSeqNo(factLine1.m_SeqNo),
                   documentType, conn);
-            } else {
-              final FactLine factLine1 = fact.createLine(line,
-                  m_tax.getAccount(DocTax.ACCTTYPE_TaxCredit_Trans, as, conn), cCurrencyID, "",
-                  taxAmt.toString(), Fact_Acct_Group_ID, nextSeqNo(SeqNo), documentType, conn);
-              factLine2 = fact.createLine(line,
-                  m_tax.getAccount(DocTax.ACCTTYPE_TaxCredit, as, conn), cCurrencyID,
-                  taxAmt.toString(), "", Fact_Acct_Group_ID, nextSeqNo(factLine1.m_SeqNo),
-                  documentType, conn);
             }
           }
-          // APC
-          else if (invoicedocumentType.equals(AcctServer.DOCTYPE_APCredit)) {
-            final FactLine factLine1 = fact.createLine(line,
-                m_tax.getAccount(DocTax.ACCTTYPE_TaxCredit_Trans, as, conn), cCurrencyID,
-                taxAmt.toString(), "", Fact_Acct_Group_ID, nextSeqNo(SeqNo), documentType, conn);
-            factLine2 = fact.createLine(line,
-                m_tax.getAccount(DocTax.ACCTTYPE_TaxCredit, as, conn), cCurrencyID, "",
-                taxAmt.toString(), Fact_Acct_Group_ID, nextSeqNo(factLine1.m_SeqNo), documentType,
-                conn);
-          }
         }
       }
       if (factLine2 != null) {