shivaansh0610-LUFFY opened a new pull request, #639:
URL: https://github.com/apache/fineract-backoffice-ui/pull/639

   <!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at
   
     http://www.apache.org/licenses/LICENSE-2.0
   
   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
   -->
   
   <!-- Commits must be signed to merge — see CONTRIBUTING.md#commit-signing if 
you haven't set this up. -->
   
   ## What and why
   
   Adds a row-level **Chargeback** action to the loan Transactions tab, so a 
repayment applied in error (or later dishonoured) can be corrected from the app 
instead of outside it.
   
   Fineract accepts `chargeback` only against a specific transaction — `POST 
/loans/{id}/transactions?command=chargeback` answers 
`error.msg.query.parameter.value.unsupported`, while `POST 
/loans/{id}/transactions/{transactionId}?command=chargeback` is recognised. So 
this is a per-row action beside the repayment, not an entry on the loan's 
Actions menu.
   
   - A chargeback button appears on repayment rows that have not been reversed, 
and only for users holding `CHARGEBACK_LOAN` (`appRequiresPermission`).
   - It opens a small dialog collecting the amount (prefilled with the full 
repayment, editable for a partial chargeback) and a payment type (defaults to 
Fineract's shipped "Repayment Adjustment Chargeback").
   - The request is `postLoansLoanIdTransactionsTransactionId(loanId, 
transactionId, { transactionAmount, locale, paymentTypeId? }, 'chargeback')`, 
then the loan is reloaded. Platform validation errors (for example an amount 
larger than what is left of the repayment) surface through the existing error 
interceptor toast.
   - Behaviour worth knowing: Fineract does not reverse the original repayment. 
It records a separate `Chargeback` transaction that adds the amount back to the 
loan balance, so the copy says "recorded", not "reversed".
   - The dialog uses the app-owned `ButtonComponent` and native form controls, 
so it adds no new `local/no-vendor-ui-import` suppression.
   
   Closes #503
   
   ## Verification
   
   - Ran against a real local Fineract (`apache/fineract`, docker) with a 
seeded Active loan and a 100.00 repayment: the chargeback row action appears on 
the repayment only (not on the disbursement or accrual rows), the dialog 
defaults to the full amount and the "Repayment Adjustment Chargeback" payment 
type, and confirming adds a `Chargeback` transaction (loan outstanding 1106.35 
→ 1206.35) and shows the "Chargeback recorded." toast.
   - Confirmed against the same backend that a second chargeback beyond the 
remaining repayment amount is rejected by the platform ("chargeback not allowed 
as loan transaction amount is not enough").
   - Unit tests added in `loan-view.component.test.ts` (eligibility, posts 
against the transaction rather than the loan, cancel sends nothing) and 
`loan-command-dialogs.test.ts` (defaults, payload shape, missing payment types, 
zero amount, cancel). `npm run test:unit` for `src/app/features/loans` — 88 
tests pass.
   - `eslint` on `src/app/features/loans` and `prettier --check .` are clean.
   - Not verified: that a chargeback reopens a loan the repayment had closed. 
The UI makes no such claim.
   
   ## Screenshots
   
   ### Before
   
   Transactions tab has no per-row action:
   
   <img width="1440" height="900" alt="before-1-transactions-tab" 
src="https://github.com/user-attachments/assets/6630aa02-5945-4496-989e-22c0eac5ddd1";
 />
   
   Transaction detail offers no chargeback:
   
   <img width="1440" height="900" alt="before-2-transaction-detail" 
src="https://github.com/user-attachments/assets/9dd7f144-0af2-4677-b893-a18c0f460f21";
 />
   
   Recording:
   
   
https://github.com/user-attachments/assets/72373db8-dfbf-4af7-a7cc-316b43fe6ac5
   
   ### After
   
   Chargeback action on the repayment row:
   
   <img width="1440" height="900" alt="after-1-transactions-tab" 
src="https://github.com/user-attachments/assets/2e1e2b0e-36cb-4f5e-9e57-f7bf06ffffe9";
 />
   
   Chargeback dialog:
   
   <img width="1440" height="900" alt="after-2-chargeback-dialog" 
src="https://github.com/user-attachments/assets/221bda9a-7795-4d74-b134-c7fbf7d4f332";
 />
   
   Result — new Chargeback transaction and confirmation toast:
   
   <img width="1440" height="900" alt="after-3-confirm" 
src="https://github.com/user-attachments/assets/d1dc0e84-afa0-4191-8b36-64881274971b";
 />
   
   Recording:
   
   
https://github.com/user-attachments/assets/d14e7078-f7d1-4f96-bf6f-8bc92017450f
   
   ## AI assistance (optional)
   
   <!-- If generative AI materially assisted this contribution, optionally 
state the tool or model and
   the harness or workflow used. The contributor remains responsible for the 
submitted change. -->
   
   - Tool / model:
   - Harness / workflow:
   
   ## Checklist
   
   <!-- Check each item, or explain why it does not apply. -->
   
   - [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/` instead of direct browser globals or imperative 
third-party APIs.
   - [x] User-facing strings use translation keys.
   - [x] I added or updated tests appropriate to this change, or explained why 
tests were not needed.
   - [ ] UI workflow changes include suitable e2e coverage, including 
real-backend testing where relevant. <!-- No Playwright spec added yet; 
exercised manually against a real backend as described above. -->
   - [ ] Commits are signed — see [Commit 
Signing](CONTRIBUTING.md#commit-signing) in CONTRIBUTING.md.
   - [ ] I followed the [AI-assisted contributions 
guidance](CONTRIBUTING.md#ai-assisted-contributions).
   


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