Skip to content

Fix return item initialization in backend - #6411

Merged
mamhoff merged 2 commits into
solidusio:mainfrom
SuperGoodSoft:fix-return-item-initialization
Feb 2, 2026
Merged

Fix return item initialization in backend#6411
mamhoff merged 2 commits into
solidusio:mainfrom
SuperGoodSoft:fix-return-item-initialization

Conversation

@forkata

@forkata forkata commented Jan 28, 2026

Copy link
Copy Markdown
Contributor

Summary

This change resolves two separate issues on multi-currency stores where return items display_* methods would not correctly get the currency and fallback to the store configured currency.

By making ReturnItem#currency public we resolved an issue with how the DisplayMoney concern test if the class it's included in defines the currency method. The current code uses respond_to? which only checks for public methods. We didn't change that behaviour but we could also use the extended form and check all visibility levels if that is preferred (i.e. respond_to?(:currency, true).

By associating non-persisted return items with the return authorization they are built for we can ensure that the display_* methods correctly get the currency from the return authorization (which delegates that to the order). In the previous implemetation that used the fallback defined in ReturnItem#currency and always used the store defaults.

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
forkata requested a review from a team as a code owner January 28, 2026 00:28
@github-actions github-actions Bot added changelog:solidus_backend Changes to the solidus_backend gem changelog:solidus_core Changes to the solidus_core gem labels Jan 28, 2026
@codecov

codecov Bot commented Jan 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.50%. Comparing base (76f15d2) to head (a570cc0).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6411   +/-   ##
=======================================
  Coverage   89.50%   89.50%           
=======================================
  Files         981      981           
  Lines       20479    20479           
=======================================
+ Hits        18329    18330    +1     
+ Misses       2150     2149    -1     

☔ 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.

@kennyadsl kennyadsl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍 Thanks for fixing these!

@tvdeyen tvdeyen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Worth a backport to 4.6 right?

forkata and others added 2 commits January 30, 2026 10:17
This fixes an issue with the `display_` money methods which require the
instance to define a public method for `#currency`. It seems like this
has been broken for a while, which meant the currency for `ReturnItem`s
would always use the store default configured currency.

Co-authored-by: Alistair Norman <alistair@super.gd>
This change ensures that return items built for a new return
authorization are correctly associated with it. This will ensure that
the display_* methods use the currency from the return authorization,
instead of the default store currency.

Co-authored-by: Alistair Norman <alistair@super.gd>
@tvdeyen
tvdeyen force-pushed the fix-return-item-initialization branch from f9581d5 to a570cc0 Compare January 30, 2026 09:17
@tvdeyen tvdeyen added the backport-v4.6 Backport this pull-request to v4.6 label Jan 30, 2026
@mamhoff mamhoff changed the title Fix return item inititialization in backend Fix return item initialization in backend Feb 2, 2026
@mamhoff
mamhoff merged commit 1db0767 into solidusio:main Feb 2, 2026
48 checks passed
@solidus-bot

solidus-bot Bot commented Feb 2, 2026

Copy link
Copy Markdown

💚 All backports created successfully

Status Branch Result
v4.6

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-v4.6 Backport this pull-request to v4.6 changelog:solidus_backend Changes to the solidus_backend gem changelog:solidus_core Changes to the solidus_core gem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants