Skip to content

Conversation

@ankitkumarrain
Copy link
Contributor

@ankitkumarrain ankitkumarrain commented Nov 20, 2025

Fixes - Jira-#Issue_Number

Didn't create a Jira ticket, click here to create new.

Please Add Screenshots If there are any UI changes.

Before After

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

  • 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

    • Four new dropdowns added to recurring deposit setup: compounding period, posting period, calculation method, and days‑in‑year.
    • Four new localized strings for those dropdown labels.
    • Interest page label updated to use "charges" wording.
  • Refactor

    • Terms view converted to a state-driven interface; selections persist and enable/disable the Next action.
  • Chores

    • Internal resource key renamed for a field officer label (no visible text change).

✏️ Tip: You can customize this high-level summary in your review settings.

WhatsApp.Video.2025-11-21.at.19.31.01_3aa68443.mp4

this is video.

@coderabbitai
Copy link

coderabbitai bot commented Nov 20, 2025

Walkthrough

Refactors Terms UI to a state-driven API: adds four new string resources, introduces RecurringAccountInterestChart state and actions in the ViewModel, updates screen wiring to pass state/onAction, and rewrites TermsPage to expose four dropdowns bound to state.

Changes

Cohort / File(s) Change Summary
String Resources
feature/recurringDeposit/src/commonMain/composeResources/values/feature_recurring_deposit_string.xml
Added 4 strings: feature_recurring_deposit_interest_compounding_period, feature_recurring_deposit_interest_posting_period, feature_recurring_deposit_interest_calculation, feature_recurring_deposit_calculation_days_in_year.
Screen Integration
feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/RecurringAccountScreen.kt
Replaced prior TermsPage(onNext = ...) usage with TermsPage(state = state, onAction = onAction).
ViewModel: State & Actions
feature/recurringDeposit/src/commonMain/kotlin/.../RecurringAccountViewModel.kt
Added RecurringAccountInterestChartState (four nullable Int fields + derived isTermsButtonEnabled), extended RecurringAccountState with recurringDepositAccountInterestChart, added RecurringAccountInterestChartAction variants, and private handlers wired into action dispatcher to update state via .copy().
Pages: Terms & Interest
feature/recurringDeposit/src/commonMain/kotlin/.../pages/TermsPage.kt, feature/recurringDeposit/src/commonMain/kotlin/.../pages/InterestPage.kt
TermsPage signature changed to TermsPage(state: RecurringAccountState, onAction: (RecurringAccountAction) -> Unit); replaced static terms UI with four MifosTextFieldDropdowns bound to state and dispatching interest-chart actions; InterestPage now uses feature_recurring_deposit_charges_page resource.
Client strings & usages
feature/client/src/commonMain/composeResources/values/strings.xml, feature/client/src/commonMain/kotlin/.../DetailsPage.kt
Renamed resource Field_officerfield_officer and updated import/usage in DetailsPage.kt.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant TermsPage
    participant RecurringAccountScreen
    participant RecurringAccountViewModel
    participant StateStore

    Note over TermsPage,RecurringAccountViewModel: State-driven dropdown flow
    User->>TermsPage: select dropdown option
    TermsPage->>RecurringAccountScreen: onAction(RecurringAccountInterestChartAction.*)
    RecurringAccountScreen->>RecurringAccountViewModel: handleAction(action)
    RecurringAccountViewModel->>RecurringAccountViewModel: route -> private handler -> update state.copy()
    RecurringAccountViewModel->>StateStore: emit updated RecurringAccountState
    StateStore-->>RecurringAccountScreen: state updated
    RecurringAccountScreen->>TermsPage: pass new state
    TermsPage->>User: UI recomposed with updated selection
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify each RecurringAccountInterestChartAction routes to the correct private handler.
  • Confirm isTermsButtonEnabled logic and nullable defaults (use of -1 checks).
  • Check TermsPage bindings dispatch correct action payloads and string resource keys.

Possibly related PRs

Suggested reviewers

  • biplab1
  • sam-arth07

Poem

🐰 I hopped from callbacks into state so true,
Four tiny dropdowns popped into view,
Actions nibble, state grows neat and bright,
Compounding, posting, calculation in sight,
A carrot-cheer for UI now just right 🥕

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 'Feature Terms Steps for Recurring Deposit account Flow. 551' directly describes the main changes: implementation of a terms page/step in the recurring deposit account creation flow, matching the substantial refactoring of TermsPage and related interest chart state management.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

@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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/RecurringAccountViewModel.kt (2)

113-116: Critical: Interest chart values not used in payload.

The interest chart fields are hardcoded to null in the payload despite being collected in the UI through recurringDepositAccountInterestChart. This means user selections from the Interest page are ignored when creating the account.

Apply this diff:

-                interestCalculationDaysInYearType = null,
-                interestCalculationType = null,
-                interestCompoundingPeriodType = null,
-                interestPostingPeriodType = null,
+                interestCalculationDaysInYearType = s.recurringDepositAccountInterestChart.interestCalculationDaysInYearType,
+                interestCalculationType = s.recurringDepositAccountInterestChart.interestCalculationType,
+                interestCompoundingPeriodType = s.recurringDepositAccountInterestChart.interestCompoundingPeriodType,
+                interestPostingPeriodType = s.recurringDepositAccountInterestChart.interestPostingPeriodType,

211-226: Include interest chart state in reset.

The resetForRetry method resets all state fields except recurringDepositAccountInterestChart, which should also be cleared to ensure a clean retry state.

Apply this diff:

     private fun resetForRetry() {
         mutableStateFlow.update {
             it.copy(
                 isOnline = false,
                 clientId = -1,
                 currentStep = 0,
                 screenState = ScreenState.Loading,
                 recurringDepositAccountDetail = RecurringAccountDetailsState(),
                 template = RecurringDepositAccountTemplate(),
                 recurringDepositAccountSettings = RecurringAccountSettingsState(),
+                recurringDepositAccountInterestChart = RecurringAccountInterestChartState(),
                 currencyIndex = -1,
                 currencyError = null,
             )
         }
         loadRecurringAccountTemplate()
     }
🧹 Nitpick comments (1)
feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/pages/InterestPage.kt (1)

36-41: Consider using empty string instead of space for null values.

All four dropdowns use a single space " " when the value is null. Using an empty string "" would be more conventional and avoid potential display issues.

Example for first dropdown:

             value = if (state.recurringDepositAccountInterestChart.interestCompoundingPeriodType == null) {
-                " "
+                ""
             } else {

Apply the same change to the other three dropdowns.

Also applies to: 57-62, 78-83, 99-104

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a762133 and b776b40.

📒 Files selected for processing (4)
  • feature/recurringDeposit/src/commonMain/composeResources/values/feature_recurring_deposit_string.xml (1 hunks)
  • feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/RecurringAccountScreen.kt (1 hunks)
  • feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/RecurringAccountViewModel.kt (5 hunks)
  • feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/pages/InterestPage.kt (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/pages/InterestPage.kt (1)
core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/component/MifosTextFieldDropdown.kt (1)
  • MifosTextFieldDropdown (39-112)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: PR Checks / Static Analysis Check
🔇 Additional comments (5)
feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/RecurringAccountViewModel.kt (4)

173-209: LGTM!

The handler methods correctly update the recurringDepositAccountInterestChart state using immutable copy operations.


619-630: LGTM!

Action routing to the interest chart handlers is correctly implemented.


670-675: LGTM!

The RecurringAccountInterestChartState data class is well-structured with appropriate nullable Int fields for the four interest parameters.


778-783: LGTM!

The RecurringAccountInterestChartAction sealed class properly defines actions for all four interest chart parameters.

feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/RecurringAccountScreen.kt (1)

94-97: LGTM!

The InterestPage invocation correctly passes both state and onAction, aligning with the refactored stateful API.

<string name="feature_recurring_deposit_interest_compounding_period">Interest Compounding Period</string>
<string name="feature_recurring_deposit_interest_posting_period">Interest Posting Period</string>
<string name="feature_recurring_deposit_interest_calculation">Interest Calculated Using</string>
<string name="feature_recurring_deposit_Calculation_Days_In_Year">Days In Year </string>
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix inconsistent naming convention and remove trailing space.

The string resource name uses an inconsistent naming pattern with a capital 'C' in Calculation_Days_In_Year, while all other resource names use lowercase. Additionally, the string value has a trailing space.

Apply this diff:

-    <string name="feature_recurring_deposit_Calculation_Days_In_Year">Days In Year </string>
+    <string name="feature_recurring_deposit_calculation_days_in_year">Days In Year</string>
🤖 Prompt for AI Agents
In
feature/recurringDeposit/src/commonMain/composeResources/values/feature_recurring_deposit_string.xml
around line 55, the string resource name uses an inconsistent capital 'C'
("Calculation_Days_In_Year") and the value contains a trailing space; rename the
resource to use lowercase and match the project's snake_case style (e.g.,
"calculation_days_in_year") and remove the trailing space from the string value
so it becomes "Days In Year".

Comment on lines 35 to 54
MifosTextFieldDropdown(
value = if (state.recurringDepositAccountInterestChart.interestCompoundingPeriodType == null) {
" "
} else {
state.template.interestCalculationDaysInYearTypeOptions?.get(state.recurringDepositAccountInterestChart.interestCompoundingPeriodType)?.value
?: ""
},
onValueChanged = { },
onOptionSelected = { index, value ->
onAction(
RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCompoundingPeriodType(
index,
),
)
},
options = state.template.interestCompoundingPeriodTypeOptions?.map {
it.value ?: ""
} ?: emptyList(),
label = stringResource(Res.string.feature_recurring_deposit_interest_compounding_period),
)
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: Wrong template options list used for dropdown value.

Line 39 accesses state.template.interestCalculationDaysInYearTypeOptions when it should use state.template.interestCompoundingPeriodTypeOptions to match the interestCompoundingPeriodType field.

Apply this diff:

         MifosTextFieldDropdown(
             value = if (state.recurringDepositAccountInterestChart.interestCompoundingPeriodType == null) {
                 " "
             } else {
-                state.template.interestCalculationDaysInYearTypeOptions?.get(state.recurringDepositAccountInterestChart.interestCompoundingPeriodType)?.value
+                state.template.interestCompoundingPeriodTypeOptions?.get(state.recurringDepositAccountInterestChart.interestCompoundingPeriodType)?.value
                     ?: ""
             },
🤖 Prompt for AI Agents
In
feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/pages/InterestPage.kt
around lines 35 to 54, the dropdown value lookup uses
state.template.interestCalculationDaysInYearTypeOptions but must use
state.template.interestCompoundingPeriodTypeOptions to match the
interestCompoundingPeriodType field and the options list; update the value
expression to fetch the selected display string from
state.template.interestCompoundingPeriodTypeOptions (same null-safe access and
fallback logic) so it aligns with the options passed to the
MifosTextFieldDropdown.

Copy link

@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

🧹 Nitpick comments (3)
feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/pages/TermsPage.kt (3)

38-38: Use empty string instead of space for null values.

All four dropdowns use a space " " when the state value is null. Consider using an empty string "" instead for consistency and to avoid potential spacing issues in the UI.

Apply this diff to all four dropdowns:

-        value = if (state.recurringDepositAccountInterestChart.interestCompoundingPeriodType == null) {
-            " "
-        } else {
+        value = if (state.recurringDepositAccountInterestChart.interestCompoundingPeriodType == null) {
+            ""
+        } else {

Also applies to: 59-59, 80-80, 101-101


36-118: Consider extracting a helper function to reduce duplication.

All four dropdown components follow an identical pattern with only minor variations. Extracting a helper function would improve maintainability and reduce the risk of copy-paste errors (like the one on line 40).

Example approach:

@Composable
private fun InterestChartDropdown(
    value: Int?,
    options: List<ValueOption>?,
    label: String,
    onOptionSelected: (Int) -> Unit
) {
    MifosTextFieldDropdown(
        value = if (value == null) {
            ""
        } else {
            options?.get(value)?.value ?: ""
        },
        onValueChanged = { },
        onOptionSelected = { index, _ ->
            onOptionSelected(index)
        },
        options = options?.map { it.value ?: "" } ?: emptyList(),
        label = label,
    )
}

13-13: String resource name has inconsistent casing.

The resource name feature_recurring_deposit_Calculation_Days_In_Year has a capital 'C' in the middle, breaking the snake_case naming convention. This should be feature_recurring_deposit_calculation_days_in_year.

Note: This change would need to be made in the string resource file feature_recurring_deposit_string.xml and updated here accordingly.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b776b40 and 65c30ac.

📒 Files selected for processing (3)
  • feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/RecurringAccountScreen.kt (1 hunks)
  • feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/pages/InterestPage.kt (2 hunks)
  • feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/pages/TermsPage.kt (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/RecurringAccountScreen.kt
  • feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/pages/InterestPage.kt
🧰 Additional context used
🧬 Code graph analysis (1)
feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/pages/TermsPage.kt (1)
core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/component/MifosTextFieldDropdown.kt (1)
  • MifosTextFieldDropdown (39-112)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: PR Checks / Static Analysis Check
🔇 Additional comments (1)
feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/pages/TermsPage.kt (1)

32-33: State structure and template field definitions verified—all required fields are properly defined.

Verification confirms:

  • RecurringAccountState has recurringDepositAccountInterestChart: RecurringAccountInterestChartState
  • RecurringAccountState has template: RecurringDepositAccountTemplate
  • RecurringAccountInterestChartState has all four properties (interestCalculationDaysInYearType, interestCalculationType, interestCompoundingPeriodType, interestPostingPeriodType)
  • RecurringDepositAccountTemplate has all four *Options lists
  • RecurringAccountAction.RecurringAccountInterestChartAction has all four required action types

Copy link

@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

♻️ Duplicate comments (1)
feature/recurringDeposit/src/commonMain/composeResources/values/feature_recurring_deposit_string.xml (1)

55-55: Remove trailing space from string value.

The string value contains a trailing space after "Year".

Apply this diff:

-    <string name="feature_recurring_deposit_calculation_days_in_year">Days In Year </string>
+    <string name="feature_recurring_deposit_calculation_days_in_year">Days In Year</string>
🧹 Nitpick comments (1)
feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/pages/TermsPage.kt (1)

35-117: Consider extracting common dropdown pattern.

All four dropdowns follow an identical structure with only the state field, action, options list, and label differing. A helper composable function could reduce duplication and improve maintainability.

Example approach:

@Composable
private fun InterestChartDropdown(
    selectedIndex: Int?,
    options: List<String>,
    label: String,
    onSelect: (Int) -> Unit
) {
    MifosTextFieldDropdown(
        value = selectedIndex?.let { options.getOrNull(it) } ?: " ",
        onValueChanged = { },
        onOptionSelected = { index, _ -> onSelect(index) },
        options = options,
        label = label,
    )
}

Then use it for each dropdown:

InterestChartDropdown(
    selectedIndex = state.recurringDepositAccountInterestChart.interestCompoundingPeriodType,
    options = state.template.interestCompoundingPeriodTypeOptions?.mapNotNull { it.value } ?: emptyList(),
    label = stringResource(Res.string.feature_recurring_deposit_interest_compounding_period),
    onSelect = { index ->
        onAction(RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCompoundingPeriodType(index))
    }
)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 65c30ac and 2b1d86f.

📒 Files selected for processing (3)
  • feature/recurringDeposit/src/commonMain/composeResources/values/feature_recurring_deposit_string.xml (1 hunks)
  • feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/pages/InterestPage.kt (2 hunks)
  • feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/pages/TermsPage.kt (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/pages/InterestPage.kt
🧰 Additional context used
🧬 Code graph analysis (1)
feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/pages/TermsPage.kt (1)
core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/component/MifosTextFieldDropdown.kt (1)
  • MifosTextFieldDropdown (39-112)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: PR Checks / Static Analysis Check
🔇 Additional comments (1)
feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/pages/TermsPage.kt (1)

30-33: Well-designed API surface change.

The refactoring from a simple callback to a state-driven pattern with actions improves testability and aligns with modern Compose architecture.

Copy link

@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: 0

🧹 Nitpick comments (2)
feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/pages/TermsPage.kt (2)

40-122: Dropdowns are correctly bound; consider extracting a shared helper to reduce duplication

All four dropdowns correctly:

  • Derive value from the corresponding *Type index using getOrNull (avoiding out‑of‑bounds),
  • Map template option values to List<String>,
  • Dispatch the appropriate RecurringAccountInterestChartAction.

Given the very similar structure, you might want to extract a small private composable to avoid repetition, e.g. something along the lines of:

@Composable
private fun InterestDropdown(
    label: String,
    selectedIndex: Int?,
    options: List<String>,
    onSelected: (Int) -> Unit,
) {
    MifosTextFieldDropdown(
        value = selectedIndex?.let { options.getOrNull(it) } ?: " ",
        onValueChanged = { },
        onOptionSelected = { index, _ -> onSelected(index) },
        options = options,
        label = label,
    )
}

Then each block becomes a one‑liner with its own label, selectedIndex, and options. This keeps behavior identical while making future changes less error‑prone.


48-54: Use _ for unused value parameter in onOptionSelected lambdas

In all four dropdowns, the value parameter of onOptionSelected = { index, value -> ... } is unused. To avoid warnings and make intent clearer, you can ignore it explicitly:

-            onOptionSelected = { index, value ->
+            onOptionSelected = { index, _ ->

Apply this change to each onOptionSelected block.

Also applies to: 69-75, 90-96, 111-117

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b1d86f and 76e90eb.

📒 Files selected for processing (1)
  • feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/pages/TermsPage.kt (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/pages/TermsPage.kt (2)
core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/component/MifosTextFieldDropdown.kt (1)
  • MifosTextFieldDropdown (39-112)
core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosTwoButtonRow.kt (1)
  • MifosTwoButtonRow (31-91)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: PR Checks / Static Analysis Check
🔇 Additional comments (2)
feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/pages/TermsPage.kt (2)

13-18: Imports for resources, design system, and state/actions look consistent

The new imports for generated string resources, design system components, and RecurringAccountState / RecurringAccountAction align with how the rest of the feature appears to be structured; nothing problematic here.

Also applies to: 22-30


34-37: State + action‑based TermsPage API and navigation wiring look correct

TermsPage now depends on RecurringAccountState and dispatches RecurringAccountAction through onAction, and the Back/Next buttons correctly emit OnBackPress / OnNextPress. This is a clean, unidirectional data‑flow setup and should integrate well with the ViewModel.

Also applies to: 124-128

@revanthkumarJ
Copy link
Contributor

@ankitkumarrain video is not uploaded check once

Copy link
Contributor

@revanthkumarJ revanthkumarJ left a comment

Choose a reason for hiding this comment

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

and also in terms page video show the options clicking and next button should be enabled only after every option selected

onFirstBtnClick = { onAction(RecurringAccountAction.OnBackPress) },
onSecondBtnClick = { onAction(RecurringAccountAction.OnNextPress) },
isButtonIconVisible = true,

Copy link
Contributor

Choose a reason for hiding this comment

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

i think you can use isButtonEnabled some thing like that in MifosTwoButtonRow to make sure next button is enabled only after everything is filled

Copy link

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/RecurringAccountViewModel.kt (2)

113-116: Populate interest chart fields from state.

The payload hardcodes these fields to null, but the PR introduces recurringDepositAccountInterestChart state to capture user selections. These fields should be populated from state.recurringDepositAccountInterestChart instead of being set to null.

Apply this diff:

                 fieldOfficerId = s.recurringDepositAccountDetail.fieldOfficer?.id,
-                interestCalculationDaysInYearType = null,
-                interestCalculationType = null,
-                interestCompoundingPeriodType = null,
-                interestPostingPeriodType = null,
+                interestCalculationDaysInYearType = s.recurringDepositAccountInterestChart.interestCalculationDaysInYearType,
+                interestCalculationType = s.recurringDepositAccountInterestChart.interestCalculationType,
+                interestCompoundingPeriodType = s.recurringDepositAccountInterestChart.interestCompoundingPeriodType,
+                interestPostingPeriodType = s.recurringDepositAccountInterestChart.interestPostingPeriodType,
                 isCalendarInherited = null,

211-226: Reset the interest chart state during retry.

The resetForRetry method resets other account state fields but does not reset recurringDepositAccountInterestChart. This could leave stale data in the state after a retry.

Apply this diff:

     private fun resetForRetry() {
         mutableStateFlow.update {
             it.copy(
                 isOnline = false,
                 clientId = -1,
                 currentStep = 0,
                 screenState = ScreenState.Loading,
                 recurringDepositAccountDetail = RecurringAccountDetailsState(),
                 template = RecurringDepositAccountTemplate(),
                 recurringDepositAccountSettings = RecurringAccountSettingsState(),
+                recurringDepositAccountInterestChart = RecurringAccountInterestChartState(),
                 currencyIndex = -1,
                 currencyError = null,
             )
         }
         loadRecurringAccountTemplate()
     }
🧹 Nitpick comments (4)
feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/pages/TermsPage.kt (3)

48-54: Consider removing unused value parameter.

All four onOptionSelected callbacks receive both index and value parameters but only use index. While this matches the MifosTextFieldDropdown signature, you could use _ for the unused parameter to make the intent clearer:

-onOptionSelected = { index, value ->
+onOptionSelected = { index, _ ->

Also applies to: 69-74, 90-96, 111-117


41-46: Consider using empty string instead of space for null values.

All four dropdowns use " " (a single space) as the default value when the state field is null. Using an empty string "" would be more conventional and avoid potential issues if other code checks for empty values via .isEmpty().

-value = if (state.recurringDepositAccountInterestChart.interestCompoundingPeriodType == null) {
-    " "
-} else {
+value = state.recurringDepositAccountInterestChart.interestCompoundingPeriodType?.let { index ->
-    state.template.interestCompoundingPeriodTypeOptions?.getOrNull(state.recurringDepositAccountInterestChart.interestCompoundingPeriodType)?.value
-        ?: ""
-},
+    state.template.interestCompoundingPeriodTypeOptions?.getOrNull(index)?.value
+} ?: "",

This pattern can be applied to all four dropdowns for cleaner null handling.

Also applies to: 62-67, 83-88, 104-109


39-39: Consider adding consistent padding.

The Column and MifosTwoButtonRow lack explicit padding modifiers, which might cause the content to appear cramped or touch screen edges. Consider adding:

-Column(horizontalAlignment = Alignment.CenterHorizontally) {
+Column(
+    horizontalAlignment = Alignment.CenterHorizontally,
+    modifier = Modifier.padding(DesignToken.padding.medium)
+) {

And adding spacing before the button row:

     if (state.recurringDepositAccountDetail.isMiniLoaderActive) {
         MifosProgressIndicatorMini()
     }
+    Spacer(modifier = Modifier.height(DesignToken.padding.large))

     MifosTwoButtonRow(

Also, remove the unnecessary blank line at line 134:

         isSecondButtonEnabled = state.recurringDepositAccountInterestChart.isTermsButtonEnabled,
         isButtonIconVisible = true,
-
     )

Also applies to: 127-136

feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/RecurringAccountViewModel.kt (1)

173-209: Remove the extra blank line for consistency.

Line 179 contains an unnecessary blank line inside the copy() call, which is inconsistent with the other three handler methods that follow the same pattern.

Apply this diff:

     private fun handleInterestCalculationDaysInYearType(action: RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCalculationDaysInYearType) {
         mutableStateFlow.update {
             it.copy(
                 recurringDepositAccountInterestChart = it.recurringDepositAccountInterestChart.copy(
                     interestCalculationDaysInYearType = action.interestCalculationTypeDaysInYear,
                 ),
-
             )
         }
     }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 76e90eb and 934483f.

📒 Files selected for processing (4)
  • feature/client/src/commonMain/composeResources/values/strings.xml (1 hunks)
  • feature/client/src/commonMain/kotlin/com/mifos/feature/client/newFixedDepositAccount/pages/DetailsPage.kt (2 hunks)
  • feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/RecurringAccountViewModel.kt (7 hunks)
  • feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/pages/TermsPage.kt (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/pages/TermsPage.kt (3)
core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/component/MifosTextFieldDropdown.kt (1)
  • MifosTextFieldDropdown (39-112)
core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosProgressIndicator.kt (1)
  • MifosProgressIndicatorMini (122-146)
core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosTwoButtonRow.kt (1)
  • MifosTwoButtonRow (31-91)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: PR Checks / Static Analysis Check
🔇 Additional comments (9)
feature/client/src/commonMain/composeResources/values/strings.xml (1)

539-545: String key rename looks consistent

Renaming the resource key to field_officer with the same user-visible text is fine and aligns with lowercase/underscore naming. Just ensure any localized resource files and all call sites have been updated to use the new key so nothing breaks at compile time.

feature/client/src/commonMain/kotlin/com/mifos/feature/client/newFixedDepositAccount/pages/DetailsPage.kt (1)

18-18: Field officer label correctly wired to renamed string key

Updating the import and dropdown label to use Res.string.field_officer matches the new resource name and keeps the UI text unchanged. This keeps the Details page in sync with the global string rename.

Also applies to: 133-133

feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/pages/TermsPage.kt (4)

12-32: LGTM! Imports align well with the state-driven refactor.

The new imports for string resources, UI components, and state management types are appropriate for the refactored implementation.


35-38: LGTM! State-driven pattern improves maintainability.

The refactored signature using RecurringAccountState and RecurringAccountAction is a solid architectural choice that improves testability and state management.


123-125: LGTM! Progress indicator placement is appropriate.

The conditional rendering of MifosProgressIndicatorMini based on isMiniLoaderActive provides good user feedback during async operations.


132-132: LGTM! Button state management addresses previous feedback.

The isSecondButtonEnabled is correctly tied to state.recurringDepositAccountInterestChart.isTermsButtonEnabled, addressing the previous review comment about ensuring the next button is only enabled when all required fields are filled.

feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/RecurringAccountViewModel.kt (3)

619-630: LGTM!

The action routing correctly dispatches the four interest chart actions to their respective handlers and follows the established pattern in the file.


644-644: LGTM!

The state field addition follows the established pattern and is correctly initialized with a default value.


787-792: LGTM!

The sealed class structure for interest chart actions is well-defined and follows the established pattern for other action groups in the file.

Comment on lines +670 to +681
data class RecurringAccountInterestChartState(
val interestCalculationDaysInYearType: Int? = null,
val interestCalculationType: Int? = null,
val interestCompoundingPeriodType: Int? = null,
val interestPostingPeriodType: Int? = null,


){
val isTermsButtonEnabled = interestCalculationDaysInYearType != -1 && interestPostingPeriodType != -1
&& interestCompoundingPeriodType != -1 && interestCalculationType != -1

}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Fix type inconsistency causing incorrect button state.

The fields are declared as Int? (nullable) with a default of null, but isTermsButtonEnabled checks them against -1. Since null != -1 evaluates to true, the button will always be enabled even when no selections have been made.

Based on the codebase convention (e.g., fieldOfficerIndex: Int = -1 on line 662), use non-nullable Int with -1 as the sentinel value.

Apply this diff:

 data class RecurringAccountInterestChartState(
-    val interestCalculationDaysInYearType: Int? = null,
-    val interestCalculationType: Int? = null,
-    val interestCompoundingPeriodType: Int? = null,
-    val interestPostingPeriodType: Int? = null,
+    val interestCalculationDaysInYearType: Int = -1,
+    val interestCalculationType: Int = -1,
+    val interestCompoundingPeriodType: Int = -1,
+    val interestPostingPeriodType: Int = -1,
 
 
 ){
     val isTermsButtonEnabled = interestCalculationDaysInYearType != -1 && interestPostingPeriodType != -1
             && interestCompoundingPeriodType != -1 && interestCalculationType != -1
 
 }
🤖 Prompt for AI Agents
In
feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/RecurringAccountViewModel.kt
around lines 670-681, the four fields (interestCalculationDaysInYearType,
interestCalculationType, interestCompoundingPeriodType,
interestPostingPeriodType) are declared as nullable Int? = null but compared to
-1, causing isTermsButtonEnabled to be true when null; change each field to a
non-nullable Int with a sentinel default of -1 (e.g., Int = -1) so the existing
comparison logic works correctly, and keep the isTermsButtonEnabled expression
as-is.

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.

2 participants