Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ data class AccountChart(
@IgnoredOnParcel val incentiveTypeOptions: List<IncentiveTypeOption>? = null,
val isPrimaryGroupingByAmount: Boolean? = null,
val name: String? = null,
val description: String? = null,
@IgnoredOnParcel val periodTypes: List<PeriodType>? = null,
) : Parcelable
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
package com.mifos.core.network.model

import com.mifos.core.model.objects.account.saving.FieldOfficerOptions
import com.mifos.core.model.objects.template.recurring.AccountChart
import com.mifos.core.model.objects.template.recurring.Currency
import com.mifos.core.model.objects.template.recurring.MaturityInstructionOption
import com.mifos.core.model.objects.template.recurring.interest.InterestCalculationDaysInYearTypeOption
Expand Down Expand Up @@ -56,4 +57,5 @@ data class FixedDepositTemplate(

val lockinPeriodFrequencyTypeOptions: List<LockinPeriodFrequencyTypeOption>? = null,
val maturityInstructionOptions: List<MaturityInstructionOption>? = null,
val accountChart: AccountChart? = null,
)
13 changes: 13 additions & 0 deletions feature/client/src/commonMain/composeResources/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -620,4 +620,17 @@
<string name="feature_fixed_deposit_setting_penal_interest">Penal Interest (%%)</string>
<string name="feature_fixed_deposit_setting_period">Period</string>

<string name="feature_fixed_deposit_interest_name">Name</string>
<string name="feature_fixed_deposit_interest_valid_from_date">Valid From Date</string>
<string name="feature_fixed_deposit_interest_end_date">End Date</string>
<string name="feature_fixed_deposit_interest_description">Description</string>
<string name="feature_fixed_deposit_interest_grouping_by_amount">Grouping By Amount</string>
<string name="feature_fixed_deposit_interest_interest_rate_chart">INTEREST RATE CHART</string>
<string name="feature_fixed_deposit_interest_rate_chart">Rate Chart</string>
<string name="feature_fixed_deposit_interest_no_interest_chart">No Interest Rate Chart available</string>
<string name="feature_fixed_deposit_interest_yes">Yes</string>
<string name="feature_fixed_deposit_interest_no">No</string>
<string name="feature_fixed_deposit_interest_empty_date">Date Not Found</string>


