[#4477] Added the amounts spent for FixedBudgets

This commit is contained in:
Eric Davis
2010-09-22 11:27:42 -07:00
parent d4de581b3c
commit 4a7484e1ea
9 changed files with 168 additions and 13 deletions
+9
View File
@@ -92,11 +92,20 @@ class Deliverable < ActiveRecord::Base
fixed_budgets.sum(:budget)
end
def fixed_budget_total_spent(date=nil)
fixed_budgets.paid.sum(:budget)
end
# OPTIMIZE: N+1
def fixed_markup_budget_total(date=nil)
fixed_budgets.inject(0) {|total, fixed_budget| total += fixed_budget.markup_value }
end
# OPTIMIZE: N+1
def fixed_markup_budget_total_spent(date=nil)
fixed_budgets.paid.inject(0) {|total, fixed_budget| total += fixed_budget.markup_value }
end
def filter_by_date(date=nil, &block)
block.call
end