From a0559b9515571640fa71e70f6bd3d45c3fc146ad Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Fri, 22 Mar 2024 14:14:36 +0100 Subject: [PATCH 1/2] Change USDC decimal places from 2 to 6 This fix can introduce a breaking change Before: ``` Money.new(100, "USDC").to_s => "1.00" ``` After: ``` Money.new(100, "USDC").to_s => "0.000100" ``` Close #1081 --- CHANGELOG.md | 2 +- config/currency_non_iso.json | 2 +- spec/money/formatting_spec.rb | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a661446471..d42541955d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Upcoming -- +- **Potential breaking change**: Fix USDC decimals places from 2 to 6 ## 6.19.0 diff --git a/config/currency_non_iso.json b/config/currency_non_iso.json index 3778e4ed44..75764fb02a 100644 --- a/config/currency_non_iso.json +++ b/config/currency_non_iso.json @@ -135,7 +135,7 @@ "disambiguate_symbol": "USDC", "alternate_symbols": [], "subunit": "Cent", - "subunit_to_unit": 100, + "subunit_to_unit": 1000000, "symbol_first": false, "html_entity": "$", "decimal_mark": ".", diff --git a/spec/money/formatting_spec.rb b/spec/money/formatting_spec.rb index 45ce525997..bed46ca8a0 100644 --- a/spec/money/formatting_spec.rb +++ b/spec/money/formatting_spec.rb @@ -858,7 +858,7 @@ expect(Money.new(1999_98, "NOK").format).to eq("1.999,98 kr") expect(Money.new(1999_98, "SEK").format).to eq("1 999,98 kr") expect(Money.new(1999_98, "BCH").format).to eq("0.00199998 ₿") - expect(Money.new(1999_98, "USDC").format).to eq("1,999.98 USDC") + expect(Money.new(1999_98, "USDC").format).to eq("0.199998 USDC") end it "returns ambiguous signs when disambiguate is false" do @@ -868,7 +868,7 @@ expect(Money.new(1999_98, "NOK").format(disambiguate: false)).to eq("1.999,98 kr") expect(Money.new(1999_98, "SEK").format(disambiguate: false)).to eq("1 999,98 kr") expect(Money.new(1999_98, "BCH").format(disambiguate: false)).to eq("0.00199998 ₿") - expect(Money.new(1999_98, "USDC").format(disambiguate: false)).to eq("1,999.98 USDC") + expect(Money.new(1999_98, "USDC").format(disambiguate: false)).to eq("0.199998 USDC") end it "returns disambiguate signs when disambiguate: true" do @@ -878,7 +878,7 @@ expect(Money.new(1999_98, "NOK").format(disambiguate: true)).to eq("1.999,98 NOK") expect(Money.new(1999_98, "SEK").format(disambiguate: true)).to eq("1 999,98 SEK") expect(Money.new(1999_98, "BCH").format(disambiguate: true)).to eq("0.00199998 ₿CH") - expect(Money.new(1999_98, "USDC").format(disambiguate: true)).to eq("1,999.98 USDC") + expect(Money.new(1999_98, "USDC").format(disambiguate: true)).to eq("0.199998 USDC") end it "returns disambiguate signs when disambiguate: true and symbol: true" do @@ -888,7 +888,7 @@ expect(Money.new(1999_98, "NOK").format(disambiguate: true, symbol: true)).to eq("1.999,98 NOK") expect(Money.new(1999_98, "SEK").format(disambiguate: true, symbol: true)).to eq("1 999,98 SEK") expect(Money.new(1999_98, "BCH").format(disambiguate: true, symbol: true)).to eq("0.00199998 ₿CH") - expect(Money.new(1999_98, "USDC").format(disambiguate: true, symbol: true)).to eq("1,999.98 USDC") + expect(Money.new(1999_98, "USDC").format(disambiguate: true, symbol: true)).to eq("0.199998 USDC") end it "returns no signs when disambiguate: true and symbol: false" do @@ -898,7 +898,7 @@ expect(Money.new(1999_98, "NOK").format(disambiguate: true, symbol: false)).to eq("1.999,98") expect(Money.new(1999_98, "SEK").format(disambiguate: true, symbol: false)).to eq("1 999,98") expect(Money.new(1999_98, "BCH").format(disambiguate: true, symbol: false)).to eq("0.00199998") - expect(Money.new(1999_98, "USDC").format(disambiguate: true, symbol: false)).to eq("1,999.98") + expect(Money.new(1999_98, "USDC").format(disambiguate: true, symbol: false)).to eq("0.199998") end it "should never return an ambiguous format with disambiguate: true" do From 5b02fc095bebb66bda2d14232972eb178c2d6e0b Mon Sep 17 00:00:00 2001 From: Shane Emmons <27679+semmons99@users.noreply.github.com> Date: Mon, 15 Apr 2024 08:36:03 -0400 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d42541955d..58cdb538da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## Upcoming +## Upcoming 7.0.0.alpha - **Potential breaking change**: Fix USDC decimals places from 2 to 6