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

This commit is contained in:
Eric Davis committed 2010-09-17 14:15:08 -07:00
1 parent 081df7874d
commit 55c9f93c6c
2 files changed
+97

No files matched your search

+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