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

feature(standingInstructions) : Implemented new module and network layer implementation for the standing instructions endpoint.

Open techsavvy185 opened this issue 6 months ago • 12 comments

Fixes - Jira-#672

With Empty response in case no SI exist:

Screen_recording_20260610_104525.webm

WIth Mock Data:(The delete isn't working since the data is populated locally)

Screen_recording_20260620_001943.webm

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

  • [x] Run the static analysis check ./gradlew check or ci-prepush.sh to make sure you didn't break anything

  • [x] If you have multiple commits please combine them into one commit by squashing them.

techsavvy185 avatar Jun 01 '26 14:06 techsavvy185

Review Change Stack

[!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

This PR adds a complete "Standing Instructions" feature enabling users to view, edit, and delete recurring payment instructions linked to client accounts. The implementation spans domain and DTO models, network service integration with Ktorfit, repository layer with mappers, MVVM state management with Compose UI, navigation routing, and seamless savings account screen integration with localized string resources.

Changes

Feature implementation layers (click to expand)

Standing Instructions Feature

Layer / File(s) Summary
Domain, entity, and DTO data models
core/model/src/.../standingInstructions/StandingInstruction.kt, core/model/src/.../standingInstructions/StandingInstructionClient.kt, core/model/src/.../standingInstructions/StandingInstructionAccount.kt, core/model/src/.../standingInstructions/StandingInstructionUpdate.kt, core/database/src/.../entities/standingInstructions/*, core/network/src/.../dto/standingInstruction/StandingInstructionDto.kt
Data models across domain, entity, and DTO layers define standing instruction structure with client/account references, amounts, validity dates, and update payload types with full serialization support.
Network service and API endpoint wiring
core/database/src/.../APIEndPoint.kt, core/network/src/.../services/StandingInstructionService.kt, core/network/src/.../BaseApiManager.kt
Adds STANDING_INSTRUCTIONS API endpoint constant; defines Ktorfit service with @GET for list retrieval and @PUT for update/delete operations with query parameters and request body; exposes service via BaseApiManager.
DataManager and network DI wiring
core/network/src/.../datamanager/DataManagerStandingInstructions.kt, core/network/src/.../di/DataMangerModule.kt
Wraps HTTP service endpoints in DataManager for convenient list, update, and delete delegation; registers DataManager as Koin singleton.
Update request and response DTOs
core/network/src/.../dto/standingInstruction/UpdateStandingInstructionDto.kt, core/network/src/.../dto/standingInstruction/StandingInstructionUpdateResponseDto.kt
Defines request DTO for update/delete payloads with configurable amount, date, locale, and format fields; response DTO with optional resource ID and field change descriptions.
Repository contract and implementation
core/data/src/.../repository/StandingInstructionsRepository.kt, core/data/src/.../repositoryImp/StandingInstructionsRepositoryImp.kt
Repository interface defines list retrieval with pagination and identity/account scoping, plus suspending update and delete operations. Implementation fetches via DataManager, maps DTOs to domain, wraps as DataState, applies network checks via withNetworkCheck, and dispatches on io thread.
DTO and entity mapper extensions
core/data/src/.../mappers/standingInstructions/StandingInstructionsDtoMapper.kt, core/data/src/.../mappers/standingInstructions/StandingInstructionEntityMapper.kt
Maps standing instruction data between network DTOs and domain models with conditional nested client/account conversions; also maps entity layer to domain and constructs update request DTOs from domain models.
ViewModel, state models, and UI actions
feature/standing-instruction/src/.../viewStandingInstructions/ViewStandingInstructionsViewModel.kt
ViewModel bootstraps from route arguments (client ID, account details, currency code), auto-loads paged data on init, maps Page to table rows with currency formatting fallbacks, manages dialog state for options/delete/edit flows, validates amount input (numeric, positive), executes repository mutations on confirmation, and emits one-time navigation events.
Compose UI: screen, dialogs, and table
feature/standing-instruction/src/.../viewStandingInstructions/ViewStandingInstructionsScreen.kt
Entry-point collects ViewModel state with lifecycle awareness and handles navigation events; content layer renders MifosScaffold with back/refresh actions and conditional DataState UI; dialogs render error/delete/edit flows with conditional date picker and amount field validation; table renders sticky header, horizontally scrollable rows with per-row dropdown menus, and empty-state message.
Navigation route and destination registration
feature/standing-instruction/src/.../viewStandingInstructions/ViewStandingInstructionsRoute.kt, feature/standing-instruction/src/.../navigation/StandingInstructionsNavigation.kt
Defines typed @Serializable ViewStandingInstructionsScreenRoute with client, account, and currency code fields; NavController extension navigateToViewStandingInstructionsScreen(...) for typed navigation; NavGraphBuilder extension to register screen destination with back-press handling via popBackStack().
Savings screen navigation and menu integration
feature/savings/src/.../navigation/SavingsNavigation.kt, feature/savings/src/.../savingsAccountSummary/SavingsAccountSummaryScreen.kt, feature/client/src/.../navigation/ClientNavigation.kt, feature/savings/src/.../composeResources/values/*
Threads onViewStandingInstructions callback through entire savings navigation graph with currency code parameter; adds dropdown menu item to savings account summary that invokes callback with client/account/currency context; client navigation registers standing instructions destination; provides localized string resources in English and Spanish.
Dependency injection and Koin module setup
core/data/src/.../di/RepositoryModule.kt, cmp-navigation/.../KoinModules.kt, feature/standing-instruction/.../di/StandingInstructionsModule.kt
Registers StandingInstructionsRepositoryImp binding in RepositoryModule; creates StandingInstructionsModule with viewModelOf binding for ViewModel; includes module in featureModules aggregate for automatic Koin discovery.
Gradle build configuration and project setup
feature/standing-instruction/build.gradle.kts, feature/standing-instruction/.gitignore, cmp-navigation/build.gradle.kts, feature/client/build.gradle.kts, feature/savings/build.gradle.kts, settings.gradle.kts, feature/standing-instruction/src/.../composeResources/values/strings.xml
Adds standing-instruction feature module to build configuration in client and savings modules; creates feature module build script with convention plugin, Kotlin serialization, Android namespace, and Compose/core dependencies; registers module in settings; provides UI string resources for table headers, section title, empty state, and edit/delete/action labels.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant SavingsUI as Savings Screen
  participant NavCtrl as NavController
  participant ViewModel
  participant Repo as Repository
  participant DataMgr as DataManager
  participant Service as HTTP Service

  User->>SavingsUI: Tap "View Standing Instructions"
  SavingsUI->>NavCtrl: navigate to instructions screen
  NavCtrl->>ViewModel: init with route args
  activate ViewModel
  ViewModel->>Repo: getStandingInstructionList()
  activate Repo
  Repo->>DataMgr: retrieveListStandingInstructions()
  activate DataMgr
  DataMgr->>Service: GET standinginstructions
  activate Service
  Service-->>DataMgr: Flow of DTOs
  deactivate Service
  DataMgr-->>Repo: Flow of DTOs
  deactivate DataMgr
  Repo->>Repo: map to domain
  Repo-->>ViewModel: DataState.Success
  deactivate Repo
  ViewModel->>ViewModel: build table data
  ViewModel-->>SavingsUI: emit state
  deactivate ViewModel
  SavingsUI->>SavingsUI: render table

  User->>SavingsUI: click Edit row
  SavingsUI->>ViewModel: OnEditClick action
  activate ViewModel
  ViewModel->>ViewModel: show edit dialog
  ViewModel-->>SavingsUI: emit state
  deactivate ViewModel

  User->>SavingsUI: confirm edit
  SavingsUI->>ViewModel: OnConfirmEdit action
  activate ViewModel
  ViewModel->>ViewModel: set loading
  ViewModel->>Repo: updateStandingInstruction()
  activate Repo
  Repo->>DataMgr: updateStandingInstruction()
  activate DataMgr
  DataMgr->>Service: PUT standinginstructions
  activate Service
  Service-->>DataMgr: response
  deactivate Service
  DataMgr-->>Repo: response
  deactivate DataMgr
  Repo-->>ViewModel: DataState.Success
  deactivate Repo
  ViewModel->>ViewModel: reload list
  ViewModel-->>SavingsUI: emit state
  deactivate ViewModel
  SavingsUI->>SavingsUI: refresh table

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes


[!IMPORTANT]

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
Jira Link And Before/After Sections ❌ Error PR description has valid Jira link but lacks required "Before:" and "After:" sections with media. Only generic video labels and no before-state shown. Add "Before:" section with a screenshot/video showing the state before changes, and restructure existing videos under an explicit "After:" section header.
Docstring Coverage ⚠️ Warning Docstring coverage is 7.32% 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
Title check ✅ Passed The PR title includes specific module scope, describes the main change (new module and network layer for standing instructions), and follows the commit message format with type and scope.
Description check ✅ Passed The PR description is related to the changeset, referencing Jira ticket MIFOSAC-672, including screen recordings demonstrating the feature, and mentioning verification of static analysis checks.
✨ 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 Jun 01 '26 14:06 coderabbitai[bot]

@techsavvy185 Why row level actions are not implemented ?

sahilshivekar avatar Jun 11 '26 07:06 sahilshivekar

@sahilshivekar Row level actions are not implemented since there is no implementation for edit or delete for standing instructions in the app as of yet, and the jira ticket only specified creating the View SI screen as a requirement.

techsavvy185 avatar Jun 12 '26 05:06 techsavvy185

@sahilshivekar Row level actions are not implemented since there is no implementation for edit or delete for standing instructions in the app as of yet, and the jira ticket only specified creating the View SI screen as a requirement.

@techsavvy185 I see it's mentioned in the ticket to implement row level actions. Also there is a API on swagger UI for it. image image

sahilshivekar avatar Jun 12 '26 05:06 sahilshivekar

@sahilshivekar Oh, I missed that one. I will implement those and push the commits asap.

techsavvy185 avatar Jun 12 '26 07:06 techsavvy185

@techsavvy185 Please address the CodeRabbitAI suggestions relevant to your PR.

biplab1 avatar Jun 16 '26 12:06 biplab1

@techsavvy185 It's showing 500 amount even though you edited it to 5005 Also for showing the empty UI you can use the MifosErrorComponent

sahilshivekar avatar Jun 21 '26 10:06 sahilshivekar

@sahilshivekar It's because I populated this list manually to show how it is going to look like. While the edit functionality is pinging to change the value using the API, for which the account does not exist obviously.

techsavvy185 avatar Jun 21 '26 11:06 techsavvy185

And, I've used MifosEmptyCard for the current empty state.

techsavvy185 avatar Jun 21 '26 16:06 techsavvy185

@sahilshivekar It's because I populated this list manually to show how it is going to look like. While the edit functionality is pinging to change the value using the API, for which the account does not exist obviously.

Understood. But it should be tested with real account for which SI exists, if there is no such account then try to create one please (you can take help from victor for it).

sahilshivekar avatar Jun 25 '26 08:06 sahilshivekar

@sahilshivekar well that's the issue with this functionality, it is not really working and @biplab1 was following up on this i believe.

techsavvy185 avatar Jun 25 '26 08:06 techsavvy185

@sahilshivekar @biplab1 @revanthkumarJ could you guys review this PR

niyajali avatar Jun 30 '26 10:06 niyajali

@techsavvy185 are the apis working ?. If they are working please upload the latest video.

revanthkumarJ avatar Jun 30 '26 10:06 revanthkumarJ