From ba7ffaff92aa9c1d7840d7d171b7e4dbc8626706 Mon Sep 17 00:00:00 2001 From: sb Date: Tue, 7 Jul 2026 23:42:33 +0900 Subject: [PATCH] =?UTF-8?q?fix(entry):=20=EB=8C=80=EC=B6=9C=20=EC=83=81?= =?UTF-8?q?=ED=99=98=20=EC=9E=90=EB=8F=99=EC=84=B8=ED=8C=85=EC=97=90=20?= =?UTF-8?q?=EC=9B=94=20=EC=83=81=ED=99=98=EA=B8=88(loanPayment)=20?= =?UTF-8?q?=EC=9A=B0=EC=84=A0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 가계부에서 원리금균등 대출 선택 시 최초원금 PMT 추정값(옛 방식) 대신 저장된 월 상환금을 그대로 사용 → 은행/상환표와 일치 - 잔액이 작은 마지막 회차는 원금을 잔액까지만(초과 상환 방지) Co-Authored-By: Claude Opus 4.8 --- src/views/account/AccountView.vue | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/views/account/AccountView.vue b/src/views/account/AccountView.vue index 137574c..6641711 100644 --- a/src/views/account/AccountView.vue +++ b/src/views/account/AccountView.vue @@ -173,13 +173,23 @@ 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 } + 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) + const r = Number(loan.loanRate) / 100 / 12 + const n = loan.loanMonths + M = Math.round(Number(loan.loanAmount) * r * Math.pow(1 + r, n) / (Math.pow(1 + r, n) - 1)) + } + 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 } })