Skip to content

Fix formatLocaleNumericRoundedByCurrency #18409

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

Merged
merged 1 commit into from
Sep 8, 2020

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

The function was rounding by a max of 2 regardless of the number of places passed - it
was only tested for 2 so seemed to work

Before

Regardless of the value of $numberOfPlaces it is always rounded to 2

 protected static function formatLocaleNumericRounded($amount, $numberOfPlaces) {

After

Rounds to actual number of places

Technical Details

This is the function fix pulled out of #18297

In ^^ there was an example which didn't work - the issue is at the php layer - the value is truncated by php & we won't resolve that without implementing brickmoney but it seems reasonable to leave out of scope

See how hard coded amount is passed directly to a function

Screen Shot 2020-09-09 at 7 47 37 AM

But it's received differently in the functionn

Screen Shot 2020-09-09 at 7 47 45 AM

The total string length seems to matter - one less character at the beginning is one less at the end
Screen Shot 2020-09-09 at 7 53 39 AM

Comments

@civibot
Copy link

civibot bot commented Sep 8, 2020

(Standard links)

@civibot civibot bot added the master label Sep 8, 2020
The function was rounding by a max of 2 regardless of the number of places passed - it
was only tested for 2 so seemed to work
@seamuslee001
Copy link
Contributor

Looks fine to me merge on pass

@seamuslee001 seamuslee001 merged commit fae7115 into civicrm:master Sep 8, 2020
@seamuslee001 seamuslee001 deleted the j branch September 8, 2020 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants