feat(loan): Implement Loan Charge-Off Screen
Fixes - Jira-#690
Note: Loan charge-off feature is working fine, but since the action should be invoked from the Actions list of active loan account this PR will need to make changes once this https://github.com/openMF/mifos-x-field-officer-app/pull/2660 PR get's merged.
[!NOTE]
Reviews paused
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
reviews.auto_review.auto_pause_after_reviewed_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
- [ ] โถ๏ธ Resume reviews
- [ ] ๐ Trigger review
No actionable comments were generated in the recent review. ๐
โน๏ธ Recent review info
โ๏ธ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8810919d-bbc9-4279-a8c6-4c64e4b278a7
๐ฅ Commits
Reviewing files that changed from the base of the PR and between c25c091f56eb86a72daf3cff75dac92e8f783367 and 42c71b91095efdba4fbe0b931a787391f5fc4126.
๐ Files selected for processing (1)
feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanChargeOff/LoanChargeOffScreen.kt
๐ง Files skipped from review as they are similar to previous changes (1)
- feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanChargeOff/LoanChargeOffScreen.kt
๐ Recent review details
โฐ Context from checks skipped due to timeout. (1)
- GitHub Check: PR Checks / Static Analysis Check
Summary by CodeRabbit
-
New Features
- Added a new loan charge-off flow with template loading, reason selection, date entry, optional external ID and note fields, and submit confirmation.
- Added navigation support and a new charge-off action in loan screens.
- Introduced new status and charge-off string resources plus a dedicated charge-off icon.
-
Bug Fixes
- Improved list item stability in loan action screens for smoother updates and recomposition.
Walkthrough
Adds a loan charge-off flow with new models, network API wiring, repository and domain layers, a charge-off screen and view model, and navigation entry points integrated into loan actions.
Changes
Loan Charge Off Feature
Layer-by-layer breakdown
| Layer / File(s) | Summary |
|---|---|
Models and network API ChargeOffReasonOption.kt, LoanChargeOffInput.kt, LoanChargeOffRequestDto.kt, LoanChargeOffResponseDto.kt, LoanChargeOffTemplateDto.kt, LoanService.kt, DataManagerLoan.kt |
Adds charge-off model classes, serializable request/response/template DTOs, new LoanService endpoints, DataManagerLoan methods, and JSON decoding formatting changes. |
Repository and domain wiring ChargeOffReasonOptionMapper.kt, LoanChargeOffInputMapper.kt, LoanChargeOffRepository.kt, LoanChargeOffRepositoryImpl.kt, GetLoanChargeOffTemplateUseCase.kt, LoanChargeOffUseCase.kt, RepositoryModule.kt, UseCaseModule.kt |
Adds DTO-to-model mappers, the charge-off repository interface and implementation, two domain use cases, and Koin registrations for repository and use cases. |
Charge-off UI state and screen LoanChargeOffState.kt, LoanChargeOffViewModel.kt, LoanChargeOffScreen.kt, MifosIcons.kt, charge_off.xml, strings.xml |
Adds the charge-off state model, view model contracts and logic, Compose screen content, the charge-off icon and drawable, and new string resources. |
Navigation entry points LoanChargeOffScreenRoute.kt, LoanModule.kt, LoanAccountActionNavigation.kt, LoanAccountActionItem.kt, LoanAccountActionScreen.kt, LoanActionPaymentsScreen.kt, LoanNavigation.kt, LoanAccountProfileNavigation.kt, LoanAccountProfileScreen.kt |
Adds the charge-off route and navigation helper, registers the screen and view model in Koin, wires the loan account action item and callbacks, and updates loan profile screen parameter ordering. |
Estimated code review effort: 3 (Moderate) | ~25 minutes
Sequence Diagram(s)
Charge-off submission flow
sequenceDiagram
participant User
participant LoanChargeOffScreen
participant LoanChargeOffViewModel
participant LoanChargeOffUseCase
participant LoanChargeOffRepository
participant DataManagerLoan
User->>LoanChargeOffScreen: opens screen with loanId
LoanChargeOffScreen->>LoanChargeOffViewModel: init and loadTemplate()
LoanChargeOffViewModel->>LoanChargeOffUseCase: getChargeOffTemplate(loanId)
LoanChargeOffUseCase->>LoanChargeOffRepository: getChargeOffTemplate(loanId)
LoanChargeOffRepository->>DataManagerLoan: getChargeOffTemplate(loanId)
DataManagerLoan-->>LoanChargeOffRepository: template DTO
LoanChargeOffRepository-->>LoanChargeOffViewModel: DataState<List<ChargeOffReasonOption>>
User->>LoanChargeOffScreen: selects reason and submits
LoanChargeOffScreen->>LoanChargeOffViewModel: Submit
LoanChargeOffViewModel->>LoanChargeOffUseCase: chargeOff(loanId, LoanChargeOffInput)
LoanChargeOffUseCase->>LoanChargeOffRepository: chargeOff(loanId, LoanChargeOffInput)
LoanChargeOffRepository->>DataManagerLoan: chargeOff(loanId, requestDto)
DataManagerLoan-->>LoanChargeOffRepository: response DTO
LoanChargeOffRepository-->>LoanChargeOffViewModel: DataState<Unit>
LoanChargeOffViewModel-->>LoanChargeOffScreen: dialog / success event
Possibly related PRs
- openMF/mifos-x-field-officer-app#2660: Extends the loan account actions navigation and screen wiring that this charge-off flow plugs into.
Suggested reviewers: revanthkumarJ, niyajali, Nagarjuna0033
[!IMPORTANT]
Pre-merge checks failed
Please resolve all errors before merging. Addressing warnings is optional.
โ Failed checks (1 error, 1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Jira Link And Before/After Sections | โ Error | The Jira link is present, but the description has a table instead of literal Before:/After: sections, so the required sections are missing. | Rewrite the PR description with separate 'Before:' and 'After:' headings, and include image/video media under each section. |
| Docstring Coverage | โ ๏ธ Warning | Docstring coverage is 2.86% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
โ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | โ Passed | The title follows the required format and clearly summarizes the loan charge-off screen work. |
| Description check | โ Passed | The description is directly related to the charge-off screen, reload behavior, and LazyColumn key fix. |
โจ Finishing Touches
๐งช Generate unit tests (beta)
- [ ] Create PR with unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
@sahilshivekar upload video or screenshots
@sahilshivekar upload video or screenshots
@revanthkumarJ The app isn't working now. Server is responding with status code 502
@sahilshivekar upload video or screenshots
@revanthkumarJ The app isn't working now. Server is responding with status code 502
ask victor once in slack and let me know once its working and screenshots or video is attached with this pr
@sahilshivekar upload video or screenshots
@revanthkumarJ The app isn't working now. Server is responding with status code 502
ask victor once in slack and let me know once its working and screenshots or video is attached with this pr
@revanthkumarJ I did that already, he isn't active
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
while you called api show a overlay loader @sahilshivekar
@revanthkumarJ Done now