android-client icon indicating copy to clipboard operation
android-client copied to clipboard

feat(loan): Implement Loan Charge-Off Screen

Open sahilshivekar opened this issue 5 months ago โ€ข 2 comments

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.

sahilshivekar avatar Jun 19 '26 16:06 sahilshivekar

Review Change Stack

[!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_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to 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

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.

โค๏ธ Share

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot] avatar Jun 19 '26 16:06 coderabbitai[bot]

@sahilshivekar upload video or screenshots

revanthkumarJ avatar Jul 01 '26 10:07 revanthkumarJ

@sahilshivekar upload video or screenshots

@revanthkumarJ The app isn't working now. Server is responding with status code 502

sahilshivekar avatar Jul 01 '26 10:07 sahilshivekar

@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 avatar Jul 01 '26 11:07 revanthkumarJ

@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

sahilshivekar avatar Jul 01 '26 11:07 sahilshivekar

while you called api show a overlay loader @sahilshivekar

@revanthkumarJ Done now

sahilshivekar avatar Jul 02 '26 10:07 sahilshivekar