Use first payment date and maturity date instead of origination date and term
Replace the term months field with a maturity date picker - users know when their loan ends, not the month count. Compute termMonths from the two dates. Rename "Origination Date" to "First Payment Date" and adjust the amortization schedule so payment #1 falls on the entered date. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -187,11 +187,11 @@ public class LoanService : ILoanService
|
||||
var dailyRate = loan.InterestRate / 100m / 365m;
|
||||
var payment = loan.MonthlyPayment - (loan.EscrowAmount ?? 0);
|
||||
var extra = loan.ExtraPayment ?? 0;
|
||||
var previousDate = loan.OriginationDate;
|
||||
var previousDate = loan.OriginationDate.AddMonths(-1);
|
||||
|
||||
for (int i = 1; i <= loan.TermMonths && balance > 0; i++)
|
||||
{
|
||||
var paymentDate = loan.OriginationDate.AddMonths(i);
|
||||
var paymentDate = loan.OriginationDate.AddMonths(i - 1);
|
||||
var days = (paymentDate - previousDate).Days;
|
||||
var interest = balance * dailyRate * days;
|
||||
var principal = Math.Min(payment + extra - interest, balance);
|
||||
|
||||
Reference in New Issue
Block a user