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

CommentFileSizeAuthor
#5 implement_rounding-2807537-5.patch5.07 KBmglaman
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mglaman created an issue. See original summary.

bojanz’s picture

Title: Prices are not rounded. » Implement rounding
Category: Bug report » Task
Priority: Normal » Major

We 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?

mglaman’s picture

Precision. That's what it's called everywhere when it comes to rounding.

mglaman’s picture

Assigned: Unassigned » mglaman
mglaman’s picture

Status: Active » Needs review
FileSize
5.07 KB

Added bcmath based rounding. Added unit tests for Calculator and Price object.

  • bojanz authored ff11b99 on 8.x-2.x
    Issue #2807537 by mglaman, bojanz: Implement rounding (#562)
    
    
bojanz’s picture

Status: Needs review » Fixed

Many iterations later...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.