[#6574] Add a TimeEntryActivity to OverheadBudgets

This commit is contained in:
Eric Davis
2011-09-15 10:38:16 -07:00
parent b3b7fa11b0
commit 33e07ee10b
8 changed files with 35 additions and 4 deletions

View File

@@ -171,7 +171,8 @@ module RedmineContracts
deliverable.overhead_budgets << OverheadBudget.new(:deliverable => deliverable,
:budget => old_deliverable['overhead'],
:hours => hours.to_f.round(2))
:hours => hours.to_f.round(2),
:time_entry_activity => first_non_billable_activity(deliverable.project))
elsif old_deliverable['overhead_percent'].present?
overhead = total * (old_deliverable['overhead_percent'].to_f / 100)
if @overhead_rate != 0
@@ -182,7 +183,8 @@ module RedmineContracts
deliverable.overhead_budgets << OverheadBudget.new(:deliverable => deliverable,
:budget => overhead,
:hours => hours.to_f.round(2))
:hours => hours.to_f.round(2),
:time_entry_activity => first_non_billable_activity(deliverable.project))
end
end
@@ -233,5 +235,9 @@ module RedmineContracts
def self.first_billable_activity(project)
project.billable_activities.first || TimeEntryActivity.first
end
def self.first_non_billable_activity(project)
project.non_billable_activities.first || TimeEntryActivity.first
end
end
end

View File

@@ -21,6 +21,12 @@ module RedmineContracts
activity.billable?
end.first
end
def non_billable_activities
activities.partition do |activity|
activity.billable?
end.second
end
end
end
end