Aana123 opened a new pull request, #224: URL: https://github.com/apache/fineract-consumer-facing/pull/224
## What and why Moves `LoansQueryServiceImpl` behind a narrow, intent-level adapter so the loans query feature no longer depends on the generated Fineract Feign clients (option 1 in #188). - **New `LoansQueryFineractClient` / `LoansQueryFineractClientImpl`** in `infrastructure.fineractclient.service`, replacing six injected generated APIs (`LoansApi`, `LoanTransactionsApi`, `LoanChargesApi`, `GuarantorsApi`, `LoanProductsApi`, `ClientApi`). - **Intent-level methods, not a 1:1 mirror** (following #211 and the feedback on #155): e.g. `getLoanWithScheduleAndTransactions`, `getAllTransactions`, `previewSchedule`. Fineract plumbing now lives only in the adapter: the associations string, the `calculateLoanSchedule` command, `locale`/`dateFormat`/`loanType`, positional nulls and the fetch-all page size. - **Error translation stays in the feature service.** `fetch`, `previewCall` and `fetchProduct` and their `FineractCaller` mappings are unchanged, so every error code is the same. - **Named `LoansQueryFineractClient`** to stay separate from the command-side `LoansFineractClient` (#221); the two could be merged later if preferred. - Removed the now-unused `CALCULATE_SCHEDULE_COMMAND` from `LoansQueryService`. - The frozen ArchUnit store shrank by 23 lines, all `LoansQueryServiceImpl`; nothing added, regenerated by the test run. Commits: 1. Add the adapter, with a test per method asserting the exact generated call and arguments. 2. Switch the service over, update its test to mock the adapter, and shrink the store. 3. Add service tests for the read paths that had none. No behaviour change. Part of #188 ## Verification - `./gradlew test`: full suite passes (607 tests; 21 added to `LoansQueryServiceImplTest`, 10 → 31, plus 13 in `LoansQueryFineractClientImplTest`) - `./gradlew test --tests '*ArchitectureTest'`: all pass - `./gradlew compileJava spotbugsMain modernizer`: passes - Store diff vs `main` removes only `LoansQueryServiceImpl` entries - Manually exercised every loans read on the local stack: list, loan details (next due), transactions with and without a date filter, single transaction, charges, single charge, guarantors, application template (browse and product detail), schedule preview The new service tests cover `getLoan`, `calculateSchedule`, `getTransaction`, `getCharges`, `getCharge`, `getGuarantors` and `getApplicationTemplate`, previously untested, including each error mapping with its error code. ## Observed, not changed Existing behaviour I noticed while testing, left as-is to keep this a pure refactor: - `calculateSchedule`: only a Fineract 400 maps to `LoanSchedulePreviewInvalidException`; a 422 surfaces as upstream unavailable. - If Fineract returns an empty body, `getLoan`, `getTransaction`, `getCharge`, `calculateSchedule` and the product-detail template would throw a `NullPointerException` in the mappers. - Unrelated to this PR, also on `main`: submitting a loan application gives no feedback in the UI, so clicking again creates duplicate applications. I can open a separate issue for it. Happy to file the first two as issues too if useful. ## Screenshots Not applicable (backend refactor). ## AI assistance (optional) - Tool / model: Claude - Harness / workflow: drafted each commit from a written spec; I reviewed every diff against the original service, ran the checks above, and did the manual walk-through. ## Checklist - [x] I did not hand-edit generated files under `frontend/src/openapi-client/`. - [x] Backend code follows the feature and CQRS layout in AGENTS.md. - [x] I did not add entries to a lint or architecture baseline (this PR only removes them). - [x] User-facing strings use translation keys. (None changed.) - [x] I added or updated tests appropriate to this change. - [x] UI workflow changes include suitable e2e coverage. (No UI changes.) - [x] Commits are signed. - [x] I followed the AI-assisted contributions guidance. - [x] Refactor only; no dev-list discussion needed. -- 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]
