Skip to content

Add foreign key and handling for stock location deletion to customer returns - #6309

Merged
tvdeyen merged 3 commits into
solidusio:mainfrom
mamhoff:customer-return-dependent
Aug 5, 2025
Merged

Add foreign key and handling for stock location deletion to customer returns#6309
tvdeyen merged 3 commits into
solidusio:mainfrom
mamhoff:customer-return-dependent

Conversation

@mamhoff

@mamhoff mamhoff commented Jul 27, 2025

Copy link
Copy Markdown
Contributor

Summary

This PR adds a foreign key constraint such that all customer returns have a stock location ID that refers to an existing stock location. It also restricts deleting stock locations with customer returns present, as customer returns frequently also hold information about reimbursements and generally reflect real-life occurrences.

In order to provide an o-kay interface deleting a stock location with customer returns present:

grafik

(This is the legacy admin interface, solidus_admin does not have a button for deleting stock locations).

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.

@mamhoff
mamhoff requested a review from a team as a code owner July 27, 2025 21:12
@github-actions github-actions Bot added the changelog:solidus_core Changes to the solidus_core gem label Jul 27, 2025
@mamhoff
mamhoff force-pushed the customer-return-dependent branch from a778094 to a73417c Compare July 27, 2025 21:14
@codecov

codecov Bot commented Jul 27, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.31%. Comparing base (907bf8a) to head (3557e7a).
⚠️ Report is 27 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6309   +/-   ##
=======================================
  Coverage   89.31%   89.31%           
=======================================
  Files         959      959           
  Lines       20119    20119           
=======================================
  Hits        17970    17970           
  Misses       2149     2149           

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

mamhoff added 3 commits August 5, 2025 14:03
It's always been mandatory, so we can remove both the `optional: true`
and the presence validation.
Otherwise we can't be sure the stock location exists.
We have a foreign key here, but no `has_many` declaration. Because
customer returns are important, and potentially carry return items, this
needs to be present so we can present the user with a good error message
when trying to delete a stock location with existing customer returns.
@tvdeyen
tvdeyen force-pushed the customer-return-dependent branch from a73417c to 3557e7a Compare August 5, 2025 12:03
@tvdeyen
tvdeyen enabled auto-merge August 5, 2025 12:03
@tvdeyen tvdeyen added this to the 4.6 milestone Aug 5, 2025
@tvdeyen
tvdeyen merged commit b997d79 into solidusio:main Aug 5, 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

Projects

Development

Successfully merging this pull request may close these issues.

3 participants