IDEMPIERE-3155 Posting issue in Matching PO-Receipt-Invoice. Fix posting for un-matching of Receipt and Invoice.

This commit is contained in:
Heng Sin Low 2016-09-12 18:06:07 +08:00
parent 35933b6ce2
commit 5b29241d87
2 changed files with 29 additions and 3 deletions

View File

@ -191,9 +191,12 @@ public class Doc_MatchInv extends Doc
}
else
{
BigDecimal effMultiplier = multiplier;
if (getQty().signum() < 0)
effMultiplier = effMultiplier.negate();
if (!dr.updateReverseLine (MInOut.Table_ID, // Amt updated
m_receiptLine.getM_InOut_ID(), m_receiptLine.getM_InOutLine_ID(),
multiplier))
effMultiplier))
{
p_Error = "Mat.Receipt not posted yet";
return null;
@ -241,10 +244,14 @@ public class Doc_MatchInv extends Doc
}
else
{
cr.setQty(getQty().negate());
cr.setQty(getQty().negate());
BigDecimal effMultiplier = multiplier;
if (getQty().signum() < 0)
effMultiplier = effMultiplier.negate();
// Set AmtAcctCr/Dr from Invoice (sets also Project)
if (!cr.updateReverseLine (MInvoice.Table_ID, // Amt updated
m_invoiceLine.getC_Invoice_ID(), m_invoiceLine.getC_InvoiceLine_ID(), multiplier))
m_invoiceLine.getC_Invoice_ID(), m_invoiceLine.getC_InvoiceLine_ID(), effMultiplier))
{
p_Error = "Invoice not posted yet";
return null;

View File

@ -301,6 +301,25 @@ public final class FactLine extends X_Fact_Acct
*/
public void setAmtAcct(int C_Currency_ID, BigDecimal AmtAcctDr, BigDecimal AmtAcctCr)
{
if (! m_acctSchema.isAllowNegativePosting()) {
// fix Debit & Credit
if (AmtAcctDr != null)
{
if (AmtAcctDr.compareTo(Env.ZERO) == -1)
{
AmtAcctCr = AmtAcctDr.abs();
AmtAcctDr = Env.ZERO;
}
}
if (AmtAcctCr != null)
{
if (AmtAcctCr.compareTo(Env.ZERO) == -1)
{
AmtAcctDr = AmtAcctCr.abs();
AmtAcctCr = Env.ZERO;
}
}
}
setAmtAcctDr (AmtAcctDr);
setAmtAcctCr (AmtAcctCr);
// Currency Precision