2800319 Payment completion doesn't set BP open balance.
https://sourceforge.net/tracker/?func=detail&aid=2800319&group_id=176962&atid=879332
This commit is contained in:
parent
5654cfbffe
commit
2457108af3
|
@ -1770,10 +1770,29 @@ public final class MPayment extends X_C_Payment
|
||||||
// MProject project = new MProject(getCtx(), getC_Project_ID());
|
// MProject project = new MProject(getCtx(), getC_Project_ID());
|
||||||
}
|
}
|
||||||
// Update BP for Prepayments
|
// Update BP for Prepayments
|
||||||
if (getC_BPartner_ID() != 0 && getC_Invoice_ID() == 0)
|
if (getC_BPartner_ID() != 0 && getC_Invoice_ID() == 0 && getC_Charge_ID() == 0)
|
||||||
{
|
{
|
||||||
MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName());
|
MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName());
|
||||||
bp.setTotalOpenBalance();
|
// Update total balance to include this payment
|
||||||
|
BigDecimal payAmt = MConversionRate.convertBase(getCtx(), getPayAmt(),
|
||||||
|
getC_Currency_ID(), getDateAcct(), getC_ConversionType_ID(), getAD_Client_ID(), getAD_Org_ID());
|
||||||
|
if (payAmt == null)
|
||||||
|
{
|
||||||
|
m_processMsg = "Could not convert C_Currency_ID=" + getC_Currency_ID()
|
||||||
|
+ " to base C_Currency_ID=" + MClient.get(Env.getCtx()).getC_Currency_ID();
|
||||||
|
return DocAction.STATUS_Invalid;
|
||||||
|
}
|
||||||
|
// Total Balance
|
||||||
|
BigDecimal newBalance = bp.getTotalOpenBalance(false);
|
||||||
|
if (newBalance == null)
|
||||||
|
newBalance = Env.ZERO;
|
||||||
|
if (isReceipt())
|
||||||
|
newBalance = newBalance.subtract(payAmt);
|
||||||
|
else
|
||||||
|
newBalance = newBalance.add(payAmt);
|
||||||
|
|
||||||
|
bp.setTotalOpenBalance(newBalance);
|
||||||
|
bp.setSOCreditStatus();
|
||||||
bp.save();
|
bp.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue