samchinmaya opened a new pull request, #6644: URL: https://github.com/apache/fineract/pull/6644
## Description JIRA: [FINERACT-2944](https://issues.apache.org/jira/browse/FINERACT-2944) `POST /collectionsheet?command=saveCollectionSheet` returns 200 but creates no loan repayment: the response has no `loanTransactions` and the loan balance does not change. This happens with the documented request (`bulkRepaymentTransactions` at the top level) and with the shape of the current `CollectionSheetRequest` schema (lists nested inside `bulkDisbursementTransactions`). Cause: since FINERACT-2169 (a9fe523eae), `CollectionSheetApiResource` binds the body to `CollectionSheetRequest` and re-serializes it before processing. `CollectionSheetRequest` only had `bulkDisbursementTransactions` as an object holding `bulkRepaymentTransactions` and `bulkSavingsDueTransactions`, so a top-level `bulkRepaymentTransactions` (and `note`, and `staffId` for generateCollectionSheet) was dropped. `CollectionSheetBulkRepaymentCommandFromApiJsonDeserializer`, `CollectionSheetTransactionDataValidator` and `DepositAccountAssembler` read the lists at the top level, so the nested shape was ignored as well. Change: - `CollectionSheetRequest` matches the request read by the save command again: top-level `bulkDisbursementTransactions`, `bulkRepaymentTransactions` and `bulkSavingsDueTransactions` lists, plus `note`, and `staffId` (read by generateCollectionSheet). `DisbursementTransactionsRequest` becomes `DisbursementTransactionRequest` (one disbursement: `loanId`, `transactionAmount`), and `RepaymentTransactionRequest` gets the `externalId` the deserializer reads. - `CollectionSheetBulkRepaymentCommandFromApiJsonDeserializer` skipped a repayment when `transactionAmount.intValue() > 0` was false, so 0.50 was dropped; it now compares with zero. - Tests: `CollectionSheetIntegrationTest.saveIndividualCollectionSheetCreatesTheLoanRepayments` saves two repayments (1000 and 0.50) and checks both are created and the loan's total repayment is 1000.50; `CollectionSheetBulkRepaymentCommandFromApiJsonDeserializerTest` covers the amount check. Verification: - `CollectionSheetBulkRepaymentCommandFromApiJsonDeserializerTest` passes; `spotlessJavaApply`, `checkstyleMain` and `checkstyleTest` pass. (`CollectionSheetIntegrationTest` could not be compiled locally: generating fineract-client needs more memory than my machine has, so it is left to CI.) - Real API, on a Fineract image built from this branch: - `saveCollectionSheet` with `bulkRepaymentTransactions` `[{loanId: 3, transactionAmount: 100}, {loanId: 4, transactionAmount: 0.5}]` and a `note` returns `"loanTransactions": [10, 11]` and the note; loan 3 outstanding goes from 1071.39 to 971.39 and loan 4 gets a 0.50 repayment (on develop: 200 with no `loanTransactions`, balances unchanged). - The nested shape (lists inside a `bulkDisbursementTransactions` object) is now rejected with 400 `error.msg.invalid.json.data` instead of being accepted and ignored. - `generateCollectionSheet` with a `staffId` filters by staff (an unknown staff id returns no clients). Related: FINERACT-2362 (refactor of the individual collection sheet save request). The Mifos web app currently sends the nested shape; it will be switched to the documented request in a follow-up there. ## 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). - [x] 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 `CollectionSheetRequest` schema now matches the request already documented in apiLive.htm) - [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]
