Skip to content

Commit

Permalink
Merge pull request #12950 from macanudo527/unlock_bigdecimal
Browse files Browse the repository at this point in the history
Fix rounding issues by upgrading decimal maths library
  • Loading branch information
filipefurtad0 authored Nov 26, 2024
2 parents 7a2a6fa + 7a5074c commit a493d70
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ gem "active_model_serializers", "0.8.4"
gem 'activerecord-session_store'
gem 'acts-as-taggable-on'
gem 'angularjs-file-upload-rails', '~> 2.4.1'
gem 'bigdecimal', '3.0.2'
gem 'bigdecimal'
gem 'bootsnap', require: false
gem 'geocoder'
gem 'gmaps4rails'
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ GEM
base64 (0.2.0)
bcp47_spec (0.2.1)
bcrypt (3.1.20)
bigdecimal (3.0.2)
bigdecimal (3.1.8)
bindata (2.5.0)
bindex (0.8.1)
bootsnap (1.18.3)
Expand Down Expand Up @@ -865,7 +865,7 @@ DEPENDENCIES
angularjs-rails (= 1.8.0)
arel-helpers (~> 2.12)
aws-sdk-s3
bigdecimal (= 3.0.2)
bigdecimal
bootsnap
bugsnag
bullet
Expand Down
2 changes: 1 addition & 1 deletion app/services/variant_units/option_value_namer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def option_value_value_unit
def option_value_value_unit_scaled
unit_scale, unit_name = scale_for_unit_value

value = (@nameable.unit_value / unit_scale).to_d.truncate(2)
value = (@nameable.unit_value.to_d / unit_scale).round(2)

[value, unit_name]
end
Expand Down
3 changes: 2 additions & 1 deletion spec/lib/reports/sales_tax_totals_by_order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@
total = report.total_excl_tax(query_row)

# discounted order total - discounted order tax
expect(total).to eq((113.3 - 10) - (3.3 - 0.29))
# (113.3 - 10) - (3.3 - 0.29)
expect(total).to eq 100.29
end
end
end
Expand Down

0 comments on commit a493d70

Please sign in to comment.