Sistematika’s Journal

Diberkati untuk memberkati

Accounting generated for Adempiere Invoice (Vendor) activity

Posted by: Bayu Cahya P on: October 31, 2008

Folowing up our previous article, in the next activity, we were doing create Invoice (Vendor) and Matching PO-Receipt-Invoice for this invoice.

This is our condition while doing this exercises:

1. Latest version from branches/stable (352a revision 6811)
2. Multi currency transaction (IDR curr for Purchase Order while using USD as default accounting schema)
3. Costing method Average PO
4. Applying patch from previous article

This was our activity

1. Create Invoice (Vendor)
2. Matching Invoice-Receipt

What is another prerequisites or condition for doing this exercises ?
Nothing, except make sure that we are using rate IDR 10.000,- for USD 1 (for simplicity)

Sounds good.

Our activity just inserting new Invoice (Vendor) records with IDR 710.000,- as our (total) value for 1 qty of goods.

This is our Adempiere Invoice (Vendor) figure

adempiere invoice vendor

And this is our Adempiere Invoice Line figure

adempiere invoice line

Complete and posted this document, and we have this accounting fact details info

adempiere invoice accounting generated

Great, Adempiere doing the good jobs while generated Invoice General Ledger entries.

What’s next?

Because we created this Invoice manually, then we have to do document matching between Invoice and Receipts. Open Matching PO-Receipt-Invoice window with this condition:

1. Match From : Invoice
2. Match To : Receipt
3. Search Mode : Not Matched

Click search records, choose your Invoice and your matching Receipt, then click Proses as per below figure

adempiere matching invoice and receipt

After doing this activity, goes to Matched Invoices window and post this document. This is our Matched Invoices window figure

Adempiere Matched Invoices window

Check your Accounting Fact details window for this transaction as per below figure

adempiere matched invoices accounting generated

“We have got a problem. Adempiere generated value IDR 71 both for source debit and source credit instead of IDR 710.000,- ?” said our Internal Control

It seems that Adempiere generated wrong values for multi currency transaction.

“Hi developer, Could you check within Adempiere source codes about this issue?” said our team leader

After doing his/her investigation with method createFacts within Doc_MatchInv.java, our developer team said that the problem might be within method updateReverseLine (FactLine.java). She said that, while setting value for the amount source, Adempiere taken this value from getAmtAcctDr/Cr directly. This is FactLine.java source codes starting from line 1013 – 1049

String sql = "SELECT * "
                        + "FROM Fact_Acct "
                        + "WHERE C_AcctSchema_ID=? AND AD_Table_ID=? AND Record_ID=?"
                        + " AND Line_ID=? AND Account_ID=?";
   // MZ Goodwill
   // for Inventory Move
   if (MMovement.Table_ID == AD_Table_ID)
      sql += " AND M_Locator_ID=?";
   // end MZ
   PreparedStatement pstmt = null;
   ResultSet rs = null;
   try
   {
      pstmt = DB.prepareStatement(sql, get_TrxName());
      pstmt.setInt(1, getC_AcctSchema_ID());
      pstmt.setInt(2, AD_Table_ID);
      pstmt.setInt(3, Record_ID);
      pstmt.setInt(4, Line_ID);
      pstmt.setInt(5, m_acct.getAccount_ID());
      // MZ Goodwill
      // for Inventory Move
      if (MMovement.Table_ID == AD_Table_ID)
         pstmt.setInt(6, getM_Locator_ID());
      // end MZ
      rs = pstmt.executeQuery();
      if (rs.next())
      {
         MFactAcct fact = new MFactAcct(getCtx(), rs, get_TrxName());
         //  Accounted Amounts - reverse
         BigDecimal dr = fact.getAmtAcctDr();
         BigDecimal cr = fact.getAmtAcctCr();
         // setAmtAcctDr (cr.multiply(multiplier));
         // setAmtAcctCr (dr.multiply(multiplier));
         setAmtAcct(fact.getC_Currency_ID(), cr.multiply(multiplier), dr.multiply(multiplier));
         //  Source Amounts
         setAmtSource(fact.getC_Currency_ID(), getAmtAcctDr(), getAmtAcctCr());
         //

And this is our developer sugestions to fixing this issue

String sql = "SELECT * "
                        + "FROM Fact_Acct "
                        + "WHERE C_AcctSchema_ID=? AND AD_Table_ID=? AND Record_ID=?"
                        + " AND Line_ID=? AND Account_ID=?";
   // MZ Goodwill
   // for Inventory Move
   if (MMovement.Table_ID == AD_Table_ID)
      sql += " AND M_Locator_ID=?";
   // end MZ
   PreparedStatement pstmt = null;
   ResultSet rs = null;
   try
   {
      pstmt = DB.prepareStatement(sql, get_TrxName());
      pstmt.setInt(1, getC_AcctSchema_ID());
      pstmt.setInt(2, AD_Table_ID);
      pstmt.setInt(3, Record_ID);
      pstmt.setInt(4, Line_ID);
      pstmt.setInt(5, m_acct.getAccount_ID());
      // MZ Goodwill
      // for Inventory Move
      if (MMovement.Table_ID == AD_Table_ID)
         pstmt.setInt(6, getM_Locator_ID());
      // end MZ
      rs = pstmt.executeQuery();
      if (rs.next())
      {
         MFactAcct fact = new MFactAcct(getCtx(), rs, get_TrxName());
         //  Accounted Amounts - reverse
         BigDecimal dr = fact.getAmtAcctDr();
         BigDecimal cr = fact.getAmtAcctCr();
         // setAmtAcctDr (cr.multiply(multiplier));
         // setAmtAcctCr (dr.multiply(multiplier));
         setAmtAcct(fact.getC_Currency_ID(), cr.multiply(multiplier), dr.multiply(multiplier));
         //  Source Amounts
         //  setAmtSource(fact.getC_Currency_ID(), getAmtAcctDr(), getAmtAcctCr());

         // Bayu Sistematika
         // Fixing get amount source
         BigDecimal drSourceAmt = fact.getAmtSourceDr();
         BigDecimal crSourceAmt = fact.getAmtSourceCr();
         setAmtSource(fact.getC_Currency_ID(), crSourceAmt.multiply(multiplier), drSourceAmt.multiply(multiplier));

         // end Bayu

Okay, build our FactLine java files and put this file within our customization.jar. Execute run_silentsetup.bat to merge our customization onto Adempiere engine.

Let’s try our efforts. First, we have to delete our Matched Invoices records. For now, Adempiere will remove this accounting entries (we prefer to do reversal entry instead of removing records). Try to re-matching invoices receipt and post this document. Finally, this is our accounting fact details generated

adempiere matched invoices accounting generated 2

Seems the problem was gone away. For anyone whom interested with this exercises, you can access our customization.jar and our patch.

1 Response to "Accounting generated for Adempiere Invoice (Vendor) activity"

1 | Redhuan D. Oon

November 10th, 2008 at 10:23 am

Hi Bayu,
Maybe you haven’t seen this but Asia e-University is organising a Masters programme with ADempiere here http://en.wikiversity.org/wiki/Open_Source_ERP/Executive_Diploma

Hope you can join in and become of the future tutors. This is a paid project and we intend to support ourselves in a good and open way without asking for donations :D

If you are interested please sign in at the Lecturer and Assiting page, and help to suggest materials.

We intend to align with our strong contributors there such as Armen Rizal too. Since your tutorials here are visible and resourceful, you certainly are welcome.

red1

Comment Form

SEO Powered by Platinum SEO from Techblissonline