RubyMoney / money-rails

Integration of RubyMoney - Money with Rails
MIT License
1.79k stars 386 forks source link

Fix money_only_cents for negative money #688

Closed bertiecroll closed 6 months ago

bertiecroll commented 7 months ago

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.

bertiecroll commented 7 months ago

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

semmons99 commented 6 months ago

heads up. we have failing tests here.

semmons99 commented 6 months ago

ignore. I removed 2.6/2.7 from testing