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

FINERACT-2065: Fix schedule handling with higher fixed length value t… #3836

Conversation

alberto-art3ch
Copy link
Contributor

…han Loan term

Description

Following with the Loan Product Fixed Length configuration we need to consider the schedule generation with this new setting.

FINERACT-2065

  • Loan Account Term details
Screenshot 2024-03-27 at 10 50 20 p m
  • Loan Account schedule generate for this case
Screenshot 2024-03-27 at 11 09 10 p m

Checklist

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Write the commit message as per https://github.com/apache/fineract/#pull-requests

  • Acknowledge that we will not review PRs that are not passing the build ("green") - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers.

  • Create/update unit or integration tests for verifying the changes made.

  • Follow coding conventions at https://cwiki.apache.org/confluence/display/FINERACT/Coding+Conventions.

  • Add required Swagger annotation and update API documentation at fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with details of any API changes

  • Submission is not a "code dump". (Large changes can be made "in repository" via a branch. Ask on the developer mailing list for guidance, if required.)

FYI our guidelines for code reviews are at https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide.

@alberto-art3ch alberto-art3ch force-pushed the fix/schedule_handling_for_fixed_length_configuration branch from 234e7df to 3771afd Compare March 28, 2024 14:35
Copy link
Contributor

@adamsaghy adamsaghy left a comment

Choose a reason for hiding this comment

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

LGTM

@alberto-art3ch alberto-art3ch force-pushed the fix/schedule_handling_for_fixed_length_configuration branch from 3771afd to 10aa0af Compare March 28, 2024 15:48
// Fixed Length validation
final int lastPeriodIdx = periods.size() - 1;
LoanScheduleModelRepaymentPeriod lastPeriod = (LoanScheduleModelRepaymentPeriod) periods.get(lastPeriodIdx);
if (lastPeriod.getDueDate().compareTo(loanEndDate) != 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

With reschedule, i dont think it will work... :/

Based on the periodNumber of scheduleParams, you can decide in the "nextRepaymentDate()" method of DefaultScheduledDateGenerator, whether it is the last installment or not and you can set the proper repayment date. After that if the installment was rescheduled, that date would be overriden, but i guess that is fine.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! Updated to validate the last installment

@alberto-art3ch alberto-art3ch force-pushed the fix/schedule_handling_for_fixed_length_configuration branch from 10aa0af to 85e3ced Compare April 2, 2024 09:06
@@ -172,4 +172,8 @@ public void resetVariations() {
this.dueDateIterator = this.dueDateVariation.listIterator();
}

public boolean hasAnyVariation() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please leave a couple sentence what this is?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The purpose of this is to know when the Loan account has any variation and If this is true that means the Loan has been rescheduled.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reschedule type where the length of the loan does not change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is one option for rescheduling related to use other IR value for the rest of the period. Even I'm thinking for this scenarios to have Fixed Length with Reschedule to use a new kind of reschedule variation to support this, what do you thing?

Copy link
Contributor

@adamsaghy adamsaghy Apr 8, 2024

Choose a reason for hiding this comment

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

I am still not sure we need this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! removed!

@@ -1871,4 +1871,16 @@ public LocalDate getRepaymentStartDate() {
: getSubmittedOnDate();
}

public boolean isLastInstallment(final Integer installmentNumber) {
Integer numberOfRepayments = getNumberOfRepayments();
if (isDownPaymentEnabled()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

My gut feeling this is wrong...but i am not fully sure.
Can you please explain a little bit what was the idea here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using the installment number for the last installment is different when you are using Down Payment (It creates a new installment) so we need to consider that when we need to identify the last installment

Copy link
Contributor

Choose a reason for hiding this comment

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

There could be multiple disbursement and multiple down payment, so adding +1 is not right...

Copy link
Contributor

Choose a reason for hiding this comment

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

Also while the the installment number is increased when a down payment period added, the period number is not. So you might wanna use that to decide on whether it is the last or not...

@alberto-art3ch alberto-art3ch force-pushed the fix/schedule_handling_for_fixed_length_configuration branch 5 times, most recently from 90cbe3f to d2acf72 Compare April 10, 2024 00:10
@@ -55,6 +55,13 @@ public static LoanScheduleModelRepaymentPeriod repayment(final int periodNumber,
interestDue, feeChargesDue, penaltyChargesDue, totalDue, recalculatedInterestComponent);
}

public static LoanScheduleModelRepaymentPeriod copyWithNewDueDate(final LoanScheduleModelRepaymentPeriod period,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not used anywhere...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! method removed

assertTrue(loanDetails.getStatus().getActive());
});
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Please add test cases where the following happens:

  • Reschedule the very last installment to a new due date

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! TC uc135 created

validateRepaymentPeriod(loanDetails, 1, LocalDate.of(2024, 1, 31), 250.0, 0.0, 250.0, 0.0, 0.0);
validateRepaymentPeriod(loanDetails, 2, LocalDate.of(2024, 3, 15), 250.0, 0.0, 250.0, 0.0, 0.0);
validateRepaymentPeriod(loanDetails, 3, LocalDate.of(2024, 4, 14), 250.0, 0.0, 250.0, 0.0, 0.0);
validateRepaymentPeriod(loanDetails, 4, LocalDate.of(2024, 4, 30), 250.0, 0.0, 250.0, 0.0, 0.0);
Copy link
Contributor

Choose a reason for hiding this comment

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

I dont think this is right. The very last installment due date should have been rescheduled as well.

Copy link
Contributor

@adamsaghy adamsaghy left a comment

Choose a reason for hiding this comment

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

Please review my comments!

@alberto-art3ch alberto-art3ch force-pushed the fix/schedule_handling_for_fixed_length_configuration branch 2 times, most recently from 29e9482 to 8c11d37 Compare April 10, 2024 21:12
@alberto-art3ch alberto-art3ch force-pushed the fix/schedule_handling_for_fixed_length_configuration branch from 8c11d37 to 94efd2d Compare April 10, 2024 21:14
Copy link
Contributor

@adamsaghy adamsaghy left a comment

Choose a reason for hiding this comment

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

LGTM

@adamsaghy adamsaghy merged commit 35bdbcc into apache:develop Apr 11, 2024
9 checks passed
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.

2 participants