Skip to content

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

@jall

Description

@jall

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions