Aarti-panchal01 opened a new pull request, #6710:
URL: https://github.com/apache/fineract/pull/6710

   ## Description
   
   Adding a savings account charge with `feeOnMonthDay` but without 
`monthDayFormat` (or without `locale`) returned HTTP 500.
   
   `JsonParserHelper.extractMonthDayNamed` passed `monthDayFormat` and `locale` 
straight to `DateTimeFormatterBuilder`. When either one is missing, 
`appendPattern(null)` or `toFormatter(null)` throws a `NullPointerException` 
that nothing catches, so the API answers 500. Date parameters already check for 
a missing `dateFormat` and `locale` in `validateDateFormatAndLocale`, but 
month-day values had no such check.
   
   The month-day value now requires `monthDayFormat` and `locale`, and a 
missing one gives a 400 (`validation.msg.missing.monthDayFormat.parameter` or 
`validation.msg.missing.locale.parameter`). The check is in the shared helper, 
so the other endpoints that read a month-day value (savings and deposit 
charges, savings products, charge definitions, standing instructions) are 
covered too. Requests that already send both work as before.
   
   Also, when the value does not match `monthDayFormat` (for example `"14 
Oc"`), the 400 had the value in `parameterName`. It now names the parameter and 
returns the value in `value`.
   
   Tests:
   - `JsonParserHelperTest` (4 new): a valid month day parses; a missing 
`monthDayFormat` and a missing `locale` each give a validation error (both 
threw a `NullPointerException` before the fix); a value that does not match the 
format names the parameter.
   - `SavingsAccountChargeDataValidatorTest` (new, 3): `validateAdd` accepts 
`feeOnMonthDay` with format and locale, and `validateAdd` and `validateUpdate` 
reject it without `monthDayFormat`.
   
   Checked on a local Fineract (PostgreSQL 18) before and after, on an active 
savings account with an annual fee charge:
   - without `monthDayFormat`: 500 before, 400 after
   - without `locale`: 500 before, 400 after
   - with `"feeOnMonthDay": "15 March"`, `"monthDayFormat": "dd MMMM"` and 
`"locale": "en"`: 200, and the charge reads back with `feeOnMonthDay` `[3, 15]`
   - with `"14 Oc"`: 400 both times, now with `"parameterName": "feeOnMonthDay"`
   
   Found while testing the Mifos MCP server, which sent `feeOnMonthDay` without 
`monthDayFormat` (openMF/mcp-mifosx#593).
   
   JIRA: https://issues.apache.org/jira/browse/FINERACT-2980
   
   ## Checklist
   
   Please make sure these boxes are checked before submitting your pull request 
- thanks!
   
   - [x] Write the commit message as per [our 
guidelines](https://github.com/apache/fineract/blob/develop/CONTRIBUTING.md#pull-requests)
   - [x] 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.
   - [x] Create/update [unit or integration 
tests](https://fineract.apache.org/docs/current/#_testing) for verifying the 
changes made.
   - [x] Follow our [coding 
conventions](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
   - [x] [This PR must not be a "code 
dump"](https://cwiki.apache.org/confluence/display/FINERACT/Pull+Request+Size+Limit).
 Large changes can be made in a branch, with assistance. Ask for help on the 
[developer mailing list](https://fineract.apache.org/#contribute).
   - [x] If merging this PR resolves a JIRA issue, I will mark that issue as 
resolved and set "Fix Version/s" appropriately.
   - [x] I followed the [AI 
Policy](https://github.com/apache/fineract/blob/develop/CONTRIBUTING.md#ai-policy).
   


-- 
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