https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43956
Martin Renvoize (ashimema) <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |43957 Blocks| |43959 --- Comment #1 from Martin Renvoize (ashimema) <[email protected]> --- Created attachment 210077 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210077&action=edit Bug 43956: Fix and unify Koha::Number::Price rounding round() used Math::BigFloat's default half-even mode and returned strings that could be "00" or "NaN", while format() rounded floats with Number::Format, so the two disagreed (0.825 gave 0.82 vs 0.83). round() now works on the decimal representation of the value, supports the modes half_even (default, as before), half_away_from_zero, half_up, half_down and half_odd plus an optional digits parameter, returns plain numbers (undef for non-numeric input); an unknown mode is logged via Koha::Logger and the default mode is used. format() and format_for_editing() round through the same engine, so they now also round half-even by default (-2.125 formats as -2.12). To test: 1. Apply the patch and run: prove t/Number/Price.t t/db_dependent/Prices.t t/db_dependent/Budgets.t 2. Confirm all pass, and that the new subtests in t/Number/Price.t fail without the patch. Visible change for librarians (prices that fall exactly half way between two cents, such as 0.125 or 2.675, are now rounded to the even cent every time, and the display agrees with the rounding used in calculations): 3. Set CurrencyFormat to US and make sure a currency is active. 4. Acquisitions > a vendor > new basket > add an order line manually. Use a quantity of 1, vendor price 10.125 and a second line with vendor price 10.135. 5. View the basket and the order lines. Prices should display as 10.12 and 10.14 (round half to even). Before the patch the display could differ from the value used when comparing prices (for example 10.125 displaying as 10.13). 6. Repeat step 5 with CurrencyFormat set to FR and check the separator changes (10,12) but the rounded value is the same. 7. Receive a shipment for one of the lines using an actual cost with three decimals, and check the invoice shows the same two decimal value as the basket would. 8. Sanity check: ordinary prices (3, 12.50, 1234567.89) display exactly as before. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43957 [Bug 43957] Add per-currency decimal digits and configurable rounding policy preferences https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43959 [Bug 43959] Cash-up reports false surplus or deficit when amounts contain fractions of a penny -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes. _______________________________________________ Koha-bugs mailing list -- [email protected] To unsubscribe send an email to [email protected] website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
