[#4420] Adding Retainer calculation methods for specific dates.

This commit is contained in:
Eric Davis committed 2010-09-08 14:50:25 -07:00
1 parent 7ed21f7fe2
commit 0cc2523084
4 files changed
+111 -1

No files matched your search

+4
View File
@@ -58,6 +58,10 @@ class Deliverable < ActiveRecord::Base
labor_budgets.sum(:budget)
end
def labor_budget_total_for_date(date=nil) #Used on subclasses
labor_budget_total
end
def overhead_budget_total
overhead_budgets.sum(:budget)
end
+20
View File
@@ -31,6 +31,14 @@ class RetainerDeliverable < HourlyDeliverable
end_date && end_date.end_of_month.to_date
end
def date_range
(beginning_date..ending_date)
end
def within_date_range?(date)
date_range.include?(date)
end
def months
month_acc = []
@@ -67,6 +75,18 @@ class RetainerDeliverable < HourlyDeliverable
budgets
end
def labor_budget_total_for_date(date=nil)
if date
if within_date_range?(date)
labor_budgets.sum(:budget, :conditions => {:year => date.year, :month => date.month})
else
0 # outside of range
end
else
labor_budgets.sum(:budget)
end
end
def create_budgets_for_periods
# For each month in the time span
months.each do |month|