Skip to content

FINERACT-2031: Fix reschedule to next repayment date.#3656

Merged
adamsaghy merged 1 commit intoapache:developfrom
2vinodhkumar:feature/FINERACT-2031-with-integration-test
Jan 4, 2024
Merged

FINERACT-2031: Fix reschedule to next repayment date.#3656
adamsaghy merged 1 commit intoapache:developfrom
2vinodhkumar:feature/FINERACT-2031-with-integration-test

Conversation

@2vinodhkumar
Copy link
Contributor

Schedule should shift all the remaining installments to next repayment date as per the loan frequency.

Description

Describe the changes made and why they were made.

Ignore if these details are present on the associated Apache Fineract JIRA ticket.

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.

@2vinodhkumar
Copy link
Contributor Author

@adamsaghy Please review this and let me know if its good to merge.

@bharathcgowda
Copy link

@adamsaghy Could you please help us review this PR when ever you are available?

periods = (ArrayList<LinkedHashMap>) repaymentScheduleHashMap.get("periods");
ArrayList<Integer> dateToApplyHolidays = null;

for (LinkedHashMap period : periods) {
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 really understand this piece... what exactly are you testing?

I reckon it should be tested, whether all the periods are proper, but this is not testing anything but whether the last period from date is not null.

Please rewrite this to explicitly test the rescheduled periods are correct!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adamsaghy do we have any slack channel to communicate? I need to understand How to do local testing...

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.

I dont really understand this piece... what exactly are you testing?

I reckon it should be tested, whether all the periods are proper, but this is not testing anything but whether the last period from date is not null.

Please rewrite this to explicitly test the rescheduled periods are correct!

@2vinodhkumar
Copy link
Contributor Author

@adamsaghy I have updated the test case to fully check all rescheduled date's validity. Please review and let me know if this is good.

@adamsaghy
Copy link
Contributor

@adamsaghy I have updated the test case to fully check all rescheduled date's validity. Please review and let me know if this is good.

Please squash your commits!

1 PR, 1 commit ;)

if (fromDate != null && Objects.equals(fromDate.get(1), dueDateBeforeRescheduled.get(1))) {
dateToApplyHolidays = fromDate;
}
Assertions.assertNotNull(dateToApplyHolidays);
Copy link
Contributor

Choose a reason for hiding this comment

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

its still not perfect...

i was wondering whether you could test something like this:

disburse the loan on a date (example: 2023.01.01)
Assert all the periods due date.
do the reschedule, (example: reschedule the 2nd period)
assert all the "new" periods due date:

the 1st period due date is not changed.
the 2nd period due date was changed to the next one.
all the later periods was moved

i hope it gives some insight! :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adamsaghy I tried to follow similar approach. Can you please review the latest commit? I will squash the commits from next as I pushed these already

Copy link
Contributor

Choose a reason for hiding this comment

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

But you did not follow at all... you are still calculating and comparing dates with a logic which might be correct but i am having hard time to read and understand. Since you are using a fixed date: 2023.01.01 where the loan is created and disbursed, the period from and due dates are fixed as well:
2023.02.01
2023.03.01
2023.04.01
etc.

Can you please write assertions which checks whether the above dates are the ones that got used and after the holiday reschedule what are the new dates. Example:

Number of repayments: 3
Period lenght: 1 month

Before holiday reschedule
// 1st period
assertEquals(LocalDate.of(2023,1,1), periods.get(0).getFromDate())
assertEquals(LocalDate.of(2023,2,1), periods.get(0).getDueDate())
// 2nd period
assertEquals(LocalDate.of(2023,2,1), periods.get(1).getFromDate())
assertEquals(LocalDate.of(2023,3,1), periods.get(1).getDueDate())
// 3rd period
assertEquals(LocalDate.of(2023,3,1), periods.get(2).getFromDate())
assertEquals(LocalDate.of(2023,4,1), periods.get(2).getDueDate())

After holiday reschedule

Reschedule from 1st of Feb
// 1st period
assertEquals(LocalDate.of(2023,1,1), periods.get(0).getFromDate())
assertEquals(LocalDate.of(2023,2,1), periods.get(0).getDueDate())
// 2nd period (got rescheduled)
assertEquals(LocalDate.of(2023,2,1), periods.get(1).getFromDate())
assertEquals(LocalDate.of(2023,4,1), periods.get(1).getDueDate())
// 3rd period (got rescheduled)
assertEquals(LocalDate.of(2023,4,1), periods.get(2).getFromDate())
assertEquals(LocalDate.of(2023,5,1), periods.get(2).getDueDate())

This is easy to read and easy to understand what is happening

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adamsaghy Hardcoding these values will not work. On every testing actual rescheduled dates will shift to next dates. If we hard code these values in the first run it will get succeeded but in the next run due dates will get changed but hard coded values will remain same.

Copy link
Contributor

Choose a reason for hiding this comment

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

@2vinodhkumar you are creating a brand new loan with each execution and checking only the created loan periods. so i dont think it will be different for each execution at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adamsaghy I have tested this from UI/API , seems working as expected. From integration tests, All the reschedules are getting updated though the due date is before the holiday date. Let me recheck with different test cases.

Copy link
Contributor

@adamsaghy adamsaghy Jan 4, 2024

Choose a reason for hiding this comment

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

I understand what you say (the old loans might be rescheduled multiple times, but the new is only once), but with each test you are creating a brand new loan and that loan will be rescheduled just once (hence it is brand new). And that loan periods are checked, so it should be always the same. Feel free to test it ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adamsaghy I have pushed new test cases and tested this working as expected. Let me know your comments once review it.

@2vinodhkumar 2vinodhkumar force-pushed the feature/FINERACT-2031-with-integration-test branch from 1014e7b to 88855c8 Compare January 4, 2024 10:02
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
Copy link
Contributor

@2vinodhkumar Please squash your commits! The rest looks good

… shift all the remaining installments to next repayment date as per the loan frequency.

FINERACT-2031: Fix reschedule to next repayment date. Schedule should shift all the remaining installments to next repayment date as per the loan frequency.

FINERACT-2031: Fix reschedule to next repayment date. Schedule should shift all the remaining installments to next repayment date as per the loan frequency.

FINERACT-2031: Fix reschedule to next repayment date. Schedule should shift all the remaining installments to next repayment date as per the loan frequency.

FINERACT-2031: Fix reschedule to next repayment date. Schedule should shift all the remaining installments to next repayment date as per the loan frequency.
@2vinodhkumar 2vinodhkumar force-pushed the feature/FINERACT-2031-with-integration-test branch from 88855c8 to b4a7a26 Compare January 4, 2024 10:38
@2vinodhkumar
Copy link
Contributor Author

@2vinodhkumar Please squash your commits! The rest looks good

Now squashed all commmits.

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 50eefd2 into apache:develop Jan 4, 2024
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.

3 participants

Comments