GL Distribution generate positive posting regardless of the IsAllowNegativePosting flag.

Description

Open Accounting schema window and tick flag "Allow Negative Posting". Then system allow posting document like:
Dr "Account-1"
Amount = -100$
Cr "Account-2"
Amount = -100$
It is OK.

But if we use GL Distribution and change Account-2 to Account-3, then accounting processor generate posting:
Dr "Account-1"
Amount = -100$
Dr "Account-3"
Amount = +100$
That's wrong.

It happens because in Fact.java there is code:

if (dl.getAmt().signum() < 0)
factLine.setAmtSource(dLine.getC_Currency_ID(), null, dl.getAmt().abs());
else
factLine.setAmtSource(dLine.getC_Currency_ID(), dl.getAmt(), null);

That generate only positive posting regardless of the IsAllowNegativePosting flag.

The solution is.
1. Add boolean variable isDebit before distribute process.
2. Change wrong code to new with reference to isDebit variable.

Here the code in Fact.java:

} else {
// delete the line being distributed
m_lines.remove; // or it could be m_lines.remove(dLine);
i--;
}

// < 1. Add boolean variable isDebit before distribute process.
Boolean isDebit = true;
if (dLine.getAmtAcctDr().signum()==0)
isDebit = false;
// >

// 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++)

...

// F3P end
/* old code commented
if (dl.getAmt().signum() < 0)
factLine.setAmtSource(dLine.getC_Currency_ID(), null, dl.getAmt().abs());
else
factLine.setAmtSource(dLine.getC_Currency_ID(), dl.getAmt(), null);
*/

// < new code
if (isDebit)
factLine.setAmtSource(dLine.getC_Currency_ID(), dl.getAmt(), null);
else // isCredit
factLine.setAmtSource(dLine.getC_Currency_ID(), null, dl.getAmt().negate());
// >

factLine.setQty(dl.getQty());
// Convert
factLine.convert();

Environment

None

Activity

Show:
Fixed

Details

Assignee

Reporter

Components

Priority

Created April 20, 2017 at 1:45 PM
Updated June 2, 2017 at 5:29 AM
Resolved April 22, 2017 at 11:02 AM