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

expect the unexpected: add a guard for TimeEntry.hours being nil

as-opd54952540479
diff --git a/modules/reporting/app/workers/cost_query/pdf/timesheet_generator.rb b/modules/reporting/app/workers/cost_query/pdf/timesheet_generator.rb
index 22c8f6161cc..8e8d4efb4fe 100644
--- a/modules/reporting/app/workers/cost_query/pdf/timesheet_generator.rb
+++ b/modules/reporting/app/workers/cost_query/pdf/timesheet_generator.rb
@@ -151,7 +151,7 @@ class CostQuery::PDF::TimesheetGenerator
{ content: format_date(spent_on), rowspan: entry.comments.present? ? 2 : 1 },
entry.work_package&.subject || "",
with_times_column? ? format_spent_on_time(entry) : nil,
- format_hours(entry.hours),
+ format_hours(entry.hours || 0),
entry.activity&.name || ""
].compact
end
@@ -428,7 +428,7 @@ class CostQuery::PDF::TimesheetGenerator
end
def format_hours(hours)
- return "" if hours < 0
+ return "" if hours.nil? || hours < 0
DurationConverter.output(hours)
end