IDEMPIERE-5231 Create Payments from Bank Statement is not taking into account Discounts (#1248)

* IDEMPIERE-5231 Create Payments from Bank Statement is not taking into account Discounts #resolve

* - Remove misleading closing message
This commit is contained in:
Carlos Ruiz 2022-03-15 15:11:06 +01:00 committed by GitHub
parent a3e75538d2
commit 24836a7c6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -220,7 +220,10 @@ public class BankStatementPayment extends SvrProcess
payment.setPayAmt(PayAmt);
else // payment is likely to be negative
payment.setPayAmt(PayAmt.negate());
payment.setOverUnderAmt(invoice.getOpenAmt().subtract(payment.getPayAmt()));
BigDecimal discountAmt = invoice.getDiscountAmt(payment.getDateTrx());
payment.setDiscountAmt(discountAmt);
BigDecimal overUnderAmt = invoice.getOpenAmt().subtract(payment.getPayAmt()).subtract(discountAmt);
payment.setOverUnderAmt(overUnderAmt);
}
else // set Pay Amout from Invoice
{

View File

@ -72,7 +72,7 @@ public class MInvoice extends X_C_Invoice implements DocAction, IDocsPostProcess
/**
*
*/
private static final long serialVersionUID = -261338363319970683L;
private static final long serialVersionUID = -303676612533389278L;
/**
* Get Payments Of BPartner
@ -1404,6 +1404,18 @@ public class MInvoice extends X_C_Invoice implements DocAction, IDocsPostProcess
return retValue;
} // getOpenAmt
/*
* Get discount amt depending on payment date
* @return discount Amt
*/
public BigDecimal getDiscountAmt(Timestamp paymentDate)
{
BigDecimal retValue = DB.getSQLValueBDEx(get_TrxName(),
"SELECT invoiceDiscount(?,?,?) FROM DUAL",
getC_Invoice_ID(), paymentDate, 0);
return retValue;
}
/**
* Get Document Status
* @return Document Status Clear Text