Skip to content

Return BigDecimal from FlatRate zero branches#6507

Open
minhluuquang wants to merge 1 commit into
solidusio:mainfrom
minhluuquang:fix/calculator-flat-rate-bigdecimal
Open

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

Conversation

@minhluuquang

Copy link
Copy Markdown

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

1 participant