Fix date timezone shift in loan detail maturity date computation
Parse date string components directly and use Date.UTC() to avoid local timezone interpretation that shifts dates by a day in western timezones when using new Date() with date-only strings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -367,12 +367,12 @@ async function saveLoanDetail() {
|
||||
if (!props.id) return
|
||||
saving.value = true
|
||||
try {
|
||||
const originDate = new Date(loanForm.value.originationDate)
|
||||
const maturityDate = new Date(originDate)
|
||||
maturityDate.setMonth(maturityDate.getMonth() + loanForm.value.termMonths)
|
||||
const [year, month, day] = loanForm.value.originationDate.split('-').map(Number)
|
||||
const maturityDate = new Date(Date.UTC(year, month - 1 + loanForm.value.termMonths, day))
|
||||
|
||||
const payload = {
|
||||
...loanForm.value,
|
||||
originationDate: new Date(Date.UTC(year, month - 1, day)).toISOString(),
|
||||
maturityDate: maturityDate.toISOString(),
|
||||
escrowAmount: loanForm.value.escrowAmount || undefined,
|
||||
extraPayment: loanForm.value.extraPayment || undefined,
|
||||
|
||||
Reference in New Issue
Block a user