samchinmaya opened a new pull request, #6732: URL: https://github.com/apache/fineract/pull/6732
## Description Jira: [FINERACT-2991](https://issues.apache.org/jira/browse/FINERACT-2991) `LoanProductUpdateUtil.update()` recorded an external ID change under the `accountingRule` key (a copy of the accounting rule block above it). `LoanProductWritePlatformServiceJpaRepositoryImpl.updateLoanProduct()` reads `changes.containsKey("accountingRule")` as "the accounting rule changed" and calls `updateLoanProductToGLAccountMapping(..., accountingRuleChanged = true, ...)`, so: - `PUT /loanproducts/{id}` with only `externalId` fails with 400 "The parameter `accountingRule` is mandatory." - with the accounting rule and the basic GL account ids added, the request succeeds, but all GL account mappings are deleted and recreated from the request, so the advanced mappings that the request does not repeat (payment channel to fund source, fee to income, ...) are lost. The response shows the new external ID under `accountingRule`. The fix puts the change under `externalId`. **Tests:** new `LoanProductUpdateUtilTest` (2 tests): an external ID change is reported as `externalId` and not as `accountingRule`; an unchanged external ID is not reported. The first test fails on the old code. **Manual check** on a jibBuildTar image of this branch vs `apache/fineract:0df2ef786f` (develop), PostgreSQL. Product with accounting rule 3, one payment channel to fund source mapping and one fee to income mapping: | Request | develop | this PR | |---|---|---| | `PUT {description}` | 200, mappings 1, 1 → 1, 1 | 200, mappings 1, 1 → 1, 1 | | `PUT {externalId}` | **400** `accountingRule` is mandatory | 200, changes `{"externalId": ...}`, mappings kept | | `PUT {externalId}` + accounting rule + basic GL account ids | 200, changes `{"accountingRule": "<new external id>", ...}`, mappings 1, 1 → **0, 0** | 200, changes `{"externalId": ...}`, mappings 1, 1 → 1, 1 | `spotlessJavaApply` (no changes), `checkstyleTest` and the new test pass locally. ## Checklist - [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 (no API change) - [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]
