Skip to content

Instantly share code, notes, and snippets.

@iloveitaly
Created March 29, 2019 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iloveitaly/bd2cf2b5eeba573ee5a2d024368f26a4 to your computer and use it in GitHub Desktop.
Save iloveitaly/bd2cf2b5eeba573ee5a2d024368f26a4 to your computer and use it in GitHub Desktop.
# https://stripe.com/docs/currencies#zero-decimal
ZERO_DECIMAL_CURRENCIES = %w(
BIF
CLP
DJF
GNF
JPY
KMF
KRW
MGA
PYG
RWF
VND
VUV
XAF
XOF
XPF
)
def zero_decimal_currency?(currency_iso)
ZERO_DECIMAL_CURRENCIES.include?(currency_iso.upcase)
end
def normalize_stripe_amount_for_netsuite(currency_iso, amount_in_cents)
if zero_decimal_currency?(currency_iso.upcase)
amount_in_cents.to_f
else
(BigDecimal.new(amount_in_cents) / 100.0).to_f
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment