rymghosn opened a new pull request, #6544: URL: https://github.com/apache/fineract/pull/6544
## Description JIRA: https://issues.apache.org/jira/browse/FINERACT-2879 Three defects in loan guarantor handling: 1. **Duplicate-guarantor message grammar.** `GuarantorWritePlatformServiceJpaRepositoryIImpl` returned "X is already exist as a guarantor for this loan"; it now returns "X already exists as a guarantor for this loan" (create and update paths). 2. **Guarantor list fails as a whole.** `GET /loans/{loanId}/guarantors` returned 404 `error.msg.client.not.found.with.client.id` for the entire list when one guarantor client was outside the calling user's office hierarchy. Guarantor creation does not apply that check, so this is easy to get into. Catching `ClientNotFoundException` is not enough: `ClientReadPlatformServiceImpl` joins the caller's read-only transaction, so the exception marks it rollback-only and the request ends in a 500 (`UnexpectedRollbackException`). `mergeDetailsForClientOrStaffGuarantor` now checks the client's visibility first with the same criteria as `ClientRepository.fetchByClientIdAndHierarchy` (office or transfer-to office hierarchy), and returns a guarantor the user cannot see without the merged client details. An unresolvable staff guarantor is handled the same way (`StaffReadServiceImpl` is not transactional, so a catch is safe there). 3. **Fabricated hold transaction.** `GuarantorTransactionMapper.mapRow` had no `id > 0` guard, unlike `GuarantorFundingMapper`, so a funded guarantor with no hold transaction yet was returned with one `Invalid` transaction of zero amount. It now returns `null` for the unmatched left join. ### Tests - New `GuarantorReadPlatformServiceImplTest` (4 tests): funded guarantor without a hold transaction, client guarantor outside / inside the office hierarchy, unresolvable staff guarantor. The original three fail on `develop`. - Live check with `bootRun` on PostgreSQL, same requests before and after the change: - duplicate `POST /loans/{loanId}/guarantors`: "is already exist" → "already exists" - `GET /loans/{loanId}/guarantors` as a user of office A, with a guarantor client in a sibling office B: 404 → 200 with both guarantors (the office-B one unmerged); a head-office user still gets both fully merged - funded guarantor on a not-yet-approved loan: one `Invalid` zero-amount transaction → empty `guarantorTransactions` No API change (response shape unchanged). ## 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 (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). Your assigned reviewer(s) will follow our [guidelines for code reviews](https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide). -- 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]
