Dunning based on payment template

I am looking to improve the “Dunning” doctype.

Currently a sales invoice can generate several dunning, however the “outstanding amount” and due date of the invoice is used.

That means it’s all based on the TOTAL of the document.

What I’m trying to develop is something proportional to the payment schedule:

If I perform a Sales Invoice total of $150.00 and payment schedule:
Expiration rate
2021-10-15 $75.00
2021-11-15 $75.00

Today, November 1st, When creating “Dunning”, it will calculate fine and interest only for the amount of the first installment in the payment terms, which would be $75.00

NOTE: considering the “outstanding amount” of the “payment schedule”.

I know how to develop this change, but I’ve never contributed to ERPNext, but I want to contribute that, and start contributing more and more changes that I do.
What are the criteria for erpnext to accept my change instead of developing everything in my custom app

You’re lucky, I just developed this:


@ rmeyer

I’ll look at what you’ve developed, but i think my situation is more complex…

I’ll use a simple example:

If I have 1 invoice with 1 installment of $250 due date 2021-10-15, and I receive partial payment of $100 on Oct 25th.

I will generate a charge with the post date November 1st.

From October 15th to October 25th, it will generate interest based on $250.
From the 25th to the 1st of November, it will generate interest based on the remainder, which would be $150.

Fine will only generate 1 time per installment, so as this is the first time I am generating a dunning, for this late installment, it will generate a fine, in my case the fine is a percentage.

Now I’m going to generate a dunning again, but with the post date today Nov 03

Interest will be calculated considering the previous dunning, Nov 01 to Nov 03, generating only the interest difference.

It will not generate a fine, as it was already generated in the previous dunning.

NOTE: Installment = 1 payment schedule record

This is just a basic application of what I’m doing, Gl Entry directly influences the calculation of interest, as payments count and dunning are generated only with the updated value and proportional to the current days of the value.

@PHF my pull request is doing exactly what you have described in your first post.

Regarding your logic when to apply which fees, I think that’s specific to your case and not a universal requirement. IMHO the latest dunning should always show the total amount claimed, not just the difference to the previous one.

yes, but if there was a partial payment of the installment, the interest cannot be searched above the total amount.

I’m going to work on it this afternoon or tomorrow, I’m going to analyze what you’ve done.

Currently i use dunning for fine and interest collection.

Partial payments do get recognized by my approach. The interest is only calculated against any outstanding amount.

Just make sure that you have “Allocate Payment Based On Payment Terms” enabled in your Payment Terms Template.