[LSS#6684] Add the project activities only to the timesheet for the billable options

This commit is contained in:
Eric Davis
2011-11-14 16:17:16 -08:00
parent d2e96821bb
commit d574e522a9

View File

@@ -59,14 +59,18 @@ class OverheadTimesheetHook < Redmine::Hook::ViewListener
billable_options = context[:params][:timesheet][:billable]
activities = []
if billable_options.include?("billable")
activities << TimeEntryActivity.find_billable_activities
if billable_options.include?("billable") && context[:timesheet].projects.present?
context[:timesheet].projects.each do |project|
activities << project.billable_activities
end
end
if billable_options.include?("overhead")
activities << TimeEntryActivity.find_overhead_activities
if billable_options.include?("overhead") && context[:timesheet].projects.present?
context[:timesheet].projects.each do |project|
activities << project.non_billable_activities
end
end
# Overrides the activities directly
context[:timesheet].activities = activities.flatten.uniq.compact.collect(&:id).sort unless activities.empty?
end
end