Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When adding an adjustment which multiples by a percentage, the price can have a value of four decimal points. We need to implement a rounding of half up or half down line in 1.x
Comment | File | Size | Author |
---|---|---|---|
#5 | implement_rounding-2807537-5.patch | 5.07 KB | mglaman |
Comments
Comment #2
bojanz CreditAttribution: bojanz at Centarro commentedWe need a round($precision, $mode) method on the price object which invokes a method on the Calculator.
This separates the rounding from multiplication/division, which feels like better DX than rounding implicitly and adding additional $precision parameters to multiply/divide.
https://github.com/moneyphp/money/blob/master/src/Calculator/BcMathCalcu... has good examples of bcmath based rounding.
Question: Is $digits better than $precision?
Comment #3
mglamanPrecision. That's what it's called everywhere when it comes to rounding.
Comment #4
mglamanComment #5
mglamanAdded bcmath based rounding. Added unit tests for Calculator and Price object.
Comment #7
bojanz CreditAttribution: bojanz at Centarro commentedMany iterations later...