Skip to content

Commit 01c9f37

Browse files
Feature Terms Steps for Recurring Deposit account Flow. 551 (#2544)
1 parent 799e41c commit 01c9f37

File tree

7 files changed

+192
-16
lines changed

7 files changed

+192
-16
lines changed

feature/client/src/commonMain/composeResources/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@
541541
<!-- New Fixed Deposit Account -->
542542
<string name="one_year_fixed_deposit">1 Year Fixed Deposit</string>
543543
<string name="submission_on">Submission On</string>
544-
<string name="Field_officer">Field Officer</string>
544+
<string name="field_officer">Field Officer</string>
545545

546546

547547
<!-- Create Share Account -->

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
*/
1010
package com.mifos.feature.client.newFixedDepositAccount.pages
1111

12-
import androidclient.feature.client.generated.resources.Field_officer
1312
import androidclient.feature.client.generated.resources.Res
1413
import androidclient.feature.client.generated.resources.btn_back
1514
import androidclient.feature.client.generated.resources.feature_client_charge_cancel
1615
import androidclient.feature.client.generated.resources.feature_client_charge_select
1716
import androidclient.feature.client.generated.resources.feature_client_external_id
1817
import androidclient.feature.client.generated.resources.feature_client_next
18+
import androidclient.feature.client.generated.resources.field_officer
1919
import androidclient.feature.client.generated.resources.one_year_fixed_deposit
2020
import androidclient.feature.client.generated.resources.submission_on
2121
import androidx.compose.foundation.layout.Column
@@ -130,7 +130,7 @@ fun DetailsPage(
130130
state.template.fieldOfficerOptions?.get(state.fixedDepositAccountDetail.fieldOfficerIndex)?.displayName
131131
?: ""
132132
},
133-
label = stringResource(Res.string.Field_officer),
133+
label = stringResource(Res.string.field_officer),
134134
onValueChanged = {},
135135
onOptionSelected = { index, value ->
136136
onAction(NewFixedDepositAccountAction.OnFieldOfficerChange(index))

feature/recurringDeposit/src/commonMain/composeResources/values/feature_recurring_deposit_string.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,8 @@
4949
<string name="feature_recurring_deposit_next_button">Next Button</string>
5050
<string name="feature_recurring_deposit_interest_page">Interest Page</string>
5151
<string name="feature_recurring_deposit_charges_page">Charges Page</string>
52+
<string name="feature_recurring_deposit_interest_compounding_period">Interest Compounding Period</string>
53+
<string name="feature_recurring_deposit_interest_posting_period">Interest Posting Period</string>
54+
<string name="feature_recurring_deposit_interest_calculation">Interest Calculated Using</string>
55+
<string name="feature_recurring_deposit_calculation_days_in_year">Days In Year </string>
5256
</resources>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ private fun RecurringAccountScaffold(
8181
},
8282
Step(name = stringResource(Res.string.feature_recurring_deposit_step_terms)) {
8383
TermsPage(
84-
onNext = { onAction(RecurringAccountAction.OnNextPress) },
84+
state = state,
85+
onAction = onAction,
8586
)
8687
},
8788
Step(name = stringResource(Res.string.feature_recurring_deposit_step_settings)) {

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

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,44 @@ class RecurringAccountViewModel(
170170
)
171171
}
172172

173+
private fun handleInterestCalculationDaysInYearType(action: RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCalculationDaysInYearType) {
174+
mutableStateFlow.update {
175+
it.copy(
176+
recurringDepositAccountInterestChart = it.recurringDepositAccountInterestChart.copy(
177+
interestCalculationDaysInYearType = action.interestCalculationTypeDaysInYear,
178+
),
179+
180+
)
181+
}
182+
}
183+
private fun handleInterestCalculationType(action: RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCalculationType) {
184+
mutableStateFlow.update {
185+
it.copy(
186+
recurringDepositAccountInterestChart = it.recurringDepositAccountInterestChart.copy(
187+
interestCalculationType = action.interestCalculationType,
188+
),
189+
)
190+
}
191+
}
192+
private fun handleInterestCompoundingPeriodType(action: RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCompoundingPeriodType) {
193+
mutableStateFlow.update {
194+
it.copy(
195+
recurringDepositAccountInterestChart = it.recurringDepositAccountInterestChart.copy(
196+
interestCompoundingPeriodType = action.interestCompoundingPeriodType,
197+
),
198+
)
199+
}
200+
}
201+
private fun handleInterestPostingPeriodType(action: RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestPostingPeriodType) {
202+
mutableStateFlow.update {
203+
it.copy(
204+
recurringDepositAccountInterestChart = it.recurringDepositAccountInterestChart.copy(
205+
interestPostingPeriodType = action.interestPostingPeriodType,
206+
),
207+
)
208+
}
209+
}
210+
173211
private fun resetForRetry() {
174212
mutableStateFlow.update {
175213
it.copy(
@@ -577,6 +615,19 @@ class RecurringAccountViewModel(
577615
RecurringAccountAction.OnNextPress -> {
578616
moveToNextStep()
579617
}
618+
619+
is RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCalculationDaysInYearType -> {
620+
handleInterestCalculationDaysInYearType(action)
621+
}
622+
is RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCalculationType -> {
623+
handleInterestCalculationType(action)
624+
}
625+
is RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCompoundingPeriodType -> {
626+
handleInterestCompoundingPeriodType(action)
627+
}
628+
is RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestPostingPeriodType -> {
629+
handleInterestPostingPeriodType(action)
630+
}
580631
}
581632
}
582633
}
@@ -590,6 +641,7 @@ data class RecurringAccountState(
590641
val recurringDepositAccountDetail: RecurringAccountDetailsState = RecurringAccountDetailsState(),
591642
val template: RecurringDepositAccountTemplate = RecurringDepositAccountTemplate(),
592643
val recurringDepositAccountSettings: RecurringAccountSettingsState = RecurringAccountSettingsState(),
644+
val recurringDepositAccountInterestChart: RecurringAccountInterestChartState = RecurringAccountInterestChartState(),
593645
val currencyIndex: Int = -1,
594646
val currencyError: String? = null,
595647
) {
@@ -615,6 +667,16 @@ data class RecurringAccountDetailsState(
615667
) {
616668
val isDetailButtonEnabled = fieldOfficerIndex != -1 && submissionDate.isNotEmpty()
617669
}
670+
data class RecurringAccountInterestChartState(
671+
val interestCalculationDaysInYearType: Int = -1,
672+
val interestCalculationType: Int = -1,
673+
val interestCompoundingPeriodType: Int = -1,
674+
val interestPostingPeriodType: Int = -1,
675+
676+
) {
677+
val isTermsButtonEnabled = interestCalculationDaysInYearType != -1 && interestPostingPeriodType != -1 &&
678+
interestCompoundingPeriodType != -1 && interestCalculationType != -1
679+
}
618680

619681
data class RecurringAccountSettingsState(
620682
val canDoNext: Boolean = false,
@@ -627,6 +689,7 @@ data class RecurringAccountSettingsState(
627689
val minimumDepositTerm: MinimumDepositTerm = MinimumDepositTerm(),
628690
val maxDepositTerm: MaxDepositTerm = MaxDepositTerm(),
629691
val preMatureClosure: PreMatureClosure = PreMatureClosure(),
692+
630693
) {
631694

632695
data class LockInPeriod(
@@ -717,6 +780,12 @@ sealed class RecurringAccountAction {
717780
data class SetPreMatureClosureInterestPeriodIndex(val interestPeriodIndex: Int) : RecurringAccountSettingsAction()
718781
data class SetPreMatureClosureMinimumBalanceForInterestCalculation(val minimumBalanceForInterestCalculation: String) : RecurringAccountSettingsAction()
719782
}
783+
sealed class RecurringAccountInterestChartAction : RecurringAccountAction() {
784+
data class OnInterestCalculationDaysInYearType(val interestCalculationTypeDaysInYear: Int) : RecurringAccountInterestChartAction()
785+
data class OnInterestCompoundingPeriodType(val interestCompoundingPeriodType: Int) : RecurringAccountInterestChartAction()
786+
data class OnInterestCalculationType(val interestCalculationType: Int) : RecurringAccountInterestChartAction()
787+
data class OnInterestPostingPeriodType(val interestPostingPeriodType: Int) : RecurringAccountInterestChartAction()
788+
}
720789
}
721790

722791
sealed class RecurringAccountEvent {

feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/pages/InterestPage.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
package com.mifos.feature.recurringDeposit.newRecurringDepositAccount.pages
1111

1212
import androidclient.feature.recurringdeposit.generated.resources.Res
13-
import androidclient.feature.recurringdeposit.generated.resources.feature_recurring_deposit_interest_page
13+
import androidclient.feature.recurringdeposit.generated.resources.feature_recurring_deposit_charges_page
1414
import androidclient.feature.recurringdeposit.generated.resources.feature_recurring_deposit_next_button
1515
import androidx.compose.foundation.layout.Column
1616
import androidx.compose.foundation.layout.Spacer
@@ -26,7 +26,7 @@ import org.jetbrains.compose.resources.stringResource
2626
@Composable
2727
fun InterestPage(onNext: () -> Unit) {
2828
Column(horizontalAlignment = Alignment.CenterHorizontally) {
29-
Text(stringResource(Res.string.feature_recurring_deposit_interest_page))
29+
Text(stringResource(Res.string.feature_recurring_deposit_charges_page))
3030
Spacer(Modifier.height(8.dp))
3131
Button(onClick = onNext) {
3232
Text(stringResource(Res.string.feature_recurring_deposit_next_button))

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

Lines changed: 112 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,128 @@
1010
package com.mifos.feature.recurringDeposit.newRecurringDepositAccount.pages
1111

1212
import androidclient.feature.recurringdeposit.generated.resources.Res
13-
import androidclient.feature.recurringdeposit.generated.resources.feature_recurring_deposit_next_button
14-
import androidclient.feature.recurringdeposit.generated.resources.feature_recurring_deposit_terms_page
13+
import androidclient.feature.recurringdeposit.generated.resources.feature_recurring_deposit_back
14+
import androidclient.feature.recurringdeposit.generated.resources.feature_recurring_deposit_calculation_days_in_year
15+
import androidclient.feature.recurringdeposit.generated.resources.feature_recurring_deposit_interest_calculation
16+
import androidclient.feature.recurringdeposit.generated.resources.feature_recurring_deposit_interest_compounding_period
17+
import androidclient.feature.recurringdeposit.generated.resources.feature_recurring_deposit_interest_posting_period
18+
import androidclient.feature.recurringdeposit.generated.resources.feature_recurring_deposit_next
1519
import androidx.compose.foundation.layout.Column
1620
import androidx.compose.foundation.layout.Spacer
1721
import androidx.compose.foundation.layout.height
18-
import androidx.compose.material3.Button
19-
import androidx.compose.material3.Text
22+
import androidx.compose.foundation.layout.padding
2023
import androidx.compose.runtime.Composable
2124
import androidx.compose.ui.Alignment
2225
import androidx.compose.ui.Modifier
23-
import androidx.compose.ui.unit.dp
26+
import com.mifos.core.designsystem.component.MifosTextFieldDropdown
27+
import com.mifos.core.designsystem.theme.DesignToken
28+
import com.mifos.core.ui.components.MifosProgressIndicatorMini
29+
import com.mifos.core.ui.components.MifosTwoButtonRow
30+
import com.mifos.feature.recurringDeposit.newRecurringDepositAccount.RecurringAccountAction
31+
import com.mifos.feature.recurringDeposit.newRecurringDepositAccount.RecurringAccountState
2432
import org.jetbrains.compose.resources.stringResource
2533

2634
@Composable
27-
fun TermsPage(onNext: () -> Unit) {
35+
fun TermsPage(
36+
state: RecurringAccountState,
37+
onAction: (RecurringAccountAction) -> Unit,
38+
) {
2839
Column(horizontalAlignment = Alignment.CenterHorizontally) {
29-
Text(stringResource(Res.string.feature_recurring_deposit_terms_page))
30-
Spacer(Modifier.height(8.dp))
31-
Button(onClick = onNext) {
32-
Text(stringResource(Res.string.feature_recurring_deposit_next_button))
40+
MifosTextFieldDropdown(
41+
value = if (state.recurringDepositAccountInterestChart.interestCompoundingPeriodType == -1) {
42+
""
43+
} else {
44+
state.template.interestCompoundingPeriodTypeOptions?.get(state.recurringDepositAccountInterestChart.interestCompoundingPeriodType)?.value
45+
?: ""
46+
},
47+
onValueChanged = { },
48+
onOptionSelected = { index, value ->
49+
onAction(
50+
RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCompoundingPeriodType(
51+
index,
52+
),
53+
)
54+
},
55+
options = state.template.interestCompoundingPeriodTypeOptions?.map {
56+
it.value ?: ""
57+
} ?: emptyList(),
58+
label = stringResource(Res.string.feature_recurring_deposit_interest_compounding_period),
59+
)
60+
Spacer(modifier = Modifier.height(DesignToken.padding.large))
61+
MifosTextFieldDropdown(
62+
value = if (state.recurringDepositAccountInterestChart.interestPostingPeriodType == -1) {
63+
""
64+
} else {
65+
state.template.interestPostingPeriodTypeOptions?.get(state.recurringDepositAccountInterestChart.interestPostingPeriodType)?.value
66+
?: ""
67+
},
68+
onValueChanged = { },
69+
onOptionSelected = { index, value ->
70+
onAction(
71+
RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestPostingPeriodType(
72+
index,
73+
),
74+
)
75+
},
76+
options = state.template.interestPostingPeriodTypeOptions?.map {
77+
it.value ?: ""
78+
} ?: emptyList(),
79+
label = stringResource(Res.string.feature_recurring_deposit_interest_posting_period),
80+
)
81+
Spacer(modifier = Modifier.height(DesignToken.padding.large))
82+
MifosTextFieldDropdown(
83+
value = if (state.recurringDepositAccountInterestChart.interestCalculationType == -1) {
84+
""
85+
} else {
86+
state.template.interestCalculationTypeOptions?.get(state.recurringDepositAccountInterestChart.interestCalculationType)?.value
87+
?: ""
88+
},
89+
onValueChanged = { },
90+
onOptionSelected = { index, value ->
91+
onAction(
92+
RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCalculationType(
93+
index,
94+
),
95+
)
96+
},
97+
options = state.template.interestCalculationTypeOptions?.map {
98+
it.value ?: ""
99+
} ?: emptyList(),
100+
label = stringResource(Res.string.feature_recurring_deposit_interest_calculation),
101+
)
102+
Spacer(modifier = Modifier.height(DesignToken.padding.large))
103+
MifosTextFieldDropdown(
104+
value = if (state.recurringDepositAccountInterestChart.interestCalculationDaysInYearType == -1) {
105+
""
106+
} else {
107+
state.template.interestCalculationDaysInYearTypeOptions?.get(state.recurringDepositAccountInterestChart.interestCalculationDaysInYearType)?.value
108+
?: ""
109+
},
110+
onValueChanged = { },
111+
onOptionSelected = { index, value ->
112+
onAction(
113+
RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCalculationDaysInYearType(
114+
index,
115+
),
116+
)
117+
},
118+
options = state.template.interestCalculationDaysInYearTypeOptions?.map {
119+
it.value ?: ""
120+
} ?: emptyList(),
121+
label = stringResource(Res.string.feature_recurring_deposit_calculation_days_in_year),
122+
)
123+
if (state.recurringDepositAccountDetail.isMiniLoaderActive) {
124+
MifosProgressIndicatorMini()
33125
}
126+
127+
MifosTwoButtonRow(
128+
firstBtnText = stringResource(Res.string.feature_recurring_deposit_back),
129+
secondBtnText = stringResource(Res.string.feature_recurring_deposit_next),
130+
onFirstBtnClick = { onAction(RecurringAccountAction.OnBackPress) },
131+
onSecondBtnClick = { onAction(RecurringAccountAction.OnNextPress) },
132+
isSecondButtonEnabled = state.recurringDepositAccountInterestChart.isTermsButtonEnabled,
133+
isButtonIconVisible = true,
134+
135+
)
34136
}
35137
}

0 commit comments

Comments
 (0)