mobile-wallet icon indicating copy to clipboard operation
mobile-wallet copied to clipboard

feat(pocket): add pocket linked accounts POC

Open bhuvan-somisetty opened this issue 6 months ago • 2 comments

Proof of concept for the Pocket feature (issue #1997, MW-378). Covers three of the four defined goals: viewing the pocket dashboard, linking accounts, and delinking accounts.

The pocket dashboard shows all linked savings, loan, and share accounts in one view with an aggregated total balance card. A shortcut card on the home screen navigates to it. Linking an account takes an account ID and type; delinking shows a confirmation dialog before removing the account from the list.

The data layer uses an in-memory demo repository so the feature is fully interactive without a running backend. The real PocketRepositoryImpl wired to the Fineract self-service pocket API (GET /self/pockets, POST /self/pockets?command=linkAccounts, POST /self/pockets?command=delinkAccounts) is also included and can be swapped into the DI module once the API is reachable.

Navigation to the individual account detail screen is wired but the destination itself is out of scope for this POC.

Tested manually: dashboard with pre-loaded accounts (savings + loan), link/delink flow, empty state after removing all accounts, and the home screen shortcut.

Closes #1997

Summary by CodeRabbit

  • New Features
    • Added Pocket feature to home screen for managing linked accounts
    • Users can now view total balance across all linked accounts
    • Implemented account linking and unlinking functionality
    • Added dedicated dashboard screen displaying linked accounts with individual balances
    • New account linking workflow with account ID and type selection

Review Change Stack

bhuvan-somisetty avatar May 09 '26 18:05 bhuvan-somisetty

📝 Walkthrough

Walkthrough

This PR implements the complete Pocket feature, enabling users to view linked financial accounts, link/delink accounts, and access account details through a new dashboard screen. The implementation spans data models, dual repository implementations (demo and API-based), network service definitions, two Compose screens with ViewModels, navigation setup, and home screen integration.

Changes

Pocket Feature Implementation

Layer / File(s) Summary
Data Models & Repository Interface
core/model/src/commonMain/kotlin/org/mifospay/core/model/pocket/Pocket.kt, core/data/src/commonMain/kotlin/org/mifospay/core/data/repository/PocketRepository.kt
Introduces Pocket, PocketAccount, PocketAccountType enum, and API payload models (PocketLinkPayload, PocketDelinkPayload); defines PocketRepository interface with getPocket(), linkAccount(), and delinkAccount() methods returning Flow<DataState<...>>.
Network Layer
core/network/src/commonMain/kotlin/org/mifospay/core/network/services/PocketService.kt, core/network/src/commonMain/kotlin/org/mifospay/core/network/KtorfitClient.kt, core/network/src/commonMain/kotlin/org/mifospay/core/network/SelfServiceApiManager.kt, core/network/src/commonMain/kotlin/org/mifospay/core/network/utils/ApiEndPoints.kt
Defines PocketService with GET/POST endpoints (getPockets, linkAccounts, delinkAccounts); adds pocketApi property to KtorfitClient and SelfServiceApiManager; adds POCKETS endpoint constant.
Repository Implementations
core/data/src/commonMain/kotlin/org/mifospay/core/data/repositoryImpl/DemoPocketRepository.kt, core/data/src/commonMain/kotlin/org/mifospay/core/data/repositoryImpl/PocketRepositoryImpl.kt
DemoPocketRepository maintains in-memory pocket state with demo accounts; PocketRepositoryImpl wraps API calls via SelfServiceApiManager; both emit Loading then Success/Error states.
Dependency Injection
core/data/src/commonMain/kotlin/org/mifospay/core/data/di/RepositoryModule.kt, feature/pocket/src/commonMain/kotlin/org/mifospay/feature/pocket/di/PocketModule.kt, cmp-shared/src/commonMain/kotlin/org/mifospay/shared/di/KoinModules.kt, cmp-shared/build.gradle.kts, settings.gradle.kts
Registers PocketRepository with DemoPocketRepository(); creates PocketModule with PocketDashboardViewModel and LinkAccountViewModel; includes module in shared Koin config; adds gradle dependencies.
Build Configuration & Resources
feature/pocket/build.gradle.kts, feature/pocket/src/androidMain/AndroidManifest.xml, feature/pocket/src/commonMain/composeResources/values/strings.xml
Defines feature module build script with plugins and Compose dependencies; empty Android manifest; pocket feature string resources (titles, labels, errors).
Dashboard Screen & ViewModel
feature/pocket/src/commonMain/kotlin/org/mifospay/feature/pocket/dashboard/PocketDashboardScreen.kt, feature/pocket/src/commonMain/kotlin/org/mifospay/feature/pocket/dashboard/PocketDashboardViewModel.kt
PocketDashboardScreen renders loading/empty/error/success states via MifosScaffold; displays total balance and linked account cards with delink dialogs; PocketDashboardViewModel loads pocket data, manages delink flow, and handles navigation.
Link Account Screen & ViewModel
feature/pocket/src/commonMain/kotlin/org/mifospay/feature/pocket/link/LinkAccountScreen.kt, feature/pocket/src/commonMain/kotlin/org/mifospay/feature/pocket/link/LinkAccountViewModel.kt
LinkAccountScreen provides account ID input, account type chip selection, and submit button; LinkAccountViewModel validates numeric input, calls repository linking, and emits LinkSuccess.
Pocket Navigation
feature/pocket/src/commonMain/kotlin/org/mifospay/feature/pocket/navigation/PocketNavigation.kt
Defines POCKET_DASHBOARD_ROUTE and LINK_ACCOUNT_ROUTE constants; provides NavController extension functions to navigate to each route; registers NavGraphBuilder extensions for dashboard and link-account destinations.
Main Navigation Integration
cmp-shared/src/commonMain/kotlin/org/mifospay/shared/navigation/MifosNavHost.kt
Wires navigateToPocketDashboard callback from homeScreen; registers pocketDashboardScreen and linkAccountScreen destinations with callbacks for back navigation, linking, and account details.
Home Screen Integration
feature/home/src/commonMain/composeResources/values/strings.xml, feature/home/src/commonMain/kotlin/org/mifospay/feature/home/HomeScreen.kt, feature/home/src/commonMain/kotlin/org/mifospay/feature/home/HomeViewModel.kt, feature/home/src/commonMain/kotlin/org/mifospay/feature/home/navigation/HomeNavigation.kt
Adds pocket string resources; inserts PocketShortcutCard into home LazyColumn with wallet icon and title/subtitle; handles PocketClicked action in ViewModel to emit navigation event; extends homeScreen navigation to accept and wire navigateToPocketDashboard callback.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • openMF/mifos-pay#1987: Both PRs register new feature modules and navigation routes in shared app wiring (KoinModules, cmp-shared dependencies, MifosNavHost).

Suggested reviewers

  • niyajali
  • therajanmaurya

Poem

🐰 A pocket full of linked accounts, what joy!
Dashboard, link, delink—no need to deploy,
Home screen shortcuts lead the way,
MVVM flows keep data at bay. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly summarizes the main feature addition: pocket linked accounts proof-of-concept.
Linked Issues check ✅ Passed All four objectives from issue #1997 are implemented or scaffolded: View Dashboard [1], Link Accounts [2], Delink Accounts [3], and Account Details navigation [4] are present.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the Pocket feature implementation. Modifications to home screen, navigation, shared modules, and data layer are necessary for feature integration and follow the PR's declared objectives.

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

coderabbitai[bot] avatar May 09 '26 18:05 coderabbitai[bot]

@bhuvan-somisetty convert this pr into draft

Nagarjuna0033 avatar May 31 '26 06:05 Nagarjuna0033

Done, converted this to draft. This was a POC and not ready for review yet - I'll pick it back up once I've gone through the proper process (Jira ticket + assignment) and rebase it on latest dev before marking it ready again.

bhuvan-somisetty avatar Jul 05 '26 05:07 bhuvan-somisetty