Skip to content

Conversation

@forkata
Copy link
Contributor

@forkata forkata commented Nov 26, 2025

Summary

This change builds on the work in #6382 and depends on that to work correctly. The first two commits here are from #6382 and will be rebased out once that has been merged.

These were extracted from #5872 to make that PR smaller and easier to review.

This change refactors how we build discounted items and allows the order updater
to correctly update their totals.

This change also adds some test coverage and assertions for the legacy promotion system to ensure we don't introduce unnecessary writes to the database in the future.

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.

forkata and others added 2 commits November 25, 2025 15:37
Instead of destroying.

See code comments and spec changes. This is similar to how we handled
this in the legacy promotion system.

Co-authored-by: Adam Mueller <adam@super.gd>
Co-authored-by: Alistair Norman <alistair@super.gd>
Co-authored-by: An Stewart <andrew@super.gd>
Co-authored-by: benjamin wil <benjamin@super.gd>
Co-authored-by: Harmony Evangelina <harmony@super.gd>
Co-authored-by: Jared Norman <jared@super.gd>
Co-authored-by: Nick Van Doorn <nick@super.gd>
Co-authored-by: Senem Soy <senem@super.gd>
Co-authored-by: Sofia Besenski <sofia@super.gd>
When computing item totals after a line item benefit is removed, we need
to ensure we aren't using the marked for destruction items.

We also needed to make a change to the legacy promotion order updater
patch because it is incorrectly being used in our tests even when using
the new promotion system. It also did not have logic to ensure
adjustments that were marked for destruction were ignored in the
adjustment totals calculation.

Co-authored-by: Jared Norman <jared@super.gd>
Co-authored-by: Noah Silvera <noah@super.gd>
Co-authored-by: Alistair Norman <alistair@super.gd>
@forkata forkata requested a review from a team as a code owner November 26, 2025 00:10
@github-actions github-actions bot added changelog:solidus_core Changes to the solidus_core gem changelog:solidus_legacy_promotions Changes to the solidus_legacy_promotions gem changelog:solidus_promotions Changes to the solidus_promotions gem labels Nov 26, 2025
@codecov
Copy link

codecov bot commented Nov 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.45%. Comparing base (54511c8) to head (64ecee0).
⚠️ Report is 15 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6385   +/-   ##
=======================================
  Coverage   89.45%   89.45%           
=======================================
  Files         974      974           
  Lines       20322    20323    +1     
=======================================
+ Hits        18179    18180    +1     
  Misses       2143     2143           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@forkata forkata force-pushed the build-discounted-item-benefit-in-memory branch from f6444c3 to 91f7ddd Compare November 26, 2025 00:14
Noah-Silvera and others added 3 commits November 25, 2025 16:26
As part of the work to move towards reducing database writes, this
change attempts to build discounted item benefits in-memory and allow
the order updater to recalculate their totals correctly.

Co-authored-by: Adam Mueller <adam@super.gd>
Co-authored-by: Alistair Norman <alistair@super.gd>
Co-authored-by: Andrew Stewart <andrew@super.gd>
Co-authored-by: benjamin wil<benjamin@super.gd>
Co-authored-by: Chris Todorov  <chris@super.gd>
Co-authored-by: Harmony Bouvier <harmony@super.gd>
Co-authored-by: Jared Norman <jared@super.gd>
Co-authored-by: Nick Van Doorn <nick@super.gd>
Co-authored-by: Noah Silvera <noah@super.gd>
Co-authored-by: Senem Soy <senem@super.gd>
Co-authored-by: Sofia Besenski <sofia@super.gd>
In an associated change we made the `CreateDiscountedItem` benefit
create in-memory line items. That causes an issue during the
recalculation of the item totals.

Co-authored-by: benjamin wil <benjamin@super.gd>
Co-authored-by: Kendra Riga <kendra@super.gd>
Co-authored-by: Noah Silvera <noah@super.gd>
Co-authored-by: Jared Norman <jared@super.gd>
Co-authored-by: Alistair Norman <alistair@super.gd>
We want to make sure we don't persist anything when computing amounts
becuase that will cause issues with the in-memory order updater.
@forkata forkata force-pushed the build-discounted-item-benefit-in-memory branch from 91f7ddd to 64ecee0 Compare November 26, 2025 00:28
Copy link
Contributor

@mamhoff mamhoff left a comment

Choose a reason for hiding this comment

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

❤️

@mamhoff
Copy link
Contributor

mamhoff commented Nov 26, 2025

I do have a suggestion for the PR title: build discounted line items in memory - Benefits are the successor to promotion actions.

Copy link
Member

@spaghetticode spaghetticode left a comment

Choose a reason for hiding this comment

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

👏

@forkata forkata changed the title Build discounted item benefits in memory Build discounted linte items in memory Nov 26, 2025
@tvdeyen tvdeyen added this to the 4.7 milestone Nov 27, 2025
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.

Amazing mob programming work 👏🏻

@tvdeyen tvdeyen merged commit 4286a2a into solidusio:main Nov 27, 2025
39 checks passed
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 changelog:solidus_promotions Changes to the solidus_promotions gem

Projects

Development

Successfully merging this pull request may close these issues.

7 participants