refactor(loan): centralize loan status mapping across screens
Fixes - Jira-#783
Client Loan Accounts Screen
| Before | After |
|---|---|
Loan Account Profile Screen
Background color for the loan status is same as it's in the web app now
Pending Approval
| Before | After |
|---|---|
Approved
| Before | After |
|---|---|
Active
| Before | After |
|---|---|
Closed (Overpaid)
| Before | After |
|---|---|
| App crashes with exception because the send_money.xml file was using @android:color/white. Exception java.lang.IllegalArgumentException: Invalid color value @android:color/white |
Closed (Obligations Met)
| Before | After |
|---|---|
Rejected
| Before | After |
|---|---|
Loan accounts with following loan status not found
Closed (Written Off)
| Before | After |
|---|---|
Closed (Rescheduled)
| Before | After |
|---|---|
Withdrawn by Applicant
| Before | After |
|---|---|
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: 8c35c903-b451-42da-a72e-30151ff892a9
๐ฅ Commits
Reviewing files that changed from the base of the PR and between 81275fef728e7032533ad8bff6956ca1fce79eb8 and 3b74add3dd4cc306780ace21afa47bc7c82f6468.
๐ Files selected for processing (2)
feature/loan/src/commonMain/composeResources/values/strings.xmlfeature/loan/src/commonMain/kotlin/com/mifos/feature/loan/utils/LoanStatus.kt
๐ง Files skipped from review as they are similar to previous changes (1)
- feature/loan/src/commonMain/composeResources/values/strings.xml
๐ Recent review details
โฐ Context from checks skipped due to timeout. (1)
- GitHub Check: PR Checks / Static Analysis Check
๐งฐ Additional context used
๐ Path-based instructions (1)
**/*.kt
โ๏ธ CodeRabbit configuration file
**/*.kt: Additional Code Review Guidelines:
- Null Safety & Stability
- Avoid using
!!operator- Handle null cases explicitly using safe calls or proper state handling
- Do not assume values are always non-null without guarantees
- Architecture Boundaries
- ViewModel must not depend on specific network/library implementations
- Ensure proper separation between data, domain, and presentation layers
- Do not format data (currency, dates, calculations) inside the UI layer
- All formatting must be handled in the ViewModel and exposed via state (e.g., StateFlow)
- Performance Considerations
- Avoid unnecessary recompositions in Compose
- Do not attach heavy logic to frequently changing states (e.g., scrollState)
- Prefer lifting state up instead of recomputing in child composables
- Compose & Navigation Best Practices
- NEVER trigger navigation functions or side-effects directly during composition
- Always wrap navigation calls inside
LaunchedEffectorEventsEffectto avoid repeated execution on recomposition- Avoid triggering intensive side-effects during recomposition
- Navigation routes must be type-safe.
- Ensure all route classes or objects used for navigation are annotated with
@Serializable.
- UI Structure
- Dialogs must be separated into their own composables
- Do not embed dialogs inline within complex main screens
- Localization Consistency
- Ensure all supported languages are updated consistently across modules
- Verify translations exist for newly added UI strings
- Code Cleanliness
- Avoid unnecessary inline comments unless critical
- Remove leftover debug or commented code
- Focus on correctness, readability, and maintainability over cosmetic nitpicks.
- Avoid reviewing README, config, or asset files.
- Prioritize identifying bugs, performance issues, and architectural concerns.
- Naming & Intent Rules:
- Follow the official Kotlin Coding Conventions: https://kotlinlang.org/docs/coding-conventions.html
- Use self-explanatory ...
Files:
feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/utils/LoanStatus.kt
๐ง Learnings (2)
๐ Learning: 2026-02-06T13:15:16.968Z
Learnt from: sahilshivekar
Repo: openMF/android-client PR: 2603
File: feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanTransaction/LoanTransactionsViewModel.kt:43-106
Timestamp: 2026-02-06T13:15:16.968Z
Learning: Guideline: When a Kotlin function parameter is nullable (e.g., balance: Double?, currencyCode: String?, maximumFractionDigits: Int?) and downstream calls require a non-null value, add null-safety handling in all implementations. Specifically, avoid calling Currency.getInstance(currencyCode) with a possibly null currencyCode; provide a safe default (e.g., currencyCode ?: "$") or validate before use. Ensure all platform targets (Android/Desktop/Native) follow consistent null handling, and consider centralizing currencyCode normalization in the common layer if feasible. Add tests covering null currencyCode to prevent NPEs.
Applied to files:
feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/utils/LoanStatus.kt
๐ Learning: 2026-04-01T05:03:14.323Z
Learnt from: kartikey004
Repo: openMF/mifos-x-field-officer-app PR: 2659
File: feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanDisbursement/LoanAccountDisbursementScreen.kt:190-195
Timestamp: 2026-04-01T05:03:14.323Z
Learning: In this repo, existing `SelectableDates` / `SelectableDates.isSelectableDate(utcTimeMillis: Long)` implementations use `Clock.System.now().toEpochMilliseconds()` (UTC epoch millis) for date-boundary checks. During PR reviews, do not flag these checks for not using a timezone-aware `LocalDate` start-of-day approach; treat it as an established project-wide pattern. If a change is desired, handle it as a coordinated project-wide improvement rather than as a per-PR review issue.
Applied to files:
feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/utils/LoanStatus.kt
๐ Additional comments (2)
feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/utils/LoanStatus.kt (2)
68-72: LGTM!
74-85: ๐ฏ Functional CorrectnessVerify whether
closedalso needs an explicit branch.The upstream status contract still includes a separate
closedflag, but this mapper never reads it. If the backend can returnclosed == truewithout one of the more specific closed variants, these accounts will now fall through toUNKNOWN, and the downstream screens will render the gray unknown badge/action set instead of a closed state.
Summary by CodeRabbit
-
New Features
- Improved loan status display with consistent, localized labels and matching colors across loan screens.
- Added/updated loan status variants (approved, pending approval, active, closed variants, rejected, withdrawn by applicant).
- Updated next-action behavior to reflect the current loan status (approve, repay, transfer, or view details).
-
Bug Fixes
- Fixed inconsistent status rendering between loan summary and profile views by using a shared status mapping.
- Improved loan status badge behavior to always render the correct label and color.
-
Style
- Updated a drawable icon to use a fixed white fill color for more reliable rendering.
Walkthrough
Loan status handling now uses a shared LoanStatus model across loan profile, summary, and client loan account screens. Loan status strings and theme colors were updated, and the send-money icon fill color changed to white.
Changes
Loan status normalization
Loan status handling is centralized across the loan feature.
Review checkpoint table
| Layer / File(s) | Summary |
|---|---|
Status model and resources feature/loan/src/commonMain/composeResources/values/strings.xml, core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/theme/Color.kt, feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/utils/LoanStatus.kt |
Loan status strings and theme colors are defined for the new status set, and LoanStatus maps entity flags to those resources. |
Profile state and actions feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanAccountProfile/LoanAccountProfileViewModel.kt, feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanAccountProfile/LoanAccountProfileScreen.kt |
LoanAccountProfileViewModel now derives status and next actions from getLoanStatus(), and the profile screen consumes the updated state and badge rendering. |
Summary and client screens feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/loanAccountSummary/LoanAccountSummaryScreen.kt, feature/client/src/commonMain/kotlin/com/mifos/feature/client/clientLoanAccounts/ClientLoanAccountsScreen.kt |
LoanAccountSummaryScreen and ClientLoanAccountsScreen now render loan statuses through getLoanStatus(). |
The send-money icon change is separate.
Send money drawable
| Layer / File(s) | Summary |
|---|---|
Icon fill color core/ui/src/commonMain/composeResources/drawable/send_money.xml |
The drawable path fill color changes from the Android white resource to #FFFFFF. |
Sequence Diagram(s)
The shared status mapper now feeds profile, summary, and client loan account rendering.
Loan status flow
sequenceDiagram
participant LoanStatusEntity
participant LoanAccountProfileViewModel
participant LoanAccountProfileScreen
participant LoanAccountSummaryScreen
participant ClientLoanAccountsScreen
LoanStatusEntity->>LoanAccountProfileViewModel: loan.status.getLoanStatus()
LoanAccountProfileViewModel->>LoanAccountProfileScreen: currentStatus and nextActionButtonRes
LoanStatusEntity->>LoanAccountSummaryScreen: loanWithAssociations.status.getLoanStatus()
LoanStatusEntity->>ClientLoanAccountsScreen: loan.status.getLoanStatus().label
Estimated code review effort
๐ฏ 3 (Moderate) | โฑ๏ธ ~25 minutes
๐ฅ Pre-merge checks | โ 3 | โ 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 (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | โ Passed | The title matches the PR's main refactor of centralizing loan status mapping across loan screens. |
| Description check | โ Passed | The description matches the PR by describing the loan status UI refactor and the send_money.xml fix. |
| Jira Link And Before/After Sections | โ Passed | The PR description has a valid Jira link and multiple non-empty Before/After sections with image media. |
โจ 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.
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
LGTM