[#4477] Added FixedBudgets to the Deliverable finance form.

This commit is contained in:
Eric Davis
2010-09-09 17:06:35 -07:00
parent 07da5d98d8
commit feee5e8b43
9 changed files with 115 additions and 29 deletions
+1
View File
@@ -13,6 +13,7 @@ class Deliverable < ActiveRecord::Base
accepts_nested_attributes_for :labor_budgets
accepts_nested_attributes_for :overhead_budgets
accepts_nested_attributes_for :fixed_budgets
# Validations
validates_presence_of :title
+8
View File
@@ -7,6 +7,14 @@ class FixedBudget < ActiveRecord::Base
# Validations
# Accessors
def budget=(v)
if v.is_a? String
write_attribute(:budget, v.gsub(/[$ ,]/, ''))
else
write_attribute(:budget, v)
end
end
def markup_value
return 0 if budget.blank? || markup.blank?
+6
View File
@@ -83,6 +83,12 @@ class RetainerDeliverable < HourlyDeliverable
budgets
end
def fixed_budgets_for_date(date)
budgets = fixed_budgets.all(:conditions => {:year => date.year, :month => date.month})
budgets = [fixed_budgets.build(:year => date.year, :month => date.month)] if budgets.empty?
budgets
end
def labor_budget_total(date=nil)
case scope_date_status(date)
when :in