Skip to content

Commit

Permalink
format numbers with 6 significant digits
Browse files Browse the repository at this point in the history
  • Loading branch information
nudded committed Sep 30, 2024
1 parent a8c3a93 commit b136f32
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/views/helpers/money_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ def self.format(money)
end

def self.format_with_precision(amount_cents, currency)
amount_cents = if amount_cents < 1
BigDecimal("%.6g" % amount_cents.frac)
else
amount_cents.round(6)
end

Utils::MoneyWithPrecision.from_amount(amount_cents, currency).format(
format: I18n.t('money.format'),
decimal_mark: I18n.t('money.decimal_mark'),
Expand Down

0 comments on commit b136f32

Please sign in to comment.