Skip to content

Conversation

@WizCoderr
Copy link
Contributor

@WizCoderr WizCoderr commented Oct 28, 2025

Fixes - Jira-#Issue_Number

Didn't create a Jira ticket, click here to create new.

Please Add Screenshots If there are any UI changes.

Before After
Screen_recording_20251028_185703.mp4

Please make sure these boxes are checked before submitting your pull request - thanks!

  • 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

  • Bug Fixes

    • Corrected savings account status handling and visuals (labels and colors), including inactive accounts showing error styling and a fallback status display.
    • Active accounts show formatted balances; pending accounts display "PENDING APPROVAL".
  • New Features

    • Accounts are now presented in a consistent, deterministic sort order.
    • Reintroduced an active filter row in the header for easier account filtering and discovery.
  • Refactor

    • UI rendering and action handling simplified for more reliable updates.

@coderabbitai
Copy link

coderabbitai bot commented Oct 28, 2025

Walkthrough

Replaced LoanStatus with SavingStatus in savings-account UI and ViewModel; added deterministic statusOrder and sortAccountsByStatus; state now emits sorted accounts used by the screen; updated account status text, color mapping, pending string resource, local accounts usage, and enabled header Filter row.

Changes

Cohort / File(s) Summary
Savings Account Screen
feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountScreen.kt
Switched UI logic from LoanStatus to SavingStatus for comparisons and color mapping (added default branch); added pending-account string resource usage; introduced accounts = state.savingsAccount.orEmpty() for rendering; computes accountStatus (formatted balance for ACTIVE, pending label for SUBMIT_AND_PENDING_APPROVAL, else raw status); refactored onAction lambdas; replaced commented search row with active Filter row.
Savings Account ViewModel
feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountViewmodel.kt
Imported SavingStatus; added public statusOrder: List<String> to SavingsAccountState; added sortAccountsByStatus helper and uses sortedAccounts replacing prior filtered assignments across state updates; applies sorting after fetch/filter; introduced updateState helper; adjusted retry/network handling to differentiate offline/online retry behavior.

Sequence Diagram(s)

sequenceDiagram
    participant Repo as Repository
    participant VM as SavingsAccountViewModel
    participant State as SavingsAccountState
    participant Screen as SavingsAccountScreen
    participant Renderer as LazyColumn / MifosAccountCard

    rect #FFF8E1
    Repo->>VM: fetch accounts
    VM->>VM: filter results\nsortAccountsByStatus(statusOrder) -> sortedAccounts
    VM->>State: emit updated state (savingsAccount = sortedAccounts)
    end

    rect #E8F5E9
    State->>Screen: state with sortedAccounts
    Screen->>Screen: accounts = state.savingsAccount.orEmpty()
    Screen->>Screen: compute accountStatus per account\n(ACTIVE -> formatted balance\nSUBMIT_AND_PENDING_APPROVAL -> pending string\nelse -> status value)
    end

    rect #E3F2FD
    Screen->>Renderer: render accounts\nchoose color by SavingStatus (ACTIVE, SUBMIT_AND_PENDING_APPROVAL, INACTIVE, else)
    Renderer->>Renderer: display MifosAccountCard entries
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Inspect statusOrder contents and ensure sort stability across all possible SavingStatus values.
  • Confirm every place that previously used unsorted/filtered lists now uses sortedAccounts.
  • Verify accountStatus selection logic and string-resource for pending state.
  • Validate color mapping covers all SavingStatus cases and default branch.

Possibly related PRs

Poem

🐰 I hopped through statuses, neat and spry,
Placed each account in ordered sky,
Active gleams, pending waits below,
Colors aligned in tidy row,
A tiny hop — the UI says hi. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 "Order Savings Accounts by Active State Etc" directly relates to the main change in the changeset, which introduces a statusOrder property and sortAccountsByStatus helper function to sort savings accounts deterministically based on their status. The title clearly conveys that accounts are being ordered/sorted, with the primary sort criterion being the active state. The "Etc" appropriately acknowledges additional changes such as the migration from LoanStatus to SavingStatus and UI updates, without being misleading or overly vague. A developer scanning the repository history would understand that this PR focuses on reordering how savings accounts are displayed based on their status.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 70c39c6 and 294cbcd.

📒 Files selected for processing (1)
  • feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountScreen.kt (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountScreen.kt (1)
core/ui/src/commonMain/kotlin/org/mifos/mobile/core/ui/component/MifosAccountCard.kt (1)
  • MifosAccountCard (41-113)
🔇 Additional comments (3)
feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountScreen.kt (3)

55-55: LGTM! Correct model import.

Replacing LoanStatus with SavingStatus properly aligns the savings account screen with its domain model.


279-286: Verify color mapping covers all status values.

The statusOrder list includes SavingStatus.CLOSED (line 261), but the color mapping only handles ACTIVE, SUBMIT_AND_PENDING_APPROVAL, and INACTIVE. Accounts with CLOSED status will use the default onSurface color via the else branch.

Please confirm this is the intended behavior.


278-278: LGTM! Sorted list correctly applied.

Using sortedAccounts here correctly applies the canonical status ordering defined above, fulfilling the PR objective.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountScreen.kt (1)

258-270: Unknown statuses sort first; add safe fallback and optional tie-breaker.
indexOf returns -1 for unknown statuses, pushing them to the top. Sort them last; optionally add a secondary key for deterministic order within the same status.

-                    val sortedAccounts = remember(state.savingsAccount) {
-                        state.savingsAccount.orEmpty().sortedWith(
-                            compareBy { statusOrder.indexOf(it.status?.value) },
-                        )
-                    }
+                    val sortedAccounts = remember(state.savingsAccount) {
+                        state.savingsAccount.orEmpty().sortedWith(
+                            compareBy(
+                                { account ->
+                                    val idx = statusOrder.indexOf(account.status?.value)
+                                    if (idx == -1) Int.MAX_VALUE else idx
+                                },
+                                // optional: stable, human-friendly tie-breaker
+                                { it.accountNo ?: "" },
+                            ),
+                        )
+                    }

Optional: extract statusOrder to a shared constant (e.g., core) to avoid duplication across screens.

🧹 Nitpick comments (1)
feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountScreen.kt (1)

281-286: Add explicit color for CLOSED; centralize mapping.
CLOSED is in statusOrder but not colored; it falls to onSurface. Consider an explicit subdued color (e.g., onSurfaceVariant) and keep this logic in a small helper to reuse across screens.

-                            val color = when (account.status?.value) {
+                            val color = when (account.status?.value) {
                                 SavingStatus.ACTIVE.status -> AppColors.customEnable
                                 SavingStatus.SUBMIT_AND_PENDING_APPROVAL.status -> AppColors.customYellow
-
                                 SavingStatus.INACTIVE.status -> MaterialTheme.colorScheme.error
-
-                                else -> MaterialTheme.colorScheme.onSurface
+                                SavingStatus.CLOSED.status -> MaterialTheme.colorScheme.onSurfaceVariant
+                                else -> MaterialTheme.colorScheme.onSurface
                             }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 294cbcd and 530ef3a.

📒 Files selected for processing (1)
  • feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountScreen.kt (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountScreen.kt (1)
core/ui/src/commonMain/kotlin/org/mifos/mobile/core/ui/component/MifosAccountCard.kt (1)
  • MifosAccountCard (41-113)
🔇 Additional comments (4)
feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountScreen.kt (4)

43-43: Good: moved pending label to a string resource.
Using a resource instead of a hard-coded string is correct for i18n.


56-56: Correct enum usage.
Importing and using SavingStatus aligns the UI with the savings domain.


279-279: LGTM: list now renders sortedAccounts.
Keeps UI consistent with the new ordering.


306-306: LGTM: passes computed accountStatus into MifosAccountCard.
Hook-up looks correct.

@niyajali
Copy link
Collaborator

niyajali commented Oct 28, 2025

@biplab1 I noticed a couple of UI/UX problems with the video that was uploaded. The text "Hello jean," needs to be corrected to "Hello, Jean" and the services icon box is not aligned correctly (take a look at the beneficiary and FAQ sections for the icon box). Could you please open a ticket for these issues and assign it to someone who is available?

@WizCoderr WizCoderr marked this pull request as draft October 29, 2025 05:25
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountScreen.kt (1)

252-264: Localize INACTIVE and CLOSED status labels.

As noted in previous reviews, only SUBMIT_AND_PENDING_APPROVAL is localized. CLOSED and INACTIVE accounts display raw backend values instead of translated strings.

Add localized string keys (e.g., feature_savings_status_closed, feature_savings_status_inactive) to all language files, then update the logic:

                            val accountStatus = if (account.status?.active == true) {
                                CurrencyFormatter.format(
                                    account.accountBalance,
                                    account.currency?.code,
                                    account.currency?.decimalPlaces,
                                )
                            } else {
-                               if (account.status?.value == SavingStatus.SUBMIT_AND_PENDING_APPROVAL.status) {
-                                   stringResource(Res.string.feature_savings_filter_pending_account)
-                               } else {
-                                   account.status?.value ?: ""
-                               }
+                               when (account.status?.value) {
+                                   SavingStatus.SUBMIT_AND_PENDING_APPROVAL.status ->
+                                       stringResource(Res.string.feature_savings_filter_pending_account)
+                                   SavingStatus.CLOSED.status ->
+                                       stringResource(Res.string.feature_savings_status_closed)
+                                   SavingStatus.INACTIVE.status ->
+                                       stringResource(Res.string.feature_savings_status_inactive)
+                                   else -> account.status?.value ?: ""
+                               }
                            }
🧹 Nitpick comments (1)
feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountViewmodel.kt (1)

318-323: Consider moving statusOrder to a companion object.

statusOrder is immutable and identical across all state instances. Moving it to a companion object would avoid recreating the list unnecessarily.

Apply this diff to move statusOrder to a companion object:

+    companion object {
+        private val STATUS_ORDER = listOf(
+            SavingStatus.ACTIVE.status,
+            SavingStatus.SUBMIT_AND_PENDING_APPROVAL.status,
+            SavingStatus.CLOSED.status,
+            SavingStatus.INACTIVE.status,
+        )
+    }
+
-    /** Order of statuses for consistent sorting */
-    val statusOrder: List<String> = listOf(
-        SavingStatus.ACTIVE.status,
-        SavingStatus.SUBMIT_AND_PENDING_APPROVAL.status,
-        SavingStatus.CLOSED.status,
-        SavingStatus.INACTIVE.status,
-    ),

Then update line 249 to use STATUS_ORDER instead of state.statusOrder:

-    return accounts.sortedWith(compareBy { state.statusOrder.indexOf(it.status?.value) })
+    return accounts.sortedWith(compareBy { STATUS_ORDER.indexOf(it.status?.value) })
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 530ef3a and 48382e7.

📒 Files selected for processing (2)
  • feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountScreen.kt (5 hunks)
  • feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountViewmodel.kt (12 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountScreen.kt (2)
feature/savings-application/src/commonMain/kotlin/org/mifos/mobile/feature/savings/application/savingsApplication/SavingsApplyScreen.kt (1)
  • SavingsAccountDialog (90-115)
core/ui/src/commonMain/kotlin/org/mifos/mobile/core/ui/component/MifosAccountCard.kt (1)
  • MifosAccountCard (41-113)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: PR Checks KMP / Static Analysis Check
🔇 Additional comments (1)
feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountScreen.kt (1)

103-103: LGTM: Clean lambda refactoring.

The simplified lambda syntax with remember properly memoizes the action handler and follows idiomatic Compose patterns.

Also applies to: 108-108

@biplab1
Copy link
Contributor

biplab1 commented Oct 29, 2025

@biplab1 I noticed a couple of UI/UX problems with the video that was uploaded. The text "Hello jean," needs to be corrected to "Hello, Jean" and the services icon box is not aligned correctly (take a look at the beneficiary and FAQ sections for the icon box). Could you please open a ticket for these issues and assign it to someone who is available?

@WizCoderr Have you addressed all the issues mentioned above? If you have, then please upload a new video. Otherwise, let me know I will go ahead and create new tickets.

@WizCoderr
Copy link
Contributor Author

My laptop is not working properly and also i got my placement paper on 31 so I will be updating all this before Monday

@biplab1
Copy link
Contributor

biplab1 commented Oct 29, 2025

@coderabbitai configuration

@coderabbitai
Copy link

coderabbitai bot commented Oct 29, 2025

CodeRabbit configuration
language: en-US
tone_instructions: ''
early_access: false
enable_free_tier: true
reviews:
  profile: chill
  request_changes_workflow: false
  high_level_summary: true
  high_level_summary_placeholder: '@coderabbitai summary'
  high_level_summary_in_walkthrough: false
  auto_title_placeholder: '@coderabbitai'
  auto_title_instructions: ''
  review_status: true
  commit_status: true
  fail_commit_status: false
  collapse_walkthrough: false
  changed_files_summary: true
  sequence_diagrams: true
  estimate_code_review_effort: true
  assess_linked_issues: true
  related_issues: true
  related_prs: true
  suggested_labels: true
  labeling_instructions: []
  auto_apply_labels: false
  suggested_reviewers: true
  auto_assign_reviewers: false
  in_progress_fortune: true
  poem: true
  path_filters: []
  path_instructions: []
  abort_on_close: true
  disable_cache: false
  auto_review:
    enabled: true
    auto_incremental_review: true
    ignore_title_keywords: []
    labels: []
    drafts: false
    base_branches: []
    ignore_usernames: []
  finishing_touches:
    docstrings:
      enabled: true
    unit_tests:
      enabled: true
  pre_merge_checks:
    docstrings:
      mode: warning
      threshold: 80
    title:
      mode: warning
      requirements: ''
    description:
      mode: warning
    issue_assessment:
      mode: warning
    custom_checks: []
  tools:
    ast-grep:
      rule_dirs: []
      util_dirs: []
      essential_rules: true
      packages: []
    shellcheck:
      enabled: true
    ruff:
      enabled: true
    markdownlint:
      enabled: true
    github-checks:
      enabled: true
      timeout_ms: 90000
    languagetool:
      enabled: true
      enabled_rules: []
      disabled_rules: []
      enabled_categories: []
      disabled_categories: []
      enabled_only: false
      level: default
    biome:
      enabled: true
    hadolint:
      enabled: true
    swiftlint:
      enabled: true
    phpstan:
      enabled: true
      level: default
    phpmd:
      enabled: true
    phpcs:
      enabled: true
    golangci-lint:
      enabled: true
    yamllint:
      enabled: true
    gitleaks:
      enabled: true
    checkov:
      enabled: true
    detekt:
      enabled: true
    eslint:
      enabled: true
    flake8:
      enabled: true
    rubocop:
      enabled: true
    buf:
      enabled: true
    regal:
      enabled: true
    actionlint:
      enabled: true
    pmd:
      enabled: true
    clang:
      enabled: true
    cppcheck:
      enabled: true
    semgrep:
      enabled: true
    circleci:
      enabled: true
    clippy:
      enabled: true
    sqlfluff:
      enabled: true
    prismaLint:
      enabled: true
    pylint:
      enabled: true
    oxc:
      enabled: true
    shopifyThemeCheck:
      enabled: true
    luacheck:
      enabled: true
    brakeman:
      enabled: true
    dotenvLint:
      enabled: true
    htmlhint:
      enabled: true
    checkmake:
      enabled: true
    osvScanner:
      enabled: true
chat:
  art: true
  auto_reply: true
  integrations:
    jira:
      usage: auto
    linear:
      usage: auto
knowledge_base:
  opt_out: false
  web_search:
    enabled: true
  code_guidelines:
    enabled: true
    filePatterns: []
  learnings:
    scope: auto
  issues:
    scope: auto
  jira:
    usage: auto
    project_keys: []
  linear:
    usage: auto
    team_keys: []
  pull_requests:
    scope: auto
  mcp:
    usage: auto
    disabled_servers: []
code_generation:
  docstrings:
    language: en-US
    path_instructions: []
  unit_tests:
    path_instructions: []

@WizCoderr WizCoderr marked this pull request as ready for review October 30, 2025 13:42
@WizCoderr
Copy link
Contributor Author

Screen_recording_20251030_191604.webm
Latest Video

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountViewmodel.kt (1)

290-292: Handle unknown account statuses in sort order.

If account.status?.value is not in statusOrder, indexOf returns -1, causing those accounts to sort first—ahead of even ACTIVE accounts. This produces unexpected ordering.

Apply this diff to sort unknown statuses last:

 private fun sortAccountsByStatus(accounts: List<SavingAccount>): List<SavingAccount> {
-    return accounts.sortedWith(compareBy { state.statusOrder.indexOf(it.status?.value) })
+    return accounts.sortedWith(compareBy { 
+        val index = state.statusOrder.indexOf(it.status?.value)
+        if (index == -1) Int.MAX_VALUE else index
+    })
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 48382e7 and d526909.

📒 Files selected for processing (1)
  • feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountViewmodel.kt (9 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountViewmodel.kt (1)
feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccountDetails/SavingsAccountDetailsViewModel.kt (1)
  • updateState (130-132)
🔇 Additional comments (4)
feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountViewmodel.kt (4)

26-26: LGTM!

The SavingStatus import is correctly added and used in the statusOrder definition.


105-107: Good refactor for consistency.

The updateState helper follows the same pattern as in SavingsAccountDetailsViewModel.kt, improving code maintainability.


229-247: Sorted accounts integrated correctly.

The sorted accounts are correctly applied after filtering and consistently used throughout the state updates. The implementation depends on fixing the sorting function at lines 290-292 (see existing review comment).


358-365: statusOrder includes all possible SavingStatus values—no changes needed.

Verification confirms the statusOrder list contains all four enum values defined in SavingStatus.kt (ACTIVE, SUBMIT_AND_PENDING_APPROVAL, CLOSED, INACTIVE). The list is complete and correct.

Comment on lines +141 to +143
* A helper function to update the mutable state flow.
*
* @param update A lambda function that takes the current state and returns a new state.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix incorrect documentation.

The KDoc describes updateState but is placed above the retry() function. This appears to be a copy-paste error from lines 101-104.

Apply this diff to correct the documentation:

-    /**
-     * A helper function to update the mutable state flow.
-     *
-     * @param update A lambda function that takes the current state and returns a new state.
-     */
+    /**
+     * Retries loading accounts based on network status.
+     * Shows network error if offline, otherwise reloads accounts.
+     */
     private fun retry() {
🤖 Prompt for AI Agents
In
feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountViewmodel.kt
around lines 141-143, the KDoc that documents updateState was mistakenly left
above the retry() function; move that KDoc block to directly above the
updateState declaration (where lines ~101-104 originally referenced) and replace
the KDoc above retry() with a short, accurate comment describing retry()’s
purpose (e.g., triggers a retry of the last operation or refreshes state).
Ensure the moved KDoc matches the updateState signature and the new retry() KDoc
matches retry() behavior.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountViewmodel.kt (2)

288-290: Unknown statuses sort before ACTIVE.

state.statusOrder.indexOf returns -1 for any status not in the list, so those entries sort ahead of ACTIVE. That regresses the ordering whenever new statuses appear from the backend. Map missing values to the tail of the list before sorting.

-        return accounts.sortedWith(compareBy { state.statusOrder.indexOf(it.status?.value) })
+        return accounts.sortedWith(compareBy {
+            val index = state.statusOrder.indexOf(it.status?.value)
+            if (index >= 0) index else state.statusOrder.size
+        })

141-144: Fix the retry() KDoc.

The block still describes updateState, which is misleading. Replace it with documentation that reflects retry()'s behavior.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d526909 and baccf61.

📒 Files selected for processing (1)
  • feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountViewmodel.kt (8 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountViewmodel.kt (2)
feature/loan-account/src/commonMain/kotlin/org/mifos/mobile/feature/loanaccount/loanAccount/LoanAccountViewModel.kt (1)
  • updateState (105-107)
feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccountDetails/SavingsAccountDetailsViewModel.kt (1)
  • updateState (130-132)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: PR Checks KMP / Static Analysis Check

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (2)
feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountViewmodel.kt (2)

141-143: The incorrect documentation is still present.

This KDoc still describes updateState but is placed above retry(). This was flagged in the previous review but not fixed.

Apply this diff to correct the documentation:

-    /**
-     * A helper function to update the mutable state flow.
-     *
-     * @param update A lambda function that takes the current state and returns a new state.
-     */
+    /**
+     * Retries loading accounts based on network status.
+     * Shows network error if offline, otherwise reloads accounts.
+     */
     private fun retry() {

289-291: The sorting issue with unknown statuses is still present.

If account.status?.value is not in statusOrder or is null, indexOf returns -1, causing those accounts to sort first—ahead of even ACTIVE accounts. This was flagged in the previous review but not fixed.

Apply this diff to sort unknown statuses last:

 private fun sortAccountsByStatus(accounts: List<SavingAccount>): List<SavingAccount> {
-    return accounts.sortedWith(compareBy { state.statusOrder.indexOf(it.status?.value) })
+    return accounts.sortedWith(compareBy { 
+        val index = state.statusOrder.indexOf(it.status?.value)
+        if (index == -1) Int.MAX_VALUE else index
+    })
 }
🧹 Nitpick comments (1)
feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountViewmodel.kt (1)

232-233: Consider using state.decimals as the final fallback.

The decimals fallback now includes allSavings, which is good. However, the final fallback is still a hardcoded 2 instead of state.decimals. The previous review suggested preserving the existing state value to maintain precision across state updates.

Apply this diff:

-                        decimals = sortedAccounts.firstOrNull()?.currency?.decimalPlaces
-                            ?: allSavings.firstOrNull()?.currency?.decimalPlaces ?: 2,
+                        decimals = sortedAccounts.firstOrNull()?.currency?.decimalPlaces
+                            ?: allSavings.firstOrNull()?.currency?.decimalPlaces ?: state.decimals,
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between baccf61 and cdcdd08.

📒 Files selected for processing (1)
  • feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountViewmodel.kt (8 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountViewmodel.kt (1)
feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccountDetails/SavingsAccountDetailsViewModel.kt (1)
  • updateState (130-132)
🔇 Additional comments (1)
feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountViewmodel.kt (1)

358-364: The status sort order looks reasonable.

The defined order (ACTIVE → SUBMIT_AND_PENDING_APPROVAL → CLOSED → INACTIVE) makes sense for displaying accounts with active ones first.

@therajanmaurya therajanmaurya merged commit a07a625 into openMF:development Oct 31, 2025
8 checks passed
@WizCoderr WizCoderr deleted the MM-450 branch October 31, 2025 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants