Dear GnuCash Community,

I am a newcomer to GnuCash and have been exploring its features. While using the loan repayment tool to generate scheduled transactions, I encountered an issue with the loan review functionality, where the repayment schedule appears to be misaligned. This problem has been previously discussed on Reddit (https://www.reddit.com/r/GnuCash/comments/umzb91/mortgage_amortization/) and a bug report has been filed on Bugzilla (https://bugs.gnucash.org/show_bug.cgi?id=797824).

After investigating the issue, I believe I have identified the root cause. As I am unfamiliar with the contribution process for GNU projects, I thought this would be the appropriate channel to share my findings.

Steps to Reproduce the Issue:

1. Navigate to Actions -> Scheduled Transactions -> Mortgage & Loan Repayments.

2. Loan Details: Amount 1000, Start Date is 02/01/2025, Length: 6 Months Remaining: 6

3. Loan Repayment: Monthly Start Date is 02/01/2025, Every 1 Month on the 1st, weekends: no change

4. Loan Review: when selecting the current year, we got the schedules starting from 01/31/2025, 02/01/2025 ... 06/01/2025. While if we choose whole loan, the 01/31/2025 is missing and the last repayment is still 06/01/2025

The expected repayment schedule should be 02/01/2025, 03/01/2025 ... 07/01/2025. It seems the first repayment is incorrectly set to one day before the start date, causing the entire schedule to shift.

I think the issue originates in the loan_rev_recalc_schedule function within the assistant-loan.cpp file, https://github.com/Gnucash/gnucash/blob/f6c73b15fb6896b91bbbf1845cee41d7077ee5b3/gnucash/gnome/assistant-loan.cpp#L2062

In this function, curDate is initialized as the start date minus one day, then we got the nextDate.

Subsequently, the for loop uses curDate as the first repayment date, resulting in the first repayment being scheduled one day prior to the intended start date. This misalignment propagates through the entire repayment schedule, shifting the final repayment date as well.

curDate = start;

g_date_subtract_days( &curDate, 1 );

recurrenceListNextInstance(ldd->ld.repayment_schedule, &curDate, &nextDate);

I hope my analysis helps in confirming the root cause of this issue. I would be more than happy to submit a pull request to address the problem. Please let me know if additional details or further clarification are required to proceed.


Jianshi Liu
Senior Engineer - Machine Learning
Email: genie_...@outlook.com



Attachment: OpenPGP_0xA1A4CA548458C2A8.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

_______________________________________________
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel

Reply via email to