Samer-Melhem-FOO opened a new pull request, #6172:
URL: https://github.com/apache/fineract/pull/6172
## Summary
- When an "Entity Datatable Check" is configured to be required only for a
specific client legal-form sub-type (`Person` or `Entity`), client creation for
the *other* sub-type incorrectly failed with "Datatable cannot be empty", even
though no datatable check actually applies to that sub-type.
- Root cause was twofold:
1. `EntityDatatableChecksWritePlatformServiceImpl.runTheCheck(...)`
upper-cased the `entitySubtype` before looking it up
(`entitySubtype.toUpperCase()`), but the value is stored verbatim (e.g.
`"Person"`, `"Entity"`, matching `LegalForm.getLabel()`), so the lookup could
silently return nothing.
2. `ClientDataValidator.validateForCreate(...)` unconditionally required
the `datatables` JSON array to be non-empty whenever the `datatables` parameter
was present in the request, regardless of whether any datatable check actually
applies to the submitted legal form.
- Fix: removed the erroneous `.toUpperCase()`, and added
`areDatatablesRequiredForLegalForm(...)` so the non-empty `datatables` check is
only enforced when at least one `EntityDatatableChecks` record is actually
configured for the client's legal-form subtype (or globally, when no subtype is
set).
## Test plan
- [x] Extended `ClientDataValidatorTest` with 2 new tests:
-
`validateForCreate_withEmptyDatatables_whenNoneRequiredForLegalForm_doesNotThrow`
-
`validateForCreate_withEmptyDatatables_whenRequiredForLegalForm_throwsPlatformApiDataValidationException`
- [x] All 11 tests in `ClientDataValidatorTest` pass
- [x] `./gradlew :fineract-provider:compileJava
:fineract-provider:compileTestJava` — builds clean
- [x] `./gradlew :fineract-provider:spotlessApply` — no formatting drift
beyond this change
- [ ] Manual verification: configure a `Person`-only required datatable,
create an `Entity` client without datatables, confirm it now succeeds
https://issues.apache.org/jira/browse/FINERACT-2703
--
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]