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

Register calculation for done_ratio in work package factory

Aaron Contreras9f84814923e5
diff --git a/spec/factories/work_package_factory.rb b/spec/factories/work_package_factory.rb
index f7794710995..2594e2a9bca 100644
--- a/spec/factories/work_package_factory.rb
+++ b/spec/factories/work_package_factory.rb
@@ -125,5 +125,12 @@ FactoryBot.define do
updated_at: work_package.journals.maximum(:updated_at))
end
end
+
+ callback(:after_build) do |work_package, _evaluator|
+ if work_package.estimated_hours.present? && work_package.remaining_hours.present?
+ work_package.done_ratio = (work_package.estimated_hours - work_package.remaining_hours) \
+ / work_package.estimated_hours * 100
+ end
+ end
end
end