Skip to content

Add car loan estimator: domain, service, API, validation, and tests#79

Merged
jmpompeo merged 3 commits into
mainfrom
codex/plan-feature-for-car-payments-calculator
Apr 21, 2026
Merged

Add car loan estimator: domain, service, API, validation, and tests#79
jmpompeo merged 3 commits into
mainfrom
codex/plan-feature-for-car-payments-calculator

Conversation

@jmpompeo

Copy link
Copy Markdown
Owner

Motivation

  • Provide a car loan estimation feature that computes amount financed, monthly payment, total paid, total interest and an amortization schedule while supporting sales tax as either percent or amount.
  • Expose the car loan calculation through the existing API surface with request validation and consistent response formatting.

Description

  • Added domain request and response types: CarLoanRequest and CarLoanResult (and CarLoanAmortizationEntry) with input validation and rounding/display formatting logic.
  • Implemented car loan calculation in CalculationService via CalculateCarLoanEstimate and a BuildAmortizationSchedule helper that produces a month-by-month amortization list.
  • Updated the service contract ICalculationService to include CalculateCarLoanEstimate.
  • Added API surface: CarLoanController, request DTO CarLoanEstimateRequestDto, response DTO CarLoanEstimateResponseDto, and mapping logic in CalculationMapper.
  • Added request validation with CarLoanEstimateRequestValidator (FluentValidation) ensuring value ranges and that exactly one of salesTaxPercent or salesTaxAmount is provided.
  • Added automated tests: integration CarLoanControllerTests and unit tests in CalculationServiceTests covering normal and zero-APR scenarios.

Testing

  • Ran unit tests in CompoundInterestCalculatorTests including new CalculationServiceTests cases for CalculateCarLoanEstimate, and they passed.
  • Ran integration tests including CarLoanControllerTests that post to /api/v1/car-loan/estimate using WebApplicationFactory, and they passed.
  • Full test suite executed successfully with no failing tests.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +133 to +134
var netTradeInCredit = Math.Max(request.TradeInValue - request.TradeInPayoff, 0m);
var totalUpfrontCredit = request.CashDownPayment + netTradeInCredit;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@jmpompeo jmpompeo merged commit d90f284 into main Apr 21, 2026
5 checks passed
@jmpompeo jmpompeo deleted the codex/plan-feature-for-car-payments-calculator branch June 14, 2026 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant