Skip to content

feat(settings): Fix settings to use savings accountId for disabling accounts#2014

Open
IITI-tushar wants to merge 1 commit into
openMF:developmentfrom
IITI-tushar:fix/block-account-uses-account-id
Open

feat(settings): Fix settings to use savings accountId for disabling accounts#2014
IITI-tushar wants to merge 1 commit into
openMF:developmentfrom
IITI-tushar:fix/block-account-uses-account-id

Conversation

@IITI-tushar
Copy link
Copy Markdown

@IITI-tushar IITI-tushar commented May 9, 2026

…ing account

Issue Fix

Fixes #2013
Jira Task: Task_Number

Screenshots

image

Description

  • Read the default savings account id from preferences in the settings disable flow.
  • Show a clear error if the default account is missing.
  • Call block with the correct account id.

  • Apply the AndroidStyle.xml style template to your code in Android Studio.

  • Run the unit tests with ./gradlew check 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
    • Enhanced account disabling feature to use default account preference with improved error handling for edge cases where account information may be unavailable.

@IITI-tushar IITI-tushar requested a review from a team May 9, 2026 04:02
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 9, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

The handleDisableAccount() method in SettingsViewModel is updated to use the user's default account ID from preferences instead of the client ID. It adds validation for missing account IDs and sets appropriate error state before calling the account blocking repository method.

Changes

Account Disabling Logic Fix

Layer / File(s) Summary
Account Blocking Implementation
feature/settings/src/commonMain/kotlin/org/mifospay/feature/settings/SettingsViewModel.kt
handleDisableAccount() now retrieves userPreferencesRepository.defaultAccountId instead of using state.client.id. Adds null check that sets error dialog state if account ID is missing; otherwise sets Loading state, calls repository.blockAccount(accountId), and dispatches DisableAccountResult.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A settings fix, small but true,
Account ID swap—now blocking works through!
From client to account, the right way to go,
With validation in place, no more don't-know. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: using the savings accountId instead of clientId for disabling accounts.
Linked Issues check ✅ Passed The PR fully addresses issue #2013: it replaces state.client.id with userPreferencesRepository.defaultAccountId and adds error handling for missing accounts.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the account disabling flow in SettingsViewModel to use the correct account identifier.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

Copy link
Copy Markdown
Contributor

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@feature/settings/src/commonMain/kotlin/org/mifospay/feature/settings/SettingsViewModel.kt`:
- Line 231: The hardcoded user-facing message in SettingsViewModel (the
expression it.copy(dialogState = DialogState.Error("Default account not
available"))) should be replaced with the localized string resource used
elsewhere (e.g., Res.string.* or the existing getString(...) helper); update the
DialogState.Error call to pass the resource-backed string (fetching the
appropriate "default_account_not_available" resource) so the ViewModel uses
i18n-consistent messaging.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8359cd1e-883b-4c2c-9834-f679340d7049

📥 Commits

Reviewing files that changed from the base of the PR and between d399e0a and 908428d.

📒 Files selected for processing (1)
  • feature/settings/src/commonMain/kotlin/org/mifospay/feature/settings/SettingsViewModel.kt

val accountId = userPreferencesRepository.defaultAccountId.value
if (accountId == null) {
mutableStateFlow.update {
it.copy(dialogState = DialogState.Error("Default account not available"))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Replace hardcoded error text with a string resource.

"Default account not available" is user-facing and currently hardcoded, while this ViewModel otherwise uses localized Res.string.*/getString(...) messages. Please move this to resources for i18n consistency.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@feature/settings/src/commonMain/kotlin/org/mifospay/feature/settings/SettingsViewModel.kt`
at line 231, The hardcoded user-facing message in SettingsViewModel (the
expression it.copy(dialogState = DialogState.Error("Default account not
available"))) should be replaced with the localized string resource used
elsewhere (e.g., Res.string.* or the existing getString(...) helper); update the
DialogState.Error call to pass the resource-backed string (fetching the
appropriate "default_account_not_available" resource) so the ViewModel uses
i18n-consistent messaging.

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.

Fix disable account to use savings account id

1 participant