Related to bug 27580 Wrong journal entries when you void a purchase invoice
authorSandra Huguet <sandra.huguet@openbravo.com>
Mon, 15 Dec 2014 11:16:59 +0100
changeset 25591 798bebfeabb6
parent 25590 fa79e561d3c6
child 25592 e565273a954e
Related to bug 27580 Wrong journal entries when you void a purchase invoice
src-db/database/sourcedata/AD_FIELD.xml
src/org/openbravo/erpCommon/ad_forms/DocInvoice.java
--- a/src-db/database/sourcedata/AD_FIELD.xml	Fri Dec 12 09:23:03 2014 -0500
+++ b/src-db/database/sourcedata/AD_FIELD.xml	Mon Dec 15 11:16:59 2014 +0100
@@ -224244,6 +224244,32 @@
 <!--6841B874AC264D47A6677C6D9CBE7731-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--6841B874AC264D47A6677C6D9CBE7731--></AD_FIELD>
 
+<!--6843062540404D50810D45927D4C7E8F--><AD_FIELD>
+<!--6843062540404D50810D45927D4C7E8F-->  <AD_FIELD_ID><![CDATA[6843062540404D50810D45927D4C7E8F]]></AD_FIELD_ID>
+<!--6843062540404D50810D45927D4C7E8F-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--6843062540404D50810D45927D4C7E8F-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--6843062540404D50810D45927D4C7E8F-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--6843062540404D50810D45927D4C7E8F-->  <NAME><![CDATA[Prepayment Amount]]></NAME>
+<!--6843062540404D50810D45927D4C7E8F-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--6843062540404D50810D45927D4C7E8F-->  <AD_TAB_ID><![CDATA[290]]></AD_TAB_ID>
+<!--6843062540404D50810D45927D4C7E8F-->  <AD_COLUMN_ID><![CDATA[44E4C65BE1494A04AA7205582FA1A64D]]></AD_COLUMN_ID>
+<!--6843062540404D50810D45927D4C7E8F-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
+<!--6843062540404D50810D45927D4C7E8F-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--6843062540404D50810D45927D4C7E8F-->  <DISPLAYLENGTH><![CDATA[22]]></DISPLAYLENGTH>
+<!--6843062540404D50810D45927D4C7E8F-->  <ISREADONLY><![CDATA[Y]]></ISREADONLY>
+<!--6843062540404D50810D45927D4C7E8F-->  <SEQNO><![CDATA[2070]]></SEQNO>
+<!--6843062540404D50810D45927D4C7E8F-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--6843062540404D50810D45927D4C7E8F-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--6843062540404D50810D45927D4C7E8F-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--6843062540404D50810D45927D4C7E8F-->  <SHOWINRELATION><![CDATA[N]]></SHOWINRELATION>
+<!--6843062540404D50810D45927D4C7E8F-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--6843062540404D50810D45927D4C7E8F-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--6843062540404D50810D45927D4C7E8F-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--6843062540404D50810D45927D4C7E8F-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--6843062540404D50810D45927D4C7E8F-->  <ISSHOWNINSTATUSBAR><![CDATA[Y]]></ISSHOWNINSTATUSBAR>
+<!--6843062540404D50810D45927D4C7E8F-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--6843062540404D50810D45927D4C7E8F--></AD_FIELD>
+
 <!--6848AF012E134703B88D3A802292B2E3--><AD_FIELD>
 <!--6848AF012E134703B88D3A802292B2E3-->  <AD_FIELD_ID><![CDATA[6848AF012E134703B88D3A802292B2E3]]></AD_FIELD_ID>
 <!--6848AF012E134703B88D3A802292B2E3-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src/org/openbravo/erpCommon/ad_forms/DocInvoice.java	Fri Dec 12 09:23:03 2014 -0500
+++ b/src/org/openbravo/erpCommon/ad_forms/DocInvoice.java	Mon Dec 15 11:16:59 2014 +0100
@@ -365,9 +365,15 @@
       if ((m_payments == null || m_payments.length == 0)
           && (m_debt_payments == null || m_debt_payments.length == 0)) {
         if (!prepaymentamt.equals("0")) {
-          fact.createLine(null, getAccountBPartner(C_BPartner_ID, as, true, true, conn),
-              this.C_Currency_ID, prepaymentamt, "", Fact_Acct_Group_ID, nextSeqNo(SeqNo),
-              DocumentType, conn);
+          if (IsReturn.equals("Y")) {
+            fact.createLine(null, getAccountBPartner(C_BPartner_ID, as, true, true, conn),
+                this.C_Currency_ID, "", prepaymentamt, Fact_Acct_Group_ID, nextSeqNo(SeqNo),
+                DocumentType, conn);
+          } else {
+            fact.createLine(null, getAccountBPartner(C_BPartner_ID, as, true, true, conn),
+                this.C_Currency_ID, prepaymentamt, "", Fact_Acct_Group_ID, nextSeqNo(SeqNo),
+                DocumentType, conn);
+          }
         } else {
           fact.createLine(null, getAccountBPartner(C_BPartner_ID, as, true, false, conn),
               this.C_Currency_ID, Amounts[AMTTYPE_Gross], "", Fact_Acct_Group_ID, nextSeqNo(SeqNo),
@@ -672,9 +678,22 @@
         }
       if ((m_payments == null || m_payments.length == 0)
           && (m_debt_payments == null || m_debt_payments.length == 0)) {
-        fact.createLine(null, getAccountBPartner(C_BPartner_ID, as, false, false, conn),
-            this.C_Currency_ID, "", Amounts[AMTTYPE_Gross], Fact_Acct_Group_ID, nextSeqNo(SeqNo),
-            DocumentType, conn);
+        if (!prepaymentamt.equals("0")) {
+          if (IsReturn.equals("Y")) {
+            fact.createLine(null, getAccountBPartner(C_BPartner_ID, as, false, true, conn),
+                this.C_Currency_ID, prepaymentamt, "", Fact_Acct_Group_ID, nextSeqNo(SeqNo),
+                DocumentType, conn);
+          } else {
+            fact.createLine(null, getAccountBPartner(C_BPartner_ID, as, false, true, conn),
+                this.C_Currency_ID, "", prepaymentamt, Fact_Acct_Group_ID, nextSeqNo(SeqNo),
+                DocumentType, conn);
+          }
+        } else {
+          fact.createLine(null, getAccountBPartner(C_BPartner_ID, as, false, false, conn),
+              this.C_Currency_ID, "", Amounts[AMTTYPE_Gross], Fact_Acct_Group_ID, nextSeqNo(SeqNo),
+              DocumentType, conn);
+        }
+
       }
       // Charge DR
       fact.createLine(null, getAccount(AcctServer.ACCTTYPE_Charge, as, conn), this.C_Currency_ID,