samchinmaya opened a new pull request, #6627: URL: https://github.com/apache/fineract/pull/6627
## Description JIRA: [FINERACT-2917](https://issues.apache.org/jira/browse/FINERACT-2917) Since FINERACT-2548, updating attendance on an existing meeting (`POST /{entityType}/{entityId}/meetings/{meetingId}?command=saveOrUpdateAttendance`) had three problems in `MeetingAttendanceWriteServiceImpl`: - **The wrong meeting was updated.** The meeting was loaded with `request.getEntityId()`, which is the group or center id from the URL, so the change went to whichever meeting had that id. A meeting id that doesn't exist was accepted too. The legacy code loaded the meeting by the meeting id. - **New attendees were not saved.** Clients without attendance on the meeting were added to the local set built from the request instead of the meeting's own `clientsAttendance`, so the response reported the change but nothing was persisted. - **`clientsAttendance` gave a 500.** The update request calls the list `meetingAttendance`, while the legacy API, the create request and the response all use `clientsAttendance`. Change: - Load the meeting with `request.getId()` (the `{meetingId}` from the URL); an unknown id gives 404 (`MeetingNotFoundException`). - Add new attendees to `meeting.getClientsAttendance()` (cascade and orphan removal are already set on the mapping). - `@JsonAlias("clientsAttendance")` on `meetingAttendance`, so both names work. - New `MeetingAttendanceWriteServiceImplTest`: the meeting from the URL is updated, unknown meeting gives not found, a new attendee is added to the meeting, an existing attendee's type is updated, and `clientsAttendance` is read into the list. Verification: - `MeetingAttendanceWriteServiceImplTest` passes (5/5), and all 5 fail with the main-code change reverted. `spotlessJavaCheck`, `checkstyle` and `spotbugs` pass. - Real API, same requests against `develop` and against a build of this branch (fresh database), on a group with meetings on 07 Sep (client present), 14 Sep and 21 Sep (no attendance): | Request | develop | this branch | |---|---|---| | Add the client as present on the 14 Sep meeting | 200, but the response is for another meeting and nothing is saved on 14 Sep | 200, saved on 14 Sep | | Mark the client absent on the 07 Sep meeting | overwritten by the next request (it went to the same meeting) | 07 Sep stays absent | | Same request with `clientsAttendance` instead of `meetingAttendance` | 500 | 200, saved | | Meeting id that doesn't exist | 200, changes another meeting | 404 "Meeting with identifier 999999 does not exist" | Not changed: the meeting isn't checked against the group or center in the URL (the legacy code didn't either; for a group inside a center, the meeting belongs to the center's calendar). ## 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). 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]
