-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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: split_invoices_based_on_payment_terms
#37859
fix: split_invoices_based_on_payment_terms
#37859
Conversation
- Invoices were in the wrong order due to the logic. The invoices with payment terms were added first and the rest after. - Overly long function with unnecessary loops (reduced to one main loop) and complexity - The split row as per payment terms was not ordered. So the second installment was allocated first
Codecov Report
@@ Coverage Diff @@
## develop #37859 +/- ##
===========================================
- Coverage 67.40% 67.39% -0.01%
===========================================
Files 757 757
Lines 60337 60375 +38
===========================================
+ Hits 40668 40688 +20
- Misses 19669 19687 +18
|
Sorry for bothering you again.
In general, this is indeed the expectation, so this PR definitely improves things. I would actually consider it a bugfix, name it accordingly, and make sure it’s backported, although refactoring may be part of the solution. However, there are quite many situation where the allocation order needs to be different:
While your PR does implement a sensible default, in followups we should iterate over this to simplify switching the allocation order or even to implement allocation rules. |
@bosue Sounds good. Unfortunately I don't have the bandwidth to take this up, but I'd suggest moving your suggestion to a separate issue where it can be tracked and worked on. Thanks for taking the effort :) |
A pleasure. Think we need a basic test to fail ahead of the bugfix while passing with it, and then this should be merged and backported. Probably even as “fix!” as it may break previous expectations. |
This comment was marked as resolved.
This comment was marked as resolved.
split_invoices_based_on_payment_terms
split_invoices_based_on_payment_terms
@marination This(allocating the oldest first) doesn't happen.
term_based_allocation.mp4 |
With adapted columns (added Due Date) it’s easier to spot. |
@ruthra-kumar I worded this wrongly. My apologies
What @bosue has shown in his last comment is the issue. The invoices are fetched as per due date but |
…effective test - Make invoice due dates are different so that the invoice with the earliest due date is allocated first in the test - Translate voucher type, simplify alert message. The invoice could be "split" into 1 row, no. of rows in the message seems unnecessary.
@bosue I'm personally not sure/very opinionated on what columns users would deem important although I agree with your suggestion. Let this be tackled in a separate PR/issue |
Ignoring unrelated test failure https://github.com/frappe/erpnext/actions/runs/6812843279/job/18526119760?pr=37859 |
…-37859 fix: `split_invoices_based_on_payment_terms` (#37859)
* refactor: `split_invoices_based_on_payment_terms` - Invoices were in the wrong order due to the logic. The invoices with payment terms were added first and the rest after. - Overly long function with unnecessary loops (reduced to one main loop) and complexity - The split row as per payment terms was not ordered. So the second installment was allocated first (cherry picked from commit 6bd56d2) * test: `get_outstanding_reference_documents` (triggered via UI) (cherry picked from commit 162c049) # Conflicts: # erpnext/accounts/doctype/payment_entry/test_payment_entry.py * fix: Alert message and make sure invoice due dates are different for effective test - Make invoice due dates are different so that the invoice with the earliest due date is allocated first in the test - Translate voucher type, simplify alert message. The invoice could be "split" into 1 row, no. of rows in the message seems unnecessary. (cherry picked from commit 56ac342) * style: Remove spaces introduced via merge conflict (cherry picked from commit 4b4b176) # Conflicts: # erpnext/accounts/doctype/payment_entry/test_payment_entry.py * fix: Re-add no.of rows split in alert message (cherry picked from commit 1fc5844) * fix: Merge conflicts in tests --------- Co-authored-by: marination <maricadsouza221197@gmail.com>
# [15.6.0](v15.5.0...v15.6.0) (2023-12-12) ### Bug Fixes * `split_invoices_based_on_payment_terms` (backport [#37859](#37859)) ([#38488](#38488)) ([4b76cc4](4b76cc4)) * 1st row depr. sch. value of asset put to less than 180 days acc. to I.T. S. 32 (backport [#38696](#38696)) ([#38703](#38703)) ([2bd9671](2bd9671)) * auto delete draft serial and batch bundle (backport [#38637](#38637)) ([#38654](#38654)) ([b0675f6](b0675f6)) * close PO on SCO close (backport [#38667](#38667)) ([#38681](#38681)) ([4055543](4055543)) * format only if searched text contain link value text ([d79e6e3](d79e6e3)) * get customers for leaderboard ([9d5c79d](9d5c79d)) * get items for leaderboard ([7cb38a8](7cb38a8)) * get sales partner for leaderboard ([3845d42](3845d42)) * get sales person for leaderboard ([2fcfebe](2fcfebe)) * get suppliers for leaderboard ([e205772](e205772)) * ignore non-existing regional customizations (backport [#38621](#38621)) ([#38624](#38624)) ([c70e6f2](c70e6f2)) * limit end date to current date ([dbdb971](dbdb971)) * negative batch issue (backport [#38688](#38688)) ([#38694](#38694)) ([a75081b](a75081b)) * not able to make serial and batch using csv import (backport [#38659](#38659)) ([#38662](#38662)) ([dd07eca](dd07eca)) * only highest eligible coupon applied ([#38416](#38416)) ([aa66ee6](aa66ee6)) * serial and batch bundle permission (backport [#38618](#38618)) ([#38619](#38619)) ([ce2bd15](ce2bd15)) * serial no filter in the Serial No Ledger report (backport [#38669](#38669)) ([#38682](#38682)) ([d188c8e](d188c8e)) * Shipping Address Link Showing in Buying (backport [#38634](#38634)) ([#38646](#38646)) ([4150ed9](4150ed9)) * show stock qty in popup (backport [#38698](#38698)) ([#38699](#38699)) ([6e2cde4](6e2cde4)) * typeerror on new sites ([#38692](#38692)) ([9239e73](9239e73)) * typo in unittest ([#38673](#38673)) ([14ee13c](14ee13c)) * **ux:** don't update qty blindly (backport [#38608](#38608)) ([#38639](#38639)) ([0b2e2a2](0b2e2a2)) ### Features * add employee number to client user bootinfo (backport [#38477](#38477)) ([#38603](#38603)) ([c7dbcbc](c7dbcbc))
Issues:
Before:
After:
Misc:
split_invoices_based_on_payment_terms
intoget_currency_data
andget_split_invoice_rows