diff --git a/org.adempiere.base.process/src/org/compiere/process/BankStatementPayment.java b/org.adempiere.base.process/src/org/compiere/process/BankStatementPayment.java index 7b7492cda8..82b4554909 100644 --- a/org.adempiere.base.process/src/org/compiere/process/BankStatementPayment.java +++ b/org.adempiere.base.process/src/org/compiere/process/BankStatementPayment.java @@ -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 { diff --git a/org.adempiere.base/src/org/compiere/model/MInvoice.java b/org.adempiere.base/src/org/compiere/model/MInvoice.java index 601f9f63ef..2aee361e4d 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoice.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoice.java @@ -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