diff --git a/src/views/account/AccountView.vue b/src/views/account/AccountView.vue index 122be5f..137574c 100644 --- a/src/views/account/AccountView.vue +++ b/src/views/account/AccountView.vue @@ -161,7 +161,7 @@ function monthlyInterestOf(loan) { return Math.round(Math.abs(loan.balance || 0) * (Number(loan.loanRate) / 100 / 12)) } -// 상환방식별 자동계산: 원금균등·만기일시는 납입금액 입력 불필요 +// 상환방식별 자동계산: 원금균등·만기일시·원리금균등(PMT) 모두 자동, 나머지만 수동 const loanAutoResult = computed(() => { const loan = repayTargetLoanWallet.value if (!loan) return null @@ -173,6 +173,14 @@ const loanAutoResult = computed(() => { const principal = Math.round(Number(loan.loanAmount) / loan.loanMonths) return { interest, principal, total: principal + interest, needsInput: false } } + if (loan.loanMethod === 'EQUAL_PAYMENT' && loan.loanAmount && loan.loanMonths && loan.loanRate) { + // PMT 공식: M = P × r(1+r)^n / ((1+r)^n − 1) + const r = Number(loan.loanRate) / 100 / 12 + const n = loan.loanMonths + const M = Math.round(Number(loan.loanAmount) * r * Math.pow(1 + r, n) / (Math.pow(1 + r, n) - 1)) + const principal = Math.max(0, M - interest) + return { interest, principal, total: M, needsInput: false } + } return { interest: null, principal: null, total: null, needsInput: true } })