Add car loan estimator: domain, service, API, validation, and tests#79
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0c63074ccc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| var netTradeInCredit = Math.Max(request.TradeInValue - request.TradeInPayoff, 0m); | ||
| var totalUpfrontCredit = request.CashDownPayment + netTradeInCredit; |
There was a problem hiding this comment.
Include negative trade-in equity in financed balance
The trade-in payoff is currently clamped to a non-negative credit (Math.Max(...)), which drops negative equity when tradeInPayoff > tradeInValue and underestimates amountFinanced, monthly payment, and total paid. In that scenario, the deficit should increase the financed amount (or reduce upfront credit), otherwise requests like a $5,000 trade-in with an $8,000 payoff miss $3,000 of debt in the calculation.
Useful? React with 👍 / 👎.
Motivation
Description
CarLoanRequestandCarLoanResult(andCarLoanAmortizationEntry) with input validation and rounding/display formatting logic.CalculationServiceviaCalculateCarLoanEstimateand aBuildAmortizationSchedulehelper that produces a month-by-month amortization list.ICalculationServiceto includeCalculateCarLoanEstimate.CarLoanController, request DTOCarLoanEstimateRequestDto, response DTOCarLoanEstimateResponseDto, and mapping logic inCalculationMapper.CarLoanEstimateRequestValidator(FluentValidation) ensuring value ranges and that exactly one ofsalesTaxPercentorsalesTaxAmountis provided.CarLoanControllerTestsand unit tests inCalculationServiceTestscovering normal and zero-APR scenarios.Testing
CompoundInterestCalculatorTestsincluding newCalculationServiceTestscases forCalculateCarLoanEstimate, and they passed.CarLoanControllerTeststhat post to/api/v1/car-loan/estimateusingWebApplicationFactory, and they passed.Codex Task