Move extra bills to credit cards
This commit is contained in:
parent
c14a408f9a
commit
0887a5f6b9
38 changed files with 242 additions and 251 deletions
5
app/models/credit_card_bill.rb
Normal file
5
app/models/credit_card_bill.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class CreditCardBill < ApplicationRecord
|
||||
def unpaid
|
||||
amount - Expense.credit_card_monthly_total
|
||||
end
|
||||
end
|
|
@ -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
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
class ExtraBill < ApplicationRecord
|
||||
def adjusted_amount
|
||||
deduct_autopaid? ? amount - Expense.autopaid_total : amount
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue