Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,8 @@
<string name="feature_recurring_deposit_next_button">Next Button</string>
<string name="feature_recurring_deposit_interest_page">Interest Page</string>
<string name="feature_recurring_deposit_charges_page">Charges Page</string>
<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>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ private fun RecurringAccountScaffold(
},
Step(name = stringResource(Res.string.feature_recurring_deposit_step_interest)) {
InterestPage(
onNext = { onAction(RecurringAccountAction.OnNextPress) },
state = state,
onAction = onAction,
)
},
Step(name = stringResource(Res.string.feature_recurring_deposit_step_charges)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,44 @@ class RecurringAccountViewModel(
)
}

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

)
}
}
private fun handleInterestCalculationType(action: RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCalculationType) {
mutableStateFlow.update {
it.copy(
recurringDepositAccountInterestChart = it.recurringDepositAccountInterestChart.copy(
interestCalculationType = action.interestCalculationType,
),
)
}
}
private fun handleInterestCompoundingPeriodType(action: RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCompoundingPeriodType) {
mutableStateFlow.update {
it.copy(
recurringDepositAccountInterestChart = it.recurringDepositAccountInterestChart.copy(
interestCompoundingPeriodType = action.interestCompoundingPeriodType,
),
)
}
}
private fun handleInterestPostingPeriodType(action: RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestPostingPeriodType) {
mutableStateFlow.update {
it.copy(
recurringDepositAccountInterestChart = it.recurringDepositAccountInterestChart.copy(
interestPostingPeriodType = action.interestPostingPeriodType,
),
)
}
}

private fun resetForRetry() {
mutableStateFlow.update {
it.copy(
Expand Down Expand Up @@ -577,6 +615,19 @@ class RecurringAccountViewModel(
RecurringAccountAction.OnNextPress -> {
moveToNextStep()
}

is RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCalculationDaysInYearType -> {
handleInterestCalculationDaysInYearType(action)
}
is RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCalculationType -> {
handleInterestCalculationType(action)
}
is RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCompoundingPeriodType -> {
handleInterestCompoundingPeriodType(action)
}
is RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestPostingPeriodType -> {
handleInterestPostingPeriodType(action)
}
}
}
}
Expand All @@ -590,6 +641,7 @@ data class RecurringAccountState(
val recurringDepositAccountDetail: RecurringAccountDetailsState = RecurringAccountDetailsState(),
val template: RecurringDepositAccountTemplate = RecurringDepositAccountTemplate(),
val recurringDepositAccountSettings: RecurringAccountSettingsState = RecurringAccountSettingsState(),
val recurringDepositAccountInterestChart: RecurringAccountInterestChartState = RecurringAccountInterestChartState(),
val currencyIndex: Int = -1,
val currencyError: String? = null,
) {
Expand All @@ -615,6 +667,12 @@ data class RecurringAccountDetailsState(
) {
val isDetailButtonEnabled = fieldOfficerIndex != -1 && submissionDate.isNotEmpty()
}
data class RecurringAccountInterestChartState(
val interestCalculationDaysInYearType: Int? = null,
val interestCalculationType: Int? = null,
val interestCompoundingPeriodType: Int? = null,
val interestPostingPeriodType: Int? = null,
)

data class RecurringAccountSettingsState(
val canDoNext: Boolean = false,
Expand Down Expand Up @@ -717,6 +775,12 @@ sealed class RecurringAccountAction {
data class SetPreMatureClosureInterestPeriodIndex(val interestPeriodIndex: Int) : RecurringAccountSettingsAction()
data class SetPreMatureClosureMinimumBalanceForInterestCalculation(val minimumBalanceForInterestCalculation: String) : RecurringAccountSettingsAction()
}
sealed class RecurringAccountInterestChartAction : RecurringAccountAction() {
data class OnInterestCalculationDaysInYearType(val interestCalculationTypeDaysInYear: Int) : RecurringAccountInterestChartAction()
data class OnInterestCompoundingPeriodType(val interestCompoundingPeriodType: Int) : RecurringAccountInterestChartAction()
data class OnInterestCalculationType(val interestCalculationType: Int) : RecurringAccountInterestChartAction()
data class OnInterestPostingPeriodType(val interestPostingPeriodType: Int) : RecurringAccountInterestChartAction()
}
}

sealed class RecurringAccountEvent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,110 @@
package com.mifos.feature.recurringDeposit.newRecurringDepositAccount.pages

import androidclient.feature.recurringdeposit.generated.resources.Res
import androidclient.feature.recurringdeposit.generated.resources.feature_recurring_deposit_interest_page
import androidclient.feature.recurringdeposit.generated.resources.feature_recurring_deposit_next_button
import androidclient.feature.recurringdeposit.generated.resources.feature_recurring_deposit_Calculation_Days_In_Year
import androidclient.feature.recurringdeposit.generated.resources.feature_recurring_deposit_interest_calculation
import androidclient.feature.recurringdeposit.generated.resources.feature_recurring_deposit_interest_compounding_period
import androidclient.feature.recurringdeposit.generated.resources.feature_recurring_deposit_interest_posting_period
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.mifos.core.designsystem.component.MifosTextFieldDropdown
import com.mifos.core.designsystem.theme.DesignToken
import com.mifos.feature.recurringDeposit.newRecurringDepositAccount.RecurringAccountAction
import com.mifos.feature.recurringDeposit.newRecurringDepositAccount.RecurringAccountState
import org.jetbrains.compose.resources.stringResource

@Composable
fun InterestPage(onNext: () -> Unit) {
fun InterestPage(
state: RecurringAccountState,
onAction: (RecurringAccountAction) -> Unit,
) {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
Text(stringResource(Res.string.feature_recurring_deposit_interest_page))
Spacer(Modifier.height(8.dp))
Button(onClick = onNext) {
Text(stringResource(Res.string.feature_recurring_deposit_next_button))
}
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),
)
Spacer(modifier = Modifier.height(DesignToken.padding.large))
MifosTextFieldDropdown(
value = if (state.recurringDepositAccountInterestChart.interestPostingPeriodType == null) {
" "
} else {
state.template.interestPostingPeriodTypeOptions?.get(state.recurringDepositAccountInterestChart.interestPostingPeriodType)?.value
?: ""
},
onValueChanged = { },
onOptionSelected = { index, value ->
onAction(
RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestPostingPeriodType(
index,
),
)
},
options = state.template.interestPostingPeriodTypeOptions?.map {
it.value ?: ""
} ?: emptyList(),
label = stringResource(Res.string.feature_recurring_deposit_interest_posting_period),
)
Spacer(modifier = Modifier.height(DesignToken.padding.large))
MifosTextFieldDropdown(
value = if (state.recurringDepositAccountInterestChart.interestCalculationType == null) {
" "
} else {
state.template.interestCalculationTypeOptions?.get(state.recurringDepositAccountInterestChart.interestCalculationType)?.value
?: ""
},
onValueChanged = { },
onOptionSelected = { index, value ->
onAction(
RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCalculationType(
index,
),
)
},
options = state.template.interestCalculationTypeOptions?.map {
it.value ?: ""
} ?: emptyList(),
label = stringResource(Res.string.feature_recurring_deposit_interest_calculation),
)
Spacer(modifier = Modifier.height(DesignToken.padding.large))
MifosTextFieldDropdown(
value = if (state.recurringDepositAccountInterestChart.interestCalculationDaysInYearType == null) {
" "
} else {
state.template.interestCalculationDaysInYearTypeOptions?.get(state.recurringDepositAccountInterestChart.interestCalculationDaysInYearType)?.value
?: ""
},
onValueChanged = { },
onOptionSelected = { index, value ->
onAction(
RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCalculationDaysInYearType(
index,
),
)
},
options = state.template.interestCalculationDaysInYearTypeOptions?.map {
it.value ?: ""
} ?: emptyList(),
label = stringResource(Res.string.feature_recurring_deposit_Calculation_Days_In_Year),
)
}
}