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

feat(loan): implement loan dashboard screen

Open sahilshivekar opened this issue 8 months ago β€’ 12 comments

Fixes - Jira-#668

Before

https://github.com/user-attachments/assets/03fd4225-c676-4332-b6cb-5770bd136e81

After

As the content displayed on screen changes based on loan status, separate screen recording is added for each loan status

Active

https://github.com/user-attachments/assets/d6ac1a49-a8cd-41f5-a92f-17ea9dde9e97

Overpaid

https://github.com/user-attachments/assets/2189f780-0dae-42a9-9bdc-12b585d5fde2

Waiting for disbursal

https://github.com/user-attachments/assets/2ecf993c-fed4-48c6-845f-12b7a69832be

Pending approval

Screenshot 2026-04-03 200327

Rejected

Screenshot 2026-04-03 191425

Withdrawn by applicant

Screenshot 2026-04-03 200351

Closed obligations met

https://github.com/user-attachments/assets/1e71814b-8639-4f49-8660-4ab76144cf15

For following statuses no loan account found in the app, previews was failing with rendering issues

Closed written off Closed rescheduled

Summary by CodeRabbit

  • New Features

    • Full Loan Dashboard: detailed summary, timeline, recent transactions, graphs, actions and state-driven views.
  • UI / Visual

    • Interactive donut and stacked-bar charts with tooltips, legends, toggles, and new financial/analytics icons.
    • Multiple composed dashboard cards and preview states.
  • Theme

    • Added chart colors, status colors, negative spacing tokens, stroke token, and chart sizing.
  • Localization

    • Extensive new loan-related string resources.
  • Navigation

    • Dashboard routes and navigation callbacks wired for dashboard, profile, and transaction flows.
  • Chores

    • Added optional overpaid and withdrawn date fields for loans; view model/module wiring updates.

sahilshivekar avatar Mar 12 '26 13:03 sahilshivekar

[!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 Loan Dashboard feature (UI, state, viewmodel, routing), new chart composables, icons/colors/design tokens, many loan strings, DI/navigation wiring for dashboard, and two optional date-array fields on loan entities (overpaidOnDate, withdrawnOnDate).

Changes

Cohort / File(s) Summary
Entity changes
core/database/.../LoanWithAssociationsEntity.kt, core/database/.../LoanTimelineEntity.kt
Added optional date-array properties: overpaidOnDate: List<Int>? = null and withdrawnOnDate: List<Int>? = null.
Design system β€” Charts
core/designsystem/.../MifosDonutGraph.kt, core/designsystem/.../MifosStackedBarChart.kt
Added MifosDonutGraph and MifosStackedBarChart composables, tooltips/legends, helpers, and public data classes/utilities for chart rendering.
Design system β€” Icons / Colors / Tokens
core/designsystem/.../icon/MifosIcons.kt, core/designsystem/.../theme/Color.kt, core/designsystem/.../theme/DesignToken.kt
Added new icons, several AppColors (loan statuses, chartPrimary, chartSecondary), and new design tokens (negativeDp2/8/20, chartHeight, dp10).
Loan dashboard feature
feature/loan/.../loanDashboard/...
Implemented dashboard UI composables, state model, LoanDashboardViewModel, routing (LoanDashboardScreenRoute), navigation helpers, charts/timeline/transactions UI, previews, and action/event types.
Navigation & DI wiring
feature/loan/.../loanAccountProfile/LoanAccountProfileNavigation.kt, .../LoanAccountProfileScreen.kt, feature/loan/.../navigation/LoanNavigation.kt, feature/loan/.../di/LoanModule.kt
Registered LoanDashboardViewModel in DI; added and propagated navigateToDashboard: (Int) -> Unit through profile navigation; integrated dashboard route into loan navigation graph.
Strings / Localization
feature/loan/.../composeResources/values/strings.xml
Removed one string and added 50+ loan/dashboard-related string resources (statuses, labels, transactions, timeline, buttons); fixed malformed repayment key; some duplicated blocks present.

Sequence Diagram(s)

sequenceDiagram
    participant User as User
    participant Nav as Navigation
    participant Screen as LoanDashboardScreen
    participant VM as LoanDashboardViewModel
    participant Repo as LoanAccountSummaryRepository

    User->>Nav: navigateToLoanDashboardScreen(loanId)
    Nav->>Screen: instantiate with loanId
    Screen->>VM: request state for loanId
    VM->>Repo: loadLoanAccountSummary(loanId)
    Repo-->>VM: DataState (Loading / Success / Error)
    VM->>Screen: emit ViewState (Loading / Success / Error)
    Screen->>User: render UI (hero, graphs, timeline, transactions)
    User->>Screen: interact (toggle legend, tap graph, open transaction)
    Screen->>VM: dispatch LoanDashboardAction
    VM->>Nav: emit navigation event (NavigateToTransactions / NavigateBack / other)

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

  • openMF/mifos-x-field-officer-app#2650 β€” Similar navigation signature changes adding navigateToX: (Int) -> Unit for loan profile destinations.
  • openMF/mifos-x-field-officer-app#2611 β€” Related to loan data model and repayment schedule handling; touches LoanWithAssociationsEntity and overlapping loan strings.

Suggested reviewers

  • biplab1
  • niyajali
  • revanthkumarJ

Poem

🐰 I hopped with charts and gleam,
Donuts, bars, and dashboard dream,
Dates and strings in tidy rows,
Icons, tokens, colors glow,
A little hop β€” the dashboard grows!

πŸš₯ Pre-merge checks | βœ… 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 PR title 'feat(loan): implement loan dashboard screen' clearly and directly describes the main change: implementing a new loan dashboard screen feature.

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

✨ 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 Mar 12 '26 13:03 coderabbitai[bot]

@sahilshivekar Please fix the merge conflicts.

Also, is this graph interactive as in the web-app?

image

biplab1 avatar Mar 16 '26 09:03 biplab1

@sahilshivekar Please fix the merge conflicts.

Also, is this graph interactive as in the web-app?

@biplab1 Merge conflicts are resolved now. Donut Graph is now interactive, I have updated the screen recording for active loan status to show that.

sahilshivekar avatar Mar 16 '26 11:03 sahilshivekar

@sahilshivekar The typography, color scheme, icons (colors, sizes), and other UI components don't look aligned with the UI of the Client Flow. Please review.

biplab1 avatar Mar 16 '26 13:03 biplab1

@sahilshivekar The typography, color scheme, icons (colors, sizes), and other UI components don't look aligned with the UI of the Client Flow. Please review.

@biplab1 I have made changes, give it a look when you get time

sahilshivekar avatar Mar 17 '26 19:03 sahilshivekar

@sahilshivekar Please fix the merge conflicts.

Also, is this graph interactive as in the web-app? image

I was talking about this kind of interactivity shown in the screen recording from web-app where one can toggle the graph sections like in the bar graph:

https://github.com/user-attachments/assets/8ac1ab48-48f1-44f5-9ac4-ecb8aba3e196

biplab1 avatar Mar 24 '26 00:03 biplab1

@sahilshivekar Please fix the merge conflicts. Also, is this graph interactive as in the web-app? image

I was talking about this kind of interactivity shown in the screen recording from web-app where one can toggle the graph sections like in the bar graph:

Dashboard.Active.Account.mp4

@biplab1 I wasn't aware of this kind of interactivity on the donut graph, in current implementation we can't toggle it. I will make the donut graph interactive so that in future if we have to show more than 2 parameters in the donut graph then we can toggle some of them to get a dynamic view.

sahilshivekar avatar Mar 24 '26 14:03 sahilshivekar

@coderabbitai config

sahilshivekar avatar Apr 19 '26 13:04 sahilshivekar

[!TIP] For best results, initiate chat on the files or code changes.

🧩 Analysis chain

The PR description images show three screenshots of the Mifos loan dashboard implementation:

  1. First image: A "Pending Approval" loan (BRONZE #000000046, US$1,332.00) with a timeline showing "Application Submitted" (17 Aug 2025) and "Review in progress," plus Reject/Approve action buttons.
  2. Second image: A "Rejected" loan (PERSONAL #000000023, $5,000.00) with a timeline showing "Application Submitted" (14 Aug 2025) and "Application Rejected" (2 Mar 2026).
  3. Third image: A "Withdrawn by Applicant" loan (PERSONAL #000000051, US$10,000.00) with a timeline showing "Application Submitted" and "Application Withdrawn" (both 30 Aug 2025).

@sahilshivekar, I'll fetch the current CodeRabbit configuration for this repository.


πŸ›  Debug Information Gathered


@sahilshivekar, here is the current CodeRabbit configuration for this repository:


πŸ“‹ Repository: openMF/mifos-x-field-officer-app

Plan: Pro (Open Source)

No .coderabbit.yaml file has been committed to the repository, so all settings are at their defaults. Here are the key ones:

πŸ” Reviews

Setting Value
Profile chill
Auto Review βœ… Enabled
Incremental Review βœ… Enabled
Auto Pause After 5 reviewed commits
Request Changes Workflow ❌ Disabled
Draft PRs ❌ Skipped
High-level Summary βœ… Enabled
Sequence Diagrams βœ… Enabled
Path Filters (none)
Path Instructions (none)
Ignore Title Keywords (none)

πŸ› οΈ Tools (all enabled by default)

Detekt, AST-grep, LanguageTool, GitHub Checks, Gitleaks, TruffleHog, actionlint, markdownlint, yamllint, and many more.

🧠 Knowledge Base

Setting Value
Learnings Scope auto (local for public repos)
Web Search βœ… Enabled
Code Guidelines βœ… Enabled
Jira / Linear auto (disabled for public repos)

✨ Finishing Touches

Feature Status
Docstrings generation βœ… Enabled
Unit test generation βœ… Enabled
Simplify ❌ Disabled

If you'd like to customize the configuration (e.g., add path-specific review instructions, filter out certain files, change the review profile to assertive, or add custom pre-merge checks), you can create a .coderabbit.yaml file at the root of the repository. See the CodeRabbit configuration docs for more details.


🧠 Learnings used
Learnt from: sahilshivekar
Repo: openMF/mifos-x-field-officer-app PR: 2647
File: core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/component/MifosDonutGraph.kt:31-37
Timestamp: 2026-03-16T11:08:58.622Z
Learning: In PR `#2647` (openMF/mifos-x-field-officer-app), the `MifosDonutGraph` composable in `core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/component/MifosDonutGraph.kt` intentionally receives a `progress` value already capped at `1.0f` (100%) for overpaid loans. The ViewModel/state layer handles capping; for overpaid status the surplus balance is displayed separately on the right side of the donut graph rather than rendering a >360Β° arc. The composable itself does not clamp the value, as the caller guarantees it is in [0, 1].

Learnt from: biplab1
Repo: openMF/mifos-x-field-officer-app PR: 2647
File: feature/loan/src/commonMain/composeResources/values/strings.xml:460-460
Timestamp: 2026-03-24T00:43:11.613Z
Learning: In PR `#2647` (openMF/mifos-x-field-officer-app), the timeline string resource keys in `feature/loan/src/commonMain/composeResources/values/strings.xml` should follow the `_on_date` suffix naming pattern for date-type events (e.g., `feature_loan_timeline_amount_disbursed_on_date`, `feature_loan_timeline_application_submitted_on_date`, `feature_loan_timeline_application_approved_on_date`, `feature_loan_timeline_expected_disbursement_on_date`, `feature_loan_timeline_expected_maturity_on_date`, `feature_loan_timeline_maturity_on_date`). This was a naming convention decision by maintainer biplab1 to make date-carrying keys clearly distinguishable from state-only keys.

Learnt from: sahilshivekar
Repo: openMF/mifos-x-field-officer-app PR: 2647
File: feature/loan/src/commonMain/composeResources/values/strings.xml:452-452
Timestamp: 2026-03-16T11:54:08.124Z
Learning: In PR `#2647` (openMF/mifos-x-field-officer-app), the string resource `feature_loan_timeline_disbursed_date` in `feature/loan/src/commonMain/composeResources/values/strings.xml` intentionally uses the value "Amount Disbursed" as a timeline step label. It conveys that the loan amount was disbursed on the date shown below it in the timeline, not just a bare date field label. This is a deliberate UX copy choice.

Learnt from: sahilshivekar
Repo: openMF/mifos-x-field-officer-app PR: 2647
File: feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/navigation/LoanNavigation.kt:96-96
Timestamp: 2026-03-16T11:58:36.951Z
Learning: In `feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/navigation/LoanNavigation.kt` (Kotlin/Compose Multiplatform, mifos-x-field-officer-app), `navigateToDashboard` uses a direct method reference `navController::navigateToLoanDashboardScreen` without an ID guard. This is intentional: `LoanAccountProfileScreen` always receives a valid `loanId`, and `LoanDashboardScreen` already handles invalid/missing data by displaying a "Failed to fetch Loan details" error state. Do not flag the absence of an ID guard here in future reviews.

Learnt from: sahilshivekar
Repo: openMF/mifos-x-field-officer-app PR: 2647
File: feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDashboard/LoanDashboardViewModel.kt:283-299
Timestamp: 2026-03-17T19:33:37.858Z
Learning: In `feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDashboard/LoanDashboardViewModel.kt` (Kotlin/Compose Multiplatform, mifos-x-field-officer-app), the `isIncreasingDebt` flag in `getRecentTransactions` intentionally leaves `type.writeOff == true` in the neutral branch (`null`). Write-off transactions are neither debt-increasing nor debt-reducing from the UI perspective (no cash flow occurs), so they are displayed with a neutral icon/color. Do not flag `writeOff` being absent from the debt-reducing branch as an issue.

Learnt from: kartikey004
Repo: openMF/mifos-x-field-officer-app PR: 2651
File: core/data/src/commonMain/kotlin/com/mifos/core/data/repositoryImp/LoanReschedulesRepositoryImpl.kt:58-61
Timestamp: 2026-03-15T13:01:51.059Z
Learning: In the Loan Reschedules feature (PR `#2651`, openMF/mifos-x-field-officer-app), the `deleteReschedule` method in `LoanReschedulesRepositoryImpl` intentionally delegates to `dataManagerLoan.rejectLoanReschedule()`, which calls the backend `POST ...?command=reject`. The "delete" UI action is designed to reject the reschedule request (marking it as REJECTED), not to physically remove it from the database. This is the intended product behavior confirmed by the author.

coderabbitai[bot] avatar Apr 19 '26 13:04 coderabbitai[bot]

@sahilshivekar Please fix the conflicts and pr checks failures.

biplab1 avatar Jun 18 '26 14:06 biplab1