</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ import kotlin.time.ExperimentalTime
@Composable
fun DetailsPage(
state: CreateShareAccountState,
onAction: (CreateShareAccountAction) -> Unit,
modifier: Modifier = Modifier,
onAction: (CreateShareAccountAction) -> Unit,
) {
val submissionDatePickerState = rememberDatePickerState(
initialSelectedDateMillis = Clock.System.now().toEpochMilliseconds(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ import org.jetbrains.compose.resources.stringResource
@Composable
fun PreviewPage(
state: CreateShareAccountState,
modifier: Modifier = Modifier,
onAction: (CreateShareAccountAction) -> Unit,
) {
Column(
Modifier.fillMaxSize().padding(bottom = DesignToken.padding.large),
) {
Column(
modifier = Modifier.weight(1f).verticalScroll(rememberScrollState()),
modifier = modifier.weight(1f).verticalScroll(rememberScrollState()),
verticalArrangement = Arrangement.spacedBy(20.dp),
) {
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ import kotlin.time.ExperimentalTime
@Composable
fun TermsPage(
state: CreateShareAccountState,
onAction: (CreateShareAccountAction) -> Unit,
modifier: Modifier = Modifier,
onAction: (CreateShareAccountAction) -> Unit,
) {
val applicationDatePickerState = rememberDatePickerState(
initialSelectedDateMillis = Clock.System.now().toEpochMilliseconds(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import com.mifos.core.ui.components.Step
import com.mifos.core.ui.util.EventsEffect
import com.mifos.feature.client.newFixedDepositAccount.pages.ChargesPage
import com.mifos.feature.client.newFixedDepositAccount.pages.DetailsPage
import com.mifos.feature.client.newFixedDepositAccount.pages.FixedDepositRateChart
import com.mifos.feature.client.newFixedDepositAccount.pages.InterestPage
import com.mifos.feature.client.newFixedDepositAccount.pages.SettingPage
import com.mifos.feature.client.newFixedDepositAccount.pages.TermsPage
Expand All @@ -53,53 +54,74 @@ internal fun CreateFixedDepositAccountScreen(
NewFixedDepositAccountEvent.Finish -> onFinish()
}
}
FixedDepositAccountScaffold(
CreateFixedDepositAccountScaffold(
navController = navController,
state = state,
onAction = { viewModel.trySendAction(it) },
modifier = modifier,
)
CreateFixedDepositAccountDialog(
state = state,
onAction = { viewModel.trySendAction(it) },
)
}

@Composable
private fun FixedDepositAccountScaffold(
internal fun CreateFixedDepositAccountDialog(
state: NewFixedDepositAccountState,
onAction: (NewFixedDepositAccountAction) -> Unit,
) {
when (state.dialogState) {
NewFixedDepositAccountState.DialogState.RateChartDialog -> {
FixedDepositRateChart(
state = state,
onAction = onAction,
)
}

null -> Unit
}
}

@Composable
private fun CreateFixedDepositAccountScaffold(
navController: NavController,
state: NewFixedDepositAccountState,
onAction: (NewFixedDepositAccountAction) -> Unit,
modifier: Modifier = Modifier,
) {
val steps =
listOf(
Step(stringResource(Res.string.step_details)) {
DetailsPage(
state = state,
onAction = onAction,
)
},
Step(name = stringResource(Res.string.step_terms)) {
TermsPage(
state = state,
onAction = onAction,
)
},
val steps = listOf(
Step(stringResource(Res.string.step_details)) {
DetailsPage(
state = state,
onAction = onAction,
)
},
Step(name = stringResource(Res.string.step_terms)) {
TermsPage(
state = state,
onAction = onAction,
)
},

Step(name = stringResource(Res.string.step_settings)) {
SettingPage(
state = state,
onAction = onAction,
)
},
Step(name = stringResource(Res.string.step_interest)) {
InterestPage(
onNext = { onAction(NewFixedDepositAccountAction.OnNextPress) },
)
},
Step(stringResource(Res.string.step_charges)) {
ChargesPage(
onNext = { onAction(NewFixedDepositAccountAction.OnNextPress) },
)
},
)
Step(name = stringResource(Res.string.step_settings)) {
SettingPage(
state = state,
onAction = onAction,
)
},
Step(name = stringResource(Res.string.step_interest)) {
InterestPage(
state = state,
onAction = onAction,
)
},
Step(stringResource(Res.string.step_charges)) {
ChargesPage(
onNext = { onAction(NewFixedDepositAccountAction.OnNextPress) },
)
},
)

MifosScaffold(
modifier = modifier,
Expand Down Expand Up @@ -127,8 +149,7 @@ private fun FixedDepositAccountScaffold(
onStepChange = { newIndex ->
onAction(NewFixedDepositAccountAction.OnStepChange(newIndex))
},
modifier = Modifier
.fillMaxWidth(),
modifier = Modifier.fillMaxWidth(),

)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,90 +143,117 @@ class CreateFixedDepositAccountViewmodel(
)
}
}

is NewFixedDepositAccountAction.OnLockInPeriodFrequencyChange -> {
mutableStateFlow.update {
it.copy(
lockInPeriodFrequency = action.value,
)
}
}

is NewFixedDepositAccountAction.OnLockInPeriodTypeIndexChange -> {
mutableStateFlow.update {
it.copy(
lockInPeriodTypeIndex = action.index,
)
}
}

is NewFixedDepositAccountAction.OnMaturityInstructionIndexChange -> {
mutableStateFlow.update {
it.copy(
maturityInstructionsIndex = action.index,
)
}
}

is NewFixedDepositAccountAction.OnMaximumDepositFrequencyChange -> {
mutableStateFlow.update {
it.copy(
maximumDispositFrequency = action.value,
)
}
}

is NewFixedDepositAccountAction.OnMaximumDepositTypeIndexChange -> {
mutableStateFlow.update {
it.copy(
maximumDispositTypeIndex = action.index,
)
}
}

is NewFixedDepositAccountAction.OnMinimumDepositTermFrequencyChange -> {
mutableStateFlow.update {
it.copy(
minimumDispositTermFrequency = action.value,
)
}
}

is NewFixedDepositAccountAction.OnMinimumDepositTermTypeIndexChange -> {
mutableStateFlow.update {
it.copy(
minimumDispositTermTypeIndex = action.index,
)
}
}

is NewFixedDepositAccountAction.OnMultiplesFrequencyChange -> {
mutableStateFlow.update {
it.copy(
multiplesFrequency = action.value,
)
}
}

is NewFixedDepositAccountAction.OnMultiplesTypeIndexChange -> {
mutableStateFlow.update {
it.copy(
multiplesTypeIndex = action.index,
)
}
}

is NewFixedDepositAccountAction.OnPenalInterestChange -> {
mutableStateFlow.update {
it.copy(
penalInterest = action.value,
)
}
}

is NewFixedDepositAccountAction.OnPeriodIndexChange -> {
mutableStateFlow.update {
it.copy(
periodIndex = action.index,
)
}
}

is NewFixedDepositAccountAction.OnTransferLinkedSavingsAccountInterestChange -> {
mutableStateFlow.update {
it.copy(
transferLinkedSavingAccountInterest = action.checked,
)
}
}

NewFixedDepositAccountAction.OnDismissDialog -> {
mutableStateFlow.update {
it.copy(
dialogState = null,
)
}
}
NewFixedDepositAccountAction.OnShowRateChart -> {
mutableStateFlow.update {
it.copy(
dialogState = NewFixedDepositAccountState.DialogState.RateChartDialog,
)
}
}
}
}

Expand Down Expand Up @@ -353,9 +380,7 @@ class CreateFixedDepositAccountViewmodel(
),
)
}
if (state.template.fieldOfficerOptions == null) {
loadRecurringAccountTemplateWithProduct()
}
loadRecurringAccountTemplateWithProduct()
}

private fun handleFieldOfficerChange(action: NewFixedDepositAccountAction.OnFieldOfficerChange) {
Expand Down Expand Up @@ -466,6 +491,7 @@ class CreateFixedDepositAccountViewmodel(
mutableStateFlow.update {
it.copy(
currentStep = current + 1,
dialogState = null,
)
}
} else {
Expand All @@ -477,7 +503,7 @@ class CreateFixedDepositAccountViewmodel(
data class NewFixedDepositAccountState(
val clientId: Int = -1,
val currentStep: Int = 0,
val dialogState: Any? = null,
val dialogState: DialogState? = null,
val totalSteps: Int = 4,
val screenState: ScreenState = ScreenState.Loading,
val fixedDepositAccountDetail: FixedDepositAccountDetailsState = FixedDepositAccountDetailsState(),
Expand All @@ -500,13 +526,18 @@ data class NewFixedDepositAccountState(
val penalInterest: String = "",

val transferLinkedSavingAccountInterest: Boolean = false,

) {
sealed interface ScreenState {
data class Error(val message: String) : ScreenState
data object Loading : ScreenState
data object Success : ScreenState
}

sealed interface DialogState {
data object RateChartDialog : DialogState
}

val isRateChartEmpty = !template.accountChart?.chartSlabs.isNullOrEmpty()
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Property isRateChartEmpty has inverted semantics.

The property returns true when the chart slabs are not empty, which contradicts what the name suggests. This will confuse anyone reading the code.

Rename to reflect actual semantics:

-    val isRateChartEmpty = !template.accountChart?.chartSlabs.isNullOrEmpty()
+    val hasRateChartData = !template.accountChart?.chartSlabs.isNullOrEmpty()

Then update InterestPage.kt accordingly:

-                text = if (state.isRateChartEmpty) {
+                text = if (state.hasRateChartData) {
                     stringResource(Res.string.feature_fixed_deposit_interest_interest_rate_chart)
                 } else {
                     stringResource(Res.string.feature_fixed_deposit_interest_no_interest_chart)
                 },
-                btnEnabled = state.isRateChartEmpty,
+                btnEnabled = state.hasRateChartData,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
val isRateChartEmpty = !template.accountChart?.chartSlabs.isNullOrEmpty()
val hasRateChartData = !template.accountChart?.chartSlabs.isNullOrEmpty()
🤖 Prompt for AI Agents
In
feature/client/src/commonMain/kotlin/com/mifos/feature/client/newFixedDepositAccount/CreateFixedDepositAccountViewmodel.kt
around line 540, the property currently named isRateChartEmpty has inverted
semantics (it returns true when chart slabs are NOT empty); rename it to reflect
actual meaning (e.g., hasRateChart or isRateChartPresent) and invert the boolean
expression to match the new name (or if you keep the name, invert the logic to
use isNullOrEmpty correctly). Then update all usages (specifically
InterestPage.kt) to reference the new property name and adjust any conditional
logic to preserve original behavior.

}

data class FixedDepositAccountTermsState(
Expand Down Expand Up @@ -544,6 +575,7 @@ sealed class NewFixedDepositAccountAction {
data object OnNextPress : NewFixedDepositAccountAction()
data object OnDetailNext : NewFixedDepositAccountAction()
data object OnTermNext : NewFixedDepositAccountAction()
data object OnDismissDialog : NewFixedDepositAccountAction()
data class OnStepChange(val newIndex: Int) : NewFixedDepositAccountAction()
data object PreviousStep : NewFixedDepositAccountAction()
data object NavigateBack : NewFixedDepositAccountAction()
Expand All @@ -554,6 +586,7 @@ sealed class NewFixedDepositAccountAction {
data class OnFieldOfficerChange(val index: Int) : NewFixedDepositAccountAction()
data class OnExternalIdChange(val value: String) : NewFixedDepositAccountAction()
data object Retry : NewFixedDepositAccountAction()
data object OnShowRateChart : NewFixedDepositAccountAction()
data class OnLockInPeriodFrequencyChange(val value: String) : NewFixedDepositAccountAction()
data class OnLockInPeriodTypeIndexChange(val index: Int) : NewFixedDepositAccountAction()
data class OnMinimumDepositTermFrequencyChange(val value: String) :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ import kotlin.time.ExperimentalTime
@Composable
fun DetailsPage(
state: NewFixedDepositAccountState,
onAction: (NewFixedDepositAccountAction) -> Unit,
modifier: Modifier = Modifier,
onAction: (NewFixedDepositAccountAction) -> Unit,
) {
val submissionDatePickerState = rememberDatePickerState(
initialSelectedDateMillis = Clock.System.now().toEpochMilliseconds(),
Expand Down
Loading