fix(loan): 원리금균등 PMT 자동계산 — 납입금액 수동입력 불필요
Deploy / deploy (push) Failing after 11m34s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ByungCheol
2026-07-07 22:24:34 +09:00
parent 1ee264f2ab
commit fcd3f23a32
+9 -1
View File
@@ -161,7 +161,7 @@ function monthlyInterestOf(loan) {
return Math.round(Math.abs(loan.balance || 0) * (Number(loan.loanRate) / 100 / 12)) return Math.round(Math.abs(loan.balance || 0) * (Number(loan.loanRate) / 100 / 12))
} }
// 상환방식별 자동계산: 원금균등·만기일시는 납입금액 입력 불필요 // 상환방식별 자동계산: 원금균등·만기일시·원리금균등(PMT) 모두 자동, 나머지만 수동
const loanAutoResult = computed(() => { const loanAutoResult = computed(() => {
const loan = repayTargetLoanWallet.value const loan = repayTargetLoanWallet.value
if (!loan) return null if (!loan) return null
@@ -173,6 +173,14 @@ const loanAutoResult = computed(() => {
const principal = Math.round(Number(loan.loanAmount) / loan.loanMonths) const principal = Math.round(Number(loan.loanAmount) / loan.loanMonths)
return { interest, principal, total: principal + interest, needsInput: false } 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 } return { interest: null, principal: null, total: null, needsInput: true }
}) })