Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialising Currency from ticker string does not set correct decimal_digits #254

Open
jall opened this issue Sep 12, 2023 · 0 comments · May be fixed by #316
Open

Initialising Currency from ticker string does not set correct decimal_digits #254

jall opened this issue Sep 12, 2023 · 0 comments · May be fixed by #316

Comments

@jall
Copy link

jall commented Sep 12, 2023

We're using version 0.5.1

from stockholm import Currency

c1 = Currency("RWF")
c1
# <stockholm.Currency: "RWF">
c1.decimal_digits
# 2

c2 = Currency.RWF
c2
# <stockholm.Currency: "RWF">
c2.decimal_digits
# 0

This causes a bug for us where 100x as much money was passed as intended

from stockholm import Money

t = Money("1673861354.00", "RWF")
t
# <stockholm.Money: "1673861354.00 RWF">

t.sub_units
# Decimal('167386135400')

int(t.sub_units)
# 167386135400

Workaround:

c3 = getattr(Currency, "RWF")
c3
# <stockholm.Currency: "RWF">
c3.decimal_digits
# 0
whiskeyriver pushed a commit to whiskeyriver/stockholm that referenced this issue Mar 21, 2024
When instantiating the Currency class we need to resolve a `str`
currency symbol to its definition class to preserve any attribute
overrides.

Resolves kalaspuff#254
@whiskeyriver whiskeyriver linked a pull request Mar 21, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant