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

feat(loan): implement loan reject screen

Open gurnoorpannu opened this issue 9 months ago • 14 comments

Fixes - Jira-#703

Implementation:- Screen_recording_20260331_105718.webm

  • [ ] Run the static analysis check ./gradlew check or ci-prepush.sh to make sure you didn't break anything

  • [ ] If you have multiple commits please combine them into one commit by squashing them.

Summary by CodeRabbit

  • New Features
    • Loan rejection flow: new Reject Loan screen from loan profile with date picker, optional note, discard confirmation, and success notification that refreshes details.
    • Navigation: direct path to Reject Loan and result handling to show success snackbar and refresh.
    • Validation & UX: prevents selecting future rejection dates; loading and error feedback shown.
    • Misc UX: profile screen wired to launch rejection and auto-refreshes when returning to screens.

gurnoorpannu avatar Mar 02 '26 15:03 gurnoorpannu

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

Walkthrough

Adds a complete loan-rejection feature: new data models, network API, data/repository and use-case wiring, a Compose screen and ViewModel with validation, date helpers, navigation integration, DI registrations, and localized strings.

Changes

Cohort / File(s) Summary
Network & DataManager
core/network/.../LoanService.kt, core/network/.../DataManagerLoan.kt
Added rejectLoan API method on LoanService and a delegating DataManagerLoan.rejectLoan.
Data Models
core/model/.../RejectLoanPayload.kt, core/model/.../RejectLoanResponse.kt
New serializable request/response types for loan rejection.
Repository & DI (data layer)
Repository
core/data/repository/LoanAccountRejectRepository.kt, core/data/repositoryImp/LoanAccountRejectRepositoryImp.kt
Module
core/data/.../RepositoryModule.kt
Introduced LoanAccountRejectRepository and implementation; registered binding in repository DI module.
Domain & UseCase
core/domain/useCases/RejectLoanUseCase.kt, core/domain/.../UseCaseModule.kt
New RejectLoanUseCase that calls repository; registered in domain DI.
Feature: UI, ViewModel, State & Actions
feature/loan/loanReject/RejectLoanScreen.kt, feature/loan/loanReject/RejectLoanViewModel.kt, feature/loan/loanReject/RejectLoanViewState.kt, feature/loan/loanReject/RejectLoanAction.kt, feature/loan/loanReject/RejectLoanEvent.kt, feature/loan/loanReject/LoanRejectScreenRoute.kt
Full Compose screen, ViewModel with validation/submission/error handling, actions/events, state model, and navigation route for reject flow.
Loan Profile & Integration
feature/loan/loanAccountProfile/LoanAccountProfileScreen.kt, feature/loan/loanAccountProfile/LoanAccountProfileViewModel.kt, feature/loan/loanAccountProfile/LoanAccountProfileNavigation.kt, feature/loan/loanAccountProfile/components/LoanAccountProfileActionItem.kt
Added RejectLoan action item, consolidated detail navigation callback, added reject callback and success snackbar handling; updated events for navigation.
Feature DI & Navigation
feature/loan/di/LoanModule.kt, feature/loan/navigation/LoanNavigation.kt
Registered RejectLoanViewModel; wired reject screen into loan navigation with success result key and navigation helpers.
Date utilities
core/common/.../DateHelper.kt
Added today(), LocalDate.toDisplayDate(), LocalDate.toEpochMillis(), and Long.toLocalDate() helpers.
Strings & Client lifecycle
feature/loan/.../strings.xml, feature/client/clientLoanAccounts/ClientLoanAccountsScreen.kt
Added localized strings for rejection UI and a lifecycle observer to refresh loan accounts on resume.

Sequence Diagram(s)

sequenceDiagram
    participant UI as Client UI
    participant VM as RejectLoanViewModel
    participant UC as RejectLoanUseCase
    participant Repo as LoanAccountRejectRepository
    participant DM as DataManagerLoan
    participant API as LoanService

    UI->>VM: User fills date & note, taps Submit
    VM->>VM: validate(state)
    VM->>UC: invoke(loanId, RejectLoanPayload)
    UC->>Repo: rejectLoan(loanId, payload)
    Repo->>DM: rejectLoan(loanId, payload)
    DM->>API: POST /loans/{loanId}?command=reject
    API-->>DM: RejectLoanResponse
    DM-->>Repo: RejectLoanResponse
    Repo-->>UC: RejectLoanResponse
    UC-->>VM: RejectLoanResponse
    VM-->>UI: Emit RejectSuccess event / update state

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • itsPronay
  • revanthkumarJ
  • sahilshivekar

Poem

🐰 A tiny hop to close a loan's gate,
Dates and notes lined up in tidy state,
From screen to API the carrots flow,
Repos and use-cases help the garden grow. 🌿

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.04% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(loan): implement loan reject screen' directly and clearly describes the main feature addition in this PR—a new loan rejection screen implementation across multiple layers (data, domain, network, and UI).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests

[!TIP]

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 and usage tips.

coderabbitai[bot] avatar Mar 02 '26 15:03 coderabbitai[bot]

@gurnoorpannu View Account should navigate to Loan Profile Screen but it is still navigation the old Loan Account Summary Screen. Please review.

image

It could be possible that the local branch hasn't been updated yet. If that's the case, then please do it and update the screen recording in the PR description with the new Loan Flow UI screens.

biplab1 avatar Mar 05 '26 09:03 biplab1

@gurnoorpannu View Account should navigate to Loan Profile Screen but it is still navigation the old Loan Account Summary Screen. Please review.

image It could be possible that the local branch hasn't been updated yet. If that's the case, then please do it and update the screen recording in the PR description with the new Loan Flow UI screens.

@biplab1 Yeah! when I implemented this ticket , at that time the old LoanAccountSummaryScreen was in use , I'll update that

gurnoorpannu avatar Mar 06 '26 07:03 gurnoorpannu

@gurnoorpannu the iOS build is currently failing because this KMP project isn’t integrated using CocoaPods. As a result, there is no cmp_shared.podspec, which is why the build shows errors like generateDummyFramework not found.

Also, this project still has several existing issues. The last time I checked, there were database-related problems that prevented proper integration with iOS. It would be best to first make sure those issues are resolved and that the project is stable.

Once everything is fixed and verified, we can proceed with integrating it properly with iOS and then address the build issue.

HekmatullahAmin avatar Mar 06 '26 16:03 HekmatullahAmin

@gurnoorpannu add screen record of error screens as well. dialog dismiss, invalid date, test them and add a screen record

itsPronay avatar Mar 22 '26 14:03 itsPronay

@gurnoorpannu Also update your branch with latest changes

Arinyadav1 avatar Apr 05 '26 06:04 Arinyadav1

@gurnoorpannu Also update your branch with latest changes

@Arinyadav1 done

gurnoorpannu avatar Apr 06 '26 06:04 gurnoorpannu

Hello, it has been noted that despite undergoing review and discussion, the majority of the issues remain unresolved. Furthermore, the codebase does not adhere to established best practices and our internal guidelines. Please examine another project and implement the necessary updates accordingly.

@niyajali do you want me to press the "Resolve conversation" button too , as what I think is I have updated the code with whatever you commented here , I was told that the reviewer who made the comment will only resolve it

gurnoorpannu avatar Apr 22 '26 16:04 gurnoorpannu

@niyajali if there is some particular practice that you think I missed can you be blunt and mention it here

gurnoorpannu avatar Apr 22 '26 17:04 gurnoorpannu

Hello, it has been noted that despite undergoing review and discussion, the majority of the issues remain unresolved. Furthermore, the codebase does not adhere to established best practices and our internal guidelines. Please examine another project and implement the necessary updates accordingly.

@niyajali do you want me to press the "Resolve conversation" button too , as what I think is I have updated the code with whatever you commented here , I was told that the reviewer who made the comment will only resolve it

Hello, it has been noted that despite undergoing review and discussion, the majority of the issues remain unresolved. Furthermore, the codebase does not adhere to established best practices and our internal guidelines. Please examine another project and implement the necessary updates accordingly.

@niyajali do you want me to press the "Resolve conversation" button too , as what I think is I have updated the code with whatever you commented here , I was told that the reviewer who made the comment will only resolve it

@gurnoorpannu I believe there are still outstanding issues that need addressing. We should use a proper dispatcher, incorporate try-catch blocks, and verify network connectivity before initiating requests. We have already discussed the methodologies for these tasks, and a module refactor adhering to established conventions and standards is forthcoming. It's crucial that we align with these new standards, meanwhile concurrently resolve other problems within the UI codebase and screens.

niyajali avatar Apr 23 '26 09:04 niyajali

The PR shouldn't be having the changes related to passcode library. Please review.

biplab1 avatar Apr 23 '26 11:04 biplab1

@biplab1 sir I have made the changes , can you have a quick look and see if everything looks fine :)

gurnoorpannu avatar Apr 24 '26 06:04 gurnoorpannu

closing in reference with https://github.com/openMF/mifos-x-field-officer-app/pull/2702

revanthkumarJ avatar Jul 29 '26 04:07 revanthkumarJ