Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#67706] Display float values with a precision of 3

Tobias Dillmann1c5f7f8a5e03
diff --git a/app/models/custom_value/calculated_value_strategy.rb b/app/models/custom_value/calculated_value_strategy.rb
index 153890ca9f1..aadc40ee88c 100644
--- a/app/models/custom_value/calculated_value_strategy.rb
+++ b/app/models/custom_value/calculated_value_strategy.rb
@@ -38,7 +38,15 @@ class CustomValue::CalculatedValueStrategy < CustomValue::FormatStrategy
end
def formatted_value
- integer_value? ? value.to_s : number_with_delimiter(value.to_s)
+ return "" if value.blank?
+
+ if integer_value?
+ number_with_delimiter(value.to_i)
+ else
+ number_with_delimiter(
+ number_with_precision(value.to_f, precision: 3, strip_insignificant_zeros: true)
+ )
+ end
end
def validate_type_of_value