Discountable amounts by adjustments
Summary
This PR changes the new promotion system to calculate discounts entirely via adjustments rather than using in-memory ItemDiscount objects.
The advantage of this approach is that it allows to a) calculate discountable amounts for line items outside of the DiscountOrder loop. This is useful for calculating discounted prices, a feature I have on the roadmap. It specifically covers needs like the one addressed in this commit. This way, we have one system of record, not two.
The other advantage is that we can remove the pretty complex PersistDiscountedOrder code, and just rely on order.save! to do the right thing.
It also dovetails nicely with the work on the in-memory order updater.
Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
- [x] I agree that my PR will be published under the same license as Solidus.
- [x] I have written a thorough PR description.
- [x] I have kept my commits small and atomic.
- [x] I have localized any and all user-facing strings that I added to the source code.
- [x] I have used clear, explanatory commit messages.
The following are not always needed:
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 89.50%. Comparing base (f8779d6) to head (e3c0bbf).
Additional details and impacted files
@@ Coverage Diff @@
## main #6371 +/- ##
==========================================
+ Coverage 89.48% 89.50% +0.01%
==========================================
Files 980 982 +2
Lines 20438 20485 +47
==========================================
+ Hits 18289 18335 +46
- Misses 2149 2150 +1
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.