Wrong accounting facts if we using the GL Distribution

117 views
Skip to first unread message

Patric

unread,
Oct 13, 2016, 9:29:57 AM10/13/16
to iDempiere
Hello together,

we using the GL Distribution to switch some accounts.

As example we switching the Inventory Clearing Account for vendor invoices to another Account.

Distribution
-----------------------
PostingType    : Actual
Document Type: AP Invoices
Any Account: false
Account : our Inventory Clearing 5530
Create Reversal : true -> Important for the Costcalculation

Line
-----------------------
Overwrite Account: our destination Account 5400


The posting seems okay, but in the posting details(sql) we see the line_id in the destination account-factline is null.
In the source-account-factline and in the reverse source-account-factline to this invoice is the line_id not null.(equal the invoiceline_id)

If we paying this invoice with discount and with TaxCorrection ,
then the posting of the allocation is not right.


The accounting-facts

invoice with distribution

Account                           Debit   Credit    Record_ID    Line_ID
3300 liabilities                  0,00    122,95  1042152        null         okay
1408 deductible input tax  19,63    0,00    1042152        null         okay
5530 Inventory Clearing    103,32    0,00  1042152        1154871 okay
5530 Inventory Clearing   -103,32    0,00  1042152        1154871 okay
5400 Goods receipt          103,32    0,00  1042152        null <--        error! because it is a representation of 5530
                                       122,95    122,95   



Allocation
this posting is okay

Account                          Debit    Credit
3300 liabilities                 122,95    0,00
5736 obtained discounts  0,00        3,69
1894 Unpaid payments    0,00     119,26
5736 obtained discounts  0,59         0,00
1408 deductible input tax 0,00         0,59
                                     123,54    123,54



The system does

Account                          Debit    Credit
3300 liabilities                 122,95   0,00
5736 obtained discounts  0,00       3,69
1894 Unpaid payments    0,00       119,26
5736 obtained discounts  0,59       0,00
1408 deductible input tax 0,00       0,59
5736 obtained discounts  3,10       0,00   Error
5400 Goods receipt        0,00       3,10    Error
                                     126,64    126,64





iDempiere is looking for the needed accounting facts with:

Doc_AllocationHdr

"SELECT * "
                + "FROM Fact_Acct "
                + "WHERE AD_Table_ID=318 AND Record_ID=?"    //    Invoice
                + " AND C_AcctSchema_ID=?"
                + " AND Line_ID IS NULL"  //    header lines like tax or total


With this sql-statement the result contains also the distributed destination-account-fact from the posting, because
after the distribution of the account the line_id is null.




In the method distribute() from Fact.java is the line_id for factLine with 0 defined and later not updated, so the
posting has always null in the accounting-record.

--> line 728
            //    Prepare
            distribution.distribute(dLine.getAccount(), dLine.getSourceBalance(), dLine.getQty(), dLine.getC_Currency_ID());
            MDistributionLine[] lines = distribution.getLines(false);
            for (int j = 0; j < lines.length; j++)
            {
                MDistributionLine dl = lines[j];
                if (!dl.isActive() || dl.getAmt().signum() == 0)
                    continue;
                FactLine factLine = new FactLine (m_doc.getCtx(), m_doc.get_Table_ID(),
                    m_doc.get_ID(), 0), m_trxName);
<--



For testing I changed the declaration to


                 FactLine factLine = new FactLine (m_doc.getCtx(), m_doc.get_Table_ID(),
                    m_doc.get_ID(), dLine.getLine_ID()), m_trxName);


I re-posted the invoice and the allocation.

Now the posting is okay.



I'm not sure it is a bug or we did a mistake ?

WDYT?


Regards

Patric
Hans Auler GmbH

Patric

unread,
Oct 18, 2016, 9:53:17 AM10/18/16
to iDempiere
Hello together,

it's ok when I create a ticket ?
I think it is a bug.

redhuan d. oon

unread,
Oct 21, 2016, 3:31:15 AM10/21/16
to iDempiere
Your description seems comprehensive. Then it can be a ticket in https://idempiere.atlassian.net/

Patric

unread,
Oct 25, 2016, 7:25:25 AM10/25/16
to iDempiere
Hello together,

I have created a ticket and a patch.

https://idempiere.atlassian.net/browse/IDEMPIERE-3229

Regards,

Patric
Hans Auler GmbH
Reply all
Reply to author
Forward
0 new messages