Skip to content

Return BigDecimal from FlatRate zero branches#6507

Merged
tvdeyen merged 1 commit into
solidusio:mainfrom
minhluuquang:fix/calculator-flat-rate-bigdecimal
Jul 4, 2026
Merged

Return BigDecimal from FlatRate zero branches#6507
tvdeyen merged 1 commit into
solidusio:mainfrom
minhluuquang:fix/calculator-flat-rate-bigdecimal

Conversation

@minhluuquang

Copy link
Copy Markdown
Contributor

Description

Fixes #3756.

Spree::Calculator::FlatRate#compute returned an integer 0 when called without an object, with a blank preferred currency, or with a currency mismatch. Calculator results are expected to be BigDecimal monetary amounts, so this changes those zero branches to return Spree::ZERO.

This also updates the Calculator YARD return type and adds specs covering the FlatRate zero branches.

Testing

  • bundle exec rspec spec/models/spree/calculator/flat_rate_spec.rb
  • bundle exec rspec spec/models/spree/calculator_spec.rb spec/models/spree/calculator
  • git diff --check

Checklist:

  • I have followed the Pull Request guidelines.
  • I have added a detailed description into the commit message.
  • Guides and README updates are not needed for this bug fix.
  • I have added tests to cover this change.
  • Screenshots are not applicable.

@minhluuquang minhluuquang requested a review from a team as a code owner June 29, 2026 09:00
@github-actions github-actions Bot added the changelog:solidus_core Changes to the solidus_core gem label Jun 29, 2026
@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.68%. Comparing base (8d781ac) to head (0302ec3).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6507   +/-   ##
=======================================
  Coverage   89.68%   89.68%           
=======================================
  Files         993      993           
  Lines       20863    20863           
=======================================
  Hits        18712    18712           
  Misses       2151     2151           

☔ View full report in Codecov by Harness.
📢 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.

@tvdeyen

tvdeyen commented Jul 4, 2026

Copy link
Copy Markdown
Member

Thanks. Linting issue is unreleased and already fixed in another PR

@tvdeyen tvdeyen merged commit 1ea53fc into solidusio:main Jul 4, 2026
38 of 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

None yet

Development

Successfully merging this pull request may close these issues.

Calculator should always return a BigDecimal, but in same scenarios that's not happening

3 participants