IDEMPIERE-4828-posting of Allocation with a AR Credit Memos with disc… (#745)
* IDEMPIERE-4828-posting of Allocation with a AR Credit Memos with discount, the tax-correction has the wrong sign * IDEMPIERE-4828 - posting of Allocation with a AR Credit Memos with discount, the tax-correction has the wrong sign check for DocBaseType
This commit is contained in:
parent
93bc73c257
commit
bb2bbc710c
|
@ -32,6 +32,7 @@ import org.compiere.model.MAllocationHdr;
|
||||||
import org.compiere.model.MAllocationLine;
|
import org.compiere.model.MAllocationLine;
|
||||||
import org.compiere.model.MCashLine;
|
import org.compiere.model.MCashLine;
|
||||||
import org.compiere.model.MConversionRate;
|
import org.compiere.model.MConversionRate;
|
||||||
|
import org.compiere.model.MDocType;
|
||||||
import org.compiere.model.MFactAcct;
|
import org.compiere.model.MFactAcct;
|
||||||
import org.compiere.model.MInvoice;
|
import org.compiere.model.MInvoice;
|
||||||
import org.compiere.model.MInvoiceLine;
|
import org.compiere.model.MInvoiceLine;
|
||||||
|
@ -1856,6 +1857,9 @@ class Doc_AllocationTax
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Doc doc = DocManager.getDocument(as, MInvoice.Table_ID, factAcct.getRecord_ID(), line.getPO().get_TrxName());
|
||||||
|
MDocType dt = new MDocType(Env.getCtx(), (doc!=null)?doc.getC_DocType_ID():-1, line.getPO().get_TrxName());
|
||||||
|
String docBaseType=(dt.getC_DocType_ID()>0)?dt.getDocBaseType():"";
|
||||||
|
|
||||||
// Discount Amount
|
// Discount Amount
|
||||||
if (m_DiscountAmt.signum() != 0)
|
if (m_DiscountAmt.signum() != 0)
|
||||||
|
@ -1865,22 +1869,37 @@ class Doc_AllocationTax
|
||||||
{
|
{
|
||||||
BigDecimal amount = calcAmount(factAcct.getAmtSourceDr(),
|
BigDecimal amount = calcAmount(factAcct.getAmtSourceDr(),
|
||||||
total, m_DiscountAmt, precision);
|
total, m_DiscountAmt, precision);
|
||||||
|
|
||||||
if (amount.signum() != 0)
|
if (amount.signum() != 0)
|
||||||
{
|
{
|
||||||
//for sales actions
|
//for sales actions
|
||||||
if (m_IsSOTrx) {
|
if (m_IsSOTrx) {
|
||||||
fact.createLine (line, m_DiscountAccount,
|
if(docBaseType.equals(MDocType.DOCBASETYPE_ARCreditMemo)) {
|
||||||
as.getC_Currency_ID(), amount, null);
|
fact.createLine (line, m_DiscountAccount,
|
||||||
fact.createLine (line, taxAcct,
|
as.getC_Currency_ID(), amount.negate(), null);
|
||||||
as.getC_Currency_ID(), null, amount);
|
fact.createLine (line, taxAcct,
|
||||||
|
as.getC_Currency_ID(), null, amount.negate());
|
||||||
|
}else {
|
||||||
|
|
||||||
|
fact.createLine (line, m_DiscountAccount,
|
||||||
|
as.getC_Currency_ID(), amount, null);
|
||||||
|
fact.createLine (line, taxAcct,
|
||||||
|
as.getC_Currency_ID(), null, amount);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
//for purchase actions
|
//for purchase actions
|
||||||
fact.createLine (line, m_DiscountAccount,
|
if(docBaseType.equals(MDocType.DOCBASETYPE_APCreditMemo)) {
|
||||||
as.getC_Currency_ID(), amount.negate(), null);
|
fact.createLine (line, m_DiscountAccount,
|
||||||
fact.createLine (line, taxAcct,
|
as.getC_Currency_ID(), amount, null);
|
||||||
as.getC_Currency_ID(), null, amount.negate());
|
fact.createLine (line, taxAcct,
|
||||||
|
as.getC_Currency_ID(), null, amount);
|
||||||
|
} else {
|
||||||
|
fact.createLine (line, m_DiscountAccount,
|
||||||
|
as.getC_Currency_ID(), amount.negate(), null);
|
||||||
|
fact.createLine (line, taxAcct,
|
||||||
|
as.getC_Currency_ID(), null, amount.negate());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Original Tax is CR - need to correct it DR
|
// Original Tax is CR - need to correct it DR
|
||||||
|
@ -1892,15 +1911,33 @@ class Doc_AllocationTax
|
||||||
{
|
{
|
||||||
// for sales actions
|
// for sales actions
|
||||||
if (m_IsSOTrx) {
|
if (m_IsSOTrx) {
|
||||||
fact.createLine (line, taxAcct,
|
if(docBaseType.equals(MDocType.DOCBASETYPE_ARCreditMemo)) {
|
||||||
as.getC_Currency_ID(), amount, null);
|
fact.createLine (line, taxAcct,
|
||||||
fact.createLine (line, m_DiscountAccount,
|
as.getC_Currency_ID(), amount.negate(), null);
|
||||||
as.getC_Currency_ID(), null, amount);
|
fact.createLine (line, m_DiscountAccount,
|
||||||
|
as.getC_Currency_ID(), null, amount.negate());
|
||||||
|
}else {
|
||||||
|
|
||||||
|
fact.createLine (line, taxAcct,
|
||||||
|
as.getC_Currency_ID(), amount, null);
|
||||||
|
fact.createLine (line, m_DiscountAccount,
|
||||||
|
as.getC_Currency_ID(), null, amount);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
fact.createLine (line, taxAcct,
|
if(docBaseType.equals(MDocType.DOCBASETYPE_APCreditMemo)) {
|
||||||
as.getC_Currency_ID(), amount.negate(), null);
|
fact.createLine (line, taxAcct,
|
||||||
fact.createLine (line, m_DiscountAccount,
|
as.getC_Currency_ID(), amount, null);
|
||||||
as.getC_Currency_ID(), null, amount.negate());
|
fact.createLine (line, m_DiscountAccount,
|
||||||
|
as.getC_Currency_ID(), null, amount);
|
||||||
|
}else {
|
||||||
|
|
||||||
|
fact.createLine (line, taxAcct,
|
||||||
|
as.getC_Currency_ID(), amount.negate(), null);
|
||||||
|
fact.createLine (line, m_DiscountAccount,
|
||||||
|
as.getC_Currency_ID(), null, amount.negate());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1917,15 +1954,29 @@ class Doc_AllocationTax
|
||||||
if (amount.signum() != 0)
|
if (amount.signum() != 0)
|
||||||
{
|
{
|
||||||
if (m_IsSOTrx) {
|
if (m_IsSOTrx) {
|
||||||
fact.createLine (line, m_WriteOffAccount,
|
if(docBaseType.equals(MDocType.DOCBASETYPE_ARCreditMemo)) {
|
||||||
as.getC_Currency_ID(), amount, null);
|
fact.createLine (line, m_WriteOffAccount,
|
||||||
fact.createLine (line, taxAcct,
|
|
||||||
as.getC_Currency_ID(), null, amount);
|
|
||||||
} else {
|
|
||||||
fact.createLine (line, m_WriteOffAccount,
|
|
||||||
as.getC_Currency_ID(), amount.negate(), null);
|
as.getC_Currency_ID(), amount.negate(), null);
|
||||||
fact.createLine (line, taxAcct,
|
fact.createLine (line, taxAcct,
|
||||||
as.getC_Currency_ID(), null, amount.negate());
|
as.getC_Currency_ID(), null, amount.negate());
|
||||||
|
} else {
|
||||||
|
fact.createLine (line, m_WriteOffAccount,
|
||||||
|
as.getC_Currency_ID(), amount, null);
|
||||||
|
fact.createLine (line, taxAcct,
|
||||||
|
as.getC_Currency_ID(), null, amount);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(docBaseType.equals(MDocType.DOCBASETYPE_APCreditMemo)) {
|
||||||
|
fact.createLine (line, m_WriteOffAccount,
|
||||||
|
as.getC_Currency_ID(), amount, null);
|
||||||
|
fact.createLine (line, taxAcct,
|
||||||
|
as.getC_Currency_ID(), null, amount);
|
||||||
|
} else {
|
||||||
|
fact.createLine (line, m_WriteOffAccount,
|
||||||
|
as.getC_Currency_ID(), amount.negate(), null);
|
||||||
|
fact.createLine (line, taxAcct,
|
||||||
|
as.getC_Currency_ID(), null, amount.negate());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1937,20 +1988,33 @@ class Doc_AllocationTax
|
||||||
if (amount.signum() != 0)
|
if (amount.signum() != 0)
|
||||||
{
|
{
|
||||||
if(m_IsSOTrx) {
|
if(m_IsSOTrx) {
|
||||||
fact.createLine (line, taxAcct,
|
if(docBaseType.equals(MDocType.DOCBASETYPE_ARCreditMemo)) {
|
||||||
as.getC_Currency_ID(), amount, null);
|
fact.createLine (line, taxAcct,
|
||||||
fact.createLine (line, m_WriteOffAccount,
|
|
||||||
as.getC_Currency_ID(), null, amount);
|
|
||||||
} else {
|
|
||||||
fact.createLine (line, taxAcct,
|
|
||||||
as.getC_Currency_ID(), amount.negate(), null);
|
as.getC_Currency_ID(), amount.negate(), null);
|
||||||
fact.createLine (line, m_WriteOffAccount,
|
fact.createLine (line, m_WriteOffAccount,
|
||||||
as.getC_Currency_ID(), null, amount.negate());
|
as.getC_Currency_ID(), null, amount.negate());
|
||||||
|
} else {
|
||||||
|
fact.createLine (line, taxAcct,
|
||||||
|
as.getC_Currency_ID(), amount, null);
|
||||||
|
fact.createLine (line, m_WriteOffAccount,
|
||||||
|
as.getC_Currency_ID(), null, amount);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(docBaseType.equals(MDocType.DOCBASETYPE_APCreditMemo)) {
|
||||||
|
fact.createLine (line, taxAcct,
|
||||||
|
as.getC_Currency_ID(), amount, null);
|
||||||
|
fact.createLine (line, m_WriteOffAccount,
|
||||||
|
as.getC_Currency_ID(), null, amount);
|
||||||
|
} else {
|
||||||
|
fact.createLine (line, taxAcct,
|
||||||
|
as.getC_Currency_ID(), amount.negate(), null);
|
||||||
|
fact.createLine (line, m_WriteOffAccount,
|
||||||
|
as.getC_Currency_ID(), null, amount.negate());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // WriteOff
|
} // WriteOff
|
||||||
|
|
||||||
} // for all lines
|
} // for all lines
|
||||||
return true;
|
return true;
|
||||||
} // createEntries
|
} // createEntries
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue