Skip to content

Commit a8f7247

Browse files
authored
Implement Interest Charts Step for New Recurring Deposits Account Flow (#2552)
1 parent 38c179b commit a8f7247

File tree

8 files changed

+231
-43
lines changed

8 files changed

+231
-43
lines changed

core/common/src/androidMain/kotlin/com/mifos/core/common/utils/CurrencyFormatter.android.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ actual object CurrencyFormatter {
2121
val balanceFormatter = NumberFormat.getCurrencyInstance()
2222
balanceFormatter.maximumFractionDigits = maximumFractionDigits ?: 0
2323
balanceFormatter.currency = Currency.getInstance(currencyCode)
24-
return balanceFormatter.format(balance)
24+
return balanceFormatter.format(balance ?: 0)
2525
}
2626
}

core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosActionsListingCardComponent.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ fun MifosActionsChargeListingComponent(
604604
type: String,
605605
date: String? = null,
606606
collectedOn: String,
607-
amount: String,
607+
amount: String? = null,
608608
menuList: List<Actions> = listOf<Actions>(
609609
Actions.Edit(),
610610
Actions.Delete(),
@@ -668,11 +668,13 @@ fun MifosActionsChargeListingComponent(
668668
style = MifosTypography.bodySmall,
669669
textAlign = TextAlign.End,
670670
)
671-
Text(
672-
text = amount,
673-
style = MifosTypography.labelMedium,
674-
textAlign = TextAlign.End,
675-
)
671+
if (amount != null) {
672+
Text(
673+
text = amount,
674+
style = MifosTypography.labelMedium,
675+
textAlign = TextAlign.End,
676+
)
677+
}
676678
}
677679
Icon(
678680
modifier = Modifier

core/ui/src/commonMain/kotlin/com/mifos/core/ui/components/MifosEmptyCard.kt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,23 @@ import org.jetbrains.compose.ui.tooling.preview.Preview
2727

2828
@Composable
2929
fun MifosEmptyCard(
30-
msg: String = stringResource(Res.string.core_ui_click_here_to_view_filled_state),
30+
msg: String? = stringResource(Res.string.core_ui_click_here_to_view_filled_state),
31+
title: String = stringResource(Res.string.core_ui_no_item_found),
3132
modifier: Modifier = Modifier,
3233
) {
3334
MifosListingComponentOutline {
3435
Column(modifier.fillMaxWidth()) {
3536
Text(
36-
text = stringResource(Res.string.core_ui_no_item_found),
37+
text = title,
3738
style = MifosTypography.titleSmallEmphasized,
3839
)
39-
Spacer(Modifier.height((DesignToken.padding.medium)))
40-
Text(
41-
text = msg,
42-
style = MifosTypography.bodySmall,
43-
)
40+
if (msg != null) {
41+
Spacer(Modifier.height((DesignToken.padding.medium)))
42+
Text(
43+
text = msg,
44+
style = MifosTypography.bodySmall,
45+
)
46+
}
4447
}
4548
}
4649
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,13 @@
5353
<string name="feature_recurring_deposit_interest_posting_period">Interest Posting Period</string>
5454
<string name="feature_recurring_deposit_interest_calculation">Interest Calculated Using</string>
5555
<string name="feature_recurring_deposit_calculation_days_in_year">Days In Year </string>
56+
<string name="feature_recurring_deposit_valid_from_date">Valid from Date</string>
57+
<string name="feature_recurring_deposit_grouping_by_amount">Grouping by Amount</string>
58+
<string name="feature_recurring_deposit_interest_rate_chart">INTEREST RATE CHART</string>
59+
<string name="feature_recurring_deposit_no_interest_chart">No Interest Rate Chart available</string>
60+
<string name="feature_recurring_deposit_view">View</string>
61+
<string name="feature_recurring_deposit_rate_chart">Rate Chart</string>
62+
<string name="feature_recurring_deposit_yes">Yes</string>
63+
<string name="feature_recurring_deposit_no">No</string>
64+
<string name="feature_recurring_deposit_empty_date">Empty Date</string>
5665
</resources>

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import com.mifos.feature.recurringDeposit.newRecurringDepositAccount.RecurringAc
3535
import com.mifos.feature.recurringDeposit.newRecurringDepositAccount.pages.ChargesPage
3636
import com.mifos.feature.recurringDeposit.newRecurringDepositAccount.pages.DetailsPage
3737
import com.mifos.feature.recurringDeposit.newRecurringDepositAccount.pages.InterestPage
38+
import com.mifos.feature.recurringDeposit.newRecurringDepositAccount.pages.RateChart
3839
import com.mifos.feature.recurringDeposit.newRecurringDepositAccount.pages.SettingPage
3940
import com.mifos.feature.recurringDeposit.newRecurringDepositAccount.pages.TermsPage
4041
import org.jetbrains.compose.resources.stringResource
@@ -57,6 +58,11 @@ internal fun RecurringAccountScreen(
5758
}
5859
}
5960

61+
RecurringAccountDialog(
62+
state = state,
63+
onAction = { viewModel.trySendAction(it) },
64+
)
65+
6066
RecurringAccountScaffold(
6167
navController = navController,
6268
modifier = modifier,
@@ -65,6 +71,22 @@ internal fun RecurringAccountScreen(
6571
)
6672
}
6773

74+
@Composable
75+
fun RecurringAccountDialog(
76+
state: RecurringAccountState,
77+
onAction: (RecurringAccountAction) -> Unit,
78+
) {
79+
when (state.dialogState) {
80+
RecurringAccountState.DialogState.RateChartDialog -> {
81+
RateChart(
82+
state = state,
83+
onAction = onAction,
84+
)
85+
}
86+
null -> Unit
87+
}
88+
}
89+
6890
@Composable
6991
private fun RecurringAccountScaffold(
7092
navController: NavController,
@@ -93,7 +115,8 @@ private fun RecurringAccountScaffold(
93115
},
94116
Step(name = stringResource(Res.string.feature_recurring_deposit_step_interest)) {
95117
InterestPage(
96-
onNext = { onAction(RecurringAccountAction.OnNextPress) },
118+
state = state,
119+
onAction = onAction,
97120
)
98121
},
99122
Step(name = stringResource(Res.string.feature_recurring_deposit_step_charges)) {

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

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class RecurringAccountViewModel(
162162
)
163163
}
164164

165-
private fun handleInterestCalculationDaysInYearType(action: RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCalculationDaysInYearType) {
165+
private fun handleInterestCalculationDaysInYearType(action: RecurringAccountAction.RecurringAccountTermAction.OnInterestCalculationDaysInYearType) {
166166
mutableStateFlow.update {
167167
it.copy(
168168
recurringDepositAccountInterestChart = it.recurringDepositAccountInterestChart.copy(
@@ -173,7 +173,7 @@ class RecurringAccountViewModel(
173173
}
174174
}
175175

176-
private fun handleInterestCalculationType(action: RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCalculationType) {
176+
private fun handleInterestCalculationType(action: RecurringAccountAction.RecurringAccountTermAction.OnInterestCalculationType) {
177177
mutableStateFlow.update {
178178
it.copy(
179179
recurringDepositAccountInterestChart = it.recurringDepositAccountInterestChart.copy(
@@ -183,7 +183,7 @@ class RecurringAccountViewModel(
183183
}
184184
}
185185

186-
private fun handleInterestCompoundingPeriodType(action: RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCompoundingPeriodType) {
186+
private fun handleInterestCompoundingPeriodType(action: RecurringAccountAction.RecurringAccountTermAction.OnInterestCompoundingPeriodType) {
187187
mutableStateFlow.update {
188188
it.copy(
189189
recurringDepositAccountInterestChart = it.recurringDepositAccountInterestChart.copy(
@@ -193,7 +193,7 @@ class RecurringAccountViewModel(
193193
}
194194
}
195195

196-
private fun handleInterestPostingPeriodType(action: RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestPostingPeriodType) {
196+
private fun handleInterestPostingPeriodType(action: RecurringAccountAction.RecurringAccountTermAction.OnInterestPostingPeriodType) {
197197
mutableStateFlow.update {
198198
it.copy(
199199
recurringDepositAccountInterestChart = it.recurringDepositAccountInterestChart.copy(
@@ -670,21 +670,36 @@ class RecurringAccountViewModel(
670670
moveToNextStep()
671671
}
672672

673-
is RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCalculationDaysInYearType -> {
673+
is RecurringAccountAction.RecurringAccountTermAction.OnInterestCalculationDaysInYearType -> {
674674
handleInterestCalculationDaysInYearType(action)
675675
}
676676

677-
is RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCalculationType -> {
677+
is RecurringAccountAction.RecurringAccountTermAction.OnInterestCalculationType -> {
678678
handleInterestCalculationType(action)
679679
}
680680

681-
is RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestCompoundingPeriodType -> {
681+
is RecurringAccountAction.RecurringAccountTermAction.OnInterestCompoundingPeriodType -> {
682682
handleInterestCompoundingPeriodType(action)
683683
}
684684

685-
is RecurringAccountAction.RecurringAccountInterestChartAction.OnInterestPostingPeriodType -> {
685+
is RecurringAccountAction.RecurringAccountTermAction.OnInterestPostingPeriodType -> {
686686
handleInterestPostingPeriodType(action)
687687
}
688+
689+
RecurringAccountAction.OnDismissDialog -> {
690+
mutableStateFlow.update {
691+
it.copy(
692+
dialogState = null,
693+
)
694+
}
695+
}
696+
RecurringAccountAction.OnShowRateChartDialog -> {
697+
mutableStateFlow.update {
698+
it.copy(
699+
dialogState = RecurringAccountState.DialogState.RateChartDialog,
700+
)
701+
}
702+
}
688703
}
689704
}
690705
}
@@ -702,12 +717,18 @@ data class RecurringAccountState(
702717
val currencyIndex: Int = -1,
703718
val currencyError: String? = null,
704719
val isOverlayLoading: Boolean = false,
720+
val dialogState: DialogState? = null,
705721
) {
706722
sealed interface ScreenState {
707723
data class Error(val message: String) : ScreenState
708724
data object Loading : ScreenState
709725
data object Success : ScreenState
710726
}
727+
sealed interface DialogState {
728+
data object RateChartDialog : DialogState
729+
}
730+
731+
val isRateChartEmpty = !template.accountChart?.chartSlabs.isNullOrEmpty()
711732
}
712733

713734
data class RecurringAccountDetailsState
@@ -798,6 +819,8 @@ sealed class RecurringAccountAction {
798819
object OnBackPress : RecurringAccountAction()
799820
object OnNextPress : RecurringAccountAction()
800821
data object Retry : RecurringAccountAction()
822+
object OnShowRateChartDialog : RecurringAccountAction()
823+
object OnDismissDialog : RecurringAccountAction()
801824

802825
sealed class RecurringAccountDetailsAction : RecurringAccountAction() {
803826
data class OnProductNameChange(val index: Int) : RecurringAccountDetailsAction()
@@ -851,18 +874,18 @@ sealed class RecurringAccountAction {
851874
object OnSettingNext : RecurringAccountSettingsAction()
852875
}
853876

854-
sealed class RecurringAccountInterestChartAction : RecurringAccountAction() {
877+
sealed class RecurringAccountTermAction : RecurringAccountAction() {
855878
data class OnInterestCalculationDaysInYearType(val interestCalculationTypeDaysInYear: Int) :
856-
RecurringAccountInterestChartAction()
879+
RecurringAccountTermAction()
857880

858881
data class OnInterestCompoundingPeriodType(val interestCompoundingPeriodType: Int) :
859-
RecurringAccountInterestChartAction()
882+
RecurringAccountTermAction()
860883

861884
data class OnInterestCalculationType(val interestCalculationType: Int) :
862-
RecurringAccountInterestChartAction()
885+
RecurringAccountTermAction()
863886

864887
data class OnInterestPostingPeriodType(val interestPostingPeriodType: Int) :
865-
RecurringAccountInterestChartAction()
888+
RecurringAccountTermAction()
866889
}
867890
}
868891

0 commit comments

Comments
 (0)