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

feat(recurringDeposit): implement approve button in recurring account

Open ufuomaisaac opened this issue 10 months ago β€’ 18 comments

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

  • 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.

ufuomaisaac avatar Jan 22 '26 23:01 ufuomaisaac

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

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.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Jan 22 '26 23:01 coderabbitai[bot]

@ufuomaisaac Please address the @coderabbitai reviews which are relevant to this PR. Make sure the UI guidelines are being followed as well.

biplab1 avatar Jan 23 '26 15:01 biplab1

[!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) πŸ”΄

  1. Duplicate Plugin Installation (KtorHttpClient.android.kt):

    • ContentNegotiation is installed twice, causing DuplicatePluginException
    • Remove one of the duplicate blocks and keep a single installation
  2. Date Picker State Issue (RecurringDepositAccountApprovalScreen.kt, Line 235):

    • Local stub function rememberDatePickerState shadows the real API
    • Remove the stub so the actual date picker works correctly
  3. Navigation Wiring (ClientNavigation.kt, Lines 254-265):

    • onViewAccount callback is empty
    • Identifier inconsistency: accountNumber vs accountId
    • Wire the view account navigation properly

Important Fixes 🟑

  1. Date Format Padding (DateHelper.kt, Lines 44-50):

    • Use dayOfMonth(Padding.ZERO) instead of day() for proper "dd MMMM yyyy" format
  2. Date Picker Logic (RecurringDepositAccountApprovalScreen.kt, Lines 142-147):

    • Currently blocks today and past dates; should allow them for approvals
  3. Duplicate Fetch (RecurringDepositAccountScreen.kt, Lines 76-78):

    • LaunchedEffect causes unnecessary re-fetch on initial load
  4. Hardcoded Dialog Title (RecurringDepositAccountApprovalScreen.kt, Lines 113-121):

    • Use string resource instead of hardcoded "OK"
  5. Typo (RecurringDepositAccountScreen.kt, Line 178):

    • Fix "clientimplement" β†’ "implement"

Code Quality Improvements (Nice to Have) πŸ’‘

  • Handle null accountNo gracefully instead of empty string fallback
  • Use viewModelOf for consistency in DI
  • Use APIEndPoint constant instead of hardcoded URL
  • Make properties immutable (val vs var)
  • 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! πŸ€–

coderabbitai[bot] avatar Jan 23 '26 15:01 coderabbitai[bot]

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

ufuomaisaac avatar Jan 24 '26 14:01 ufuomaisaac

[!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! πŸ‘

coderabbitai[bot] avatar Jan 24 '26 14:01 coderabbitai[bot]

[!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! πŸ‘

coderabbitai[bot] avatar Jan 24 '26 15:01 coderabbitai[bot]

@biplab1, I have resolved all the issues raised by coderabbitai

ufuomaisaac avatar Jan 28 '26 12:01 ufuomaisaac

@biplab1 I have resolved all the issues that were raised by CodeRabbitAi

ufuomaisaac avatar Jan 28 '26 20:01 ufuomaisaac

@ufuomaisaac, please resolve conflicts and request the team for review.

itsPronay avatar Feb 02 '26 17:02 itsPronay

I've fetched the changes and tested locally. Looks good to me!

techsavvy185 avatar Feb 05 '26 13:02 techsavvy185

@ufuomaisaac, I see we have a new screen addition in your PR, we didn't have that screen before?

itsPronay avatar Feb 05 '26 14:02 itsPronay

No, the screen wasn't there before @itsPronay

Thank you for the review. I will make changes and update you.

ufuomaisaac avatar Feb 05 '26 17:02 ufuomaisaac

Thank you for the review! @techsavvy185

ufuomaisaac avatar Feb 05 '26 17:02 ufuomaisaac

@itsPronay, I have made all the requested changes. Please take a look at it when you have the time.

ufuomaisaac avatar Feb 07 '26 04:02 ufuomaisaac

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 avatar Mar 02 '26 11:03 ufuomaisaac

@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.

biplab1 avatar Mar 05 '26 13:03 biplab1

@ufuomaisaac Please fix the merge conflicts.

biplab1 avatar Mar 11 '26 17:03 biplab1