Skip to content
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: Recalculate payment amounts instead of refetching the schedule. #38044

Closed

Conversation

bosue
Copy link
Contributor

@bosue bosue commented Nov 11, 2023

Fixes #38030.

Reverts #35007 while still fixing the issue reported there.

Reverts #35285 while still fixing the issue reported there.

Also reverts #36440. Unsure whether allocate_payment_based_on_payment_terms is useful at all – either you have a schedule and allocate accordingly or you don’t. But even if turned off, we need the payment schedule to be correct. Otherwise we needed to clear the schedule altogether.

Last mostly correct commit was #34872, but we need to doublecheck if every single of the later reported cases are still covered.

Definitely needs more test cases and optimally some feedback by @ruthra-kumar, @GursheenK, and/or @deepeshgarg007.

@github-actions github-actions bot added accounts needs-tests This PR needs automated unit-tests. labels Nov 11, 2023
@bosue bosue force-pushed the fix_recalculating_payment_schedule branch from bb20473 to c084a06 Compare November 11, 2023 10:15
Copy link

codecov bot commented Nov 11, 2023

Codecov Report

Merging #38044 (c084a06) into develop (8d9f391) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head c084a06 differs from pull request most recent head 479a824. Consider uploading reports for the commit 479a824 to get more accurate results

@@             Coverage Diff             @@
##           develop   #38044      +/-   ##
===========================================
- Coverage    67.39%   67.39%   -0.01%     
===========================================
  Files          757      757              
  Lines        60379    60376       -3     
===========================================
- Hits         40692    40689       -3     
  Misses       19687    19687              
Files Coverage Δ
erpnext/controllers/accounts_controller.py 84.81% <100.00%> (-0.03%) ⬇️

@bosue bosue marked this pull request as draft November 11, 2023 10:36
@bosue
Copy link
Contributor Author

bosue commented Nov 11, 2023

Marked as draft as we need additional tests. First I will reinstate Gursheen‘s test from #36440.

Besides that, please review.

Also consider #38031: There may be a point in removing allocate_payment_based_on_payment_terms altogether. You either have a Payment Schedule and make sure payments are allocated accordingly. Or you don‘t.

And #38029: When the Sales Order already has a Payment Schedule, it‘s hard to imagine why you wouldn‘t preserve it in the Sales Invoice.

Simplifying the logic here would reduce complexity both in code and in the UI:

  1. If the Sales Order has a Payment Schedule, always fetch it in the Sales Invoice
  2. If it doesn‘t, always fetch the customer’s default template.
  3. If you end up with an invalid Payment Schedule, always fix it.
  4. If you end up with a valid Payment Schedule, always use it.
  5. Otherwise go ahead without a Payment Schedule.

@bosue bosue force-pushed the fix_recalculating_payment_schedule branch from c084a06 to 89d9fcd Compare November 11, 2023 11:40
@bosue
Copy link
Contributor Author

bosue commented Nov 11, 2023

Gursheen‘s test still fails. Need to look into what exactly is expected there and why, and add more testing.
The above questions aren‘t diminished by that, so nonetheless pls review.

Copy link

stale bot commented Nov 27, 2023

This pull request has been automatically marked as inactive because it has not had recent activity. It will be closed within 3 days if no further activity occurs, but it only takes a comment to keep a contribution alive :) Also, even if it is closed, you can always reopen the PR when you're ready. Thank you for contributing.

@stale stale bot added the inactive label Nov 27, 2023
@stale stale bot closed this Nov 30, 2023
@bosue
Copy link
Contributor Author

bosue commented Nov 30, 2023

I still think both my assessment and the solution was correct, but apologize for putting you guys off with a premature PR. Will only reopen once fully investigated.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accounts inactive needs-tests This PR needs automated unit-tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autofetch Payment Terms clears Terms Template
2 participants