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:
parent
b4d0fdbe0d
commit
a2ab217925
10 changed files with 26 additions and 13 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue