class Member < ApplicationRecord has_many :incomes def income incomes.sum(&:amount) end def included_income incomes.where(included: true).sum(&:amount) end def others_included_income Income.where(included: true) - included_income end def burden_percent (Income.total - others_included_income) / Income.total end def burden_amount burden_percent * Expense.total end end