Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Removes unwanted complexity from code
Before
Calling
passes through different code than
After
Information from the line_item array is 'lifted' early on and then the same loop is used.
Technical Details
Historically the code followed 2 loops - one for the (very rare) situation when an array of
'line_item' was passed in - in fact this array is an array of arrays where each array represents
the id of a line item and the amount to allocate.
The other loop is the main loop that allocates according to a calculation.
This fixes it so that the allocation is correctly merged in if passed in in
getPayableLineItems and from that point we only need one loop.
This simplification is tested via the testCreatePaymentLineItems
which I cleaned up and made more robust. I was able to step through it in #15685 and identify how
it was working
Comments
@kcristiano @monishdeb @pradpnayak can one of you look at this ? We merged one PR in this area relating to allocations but in our digging found other breakage - notably in the refund handling.
I want to get a few preliminary PRs merged - this one
#15640 & #15687 but I want all these fixes to hit 5.20