Skip to content

Commit 586174c

Browse files
authored
feature(savings): new savings account, details step impl (openMF#2500)
1 parent 08c7243 commit 586174c

16 files changed

Lines changed: 440 additions & 44 deletions

File tree

cmp-navigation/src/commonMain/kotlin/cmp/navigation/authenticated/AuthenticatedNavbarNavigationScreen.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ internal fun AuthenticatedNavbarNavigationScreen(
118118
name = "AuthenticatedNavbarScreen",
119119
),
120120
navigateToNewLoanAccountScreen: (Int) -> Unit,
121+
navigateToNewSavingsAccountScreen: (Int) -> Unit,
121122
viewModel: AuthenticatedNavbarNavigationViewModel = koinViewModel(),
122123
) {
123124
val scope = rememberCoroutineScope()
@@ -179,6 +180,7 @@ internal fun AuthenticatedNavbarNavigationScreen(
179180
navigateToDocumentScreen = navigateToDocumentScreen,
180181
navigateToNoteScreen = navigateToNoteScreen,
181182
navigateToNewLoanAccountScreen = navigateToNewLoanAccountScreen,
183+
navigateToNewSavingsAccountScreen = navigateToNewSavingsAccountScreen,
182184
)
183185
}
184186

@@ -190,6 +192,7 @@ internal fun AuthenticatedNavbarNavigationScreenContent(
190192
navigateToDocumentScreen: (Int, String) -> Unit,
191193
navigateToNoteScreen: (Int, String) -> Unit,
192194
navigateToNewLoanAccountScreen: (Int) -> Unit,
195+
navigateToNewSavingsAccountScreen: (Int) -> Unit,
193196
modifier: Modifier = Modifier,
194197
snackbarHostState: SnackbarHostState = remember { SnackbarHostState() },
195198
onAction: (AuthenticatedNavBarAction) -> Unit,
@@ -433,6 +436,7 @@ internal fun AuthenticatedNavbarNavigationScreenContent(
433436
hasDatatables = navController::navigateDataTableList,
434437
onDocumentClicked = navigateToDocumentScreen,
435438
navigateToNewLoanAccount = navigateToNewLoanAccountScreen,
439+
navigateToNewSavingsAccount = navigateToNewSavingsAccountScreen,
436440
)
437441
}
438442
}

cmp-navigation/src/commonMain/kotlin/cmp/navigation/authenticated/AuthenticatedNavbarRoute.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@ internal fun NavGraphBuilder.authenticatedNavbarGraph(
2727
navigateToDocumentScreen: (Int, String) -> Unit,
2828
navigateToNoteScreen: (Int, String) -> Unit,
2929
navigateToNewLoanAccountScreen: (Int) -> Unit,
30+
navigateToNewSavingsAccountScreen: (Int) -> Unit,
3031
) {
3132
composable<AuthenticatedNavbar> {
3233
AuthenticatedNavbarNavigationScreen(
3334
onDrawerItemClick = onDrawerItemClick,
3435
navigateToDocumentScreen = navigateToDocumentScreen,
3536
navigateToNoteScreen = navigateToNoteScreen,
3637
navigateToNewLoanAccountScreen = navigateToNewLoanAccountScreen,
38+
navigateToNewSavingsAccountScreen = navigateToNewSavingsAccountScreen,
3739
)
3840
}
3941
}

cmp-navigation/src/commonMain/kotlin/cmp/navigation/authenticated/AuthenticatedNavigation.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import com.mifos.feature.offline.navigation.offlineNavGraph
3333
import com.mifos.feature.path.tracking.navigation.pathTrackingRoute
3434
import com.mifos.feature.report.navigation.reportNavGraph
3535
import com.mifos.feature.savings.navigation.savingsNavGraph
36+
import com.mifos.feature.savings.savingsAccountv2.navigateToSavingsAccountRoute
3637
import com.mifos.feature.settings.navigation.settingsScreen
3738
import kotlinx.serialization.ExperimentalSerializationApi
3839
import kotlinx.serialization.InternalSerializationApi
@@ -61,6 +62,7 @@ internal fun NavGraphBuilder.authenticatedGraph(
6162
navigateToDocumentScreen = navController::navigateToDocumentListScreen,
6263
navigateToNoteScreen = navController::navigateToNoteScreen,
6364
navigateToNewLoanAccountScreen = navController::navigateToNewLoanAccountRoute,
65+
navigateToNewSavingsAccountScreen = navController::navigateToSavingsAccountRoute,
6466
)
6567

6668
checkerInboxTaskNavGraph(navController)

core/domain/src/commonMain/kotlin/com/mifos/core/domain/di/UseCaseModule.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import com.mifos.core.domain.useCases.GetClientDetailsUseCase
4646
import com.mifos.core.domain.useCases.GetClientIdentifierTemplateUseCase
4747
import com.mifos.core.domain.useCases.GetClientPinpointLocationsUseCase
4848
import com.mifos.core.domain.useCases.GetClientSavingsAccountTemplateByProductUseCase
49+
import com.mifos.core.domain.useCases.GetClientTemplateUseCase
4950
import com.mifos.core.domain.useCases.GetDataTableInfoUseCase
5051
import com.mifos.core.domain.useCases.GetDocumentsListUseCase
5152
import com.mifos.core.domain.useCases.GetGroupDetailsUseCase
@@ -104,6 +105,7 @@ val UseCaseModule = module {
104105
factoryOf(::CreateLoanAccountUseCase)
105106
factoryOf(::CreateLoanChargesUseCase)
106107
factoryOf(::CreateSavingsAccountUseCase)
108+
factoryOf(::GetClientTemplateUseCase)
107109
factoryOf(::DeleteCheckerUseCase)
108110
factoryOf(::DeleteClientAddressPinpointUseCase)
109111
factoryOf(::DeleteDataTableEntryUseCase)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2025 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9+
*/
10+
package com.mifos.core.domain.useCases
11+
12+
import com.mifos.core.common.utils.DataState
13+
import com.mifos.core.data.repository.CreateNewClientRepository
14+
import com.mifos.room.entities.templates.clients.ClientsTemplateEntity
15+
import kotlinx.coroutines.flow.Flow
16+
17+
class GetClientTemplateUseCase(
18+
private val newClientRepository: CreateNewClientRepository,
19+
) {
20+
operator fun invoke(): Flow<DataState<ClientsTemplateEntity>> {
21+
return newClientRepository.clientTemplate()
22+
}
23+
}

core/ui/src/commonMain/kotlin/com/mifos/core/ui/util/TextFieldsValidator.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ object TextFieldsValidator {
2727
}
2828
}
2929

