Skip to content

Formulary rounding fixes#899

Merged
labkey-martyp merged 1 commit intorelease24.11-SNAPSHOTfrom
24.11_fb_formulary_fixes
Mar 3, 2025
Merged

Formulary rounding fixes#899
labkey-martyp merged 1 commit intorelease24.11-SNAPSHOTfrom
24.11_fb_formulary_fixes

Conversation

@labkey-martyp
Copy link
Contributor

Rationale

A few fixes for formulary rounding

Changes

  • Fix conditional when amount rounding should be done
  • Update rounding to nearest function to handle floating point precision issues.
  • Allow greater precision in rounding field

}
let rounded = Math.round(val / round) * round;
let precision = (round.toString().split('.')[1] || "").length; // Get decimal places in `round`
return rounded.toFixed(precision); // toFixed handles floating point precision issues
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, good to know about toFixed().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

floating point is the worst

@labkey-martyp labkey-martyp merged commit b5a5ebc into release24.11-SNAPSHOT Mar 3, 2025
6 of 7 checks passed
@labkey-martyp labkey-martyp deleted the 24.11_fb_formulary_fixes branch March 3, 2025 21:35
@labkey-martyp labkey-martyp changed the title Formular rounding fixes Formulary rounding fixes Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants