Harshitmehra-270709 opened a new pull request, #5669:
URL: https://github.com/apache/fineract/pull/5669

   ## Description
   This PR resolves 
[FINERACT-2512](https://issues.apache.org/jira/browse/FINERACT-2512), where 
supplying an invalid `fee_on_month` and `fee_on_day` (e.g. `month=2`, `day=30` 
or `month=4`, `day=31`) would result in a `DateTimeException` during `MonthDay` 
instantiation, bubbling up as an HTTP 500 Internal Server error when fetching 
savings product template data.
   
   ## Root Cause
   When reading legacy database charge configurations, multiple services 
eagerly allocated 
`MonthDay.now(DateUtils.getDateTimeZoneOfTenant()).withMonth(month).withDayOfMonth(day)`.
 `DayOfMonth` exceeded the month's maximum length, causing Java time primitives 
to crash.
   
   ## Modifications
   * Introduced a reusable, defensive `DateUtils.createMonthDay(int month, int 
day)` method that clamps invalid days to the allowed maximum for that specific 
month.
   * Refactored 4 instances across `Charge.java`, 
`ChargeReadPlatformServiceImpl.java`, 
`SavingsAccountChargeReadPlatformServiceImpl.java`, and 
`StandingInstructionReadPlatformServiceImpl.java` to use the new defensive 
initialization.
   * Added boundary edge-case `MonthDay` tests to `DateUtilsTest.java` covering 
constraints for Feb, April, Sept, etc.
   
   ## Additional Context
   This cleanly bypasses the HTTP 500 error when legacy configurations exist 
returning a valid representation of the intention without cascading crashes on 
reads.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to