feat(recurringDeposit): implement approve button in recurring account
Fixes - Jira-#MIFOSAC-361
Didn't create a Jira ticket, click here to create new.
Please Add Screenshots If there are any UI changes.
| Before | After |
|---|---|
https://github.com/user-attachments/assets/e137465c-7076-444f-a124-76926c01e572
Please make sure these boxes are checked before submitting your pull request - thanks!
-
[x] Run the static analysis check
./gradlew checkorci-prepush.shto make sure you didn't break anything -
[ ] If you have multiple commits please combine them into one commit by squashing them.
Summary by CodeRabbit
-
New Features
- Recurring deposit approval flow: approval screen, navigation, backend approval endpoint, view model and use-case for approving accounts.
-
UI/UX Improvements
- Date picker, approval-reason input, save/confirm flow, success/error dialogs, lifecycle auto-refresh on resume, and list actions to approve or view accounts.
-
Other
- Added approval-related UI strings, standardized approval date formatting, and JSON encoding now includes default values.
[!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_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
- [ ] βΆοΈ Resume reviews
- [ ] π Trigger review
π Walkthrough
Walkthrough
Adds a recurring deposit approval feature: new approval model, API/service/datamanager/repository + use-case and ViewModel, navigation and approval UI (with date picker and lifecycle refresh), DateHelper date-format helper, DI wiring, strings, and a Ktor JSON config tweak.
Changes
| Cohort / File(s) | Summary |
|---|---|
Date utility core/common/src/commonMain/kotlin/com/mifos/core/common/utils/DateHelper.kt |
Added apiDateFormat and getDateAsStringForApproval(timeInMillis: Long) for approval-specific date formatting. |
Model core/model/src/commonMain/kotlin/.../recurring/approval/RecurringDepositApproval.kt |
Added @Serializable RecurringDepositApproval data class (locale, dateFormat, approvedOnDate?, note?). |
Repository & impl core/data/src/commonMain/kotlin/com/mifos/core/data/repository/RecurringAccountRepository.kt, core/data/src/commonMain/kotlin/com/mifos/core/data/repositoryImp/RecurringAccountRepositoryImp.kt |
Added suspend fun approveRecurringDepositAccount(accountId: String, approval: RecurringDepositApproval): GenericResponse to interface and implementation (delegates to datamanager). |
Network service & datamanager core/network/src/commonMain/kotlin/.../RecurringAccountService.kt, core/network/src/commonMain/kotlin/.../DataManagerRecurringAccount.kt |
Added POST API endpoint approveRecurringDepositAccount(accountId, approval); datamanager posts payload, throws on non-success, decodes GenericResponse. |
Ktor JSON config core/network/src/androidMain/kotlin/com/mifos/core/network/KtorHttpClient.android.kt |
Enabled encodeDefaults = true in Json configuration for ContentNegotiation. |
DI & use-case core/domain/src/commonMain/kotlin/.../UseCaseModule.kt, core/domain/src/commonMain/kotlin/.../useCases/ApproveRecurringDepositUseCase.kt, feature/recurringDeposit/src/commonMain/kotlin/.../RecurringDepositModule.kt |
Registered ApproveRecurringDepositUseCase and bound RecurringDepositAccountApprovalViewModel in DI; added domain use-case wrapping repository call into Flow<DataState |
Navigation feature/client/.../ClientNavigation.kt, feature/recurringDeposit/.../RecurringDepositAccountApprovalNavigation.kt |
Added RecurringDepositAccountApprovalRoute, destination and NavController helper; updated client destinations to accept onApproveAccount / onViewAccount callbacks. |
UI, ViewModel & feature feature/recurringDeposit/.../RecurringDepositAccountApprovalScreen.kt, .../RecurringDepositAccountApprovalViewModel.kt, feature/client/.../RecurringDepositAccountScreen.kt |
New approval screen/composables, ViewModel and UI state machine (Initial/Progress/Success/Error); date picker, reason input, save flow, lifecycle-driven refresh, scaffold and dialogs. |
Strings feature/recurringDeposit/src/commonMain/composeResources/values/feature_recurring_deposit_string.xml |
Added UI strings for approval flow (approve account, select date, approved on, approval reason, save/continue, success/failure titles and messages). |
Sequence Diagram(s)
sequenceDiagram
rect rgba(220,230,241,0.5)
participant User
end
rect rgba(200,240,200,0.5)
participant Screen
end
rect rgba(255,230,200,0.5)
participant VM
end
rect rgba(240,200,255,0.5)
participant UseCase
end
rect rgba(255,220,220,0.5)
participant Repo
end
rect rgba(220,255,240,0.5)
participant Service
end
rect rgba(240,240,220,0.5)
participant API
end
User->>Screen: pick date, enter reason, tap Save
Screen->>VM: approveRecurringDepositApplication(accountId, approval)
VM->>VM: emit ShowProgressbar
VM->>UseCase: invoke(accountId, approval)
UseCase->>Repo: approveRecurringDepositAccount(accountId, approval)
Repo->>Service: approveRecurringDepositAccount(accountId, approval)
Service->>API: POST /recurringdepositaccounts/{accountId}?command=approve
API-->>Service: HttpResponse
Service-->>Repo: HttpResponse
Repo->>Repo: decode -> GenericResponse or throw
Repo-->>UseCase: DataState.Success / DataState.Error
UseCase-->>VM: DataState
VM-->>Screen: update UI state (success / error)
Screen->>User: show snackbar/dialog and navigate back on success
Estimated code review effort
π― 4 (Complex) | β±οΈ ~45 minutes
Possibly related PRs
- openMF/android-client#2595 β related DateHelper/date-formatting changes.
- openMF/android-client#2539 β overlaps changes to DataManagerRecurringAccount and approve flow implementation.
- openMF/android-client#2529 β related datamanager error-handling and response extraction patterns.
Suggested reviewers
- biplab1
- itsPronay
- revanthkumarJ
Poem
π° I hopped in with a tiny grin,
Picked a date and scribbled a note,
Sent it down the VM-and-repo moat,
"Approved!" they cheered β I twitched my chin,
I nibbled a carrot, then hopped home.
π₯ Pre-merge checks | β 2 | β 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 (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | β Passed | Check skipped - CodeRabbitβs high-level summary is enabled. |
| Title check | β Passed | The title clearly and specifically describes the main change: implementation of an approve button feature for recurring deposit accounts, which is the primary objective of this changeset. |
βοΈ 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.
Comment @coderabbitai help to get the list of available commands and usage tips.
@ufuomaisaac Please address the @coderabbitai reviews which are relevant to this PR. Make sure the UI guidelines are being followed as well.
[!TIP] For best results, initiate chat on the files or code changes.
π§© Analysis chain
π Script executed:
#!/bin/bash
# List all review comments made by CodeRabbit on this PR
gh pr view 2580 --json reviews,comments --jq '.reviews[] | select(.author.login == "coderabbitai") | {state: .state, body: .body, submittedAt: .submittedAt}' 2>/dev/null || echo "No reviews found or error accessing reviews"
# Also get review comments (line-level comments)
gh api "repos/openMF/android-client/pulls/2580/comments" --jq '.[] | select(.user.login == "coderabbitai") | {path: .path, line: .line, body: .body, created_at: .created_at}' 2>/dev/null || echo "No review comments found"
Length of output: 11400
@biplab1 @ufuomaisaac, I found my review from January 23rd with several items that need attention. Here's a summary:
Critical Issues (Must Fix) π΄
-
Duplicate Plugin Installation (
KtorHttpClient.android.kt):ContentNegotiationis installed twice, causingDuplicatePluginException- Remove one of the duplicate blocks and keep a single installation
-
Date Picker State Issue (
RecurringDepositAccountApprovalScreen.kt, Line 235):- Local stub function
rememberDatePickerStateshadows the real API - Remove the stub so the actual date picker works correctly
- Local stub function
-
Navigation Wiring (
ClientNavigation.kt, Lines 254-265):onViewAccountcallback is empty- Identifier inconsistency:
accountNumbervsaccountId - Wire the view account navigation properly
Important Fixes π‘
-
Date Format Padding (
DateHelper.kt, Lines 44-50):- Use
dayOfMonth(Padding.ZERO)instead ofday()for proper "dd MMMM yyyy" format
- Use
-
Date Picker Logic (
RecurringDepositAccountApprovalScreen.kt, Lines 142-147):- Currently blocks today and past dates; should allow them for approvals
-
Duplicate Fetch (
RecurringDepositAccountScreen.kt, Lines 76-78):LaunchedEffectcauses unnecessary re-fetch on initial load
-
Hardcoded Dialog Title (
RecurringDepositAccountApprovalScreen.kt, Lines 113-121):- Use string resource instead of hardcoded "OK"
-
Typo (
RecurringDepositAccountScreen.kt, Line 178):- Fix "clientimplement" β "implement"
Code Quality Improvements (Nice to Have) π‘
- Handle null
accountNogracefully instead of empty string fallback - Use
viewModelOffor consistency in DI - Use
APIEndPointconstant instead of hardcoded URL - Make properties immutable (
valvsvar) - Extract shared response-mapping logic
I'm happy to help clarify any of these items or provide more specific guidance on how to fix them. Just let me know! π€
@ufuomaisaac Please address the @coderabbitai reviews which are relevant to this PR. Make sure the UI guidelines are being followed as well.
Alright, will work on that. Thank you!
[!TIP] For best results, initiate chat on the files or code changes.
@ufuomaisaac, sounds good! I'm here if you need any help or clarification on any of the review items as you work through them. Feel free to ping me if you have questions! π
[!TIP] For best results, initiate chat on the files or code changes.
@ufuomaisaac, sounds good! I'm here if you need any help or clarification on any of the review items as you work through them. Feel free to ping me if you have questions! π
@biplab1, I have resolved all the issues raised by coderabbitai
@biplab1 I have resolved all the issues that were raised by CodeRabbitAi
@ufuomaisaac, please resolve conflicts and request the team for review.
I've fetched the changes and tested locally. Looks good to me!
@ufuomaisaac, I see we have a new screen addition in your PR, we didn't have that screen before?
No, the screen wasn't there before @itsPronay
Thank you for the review. I will make changes and update you.
Thank you for the review! @techsavvy185
@itsPronay, I have made all the requested changes. Please take a look at it when you have the time.
from pr video it is shown like while loading or dialog shown the background content is not showing i think
the background should not hide and we have to use overlay loaading and dialog comes on top of existing content
I have made the changes
@ufuomaisaac After you push the changes, always make sure to check the File changes section of this PR to ensure relevant files are only updated.
@ufuomaisaac Please fix the merge conflicts.
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