app/models/applicant.rb
# returns an inumerable of incomes, aggregated by type and regardless of household member
returns an inumerable of incomes, aggregated by type and regardless of household member
returns an inumerable of incomes aggregated by type and regardless of household member
def incomes_by_type
    incomes = Hash.new(0)
    household_members.each do |member|
      member.incomes.each do |income|
        incomes[income.income_type_id] += income.amount
      end
    end
    Hash[incomes.map {|k, v| [IncomeType.find(k).label, v] }].sort_by {|k, v| v}.reverse
  end
def incomes_by_type incomes = Hash . new ( 0 ) household_members . each do | member | member . incomes . each do | income | incomes [ income . income_type_id ] += income . amount end end Hash [ incomes . map { | k , v | [ IncomeType . find ( k ) . label , v ] } ] . sort_by { | k , v | v } . reverse end
returns an inumerable of incomes, aggregated by type and regardless of household member
returns an inumerable of incomes aggregated by type and regardless of household member
# replace income type ID with Label value and sort in descending order