FINERACT-2031: Fix reschedule to next repayment date.#3656
Conversation
|
@adamsaghy Please review this and let me know if its good to merge. |
|
@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) { |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
@adamsaghy do we have any slack channel to communicate? I need to understand How to do local testing...
adamsaghy
left a comment
There was a problem hiding this comment.
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!
|
@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); |
There was a problem hiding this comment.
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! :)
There was a problem hiding this comment.
@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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
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 ;)
There was a problem hiding this comment.
@adamsaghy I have pushed new test cases and tested this working as expected. Let me know your comments once review it.
1014e7b to
88855c8
Compare
|
@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.
88855c8 to
b4a7a26
Compare
Now squashed all commmits. |
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.