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
|
if (!props.id) return
|
||||||
saving.value = true
|
saving.value = true
|
||||||
try {
|
try {
|
||||||
const originDate = new Date(loanForm.value.originationDate)
|
const [year, month, day] = loanForm.value.originationDate.split('-').map(Number)
|
||||||
const maturityDate = new Date(originDate)
|
const maturityDate = new Date(Date.UTC(year, month - 1 + loanForm.value.termMonths, day))
|
||||||
maturityDate.setMonth(maturityDate.getMonth() + loanForm.value.termMonths)
|
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
...loanForm.value,
|
...loanForm.value,
|
||||||
|
originationDate: new Date(Date.UTC(year, month - 1, day)).toISOString(),
|
||||||
maturityDate: maturityDate.toISOString(),
|
maturityDate: maturityDate.toISOString(),
|
||||||
escrowAmount: loanForm.value.escrowAmount || undefined,
|
escrowAmount: loanForm.value.escrowAmount || undefined,
|
||||||
extraPayment: loanForm.value.extraPayment || undefined,
|
extraPayment: loanForm.value.extraPayment || undefined,
|
||||||
|
|||||||
Reference in New Issue
Block a user