Implement MInvoice.getOpenAmt with paymentDate

Description

Nils proposed here:
https://groups.google.com/d/msg/idempiere/y3QMLFjHUJg/qoRo87-TTZ8J

Hi!

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:

Environment

None

Attachments

1

Activity

Show:

Carlos Ruiz June 25, 2020 at 1:52 PM

The patch was wrong.

I implemented a correct fix in
https://github.com/idempiere/idempiere/pull/135

Added also the corresponding unit test: InvoiceCustomerTest

Diego Ruiz June 25, 2020 at 10:41 AM

Triaged by Diego Ruiz,

, The attached patch was never integrated to the core.

Adding the label → Patch-Already-Tested to the ticket

Carlos Ruiz April 4, 2013 at 8:32 PM

Nils, thanks for your feedback.

I think is ok - the creditMemoAdjusted invert the sign of the amount when the document is a credit note.

Regards,

Carlos Ruiz

NilsK April 4, 2013 at 8:17 PM

I've tested and it works perfect! Thank you for cleaning up the code to

One thing though, I'm not sure what happens when it's a credit memo. Maybe it doesn't matter but I really don't know.

Then it could be
if (paymentDate != null && !creditMemoAdjusted) {
instead of
if (paymentDate != null) {

Nils

Carlos Ruiz April 4, 2013 at 5:31 AM

Hi Nils, I think the proposal makes sense.

I prepared (and attached) a patch IDEMPIERE-829.patch - can you please check and test it?

Regards,

Carlos Ruiz

Fixed

Details

Assignee

Reporter

Affects 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