Move extra bills to credit cards

This commit is contained in:
Andrew Tomaka 2023-03-03 18:12:59 -05:00
parent c14a408f9a
commit 0887a5f6b9
Signed by: atomaka
GPG key ID: 61209BF70A5B18BE
38 changed files with 242 additions and 251 deletions

View file

@ -0,0 +1,5 @@
class CreditCardBill < ApplicationRecord
def unpaid
amount - Expense.credit_card_monthly_total
end
end

View file

@ -19,7 +19,7 @@ class Expense < ApplicationRecord
Expense.all.map(&:monthly).sum.round(2)
end
def self.autopaid_total
Expense.where(autopaid: true).map(&:monthly).sum.round(2)
def self.credit_card_monthly_total
Expense.where(credit_card: true).map(&:monthly).sum.round(2)
end
end

View file

@ -1,5 +0,0 @@
class ExtraBill < ApplicationRecord
def adjusted_amount
deduct_autopaid? ? amount - Expense.autopaid_total : amount
end
end