1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-04 21:15:19 +02:00

Bug fixes for specialized account pages (#1275)

* Default for credit card fields

* Save institution on new account forms

* Fix property, vehicle, loan, credit card pages
This commit is contained in:
Zach Gollwitzer 2024-10-09 17:20:38 -04:00 committed by GitHub
parent b4d0fdbe0d
commit a2ab217925
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 26 additions and 13 deletions

View file

@ -3,12 +3,12 @@ class Loan < ApplicationRecord
def monthly_payment
return nil if term_months.nil? || interest_rate.nil? || rate_type.nil? || rate_type != "fixed"
return Money.new(0, account.currency) if account.original_balance.zero? || term_months.zero?
return Money.new(0, account.currency) if account.original_balance.amount.zero? || term_months.zero?
annual_rate = interest_rate / 100.0
monthly_rate = annual_rate / 12.0
payment = (account.original_balance * monthly_rate * (1 + monthly_rate)**term_months) / ((1 + monthly_rate)**term_months - 1)
payment = (account.original_balance.amount * monthly_rate * (1 + monthly_rate)**term_months) / ((1 + monthly_rate)**term_months - 1)
Money.new(payment.round, account.currency)
end