[#4477] Change Retainers to scope #fixed_budget_total and #fixed_markup_budget_total by date

This commit is contained in:
Eric Davis
2010-09-17 14:15:08 -07:00
parent 081df7874d
commit 55c9f93c6c
2 changed files with 97 additions and 0 deletions
+23
View File
@@ -122,6 +122,29 @@ class RetainerDeliverable < HourlyDeliverable
end
end
def fixed_budget_total(date=nil)
case scope_date_status(date)
when :in
fixed_budgets.sum(:budget, :conditions => {:year => date.year, :month => date.month})
when :out
0
else
super
end
end
def fixed_markup_budget_total(date=nil)
case scope_date_status(date)
when :in
fixed_budgets.
all(:conditions => {:year => date.year, :month => date.month}).
inject(0) {|total, fixed_budget| total += fixed_budget.markup_value }
when :out
0
else
super
end
end
def total_spent(date=nil)
case scope_date_status(date)
when :in