[ 1840016 ] Avoid usage of clearing accounts
problem with realized gain & loss reported by Anh Han (anhhn) https://sourceforge.net/forum/message.php?msg_id=4687667
This commit is contained in:
parent
3e6a8fbd81
commit
4f047fdb87
|
@ -159,6 +159,7 @@ public class Doc_Allocation extends Doc
|
||||||
|
|
||||||
// create Fact Header
|
// create Fact Header
|
||||||
Fact fact = new Fact(this, as, Fact.POST_Actual);
|
Fact fact = new Fact(this, as, Fact.POST_Actual);
|
||||||
|
Fact factForRGL = new Fact(this, as, Fact.POST_Actual); // dummy fact (not posted) to calculate Realized Gain & Loss
|
||||||
|
|
||||||
for (int i = 0; i < p_lines.length; i++)
|
for (int i = 0; i < p_lines.length; i++)
|
||||||
{
|
{
|
||||||
|
@ -177,13 +178,12 @@ public class Doc_Allocation extends Doc
|
||||||
BigDecimal allocationSource = line.getAmtSource()
|
BigDecimal allocationSource = line.getAmtSource()
|
||||||
.add(line.getDiscountAmt())
|
.add(line.getDiscountAmt())
|
||||||
.add(line.getWriteOffAmt());
|
.add(line.getWriteOffAmt());
|
||||||
//Modified Lines by Armen
|
BigDecimal allocationSourceForRGL = allocationSource; // for realized gain & loss purposes
|
||||||
//Old:
|
|
||||||
//BigDecimal allocationAccounted = null; // AR/AP balance corrected
|
|
||||||
BigDecimal allocationAccounted = Env.ZERO; // AR/AP balance corrected
|
BigDecimal allocationAccounted = Env.ZERO; // AR/AP balance corrected
|
||||||
//End of Modified Lines
|
BigDecimal allocationAccountedForRGL = Env.ZERO; // for realized gain & loss purposes
|
||||||
|
|
||||||
FactLine fl = null;
|
FactLine fl = null;
|
||||||
|
FactLine flForRGL = null;
|
||||||
MAccount bpAcct = null; // Liability/Receivables
|
MAccount bpAcct = null; // Liability/Receivables
|
||||||
//
|
//
|
||||||
MPayment payment = null;
|
MPayment payment = null;
|
||||||
|
@ -284,11 +284,18 @@ public class Doc_Allocation extends Doc
|
||||||
allocationAccounted = fl.getAcctBalance().negate();
|
allocationAccounted = fl.getAcctBalance().negate();
|
||||||
if (fl != null && invoice != null)
|
if (fl != null && invoice != null)
|
||||||
fl.setAD_Org_ID(invoice.getAD_Org_ID());
|
fl.setAD_Org_ID(invoice.getAD_Org_ID());
|
||||||
|
|
||||||
|
// for Realized Gain & Loss
|
||||||
|
flForRGL = factForRGL.createLine (line, bpAcct,
|
||||||
|
getC_Currency_ID(), null, allocationSourceForRGL); // payment currency
|
||||||
|
if (flForRGL != null)
|
||||||
|
allocationAccountedForRGL = flForRGL.getAcctBalance().negate();
|
||||||
}
|
}
|
||||||
else // Cash Based
|
else // Cash Based
|
||||||
{
|
{
|
||||||
allocationAccounted = createCashBasedAcct (as, fact,
|
allocationAccounted = createCashBasedAcct (as, fact,
|
||||||
invoice, allocationSource);
|
invoice, allocationSource);
|
||||||
|
allocationAccountedForRGL = allocationAccounted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Purchase Invoice
|
// Purchase Invoice
|
||||||
|
@ -306,6 +313,9 @@ public class Doc_Allocation extends Doc
|
||||||
MAccount acct_liability = getAccount(Doc.ACCTTYPE_V_Liability, as);
|
MAccount acct_liability = getAccount(Doc.ACCTTYPE_V_Liability, as);
|
||||||
boolean isUsingClearing = true;
|
boolean isUsingClearing = true;
|
||||||
|
|
||||||
|
// Save original allocation source for realized gain & loss purposes
|
||||||
|
allocationSourceForRGL = allocationSourceForRGL.negate();
|
||||||
|
|
||||||
if ((!as.isPostIfClearingEqual()) && acct_payment_select != null && acct_payment_select.equals(acct_liability)) {
|
if ((!as.isPostIfClearingEqual()) && acct_payment_select != null && acct_payment_select.equals(acct_liability)) {
|
||||||
|
|
||||||
// if not using clearing accounts, then don't post amtsource
|
// if not using clearing accounts, then don't post amtsource
|
||||||
|
@ -327,11 +337,18 @@ public class Doc_Allocation extends Doc
|
||||||
allocationAccounted = fl.getAcctBalance();
|
allocationAccounted = fl.getAcctBalance();
|
||||||
if (fl != null && invoice != null)
|
if (fl != null && invoice != null)
|
||||||
fl.setAD_Org_ID(invoice.getAD_Org_ID());
|
fl.setAD_Org_ID(invoice.getAD_Org_ID());
|
||||||
|
|
||||||
|
// for Realized Gain & Loss
|
||||||
|
flForRGL = factForRGL.createLine (line, bpAcct,
|
||||||
|
getC_Currency_ID(), allocationSourceForRGL, null); // payment currency
|
||||||
|
if (flForRGL != null)
|
||||||
|
allocationAccountedForRGL = flForRGL.getAcctBalance();
|
||||||
}
|
}
|
||||||
else // Cash Based
|
else // Cash Based
|
||||||
{
|
{
|
||||||
allocationAccounted = createCashBasedAcct (as, fact,
|
allocationAccounted = createCashBasedAcct (as, fact,
|
||||||
invoice, allocationSource);
|
invoice, allocationSource);
|
||||||
|
allocationAccountedForRGL = allocationAccounted;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Discount CR
|
// Discount CR
|
||||||
|
@ -395,7 +412,7 @@ public class Doc_Allocation extends Doc
|
||||||
|| getC_Currency_ID() != line.getInvoiceC_Currency_ID())) // allocation <> invoice currency
|
|| getC_Currency_ID() != line.getInvoiceC_Currency_ID())) // allocation <> invoice currency
|
||||||
{
|
{
|
||||||
p_Error = createRealizedGainLoss (as, fact, bpAcct, invoice,
|
p_Error = createRealizedGainLoss (as, fact, bpAcct, invoice,
|
||||||
allocationSource, allocationAccounted);
|
allocationSourceForRGL, allocationAccountedForRGL);
|
||||||
if (p_Error != null)
|
if (p_Error != null)
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue