I'm looking at MInvoice.getOpenAmt method and it looks like it's not fully implemented.The paymentDate parameter has no functionality. I think that what it's supposed to do is to consider if any discounts should be applied in regard to the payment term and timestamp. I need this to work in a different project and I wonder if below would be a solution. And I'd be very pleased for any kind of input.
One more thing about getOpenAmt that caused me trouble earlier is that if you call the method getOpenAmt once it doesn't update the value any more (" if (m_openAmt == null)" )
This is kind of dangerous if you call the method twice and in between the two calls you e.g. have allocated a payment. Then you won't get the correct value. I think the line should be removed or the method should have one more parameter "boolean reload". What do you think?
Back to the first change I was talking about. (Maybe it shouldn't be applied on credit memos?) This should be added in getOpenAmt
the "getDiscountAmt" method would be something like this:
Nils proposed here:
https://groups.google.com/d/msg/idempiere/y3QMLFjHUJg/qoRo87-TTZ8J