Skip to content
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

fix(common): calculate percentage to tenth decimal place #708

Merged
merged 2 commits into from
Jan 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/shared/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,17 +410,17 @@ $common.valueWithDefault = function valueWithDefault(variable, defaultValue) {
* function will return a percentage rounded to the tenth decimal place.
*/
$common.calcProgressPercent = function calcProgressPercent(total, completed) {
if (total > 0) {
if (completed >= total) {
// In something has already been completed (e.g. suppressed) and the completed value
// is greater than the total, return 100%
return 100;
} else if (total > 0) {
if (completed === 0) {
return 0;
} else {
let percentage = (completed / total) * 100;
return Math.round(percentage);
return Math.round(percentage * 10) / 10;
}
} else if (completed > total) {
// In something has already been completed (e.g. suppressed) and the completed value
// is greater than the total, return 100%
return 100;
}
return 0; // the absence of work does not imply progress.
};
Expand Down