app/models/service.rb
def total_allocation_within_group(group, year, allocation_precision)
    total_allocation = 0.0
    total_headcount = 0.0
    EmployeeAllocation.joins(:employee => :groups
                     ).where(:service_id => self.id, :fiscal_year_id => year.id, 
                             :groups => {:id => group.id}
                     ).each do |employee_allocation|
      total_allocation += employee_allocation.allocation
      total_headcount += 1
    end
    return ["#{self.name}", total_allocation.round(allocation_precision), total_headcount]
  end
# Returns an array which contains the name of this service, and the total allocation for this
# service within the given group. The total allocation is rounded to one decimal.
Returns an array which contains the name of this service, and the total allocation for this
service within the given group. The total allocation is rounded to one decimal.
Returns an array which contains the name of this service and the total allocation for this service within the given group . The total allocation is rounded to one decimal .
def total_allocation_within_group(group, year, allocation_precision)
    total_allocation = 0.0
    total_headcount = 0.0
    EmployeeAllocation.joins(:employee => :groups
                     ).where(:service_id => self.id, :fiscal_year_id => year.id, 
                             :groups => {:id => group.id}
                     ).each do |employee_allocation|
      total_allocation += employee_allocation.allocation
      total_headcount += 1
    end
    return ["#{self.name}", total_allocation.round(allocation_precision), total_headcount]
  end
def total_allocation_within_group ( group , year , allocation_precision ) total_allocation = 0.0 total_headcount = 0.0 EmployeeAllocation . joins ( :employee => :groups ) . where ( :service_id => self . id , :fiscal_year_id => year . id , :groups => { :id => group . id } ) . each do | employee_allocation | total_allocation += employee_allocation . allocation total_headcount += 1 end return [ "#{self.name}" , total_allocation . round ( allocation_precision ) , total_headcount ] end
Returns an array which contains the name of this service, and the total allocation for this
service within the given group.
Returns an array which contains the name of this service and the total allocation for this service within the given group .
group
year
allocation_precision