rymghosn opened a new pull request, #6538: URL: https://github.com/apache/fineract/pull/6538
## Description JIRA: https://issues.apache.org/jira/browse/FINERACT-2874 The Entity Data Table Checks template (`GET /v1/entityDatatableChecks/template`) lists Loan Product (`m_product_loan`) in `entities`. But a datatable registered on `m_product_loan` never shows up in its `datatables`, and `POST /v1/entityDatatableChecks` with `entity=m_product_loan` fails with `The parameter status must be one of [ ]`. Root cause: `EntityTables.LOAN_PRODUCT` declares no check statuses. `RegisterDataTableMapper` keeps only entities that pass `EntityTables::hasCheck`, and `EntityDatatableChecksDataValidator` checks `status` against `EntityTables.getCheckStatusCodes(entity)`, which is empty for `m_product_loan`. Loan product creation also never runs the check. This PR: - adds the `CREATE` check status to `LOAN_PRODUCT` and exposes `statusLoanProduct` in the template (data class and Swagger model); - lets `POST /v1/loanproducts` accept a `datatables` array (same shape as client, loan and savings account create). The entries are saved through `EntityDatatableChecksWritePlatformService.saveDatatables`, then `runTheCheck` enforces the CREATE check. `PUT /v1/loanproducts/{id}` still rejects `datatables`. This follows the same approach as FINERACT-2455 used for Working Capital loan creation. ### Testing - `EntityTablesTest`: new test that `LOAN_PRODUCT` has the CREATE check and `getCheckStatusCodes("m_product_loan")` returns `[100]`. - New `EntityDatatableChecksReadPlatformServiceImplTest` (2 tests): the template's datatable query includes `m_product_loan`, and `statusLoanProduct` is `[CREATE/100]`. - New `LoanProductDataValidatorDatatablesTest` (2 tests): `datatables` is a supported parameter on create and is still rejected on update. - Live on a local PostgreSQL instance booted with `bootRun`, with a datatable registered on `m_product_loan`: - `develop` (`213f517b88`): the template lists no `m_product_loan` datatables and has no `statusLoanProduct`; `POST /v1/entityDatatableChecks` (`entity=m_product_loan`, `status=100`) returns 400 `status must be one of [ ]`; `POST /v1/loanproducts` with `datatables` returns 400 `The parameter datatables is not supported`. - With this PR: the template lists the datatable, and `statusLoanProduct` is `[{"name":"CREATE","code":100}]`. The check is created (200). Loan product create without `datatables` returns 403 `error.msg.entry.required.in.datatable.[...]` and nothing is persisted. Create with `datatables` returns 200, and the row reads back from `GET /v1/datatables/{name}/{productId}`. Update with `datatables` still returns 400. - `spotlessJavaCheck` passes for `fineract-core` and `fineract-provider`. ## 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 (the template Swagger model now has `statusLoanProduct`; the loan product create Swagger model and `apiLive.htm` are not updated for `datatables` yet) - [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). Your assigned reviewer(s) will follow our [guidelines for code reviews](https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide). 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