30+
fun optionalStringValidator(input: String): StringResource? {
31+
return when {
32+
input.any { !it.isLetterOrDigit() && !it.isWhitespace() } -> Res.string.error_invalid_characters
33+
else -> null // valid
34+
}
35+
}
36+
3037
fun numberValidator(input: String): StringResource? {
3138
return when {
3239
input.isBlank() -> Res.string.error_field_empty

feature/client/src/commonMain/kotlin/com/mifos/feature/client/clientApplyNewApplications/ClientApplyNewApplicationRoute.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ data class ClientApplyNewApplicationRoute(
2222
fun NavGraphBuilder.clientApplyNewApplicationRoute(
2323
onNavigateBack: () -> Unit,
2424
onNavigateApplyLoanAccount: (Int) -> Unit,
25-
onNavigateApplySavingsAccount: () -> Unit,
25+
onNavigateApplySavingsAccount: (Int) -> Unit,
2626
onNavigateApplyShareAccount: () -> Unit,
2727
onNavigateApplyRecurringAccount: () -> Unit,
2828
onNavigateApplyFixedAccount: () -> Unit,

feature/client/src/commonMain/kotlin/com/mifos/feature/client/clientApplyNewApplications/ClientApplyNewApplicationsScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import org.koin.compose.viewmodel.koinViewModel
5757
internal fun ClientApplyNewApplicationsScreen(
5858
onNavigateBack: () -> Unit,
5959
onNavigateApplyLoanAccount: (Int) -> Unit,
60-
onNavigateApplySavingsAccount: () -> Unit,
60+
onNavigateApplySavingsAccount: (Int) -> Unit,
6161
onNavigateApplyShareAccount: () -> Unit,
6262
onNavigateApplyRecurringAccount: () -> Unit,
6363
onNavigateApplyFixedAccount: () -> Unit,
@@ -74,7 +74,7 @@ internal fun ClientApplyNewApplicationsScreen(
7474
ClientApplyNewApplicationsItem.NewFixedAccount -> onNavigateApplyFixedAccount()
7575
ClientApplyNewApplicationsItem.NewLoanAccount -> onNavigateApplyLoanAccount(state.clientId)
7676
ClientApplyNewApplicationsItem.NewRecurringAccount -> onNavigateApplyRecurringAccount()
77-
ClientApplyNewApplicationsItem.NewSavingsAccount -> onNavigateApplySavingsAccount()
77+
ClientApplyNewApplicationsItem.NewSavingsAccount -> onNavigateApplySavingsAccount(state.clientId)
7878
ClientApplyNewApplicationsItem.NewShareAccount -> onNavigateApplyShareAccount()
7979
}
8080
}

feature/client/src/commonMain/kotlin/com/mifos/feature/client/navigation/ClientNavigation.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ fun NavGraphBuilder.clientNavGraph(
9292
hasDatatables: KFunction4<List<DataTableEntity>, Any?, Int, MutableList<List<FormWidgetDTO>>, Unit>,
9393
onDocumentClicked: (Int, String) -> Unit,
9494
navigateToNewLoanAccount: (Int) -> Unit,
95+
navigateToNewSavingsAccount: (Int) -> Unit,
9596
) {
9697
navigation<ClientNavGraph>(
9798
startDestination = ClientListScreenRoute,
@@ -256,7 +257,7 @@ fun NavGraphBuilder.clientNavGraph(
256257
clientApplyNewApplicationRoute(
257258
onNavigateBack = navController::popBackStack,
258259
onNavigateApplyLoanAccount = navigateToNewLoanAccount,
259-
onNavigateApplySavingsAccount = { },
260+
onNavigateApplySavingsAccount = navigateToNewSavingsAccount,
260261
onNavigateApplyShareAccount = { },
261262
onNavigateApplyRecurringAccount = { },
262263
onNavigateApplyFixedAccount = { },

feature/savings/src/commonMain/composeResources/values/feature_savings_strings.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@
6060
<string name="feature_savings_go_back">Go Back</string>
6161
<string name="feature_savings_product">Savings Products</string>
6262
<string name="feature_savings_submit">Submit</string>
63+
<string name="feature_savings_select">Select</string>
64+
<string name="feature_savings_external_id_not_unique">ExternalId must be unique</string>
65+
<string name="feature_savings_submission_date">Submission Date</string>
66+
<string name="feature_savings_next">Next</string>
67+
<string name="feature_savings_back">Back</string>
6368
<string name="feature_savings_create_savings_account">Add Savings Account</string>
6469
<string name="feature_savings_savings_account_submitted_for_approval">The Savings Account has been submitted forApproval</string>
6570
<string name="feature_savings_field_officer">Field Officer</string>

0 commit comments

Comments
 (0)