Skip to content

Removed the double deduction of the prepayment from var remainingLoan… - #12

Open
ankitsikka1992 wants to merge 1 commit into
jabadurai:masterfrom
ankitsikka1992:bug-fix-issue-8
Open

Removed the double deduction of the prepayment from var remainingLoan…#12
ankitsikka1992 wants to merge 1 commit into
jabadurai:masterfrom
ankitsikka1992:bug-fix-issue-8

Conversation

@ankitsikka1992

@ankitsikka1992 ankitsikka1992 commented Oct 27, 2025

Copy link
Copy Markdown

Fix part payment calculation bug in loan amortization

Summary

This PR fixes a critical bug in the loan calculation logic where part payments were being deducted twice from the remaining loan balance, resulting in incorrect amortization schedules and misleading payment breakdowns.

Problem

When users entered part payments (prepayments), the application was:

  1. Adding the part payment amount to the principal column
  2. Deducting the part payment directly from the remaining balance
  3. Then deducting the inflated principal (which included the part payment) again

This caused the part payment to be subtracted twice, leading to incorrect loan balances and confusing users about their actual payment breakdown.

Solution

Modified the calculation logic in js/calc.js to:

  • Keep principal and part payment amounts separate for display purposes
  • Deduct both amounts together in a single operation from the remaining balance
  • Ensure the Principal column (A) shows only the actual principal payment
  • Ensure the Part Payment column (C) shows only the additional payment
  • Make Total Payment correctly sum all components (A + B + C)

Changes

  • js/calc.js: Fixed double deduction logic in calculateLoanSchedule() function

Testing

Tested the fix with various scenarios:

  • Monthly part payments
  • Quarterly part payments
  • Yearly part payments
  • Custom part payment schedules
  • Verified all column calculations are now accurate
  • Confirmed loan balance progression is correct

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change

This fix resolves calculation accuracy issues without changing the user interface or breaking existing functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant