details:   /erp/devel/main/rev/bc42f5aa4e93
changeset: 8583:bc42f5aa4e93
user:      Sivaraman Rajagopal <sivaraman.rajagopal <at> openbravo.com>
date:      Tue Oct 19 18:09:39 2010 +0530
summary:   Fixes issue 14564: Writeoff accounting error in settlements

Root cause:
It can be found AcctServer.ACCTTYPE_WriteOffDefault account type that was used 
earlier in DocPayment.java. That's why it was always taking the write off line 
at accounting schema level.

Solution:
Simply changing the account type from ACCTTYPE_WriteOffDefault to 
ACCTTYPE_WriteOff in WRITEOFF calculation would not work as C_BPartner_ID in 
AcctServer is nowhere populated with value (Please note, C_BPartner_ID is used 
in AcctServer.getAccount method). Therefore, the code has been modified in 
order to directly create Account object rather than calling getAccount method. 
This will resolve the issue as per the expected behaviour without any impacts.

details:   /erp/devel/main/rev/505b7225d671
changeset: 8584:505b7225d671
user:      RM packaging bot <staff.rm <at> openbravo.com>
date:      Wed Oct 20 02:38:58 2010 +0000
summary:   CI: promote changesets from pi to main

diffstat:

 src-db/database/sourcedata/AD_MODULE.xml             |   4 +-
 src/org/openbravo/erpCommon/ad_forms/DocPayment.java |  30 +++++++++++++++++--
 2 files changed, 28 insertions(+), 6 deletions(-)

diffs (61 lines):

diff -r d60f21a50638 -r 505b7225d671 src-db/database/sourcedata/AD_MODULE.xml
--- a/src-db/database/sourcedata/AD_MODULE.xml  Tue Oct 19 09:24:18 2010 +0200
+++ b/src-db/database/sourcedata/AD_MODULE.xml  Wed Oct 20 02:38:58 2010 +0000
@@ -6,7 +6,7 @@
 <!--0-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--0-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--0-->  <NAME><![CDATA[Core]]></NAME>
-<!--0-->  <VERSION><![CDATA[2.50.18452]]></VERSION>
+<!--0-->  <VERSION><![CDATA[2.50.18583]]></VERSION>
 <!--0-->  <DESCRIPTION><![CDATA[Core module is the base one]]></DESCRIPTION>
 <!--0-->  <HELP><![CDATA[Core module is the base one, all developments in core 
are included as part of the standard Openbravo ERP.]]></HELP>
 <!--0-->  <URL><![CDATA[www.openbravo.com]]></URL>
@@ -22,7 +22,7 @@
 <!--0-->  <ISTRANSLATIONMODULE><![CDATA[N]]></ISTRANSLATIONMODULE>
 <!--0-->  <HASREFERENCEDATA><![CDATA[Y]]></HASREFERENCEDATA>
 <!--0-->  <REFERENCEDATAINFO><![CDATA[Standard document types for orders, 
invoices, etc. and settings]]></REFERENCEDATAINFO>
-<!--0-->  <VERSION_LABEL><![CDATA[dev]]></VERSION_LABEL>
+<!--0-->  <VERSION_LABEL><![CDATA[CI]]></VERSION_LABEL>
 <!--0-->  <ISCOMMERCIAL><![CDATA[N]]></ISCOMMERCIAL>
 <!--0--></AD_MODULE>
 
diff -r d60f21a50638 -r 505b7225d671 
src/org/openbravo/erpCommon/ad_forms/DocPayment.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocPayment.java      Tue Oct 19 
09:24:18 2010 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/DocPayment.java      Wed Oct 20 
02:38:58 2010 +0000
@@ -320,10 +320,32 @@
         // debt-payments
         if (line.WriteOffAmt != null && !line.WriteOffAmt.equals("")
             && !line.WriteOffAmt.equals("0")) {
-          fact.createLine(line, 
getAccount(AcctServer.ACCTTYPE_WriteOffDefault, as, conn),
-              C_Currency_ID, (line.isReceipt.equals("Y") ? line.WriteOffAmt : 
""), (line.isReceipt
-                  .equals("Y") ? "" : line.WriteOffAmt), Fact_Acct_Group_ID, 
nextSeqNo(SeqNo),
-              DocumentType, conn);
+          String Account_ID = "";
+          AcctServerData[] acctData = AcctServerData.selectWriteOffAcct(conn, 
line.C_BPARTNER_ID,
+              as.getC_AcctSchema_ID());
+          if (acctData != null && acctData.length != 0) {
+            Account_ID = acctData[0].accountId;
+          } else {
+            acctData = AcctServerData.selectWriteOffDefault(conn, 
as.getC_AcctSchema_ID());
+            if (acctData != null && acctData.length != 0) {
+              Account_ID = acctData[0].accountId;
+            }
+          }
+          Account acct = null;
+          if (!Account_ID.equals("")) {
+            try {
+              acct = Account.getAccount(conn, Account_ID);
+            } catch (ServletException e) {
+              log4j.warn(e);
+              e.printStackTrace();
+            }
+          } else {
+            log4j.warn("AcctServer - getAccount - NO account Type=" + 
AcctServer.ACCTTYPE_WriteOff
+                + ", Record=" + Record_ID);
+          }
+          fact.createLine(line, acct, C_Currency_ID, 
(line.isReceipt.equals("Y") ? line.WriteOffAmt
+              : ""), (line.isReceipt.equals("Y") ? "" : line.WriteOffAmt), 
Fact_Acct_Group_ID,
+              nextSeqNo(SeqNo), DocumentType, conn);
         }
       }
 

------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to