-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fetch overdue payments in dunning #42627
base: develop
Are you sure you want to change the base?
Conversation
Perfect, thank you @Nihantra-Patel . |
Hi @Nihantra-Patel, I found this issue because I was having the same problem with generating dunnings. Your changes do fix the problem, but I'm not sure there are no unintended side effects. Why do you add # update outstanding
source.payment_schedule = []
if source.payment_schedule and len(source.payment_schedule) == 1:
target.overdue_payments[0].outstanding = source.get("outstanding_amount") |
Lines you had were clearing out So, instead of clearing |
Thank you for your quick reply @Nihantra-Patel. That makes sense! And why did you keep the if statement? The condition is always false, as |
Since source.payment_schedule is emptied before the check, the if statement will never be true. So, you don't need that if statement at all. Just keep the code that clears old payments and adds new ones to the target. This makes the code simpler and avoids any confusion. please check the video that i provided above. |
Absolutely, that's my point :D The if statement is still present in your code, so it might be good to remove those lines to keep things clean. I would do it, but can't really because it's your bug fix. |
Hmm 🤔 You said that if you remove/comment out the code below the outstanding will be updated? Did you test it? I don't think it will be an outstanding update.
|
I'm not really saying that, all I'm saying is that the line you added in this fix ensures the if statement never succeeds, effectively rendering it useless. In which case it might be better to remove it. However, to answer your question, I just tried actually removing the if statement and that does work (as it is effectively the same as your changes, it just makes the code cleaner). The I do think that this would be an issue when a sales invoice would have multiple payment schedule lines, but I'm not sure when that's the case. |
# update outstanding | ||
source.payment_schedule = [] | ||
if source.payment_schedule and len(source.payment_schedule) == 1: | ||
target.overdue_payments[0].outstanding = source.get("outstanding_amount") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# update outstanding | |
source.payment_schedule = [] | |
if source.payment_schedule and len(source.payment_schedule) == 1: | |
target.overdue_payments[0].outstanding = source.get("outstanding_amount") | |
# In the Sales Invoice, the outstanding amount of payment schedule might | |
# not be updated. This will be the case if it doesn't use a **Payment | |
# Terms Template** with _Allocate Payment Based On Payment Terms_ | |
# enabled. In this case, we use the total outstanding amount from the | |
# Sales Invoice. | |
if source.payment_schedule and len(source.payment_schedule) == 1: | |
for row in target.overdue_payments: | |
if row.payment_schedule == source.payment_schedule[0].name: | |
row.outstanding = source.outstanding_amount |
version 15
fixes: #42605
Before:
before_dunning.mp4
After:
after_dunning.mp4