[#6574] Associate LaborBudgets with TimeEntryActivities

This commit is contained in:
Eric Davis
2011-09-14 18:39:49 -07:00
parent 38c22e2f92
commit df61a1fe9e
10 changed files with 34 additions and 2 deletions

View File

@@ -103,7 +103,8 @@ module RedmineContracts
if old_deliverable['total_hours'].present? || old_deliverable['cost_per_hour'].present?
deliverable.labor_budgets << LaborBudget.new(:deliverable => deliverable,
:budget => @total_cost,
:hours => old_deliverable['total_hours'])
:hours => old_deliverable['total_hours'],
:time_entry_activity => first_billable_activity(project))
end
else
@total_cost = 0
@@ -228,5 +229,9 @@ module RedmineContracts
def self.append_old_deliverable_to_notes(old_deliverable, new_deliverable)
new_deliverable.notes += "Converted data:\n<pre>" + old_deliverable.pretty_inspect + "</pre>"
end
def self.first_billable_activity(project)
project.billable_activities.first || TimeEntryActivity.first
end
end
end

View File

@@ -16,6 +16,11 @@ module RedmineContracts
end
module InstanceMethods
def billable_activities
activities.partition do |activity|
activity.billable?
end.first
end
end
end
end