Skip to content

Commit 9bbe791

Browse files
authored
New Fixed Deposits Account Interest Charts Step (#2557)
1 parent 48b1dee commit 9bbe791

File tree

28 files changed

+289
-84
lines changed

28 files changed

+289
-84
lines changed

core/model/src/commonMain/kotlin/com/mifos/core/model/objects/template/recurring/AccountChart.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ data class AccountChart(
3131
@IgnoredOnParcel val incentiveTypeOptions: List<IncentiveTypeOption>? = null,
3232
val isPrimaryGroupingByAmount: Boolean? = null,
3333
val name: String? = null,
34+
val description: String? = null,
3435
@IgnoredOnParcel val periodTypes: List<PeriodType>? = null,
3536
) : Parcelable

core/network/src/commonMain/kotlin/com/mifos/core/network/model/FixedDepositTemplate.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
package com.mifos.core.network.model
1111

1212
import com.mifos.core.model.objects.account.saving.FieldOfficerOptions
13+
import com.mifos.core.model.objects.template.recurring.AccountChart
1314
import com.mifos.core.model.objects.template.recurring.Currency
1415
import com.mifos.core.model.objects.template.recurring.MaturityInstructionOption
1516
import com.mifos.core.model.objects.template.recurring.interest.InterestCalculationDaysInYearTypeOption
@@ -56,4 +57,5 @@ data class FixedDepositTemplate(
5657

5758
val lockinPeriodFrequencyTypeOptions: List<LockinPeriodFrequencyTypeOption>? = null,
5859
val maturityInstructionOptions: List<MaturityInstructionOption>? = null,
60+
val accountChart: AccountChart? = null,
5961
)

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,4 +620,17 @@
620620
<string name="feature_fixed_deposit_setting_penal_interest">Penal Interest (%%)</string>
621621
<string name="feature_fixed_deposit_setting_period">Period</string>
622622

623+
<string name="feature_fixed_deposit_interest_name">Name</string>
624+
<string name="feature_fixed_deposit_interest_valid_from_date">Valid From Date</string>
625+
<string name="feature_fixed_deposit_interest_end_date">End Date</string>
626+
<string name="feature_fixed_deposit_interest_description">Description</string>
627+
<string name="feature_fixed_deposit_interest_grouping_by_amount">Grouping By Amount</string>
628+
<string name="feature_fixed_deposit_interest_interest_rate_chart">INTEREST RATE CHART</string>
629+
<string name="feature_fixed_deposit_interest_rate_chart">Rate Chart</string>
630+
<string name="feature_fixed_deposit_interest_no_interest_chart">No Interest Rate Chart available</string>
631+
<string name="feature_fixed_deposit_interest_yes">Yes</string>
632+
<string name="feature_fixed_deposit_interest_no">No</string>
633+
<string name="feature_fixed_deposit_interest_empty_date">Date Not Found</string>
634+
635+
623636
</resources>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ import kotlin.time.ExperimentalTime
5151
@Composable
5252
fun DetailsPage(
5353
state: CreateShareAccountState,
54-
onAction: (CreateShareAccountAction) -> Unit,
5554
modifier: Modifier = Modifier,
55+
onAction: (CreateShareAccountAction) -> Unit,
5656
) {
5757
val submissionDatePickerState = rememberDatePickerState(
5858
initialSelectedDateMillis = Clock.System.now().toEpochMilliseconds(),

feature/client/src/commonMain/kotlin/com/mifos/feature/client/createShareAccount/pages/PreviewPage.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,14 @@ import org.jetbrains.compose.resources.stringResource
5252
@Composable
5353
fun PreviewPage(
5454
state: CreateShareAccountState,
55+
modifier: Modifier = Modifier,
5556
onAction: (CreateShareAccountAction) -> Unit,
5657
) {
5758
Column(
5859
Modifier.fillMaxSize().padding(bottom = DesignToken.padding.large),
5960
) {
6061
Column(
61-
modifier = Modifier.weight(1f).verticalScroll(rememberScrollState()),
62+
modifier = modifier.weight(1f).verticalScroll(rememberScrollState()),
6263
verticalArrangement = Arrangement.spacedBy(20.dp),
6364
) {
6465
Text(

feature/client/src/commonMain/kotlin/com/mifos/feature/client/createShareAccount/pages/TermsPage.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ import kotlin.time.ExperimentalTime
6262
@Composable
6363
fun TermsPage(
6464
state: CreateShareAccountState,
65-
onAction: (CreateShareAccountAction) -> Unit,
6665
modifier: Modifier = Modifier,
66+
onAction: (CreateShareAccountAction) -> Unit,
6767
) {
6868
val applicationDatePickerState = rememberDatePickerState(
6969
initialSelectedDateMillis = Clock.System.now().toEpochMilliseconds(),

feature/client/src/commonMain/kotlin/com/mifos/feature/client/newFixedDepositAccount/CreateFixedDepositAccountScreen.kt

Lines changed: 56 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import com.mifos.core.ui.components.Step
3232
import com.mifos.core.ui.util.EventsEffect
3333
import com.mifos.feature.client.newFixedDepositAccount.pages.ChargesPage
3434
import com.mifos.feature.client.newFixedDepositAccount.pages.DetailsPage
35+
import com.mifos.feature.client.newFixedDepositAccount.pages.FixedDepositRateChart
3536
import com.mifos.feature.client.newFixedDepositAccount.pages.InterestPage
3637
import com.mifos.feature.client.newFixedDepositAccount.pages.SettingPage
3738
import com.mifos.feature.client.newFixedDepositAccount.pages.TermsPage
@@ -53,53 +54,74 @@ internal fun CreateFixedDepositAccountScreen(
5354
NewFixedDepositAccountEvent.Finish -> onFinish()
5455
}
5556
}
56-
FixedDepositAccountScaffold(
57+
CreateFixedDepositAccountScaffold(
5758
navController = navController,
5859
state = state,
5960
onAction = { viewModel.trySendAction(it) },
6061
modifier = modifier,
6162
)
63+
CreateFixedDepositAccountDialog(
64+
state = state,
65+
onAction = { viewModel.trySendAction(it) },
66+
)
6267
}
6368

6469
@Composable
65-
private fun FixedDepositAccountScaffold(
70+
internal fun CreateFixedDepositAccountDialog(
71+
state: NewFixedDepositAccountState,
72+
onAction: (NewFixedDepositAccountAction) -> Unit,
73+
) {
74+
when (state.dialogState) {
75+
NewFixedDepositAccountState.DialogState.RateChartDialog -> {
76+
FixedDepositRateChart(
77+
state = state,
78+
onAction = onAction,
79+
)
80+
}
81+
82+
null -> Unit
83+
}
84+
}
85+
86+
@Composable
87+
private fun CreateFixedDepositAccountScaffold(
6688
navController: NavController,
6789
state: NewFixedDepositAccountState,
6890
onAction: (NewFixedDepositAccountAction) -> Unit,
6991
modifier: Modifier = Modifier,
7092
) {
71-
val steps =
72-
listOf(
73-
Step(stringResource(Res.string.step_details)) {
74-
DetailsPage(
75-
state = state,
76-
onAction = onAction,
77-
)
78-
},
79-
Step(name = stringResource(Res.string.step_terms)) {
80-
TermsPage(
81-
state = state,
82-
onAction = onAction,
83-
)
84-
},
93+
val steps = listOf(
94+
Step(stringResource(Res.string.step_details)) {
95+
DetailsPage(
96+
state = state,
97+
onAction = onAction,
98+
)
99+
},
100+
Step(name = stringResource(Res.string.step_terms)) {
101+
TermsPage(
102+
state = state,
103+
onAction = onAction,
104+
)
105+
},
85106

86-
Step(name = stringResource(Res.string.step_settings)) {
87-
SettingPage(
88-
state = state,
89-
onAction = onAction,
90-
)
91-
},
92-
Step(name = stringResource(Res.string.step_interest)) {
93-
InterestPage(
94-
onNext = { onAction(NewFixedDepositAccountAction.OnNextPress) },
95-
)
96-
},
97-
Step(stringResource(Res.string.step_charges)) {
98-
ChargesPage(
99-
onNext = { onAction(NewFixedDepositAccountAction.OnNextPress) },
100-
)
101-
},
102-
)
107+
Step(name = stringResource(Res.string.step_settings)) {
108+
SettingPage(
109+
state = state,
110+
onAction = onAction,
111+
)
112+
},
113+
Step(name = stringResource(Res.string.step_interest)) {
114+
InterestPage(
115+
state = state,
116+
onAction = onAction,
117+
)
118+
},
119+
Step(stringResource(Res.string.step_charges)) {
120+
ChargesPage(
121+
onNext = { onAction(NewFixedDepositAccountAction.OnNextPress) },
122+
)
123+
},
124+
)
103125

104126
MifosScaffold(
105127
modifier = modifier,
@@ -127,8 +149,7 @@ private fun FixedDepositAccountScaffold(
127149
onStepChange = { newIndex ->
128150
onAction(NewFixedDepositAccountAction.OnStepChange(newIndex))
129151
},
130-
modifier = Modifier
131-
.fillMaxWidth(),
152+
modifier = Modifier.fillMaxWidth(),
132153

133154
)
134155
}

feature/client/src/commonMain/kotlin/com/mifos/feature/client/newFixedDepositAccount/CreateFixedDepositAccountViewmodel.kt

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,90 +143,117 @@ class CreateFixedDepositAccountViewmodel(
143143
)
144144
}
145145
}
146+
146147
is NewFixedDepositAccountAction.OnLockInPeriodFrequencyChange -> {
147148
mutableStateFlow.update {
148149
it.copy(
149150
lockInPeriodFrequency = action.value,
150151
)
151152
}
152153
}
154+
153155
is NewFixedDepositAccountAction.OnLockInPeriodTypeIndexChange -> {
154156
mutableStateFlow.update {
155157
it.copy(
156158
lockInPeriodTypeIndex = action.index,
157159
)
158160
}
159161
}
162+
160163
is NewFixedDepositAccountAction.OnMaturityInstructionIndexChange -> {
161164
mutableStateFlow.update {
162165
it.copy(
163166
maturityInstructionsIndex = action.index,
164167
)
165168
}
166169
}
170+
167171
is NewFixedDepositAccountAction.OnMaximumDepositFrequencyChange -> {
168172
mutableStateFlow.update {
169173
it.copy(
170174
maximumDispositFrequency = action.value,
171175
)
172176
}
173177
}
178+
174179
is NewFixedDepositAccountAction.OnMaximumDepositTypeIndexChange -> {
175180
mutableStateFlow.update {
176181
it.copy(
177182
maximumDispositTypeIndex = action.index,
178183
)
179184
}
180185
}
186+
181187
is NewFixedDepositAccountAction.OnMinimumDepositTermFrequencyChange -> {
182188
mutableStateFlow.update {
183189
it.copy(
184190
minimumDispositTermFrequency = action.value,
185191
)
186192
}
187193
}
194+
188195
is NewFixedDepositAccountAction.OnMinimumDepositTermTypeIndexChange -> {
189196
mutableStateFlow.update {
190197
it.copy(
191198
minimumDispositTermTypeIndex = action.index,
192199
)
193200
}
194201
}
202+
195203
is NewFixedDepositAccountAction.OnMultiplesFrequencyChange -> {
196204
mutableStateFlow.update {
197205
it.copy(
198206
multiplesFrequency = action.value,
199207
)
200208
}
201209
}
210+
202211
is NewFixedDepositAccountAction.OnMultiplesTypeIndexChange -> {
203212
mutableStateFlow.update {
204213
it.copy(
205214
multiplesTypeIndex = action.index,
206215
)
207216
}
208217
}
218+
209219
is NewFixedDepositAccountAction.OnPenalInterestChange -> {
210220
mutableStateFlow.update {
211221
it.copy(
212222
penalInterest = action.value,
213223
)
214224
}
215225
}
226+
216227
is NewFixedDepositAccountAction.OnPeriodIndexChange -> {
217228
mutableStateFlow.update {
218229
it.copy(
219230
periodIndex = action.index,
220231
)
221232
}
222233
}
234+
223235
is NewFixedDepositAccountAction.OnTransferLinkedSavingsAccountInterestChange -> {
224236
mutableStateFlow.update {
225237
it.copy(
226238
transferLinkedSavingAccountInterest = action.checked,
227239
)
228240
}
229241
}
242+
243+
NewFixedDepositAccountAction.OnDismissDialog -> {
244+
mutableStateFlow.update {
245+
it.copy(
246+
dialogState = null,
247+
)
248+
}
249+
}
250+
NewFixedDepositAccountAction.OnShowRateChart -> {
251+
mutableStateFlow.update {
252+
it.copy(
253+
dialogState = NewFixedDepositAccountState.DialogState.RateChartDialog,
254+
)
255+
}
256+
}
230257
}
231258
}
232259

@@ -353,9 +380,7 @@ class CreateFixedDepositAccountViewmodel(
353380
),
354381
)
355382
}
356-
if (state.template.fieldOfficerOptions == null) {
357-
loadRecurringAccountTemplateWithProduct()
358-
}
383+
loadRecurringAccountTemplateWithProduct()
359384
}
360385

361386
private fun handleFieldOfficerChange(action: NewFixedDepositAccountAction.OnFieldOfficerChange) {
@@ -466,6 +491,7 @@ class CreateFixedDepositAccountViewmodel(
466491
mutableStateFlow.update {
467492
it.copy(
468493
currentStep = current + 1,
494+
dialogState = null,
469495
)
470496
}
471497
} else {
@@ -477,7 +503,7 @@ class CreateFixedDepositAccountViewmodel(
477503
data class NewFixedDepositAccountState(
478504
val clientId: Int = -1,
479505
val currentStep: Int = 0,
480-
val dialogState: Any? = null,
506+
val dialogState: DialogState? = null,
481507
val totalSteps: Int = 4,
482508
val screenState: ScreenState = ScreenState.Loading,
483509
val fixedDepositAccountDetail: FixedDepositAccountDetailsState = FixedDepositAccountDetailsState(),
@@ -500,13 +526,18 @@ data class NewFixedDepositAccountState(
500526
val penalInterest: String = "",
501527

502528
val transferLinkedSavingAccountInterest: Boolean = false,
503-
504529
) {
505530
sealed interface ScreenState {
506531
data class Error(val message: String) : ScreenState
507532
data object Loading : ScreenState
508533
data object Success : ScreenState
509534
}
535+
536+
sealed interface DialogState {
537+
data object RateChartDialog : DialogState
538+
}
539+
540+
val isRateChartEmpty = !template.accountChart?.chartSlabs.isNullOrEmpty()
510541
}
511542

512543
data class FixedDepositAccountTermsState(
@@ -544,6 +575,7 @@ sealed class NewFixedDepositAccountAction {
544575
data object OnNextPress : NewFixedDepositAccountAction()
545576
data object OnDetailNext : NewFixedDepositAccountAction()
546577
data object OnTermNext : NewFixedDepositAccountAction()
578+
data object OnDismissDialog : NewFixedDepositAccountAction()
547579
data class OnStepChange(val newIndex: Int) : NewFixedDepositAccountAction()
548580
data object PreviousStep : NewFixedDepositAccountAction()
549581
data object NavigateBack : NewFixedDepositAccountAction()
@@ -554,6 +586,7 @@ sealed class NewFixedDepositAccountAction {
554586
data class OnFieldOfficerChange(val index: Int) : NewFixedDepositAccountAction()
555587
data class OnExternalIdChange(val value: String) : NewFixedDepositAccountAction()
556588
data object Retry : NewFixedDepositAccountAction()
589+
data object OnShowRateChart : NewFixedDepositAccountAction()
557590
data class OnLockInPeriodFrequencyChange(val value: String) : NewFixedDepositAccountAction()
558591
data class OnLockInPeriodTypeIndexChange(val index: Int) : NewFixedDepositAccountAction()
559592
data class OnMinimumDepositTermFrequencyChange(val value: String) :

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ import kotlin.time.ExperimentalTime
5353
@Composable
5454
fun DetailsPage(
5555
state: NewFixedDepositAccountState,
56-
onAction: (NewFixedDepositAccountAction) -> Unit,
5756
modifier: Modifier = Modifier,
57+
onAction: (NewFixedDepositAccountAction) -> Unit,
5858
) {
5959
val submissionDatePickerState = rememberDatePickerState(
6060
initialSelectedDateMillis = Clock.System.now().toEpochMilliseconds(),

0 commit comments

Comments
 (0)