diff --git a/app/models/member.rb b/app/models/member.rb index c8aad4b..6231711 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -1,5 +1,5 @@ class Member < ApplicationRecord - has_many :incomes + has_many :incomes, dependent: :destroy def income incomes.sum(&:amount) @@ -15,6 +15,8 @@ class Member < ApplicationRecord def burden_percent ((Income.total - others_included_income) / Income.total).round(2) + rescue + 0 end def burden_amount(total_amount: Expense.monthly_total)