Add extra bills tracking
This commit is contained in:
parent
a21639ff6f
commit
63487a9cba
22 changed files with 353 additions and 3 deletions
|
@ -14,4 +14,12 @@ class Expense < ApplicationRecord
|
|||
def self.total
|
||||
Expense.sum(&:payment)
|
||||
end
|
||||
|
||||
def self.monthly_total
|
||||
Expense.all.map(&:monthly).sum.round(2)
|
||||
end
|
||||
|
||||
def self.autopaid_total
|
||||
Expense.where(autopaid: true).map(&:monthly).sum.round(2)
|
||||
end
|
||||
end
|
||||
|
|
5
app/models/extra_bill.rb
Normal file
5
app/models/extra_bill.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class ExtraBill < ApplicationRecord
|
||||
def adjusted_amount
|
||||
deduct_autopaid? ? amount - Expense.autopaid_total : amount
|
||||
end
|
||||
end
|
|
@ -17,7 +17,7 @@ class Member < ApplicationRecord
|
|||
((Income.total - others_included_income) / Income.total).round(2)
|
||||
end
|
||||
|
||||
def burden_amount
|
||||
burden_percent * Expense.all.map(&:monthly).sum.round(2)
|
||||
def burden_amount(total_amount: Expense.monthly_total)
|
||||
burden_percent * total_amount
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue