vimeo / py-money

Money class for Python 3
MIT License
125 stars 27 forks source link

Allow constructing money from sub-units. #5

Closed raymondjavaxx closed 6 years ago

raymondjavaxx commented 6 years ago

Hi all,

I have added a pair of methods for working with sub-units that can come in handy for those storing money in sub units.

price = Money.from_sub_units(101, Currency.USD)  # $1.01 USD
total = price * 2
total.sub_units  # 202 (cents)

Thank you for crafting this library and reviewing this PR.

-R

nickyr commented 6 years ago

Looks great! Pulled it locally to run the tests and pylint and discovered that pylint is complaining about there being too many public methods in the test file now, which I think we should just ignore.

Could you add too-many-public-methods to the list here? https://github.com/vimeo/py-money/blob/4b6a06466c96e27e7137818d81947d9718bec83c/money/tests/test_money.py#L10

After that, I'll merge!

(Guess I should set up a travis build on this thing at some point...)

raymondjavaxx commented 6 years ago

Cool. I just added too-many-public-methods to the list.

nickyr commented 6 years ago

Release is up on PyPi as 0.3.0. LMK if it's not working for you, I had so many PyPi issues (as usual)