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

add protomoney Sub fix #72

Merged
merged 2 commits into from
Aug 8, 2024
Merged

add protomoney Sub fix #72

merged 2 commits into from
Aug 8, 2024

Conversation

sameaste92
Copy link

What change does this introduce?

fix subtraction errors in Sub func in protomoney pkg

Why make this change?

currently the below example will panic

FortyDollarsUSD := &money.Money{
	CurrencyCode: "USD",
	Units:        40,
	Nanos:        0,
}
FiftyCentsUSD := &money.Money{
	CurrencyCode: "USD",
	Units:        0,
	Nanos:        500_000_000,
}

value := protomoney.Sub(FortyDollarsUSD, FiftyCentsUSD)

Is there anything you are unsure about?

Originally I had converted a and b to Amounts within the Sub() func.

But was unsure if we were avoiding that as no other math funcs use the main dosh pkg 🤷‍♂️

What issues does this relate to?

Maths is broken

protomoney/math_test.go Outdated Show resolved Hide resolved
@sameaste92 sameaste92 requested a review from koden-km August 8, 2024 02:26
@jmalloc jmalloc merged commit e22e107 into dogmatiq:main Aug 8, 2024
4 checks passed
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.

4 participants