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

feat: split money into parts #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

barredterra
Copy link

@barredterra barredterra commented Dec 17, 2024

Add a method to easily split a Money object into a number of parts, ensuring that the sum of the parts equals the original amount:

>>> Money('10.00', 'USD').split(3)
[Money(3.34, "USD"), Money(3.33, "USD"), Money(3.33, "USD")]

>>> sum(Money('10', 'USD').split(3)) == Money('10', 'USD')
True

Note that the precision of the split amounts will be the same as the original amount.

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 this pull request may close these issues.

1 participant