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

Fix money_only_cents for negative money #688

Merged

Conversation

bertiecroll
Copy link
Contributor

What/Why
When given negative money, money_only_cents view helper does not return the expected subunit value due to how modulo handles negative numbers.
For example: -125 % 100 = 75

What was done
To fix, I've updated the calculation to use the absolute value and added a new spec to cover the use case.

When given negative money, #money_only_cents does not return the expected subunit value due to how modulo handles negative numbers,
for example: -125 % 100 = 75

To fix, updates calculation to use absolute value.
sunny
sunny previously approved these changes Feb 17, 2024
Copy link
Contributor

@sunny sunny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! 🔥

spec/helpers/action_view_extension_spec.rb Outdated Show resolved Hide resolved
Co-authored-by: Sunny Ripert <sunny@sunfox.org>
@bertiecroll
Copy link
Contributor Author

Thanks for the quick review, I've added the suggested improvement 👍🏽

@semmons99
Copy link
Member

heads up. we have failing tests here.

@semmons99
Copy link
Member

ignore. I removed 2.6/2.7 from testing

@semmons99 semmons99 merged commit 72c3773 into RubyMoney:main Mar 13, 2024
1 check 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.

3 participants