[#4182] Added an OverheadBudget to track a Deliverable's overhead.

This commit is contained in:
Eric Davis
2010-07-07 10:38:58 -07:00
parent fdd49642b2
commit b22db284c5
9 changed files with 105 additions and 7 deletions
+1
View File
@@ -2,6 +2,7 @@ module ContractsHelper
def setup_nested_deliverable_records(deliverable)
returning(deliverable) do |d|
d.labor_budgets.build if d.labor_budgets.empty?
d.overhead_budgets.build if d.overhead_budgets.empty?
end
end
end
+2
View File
@@ -5,8 +5,10 @@ class Deliverable < ActiveRecord::Base
belongs_to :contract
belongs_to :manager, :class_name => 'User', :foreign_key => 'manager_id'
has_many :labor_budgets
has_many :overhead_budgets
accepts_nested_attributes_for :labor_budgets
accepts_nested_attributes_for :overhead_budgets
# Validations
validates_presence_of :title
+18
View File
@@ -0,0 +1,18 @@
class OverheadBudget < ActiveRecord::Base
unloadable
# Associations
belongs_to :deliverable
# Validations
# Accessors
def budget=(v)
if v.is_a? String
write_attribute(:budget, v.gsub(/[$ ,]/, ''))
else
write_attribute(:budget, v)
end
end
end
+8 -1
View File
@@ -25,11 +25,18 @@
<% form.inputs :name => l(:text_deliverable_finances), :id => 'deliverable-finances' do %>
<% form.semantic_fields_for :labor_budgets do |labor_budget| %>
<% labor_budget.inputs :name => l(:field_labor) do %>
<% labor_budget.inputs :name => l(:field_labor), :id => 'deliverable-labor' do %>
<%= labor_budget.input :hours, :label => l(:text_short_hours), :input_html => {:size => 10} %>
<%= labor_budget.input :budget, :label => l(:text_dollar_sign), :input_html => {:size => 10} %>
<% end %>
<% end %>
<% form.semantic_fields_for :overhead_budgets do |overhead_budget| %>
<% overhead_budget.inputs :name => l(:field_overhead), :id => 'deliverable-overhead' do %>
<%= overhead_budget.input :hours, :label => l(:text_short_hours), :input_html => {:size => 10} %>
<%= overhead_budget.input :budget, :label => l(:text_dollar_sign), :input_html => {:size => 10} %>
<% end %>
<% end %>
<% end %>
<% end %>