Skip to content

backend(loanController): amortization schedule doesn't handle edge case where accrued interest exceeds remaining principal #657

@ogazboiz

Description

@ogazboiz

Join our community: https://t.me/+DOylgFv1jyJlNzM0

Description

getLoanAmortizationSchedule() in backend/src/controllers/loanController.ts builds a payment schedule by distributing principal and interest across the loan term. For high-interest or long-overdue loans, the accrued interest can exceed the scheduled payment amount, causing the running balance to increase rather than decrease with each payment.

This creates a negative amortization scenario where the schedule shows the balance growing, which the UI likely does not handle gracefully (could show negative amounts or NaN in later periods).

Expected Behavior

The amortization calculator should cap interest at each period so that the running balance never increases. If the full interest cannot be covered by the minimum payment, the schedule should show an interest-only payment for that period and flag the loan as requiring renegotiation.

Alternatively, add a validation that rejects schedule generation if interest rate is so high that negative amortization would occur.

Impact

Low-Medium. Edge case for high-rate or highly overdue loans. Currently shows confusing numbers in the repayment schedule UI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions