Fixed
Details
Assignee
Carlos RuizCarlos RuizReporter
Carlos RuizCarlos RuizAffects versions
Priority
Major
Details
Details
Assignee
Carlos Ruiz
Carlos RuizReporter
Carlos Ruiz
Carlos RuizAffects versions
Priority
Created April 4, 2013 at 5:28 AM
Updated September 4, 2020 at 8:52 PM
Resolved July 13, 2020 at 8:47 AM
Nils proposed here:
https://groups.google.com/d/msg/idempiere/y3QMLFjHUJg/qoRo87-TTZ8J
if (paymentDate != null) { if (getC_PaymentTerm_ID()>0) { BigDecimal discount = getDiscountAmt(paymentDate); if (discount!=null) m_openAmt = m_openAmt.subtract(discount); } }
* Get discount amt depending on payment term and timestamp * @return pos/neg amount or null */ public BigDecimal getDiscountAmt (Timestamp paymentDate) { BigDecimal retValue = null; String sql = "SELECT " + " invoiceDiscount(?,?,?) "; PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = DB.prepareStatement(sql, get_TrxName()); pstmt.setInt(1, getC_Invoice_ID()); pstmt.setTimestamp(2, paymentDate); pstmt.setInt(3, getC_PaymentTerm_ID()); rs = pstmt.executeQuery(); if (rs.next()) { retValue = rs.getBigDecimal(1); } rs.close(); pstmt.close(); pstmt = null; } catch (SQLException e) { throw new DBException(e, sql); } finally { DB.close(rs, pstmt); rs = null; pstmt = null; } return retValue; } // getDiscountAmt