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

Refactor Line Item Total Calculations #6080

Merged

Conversation

jarednorman
Copy link
Member

Summary

This is related to #5872, but it is not a functional change. It refactors the existing order updater to use a class that we created for the in-memory order updater. The goal here is just to reduce the scope of that PR, though it's also a small design improvement.

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

@jarednorman jarednorman requested a review from a team as a code owner January 17, 2025 22:26
@github-actions github-actions bot added the changelog:solidus_core Changes to the solidus_core gem label Jan 17, 2025
@jarednorman jarednorman force-pushed the refactor-line-item-total-updates branch from c3214bb to 9a82ff7 Compare January 17, 2025 22:29
@fthobe
Copy link
Contributor

fthobe commented Jan 19, 2025

Hey @jarednorman

Do you think also #1837 could be tackled in #5872 .

Think what you are doing here will also reduce testing time significantly which is also great.

If not we would like to align with you and dedicate some resources to fix #1837 already on your new model.

@jarednorman
Copy link
Member Author

We are not looking to make additional functional changes as part of #5872, but it's likely that it will be easier to fix #1837 once we've completed this work.

@fthobe
Copy link
Contributor

fthobe commented Jan 20, 2025

Ok, when you finished #5872 if you like @shahmayur001 can take a look at #1837

@adammathys adammathys force-pushed the refactor-line-item-total-updates branch from 9a82ff7 to 15dac06 Compare January 30, 2025 19:10
@github-actions github-actions bot added the changelog:solidus_legacy_promotions Changes to the solidus_legacy_promotions gem label Jan 30, 2025
Copy link

codecov bot commented Jan 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.70%. Comparing base (ca1ae4d) to head (7a3bfc2).
Report is 14 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6080      +/-   ##
==========================================
- Coverage   92.42%   88.70%   -3.73%     
==========================================
  Files         389      830     +441     
  Lines        8005    17998    +9993     
==========================================
+ Hits         7399    15965    +8566     
- Misses        606     2033    +1427     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I really like that we make solidus more composable. Can we make this a configuration then to fulfil the goal completely?

core/app/models/spree/item_total.rb Outdated Show resolved Hide resolved
core/app/models/spree/order_updater.rb Outdated Show resolved Hide resolved
jarednorman and others added 2 commits January 31, 2025 08:15
While working on the in-memory updater in solidusio#5872, we found the need to
change how item totals were being calculated, so that we could mark
adjustments for destruction without actually destroying them, while
still keeping tax adjustments intact. This change is completely
backwards-compatible with the current OrderUpdater, so to reduce the
scope of our PR, we wanted to make this change separately.

Since the OrderUpdater is already very large, this helps reduce its
responsibilities and makes it easier to test this behaviour. We don't
see it as necessary to make this a configurable class, but this change
leaves that option open in the future.

Co-authored-by: Adam Mueller <[email protected]>
Co-authored-by: Alistair Norman <[email protected]>
Co-authored-by: Chris Todorov <[email protected]>
Co-authored-by: Harmony Bouvier <[email protected]>
Co-authored-by: Sofia Besenski <[email protected]>
Co-authored-by: benjamin wil <[email protected]>
I don't know if there's all that much customizing people will perform on
this class, but it's easy enough to make it configurable just in case.
@adammathys adammathys force-pushed the refactor-line-item-total-updates branch from 15dac06 to 7a3bfc2 Compare January 31, 2025 16:24
@adammathys adammathys requested a review from tvdeyen January 31, 2025 16:27
Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super good

@fthobe
Copy link
Contributor

fthobe commented Feb 10, 2025

@kennyadsl can we merge this, it seems to be universally approved.

Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, just left a question, but I'm good with the PR as is. 🙏

core/app/models/spree/order_updater.rb Show resolved Hide resolved
@jarednorman jarednorman merged commit 95a9ea8 into solidusio:main Feb 11, 2025
17 of 18 checks passed
@jarednorman jarednorman deleted the refactor-line-item-total-updates branch February 11, 2025 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:solidus_core Changes to the solidus_core gem changelog:solidus_legacy_promotions Changes to the solidus_legacy_promotions gem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants