Aman-Mittal opened a new pull request, #677:
URL: https://github.com/apache/fineract-backoffice-ui/pull/677

   ## What and why
   
   Adds `LOAN_API` and `LOAN_TRANSACTION_API` under the ADR 0006 boundary and 
migrates the four files that can move without cascading into `loan-view`. The 
`local/no-generated-api-import` baseline falls **462 → 458**.
   
   Every disagreement below was verified against a running `apache/fineract`, 
not read off the spec.
   
   ### The generated loan status is wrong, and a template was branching on it
   
   `GetLoansLoanIdStatus` does not declare `value` — which every loan status 
carries — and *does* declare `description`, which no payload sends:
   
   ```json
   
{"id":200,"code":"loanStatusType.approved","value":"Approved","waitingForDisbursal":true,...}
   ```
   
   The application was reaching around that in eight places, two of them like 
this:
   
   ```ts
   return (status as unknown as Record<string, unknown>)?.['value'] === 
'Approved';
   ```
   
   In the loans list it was a **live defect**:
   
   ```html
   @if (loan.status?.value === 'Approved') { <!-- offers Disburse --> }
   ```
   
   `value` comes from a localisable enum, so a platform serving any other 
locale offers neither Approve nor Disburse, and nothing indicates why. Nothing 
caught it either: these buttons sit in an `<ng-template appCellTemplate>` whose 
`let-loan` context is `any`, so `strictTemplates` never checked a field the 
generated model does not even declare. The compiler was not going to catch this 
one.
   
   The gates now read Fineract's own flags — `pendingApproval`, 
`waitingForDisbursal`.
   
   ### One transaction payload, two generated types, both wrong
   
   The generated client models the same `type` object twice and inconsistently: 
`GetLoansLoanIdLoanTransactionEnumData` declares `value`, `GetLoansType` does 
not and declares `description` instead. `date` is declared `string` on both and 
arrives as `[2026, 10, 2]`.
   
   `transaction-detail-dialog.component.ts` carried the consequences — the date 
converted twice, two different ways, each through a cast or an `unknown`, and 
the type label reached through `Record<string, unknown>` with a three-way 
fallback. It already had a comment naming the cause, which is how this was 
found.
   
   `GetPaymentTypeOptions` likewise omits the `codeName` the chargeback dialog 
selects its default payment type by. **That lookup does work today** — option 2 
carries the field — so this is not a bug being fixed; it is a cast removed from 
a line whose correctness nothing else was checking.
   
   ## Recorded, not fixed here
   
   The loans list passes its search box to Fineract's `accountNo` parameter, 
which is an **exact** match:
   
   | query | rows |
   | --- | --- |
   | `accountNo=000000053` | 1 |
   | `accountNo=0000` | 0 |
   | `accountNo=E2E` | 0 |
   
   So the list offers a search box that only answers a full zero-padded account 
number and silently empties the table for a client name, a product, or a 
partial number. `GET /loans` has no free-text parameter to point it at, so 
correcting it needs a product decision. `LoanQuery` names the field `accountNo` 
rather than `search` so the next caller does not assume otherwise.
   
   ## Scope
   
   The honest batch is smaller than a "clears the most violations" search 
suggests, and ADR 0006 now records why. The files such a search ranks highest — 
`loan-charge-refund.ts`, `loan-contract-termination.ts`, 
`loan-delinquency-action.model.ts` — are pure functions that merely *name* 
generated types in their signatures. Re-typing them clears nothing on its own, 
because every one of them is called from `loan-view.component.ts`, which stays 
on the generated client, so the change cascades into a 1,900-line component 
that is not being migrated. Prefer files that *inject* a generated service: 
there the adapter replaces the dependency outright and the blast radius stops 
at the file.
   
   `toIsoFineractDate` moves to `fineract-date.ts` now that two adapters 
convert inbound dates; a second copy would be a second place for the month base 
to be wrong.
   
   ## Verification
   
   - `npm run lint` clean; `prettier --check .` clean; baseline re-pruned 
(`lint:prune`), 782 → 778 total.
   - **1874 unit tests pass** (282 files, 30 new), exercised against a live 
Fineract for every fixture in the new adapter specs.
   - **Eight mutations killed.** Dropping `waitingForDisbursal`; misplacing 
`accountNo` in the positional argument list; reverting `displayName` to the 
generated type's phantom field; dropping `codeName`; dropping the `dateFormat` 
the platform parses the date against; and restoring the two original 
English-text gates.
   
   That last mutation is the one worth reporting: it failed **exactly one** 
test — the non-English-locale case — while all four English-status tests still 
passed. The old code is correct for English and wrong for every other locale, 
and only that test tells them apart, which is the whole point of the change.
   
   One visible change beyond the refactor: the detail dialog's transaction date 
was rendered with `toLocaleDateString()` on the raw array and now uses the 
project's `formatDateToFineract` (`02 October 2026`), which reads a date-only 
string through its parts and so does not drift a day west of Greenwich — the 
hazard `core/utils/date-formatter.ts` documents at length.
   
   ## Screenshots
   
   Not applicable — no visual change beyond the date format noted above and the 
two action buttons now appearing for the correct statuses.
   
   ## Checklist
   
   - [x] I did not hand-edit generated files under `src/app/api/`.
   - [x] New component or service code uses the adapter boundary in 
`src/app/core/adapters/`.
   - [x] User-facing strings use translation keys.
   - [x] I added or updated tests appropriate to this change.
   - [ ] UI workflow changes include suitable e2e coverage — not added here. 
The loans-list gates are covered by a component spec that renders the real cell 
templates; the backend-project e2e for loan approve/disburse already exists and 
is unaffected.
   - [x] Commits are signed.
   


-- 
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]

Reply via email to