Add realistic loan amortization with currentBalance back-calculation
- Extend schema with effectiveAnnualRate, totalInterest, totalAmount - Back-calculate paid months from currentBalance and rebuild schedule - Allow schedule calculation from termMonths without monthlyPayment - Handle NaN form values gracefully - Show effective rate, total interest and total amount in UI - Add amortization unit tests
This commit is contained in:
@@ -81,10 +81,13 @@ export default defineSchema({
|
||||
categoryId: v.optional(v.id("categories")),
|
||||
principal: v.number(),
|
||||
annualInterestRate: v.number(),
|
||||
effectiveAnnualRate: v.optional(v.number()),
|
||||
monthlyPayment: v.optional(v.number()),
|
||||
termMonths: v.optional(v.number()),
|
||||
startDate: v.string(),
|
||||
currentBalance: v.optional(v.number()),
|
||||
totalInterest: v.optional(v.number()),
|
||||
totalAmount: v.optional(v.number()),
|
||||
status: loanStatus,
|
||||
notes: v.optional(v.string()),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user