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

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

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