You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by "mohitsinha (via GitHub)" <gi...@apache.org> on 2023/04/08 20:43:41 UTC

[GitHub] [fineract] mohitsinha opened a new pull request, #3109: FINERACT-1919: Fix monthly loan schedule due dates to maximize accord…

mohitsinha opened a new pull request, #3109:
URL: https://github.com/apache/fineract/pull/3109

   Loan Schedule due dates are lessened when a smaller month comes in between
   
   ## Description
   
    [Apache Fineract JIRA ticket](https://issues.apache.org/jira/browse/FINERACT-1919).
   
   ## 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.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [fineract] mohitsinha merged pull request #3109: FINERACT-1919: Fix monthly loan schedule due dates to maximize accord…

Posted by "mohitsinha (via GitHub)" <gi...@apache.org>.
mohitsinha merged PR #3109:
URL: https://github.com/apache/fineract/pull/3109


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [fineract] mohitsinha commented on a diff in pull request #3109: FINERACT-1919: Fix monthly loan schedule due dates to maximize accord…

Posted by "mohitsinha (via GitHub)" <gi...@apache.org>.
mohitsinha commented on code in PR #3109:
URL: https://github.com/apache/fineract/pull/3109#discussion_r1162523268


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/calendar/service/CalendarUtils.java:
##########
@@ -90,36 +90,13 @@ public static LocalDate getNextRecurringDate(final String recurringRule, final L
     }
 
     public static Temporal adjustDate(final Temporal date, final Temporal seedDate, final PeriodFrequencyType frequencyType) {
-        Temporal adjustedVal = date;
-        if (frequencyType.isMonthly() && seedDate.get(ChronoField.DAY_OF_MONTH) > 28 && date.get(ChronoField.DAY_OF_MONTH) > 28) {
-            switch (date.get(ChronoField.MONTH_OF_YEAR)) {
-                case 2:
-                    if (IsoChronology.INSTANCE.isLeapYear(date.get(ChronoField.YEAR))) {
-                        adjustedVal = date.with(ChronoField.DAY_OF_MONTH, 29);
-                    }
-                break;
-                case 4:
-                case 6:
-                case 9:
-                case 11:
-                    if (seedDate.get(ChronoField.DAY_OF_MONTH) > 30) {
-                        adjustedVal = date.with(ChronoField.DAY_OF_MONTH, 30);
-                    } else {
-                        adjustedVal = date.with(ChronoField.DAY_OF_MONTH, seedDate.get(ChronoField.DAY_OF_MONTH));
-                    }
-                break;
-                case 1:
-                case 3:
-                case 5:
-                case 7:
-                case 8:
-                case 10:
-                case 12:
-                    adjustedVal = date.with(ChronoField.DAY_OF_MONTH, seedDate.get(ChronoField.DAY_OF_MONTH));
-                break;
-            }
+        if (frequencyType.isMonthly() && seedDate.get(ChronoField.DAY_OF_MONTH) > 28 && date.get(ChronoField.DAY_OF_MONTH) >= 28) {

Review Comment:
   @adamsaghy Yes it was intentional, otherwise this logic wouldn't get applied for non-leap years because we also want to apply this logic to find the next dueDate when `Temporal date` was `28 February 2022`
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [fineract] adamsaghy commented on pull request #3109: FINERACT-1919: Fix monthly loan schedule due dates to maximize accord…

Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on PR #3109:
URL: https://github.com/apache/fineract/pull/3109#issuecomment-1504914834

   @mohitsinha LGTM, but please squash your commits!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [fineract] galovics commented on a diff in pull request #3109: FINERACT-1919: Fix monthly loan schedule due dates to maximize accord…

Posted by "galovics (via GitHub)" <gi...@apache.org>.
galovics commented on code in PR #3109:
URL: https://github.com/apache/fineract/pull/3109#discussion_r1162387268


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/calendar/service/CalendarUtils.java:
##########
@@ -90,36 +90,13 @@ public static LocalDate getNextRecurringDate(final String recurringRule, final L
     }
 
     public static Temporal adjustDate(final Temporal date, final Temporal seedDate, final PeriodFrequencyType frequencyType) {
-        Temporal adjustedVal = date;
-        if (frequencyType.isMonthly() && seedDate.get(ChronoField.DAY_OF_MONTH) > 28 && date.get(ChronoField.DAY_OF_MONTH) > 28) {
-            switch (date.get(ChronoField.MONTH_OF_YEAR)) {
-                case 2:
-                    if (IsoChronology.INSTANCE.isLeapYear(date.get(ChronoField.YEAR))) {
-                        adjustedVal = date.with(ChronoField.DAY_OF_MONTH, 29);
-                    }
-                break;
-                case 4:
-                case 6:
-                case 9:
-                case 11:
-                    if (seedDate.get(ChronoField.DAY_OF_MONTH) > 30) {
-                        adjustedVal = date.with(ChronoField.DAY_OF_MONTH, 30);
-                    } else {
-                        adjustedVal = date.with(ChronoField.DAY_OF_MONTH, seedDate.get(ChronoField.DAY_OF_MONTH));
-                    }
-                break;
-                case 1:
-                case 3:
-                case 5:
-                case 7:
-                case 8:
-                case 10:
-                case 12:
-                    adjustedVal = date.with(ChronoField.DAY_OF_MONTH, seedDate.get(ChronoField.DAY_OF_MONTH));
-                break;
-            }
+        if (frequencyType.isMonthly() && seedDate.get(ChronoField.DAY_OF_MONTH) > 28 && date.get(ChronoField.DAY_OF_MONTH) >= 28) {

Review Comment:
   Why can't we have a simple unit test for this method (in addition to the integration test you wrote)?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [fineract] mohitsinha commented on a diff in pull request #3109: FINERACT-1919: Fix monthly loan schedule due dates to maximize accord…

Posted by "mohitsinha (via GitHub)" <gi...@apache.org>.
mohitsinha commented on code in PR #3109:
URL: https://github.com/apache/fineract/pull/3109#discussion_r1162575090


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/calendar/service/CalendarUtils.java:
##########
@@ -90,36 +90,13 @@ public static LocalDate getNextRecurringDate(final String recurringRule, final L
     }
 
     public static Temporal adjustDate(final Temporal date, final Temporal seedDate, final PeriodFrequencyType frequencyType) {
-        Temporal adjustedVal = date;
-        if (frequencyType.isMonthly() && seedDate.get(ChronoField.DAY_OF_MONTH) > 28 && date.get(ChronoField.DAY_OF_MONTH) > 28) {
-            switch (date.get(ChronoField.MONTH_OF_YEAR)) {
-                case 2:
-                    if (IsoChronology.INSTANCE.isLeapYear(date.get(ChronoField.YEAR))) {
-                        adjustedVal = date.with(ChronoField.DAY_OF_MONTH, 29);
-                    }
-                break;
-                case 4:
-                case 6:
-                case 9:
-                case 11:
-                    if (seedDate.get(ChronoField.DAY_OF_MONTH) > 30) {
-                        adjustedVal = date.with(ChronoField.DAY_OF_MONTH, 30);
-                    } else {
-                        adjustedVal = date.with(ChronoField.DAY_OF_MONTH, seedDate.get(ChronoField.DAY_OF_MONTH));
-                    }
-                break;
-                case 1:
-                case 3:
-                case 5:
-                case 7:
-                case 8:
-                case 10:
-                case 12:
-                    adjustedVal = date.with(ChronoField.DAY_OF_MONTH, seedDate.get(ChronoField.DAY_OF_MONTH));
-                break;
-            }
+        if (frequencyType.isMonthly() && seedDate.get(ChronoField.DAY_OF_MONTH) > 28 && date.get(ChronoField.DAY_OF_MONTH) >= 28) {

Review Comment:
   Added UT for this method



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [fineract] mohitsinha commented on a diff in pull request #3109: FINERACT-1919: Fix monthly loan schedule due dates to maximize accord…

Posted by "mohitsinha (via GitHub)" <gi...@apache.org>.
mohitsinha commented on code in PR #3109:
URL: https://github.com/apache/fineract/pull/3109#discussion_r1162639611


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/calendar/service/CalendarUtils.java:
##########
@@ -90,36 +90,13 @@ public static LocalDate getNextRecurringDate(final String recurringRule, final L
     }
 
     public static Temporal adjustDate(final Temporal date, final Temporal seedDate, final PeriodFrequencyType frequencyType) {
-        Temporal adjustedVal = date;
-        if (frequencyType.isMonthly() && seedDate.get(ChronoField.DAY_OF_MONTH) > 28 && date.get(ChronoField.DAY_OF_MONTH) > 28) {
-            switch (date.get(ChronoField.MONTH_OF_YEAR)) {
-                case 2:
-                    if (IsoChronology.INSTANCE.isLeapYear(date.get(ChronoField.YEAR))) {
-                        adjustedVal = date.with(ChronoField.DAY_OF_MONTH, 29);
-                    }
-                break;
-                case 4:
-                case 6:
-                case 9:
-                case 11:
-                    if (seedDate.get(ChronoField.DAY_OF_MONTH) > 30) {
-                        adjustedVal = date.with(ChronoField.DAY_OF_MONTH, 30);
-                    } else {
-                        adjustedVal = date.with(ChronoField.DAY_OF_MONTH, seedDate.get(ChronoField.DAY_OF_MONTH));
-                    }
-                break;
-                case 1:
-                case 3:
-                case 5:
-                case 7:
-                case 8:
-                case 10:
-                case 12:
-                    adjustedVal = date.with(ChronoField.DAY_OF_MONTH, seedDate.get(ChronoField.DAY_OF_MONTH));
-                break;
-            }
+        if (frequencyType.isMonthly() && seedDate.get(ChronoField.DAY_OF_MONTH) > 28 && date.get(ChronoField.DAY_OF_MONTH) >= 28) {

Review Comment:
   @adamsaghy This is exactly for the case mentioned in the ticket. 
   Where firstRepaymentDate is 31 Jan 2023, 
   second will be 28 Feb 2023, 
   And for March, the date will be 28 March 2023, if we don't have `>=` this logic won't get executed. Hence it is needed for all `dates>=28`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [fineract] mohitsinha commented on a diff in pull request #3109: FINERACT-1919: Fix monthly loan schedule due dates to maximize accord…

Posted by "mohitsinha (via GitHub)" <gi...@apache.org>.
mohitsinha commented on code in PR #3109:
URL: https://github.com/apache/fineract/pull/3109#discussion_r1162523268


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/calendar/service/CalendarUtils.java:
##########
@@ -90,36 +90,13 @@ public static LocalDate getNextRecurringDate(final String recurringRule, final L
     }
 
     public static Temporal adjustDate(final Temporal date, final Temporal seedDate, final PeriodFrequencyType frequencyType) {
-        Temporal adjustedVal = date;
-        if (frequencyType.isMonthly() && seedDate.get(ChronoField.DAY_OF_MONTH) > 28 && date.get(ChronoField.DAY_OF_MONTH) > 28) {
-            switch (date.get(ChronoField.MONTH_OF_YEAR)) {
-                case 2:
-                    if (IsoChronology.INSTANCE.isLeapYear(date.get(ChronoField.YEAR))) {
-                        adjustedVal = date.with(ChronoField.DAY_OF_MONTH, 29);
-                    }
-                break;
-                case 4:
-                case 6:
-                case 9:
-                case 11:
-                    if (seedDate.get(ChronoField.DAY_OF_MONTH) > 30) {
-                        adjustedVal = date.with(ChronoField.DAY_OF_MONTH, 30);
-                    } else {
-                        adjustedVal = date.with(ChronoField.DAY_OF_MONTH, seedDate.get(ChronoField.DAY_OF_MONTH));
-                    }
-                break;
-                case 1:
-                case 3:
-                case 5:
-                case 7:
-                case 8:
-                case 10:
-                case 12:
-                    adjustedVal = date.with(ChronoField.DAY_OF_MONTH, seedDate.get(ChronoField.DAY_OF_MONTH));
-                break;
-            }
+        if (frequencyType.isMonthly() && seedDate.get(ChronoField.DAY_OF_MONTH) > 28 && date.get(ChronoField.DAY_OF_MONTH) >= 28) {

Review Comment:
   @adamsaghy Yes it was intentional, otherwise this logic wouldn't get applied for non-leap years.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [fineract] adamsaghy commented on a diff in pull request #3109: FINERACT-1919: Fix monthly loan schedule due dates to maximize accord…

Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #3109:
URL: https://github.com/apache/fineract/pull/3109#discussion_r1162514205


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/calendar/service/CalendarUtils.java:
##########
@@ -90,36 +90,13 @@ public static LocalDate getNextRecurringDate(final String recurringRule, final L
     }
 
     public static Temporal adjustDate(final Temporal date, final Temporal seedDate, final PeriodFrequencyType frequencyType) {
-        Temporal adjustedVal = date;
-        if (frequencyType.isMonthly() && seedDate.get(ChronoField.DAY_OF_MONTH) > 28 && date.get(ChronoField.DAY_OF_MONTH) > 28) {
-            switch (date.get(ChronoField.MONTH_OF_YEAR)) {
-                case 2:
-                    if (IsoChronology.INSTANCE.isLeapYear(date.get(ChronoField.YEAR))) {
-                        adjustedVal = date.with(ChronoField.DAY_OF_MONTH, 29);
-                    }
-                break;
-                case 4:
-                case 6:
-                case 9:
-                case 11:
-                    if (seedDate.get(ChronoField.DAY_OF_MONTH) > 30) {
-                        adjustedVal = date.with(ChronoField.DAY_OF_MONTH, 30);
-                    } else {
-                        adjustedVal = date.with(ChronoField.DAY_OF_MONTH, seedDate.get(ChronoField.DAY_OF_MONTH));
-                    }
-                break;
-                case 1:
-                case 3:
-                case 5:
-                case 7:
-                case 8:
-                case 10:
-                case 12:
-                    adjustedVal = date.with(ChronoField.DAY_OF_MONTH, seedDate.get(ChronoField.DAY_OF_MONTH));
-                break;
-            }
+        if (frequencyType.isMonthly() && seedDate.get(ChronoField.DAY_OF_MONTH) > 28 && date.get(ChronoField.DAY_OF_MONTH) >= 28) {

Review Comment:
   the additional = for the `date.get(ChronoField.DAY_OF_MONTH) >= 28` was intentional?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [fineract] mohitsinha commented on a diff in pull request #3109: FINERACT-1919: Fix monthly loan schedule due dates to maximize accord…

Posted by "mohitsinha (via GitHub)" <gi...@apache.org>.
mohitsinha commented on code in PR #3109:
URL: https://github.com/apache/fineract/pull/3109#discussion_r1162639611


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/calendar/service/CalendarUtils.java:
##########
@@ -90,36 +90,13 @@ public static LocalDate getNextRecurringDate(final String recurringRule, final L
     }
 
     public static Temporal adjustDate(final Temporal date, final Temporal seedDate, final PeriodFrequencyType frequencyType) {
-        Temporal adjustedVal = date;
-        if (frequencyType.isMonthly() && seedDate.get(ChronoField.DAY_OF_MONTH) > 28 && date.get(ChronoField.DAY_OF_MONTH) > 28) {
-            switch (date.get(ChronoField.MONTH_OF_YEAR)) {
-                case 2:
-                    if (IsoChronology.INSTANCE.isLeapYear(date.get(ChronoField.YEAR))) {
-                        adjustedVal = date.with(ChronoField.DAY_OF_MONTH, 29);
-                    }
-                break;
-                case 4:
-                case 6:
-                case 9:
-                case 11:
-                    if (seedDate.get(ChronoField.DAY_OF_MONTH) > 30) {
-                        adjustedVal = date.with(ChronoField.DAY_OF_MONTH, 30);
-                    } else {
-                        adjustedVal = date.with(ChronoField.DAY_OF_MONTH, seedDate.get(ChronoField.DAY_OF_MONTH));
-                    }
-                break;
-                case 1:
-                case 3:
-                case 5:
-                case 7:
-                case 8:
-                case 10:
-                case 12:
-                    adjustedVal = date.with(ChronoField.DAY_OF_MONTH, seedDate.get(ChronoField.DAY_OF_MONTH));
-                break;
-            }
+        if (frequencyType.isMonthly() && seedDate.get(ChronoField.DAY_OF_MONTH) > 28 && date.get(ChronoField.DAY_OF_MONTH) >= 28) {

Review Comment:
   This is exactly for the case mentioned in the ticket. 
   Where firstRepaymentDate is 31 Jan 2023, 
   second will be 28 Feb 2023, 
   And for March, the date will be 28 March 2023, if we don't have `>=` this logic won't get executed. Hence it is needed for all `dates>=28`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org