Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: calc monthly_repayment_amount correctly in regenerate_repayment_schedule #38636

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,8 @@ def regenerate_repayment_schedule(loan, cancel=0):
last_repayment_amount = None
last_balance_amount = None

original_repayment_schedule_len = len(loan_doc.get("repayment_schedule"))

for term in reversed(loan_doc.get("repayment_schedule")):
if not term.is_accrued:
next_accrual_date = term.payment_date
Expand All @@ -616,7 +618,7 @@ def regenerate_repayment_schedule(loan, cancel=0):

if loan_doc.repayment_method == "Repay Fixed Amount per Period":
monthly_repayment_amount = flt(
balance_amount / len(loan_doc.get("repayment_schedule")) - accrued_entries
balance_amount / (original_repayment_schedule_len - accrued_entries)
)
else:
repayment_period = loan_doc.repayment_periods - accrued_entries
Expand Down
Loading