- 가계부에서 원리금균등 대출 선택 시 최초원금 PMT 추정값(옛 방식) 대신 저장된 월 상환금을 그대로 사용 → 은행/상환표와 일치 - 잔액이 작은 마지막 회차는 원금을 잔액까지만(초과 상환 방지) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -173,13 +173,23 @@ 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) {
|
if (loan.loanMethod === 'EQUAL_PAYMENT') {
|
||||||
|
// 월 상환금이 저장돼 있으면 그대로 사용(은행과 일치) → 없으면 원금·개월수로 PMT 추정
|
||||||
|
let M = null
|
||||||
|
if (loan.loanPayment) {
|
||||||
|
M = Number(loan.loanPayment)
|
||||||
|
} else if (loan.loanAmount && loan.loanMonths && loan.loanRate) {
|
||||||
// PMT 공식: M = P × r(1+r)^n / ((1+r)^n − 1)
|
// PMT 공식: M = P × r(1+r)^n / ((1+r)^n − 1)
|
||||||
const r = Number(loan.loanRate) / 100 / 12
|
const r = Number(loan.loanRate) / 100 / 12
|
||||||
const n = loan.loanMonths
|
const n = loan.loanMonths
|
||||||
const M = Math.round(Number(loan.loanAmount) * r * Math.pow(1 + r, n) / (Math.pow(1 + r, n) - 1))
|
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 }
|
if (M != null) {
|
||||||
|
// 마지막 회차 등 잔액이 작을 땐 원금을 잔액까지만(초과 상환 방지)
|
||||||
|
const bal = Math.abs(Number(loan.balance) || 0)
|
||||||
|
const principal = Math.min(Math.max(0, M - interest), bal)
|
||||||
|
return { interest, principal, total: principal + interest, needsInput: false }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return { interest: null, principal: null, total: null, needsInput: true }
|
return { interest: null, principal: null, total: null, needsInput: true }
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user