-
Notifications
You must be signed in to change notification settings - Fork 657
Implement New Share Account – Details Step #2530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /* | ||
| * Copyright 2025 Mifos Initiative | ||
| * | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
| * | ||
| * See https://github.com/openMF/android-client/blob/master/LICENSE.md | ||
| */ | ||
| package com.mifos.core.data.repository | ||
|
|
||
| import com.mifos.core.common.utils.DataState | ||
| import com.mifos.core.network.model.share.ShareTemplate | ||
| import kotlinx.coroutines.flow.Flow | ||
|
|
||
| interface ShareAccountRepository { | ||
|
|
||
| fun getShareTemplate(clientId: Int): Flow<DataState<ShareTemplate>> | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /* | ||
| * Copyright 2025 Mifos Initiative | ||
| * | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
| * | ||
| * See https://github.com/openMF/android-client/blob/master/LICENSE.md | ||
| */ | ||
| package com.mifos.core.data.repositoryImp | ||
|
|
||
| import com.mifos.core.common.utils.DataState | ||
| import com.mifos.core.common.utils.asDataStateFlow | ||
| import com.mifos.core.data.repository.ShareAccountRepository | ||
| import com.mifos.core.network.datamanager.DataManagerShare | ||
| import com.mifos.core.network.model.share.ShareTemplate | ||
| import kotlinx.coroutines.flow.Flow | ||
|
|
||
| class ShareAccountRepositoryImpl( | ||
| private val dataManagerShare: DataManagerShare, | ||
| ) : ShareAccountRepository { | ||
|
|
||
| override fun getShareTemplate(clientId: Int): Flow<DataState<ShareTemplate>> { | ||
| return dataManagerShare.getShareTemplate(clientId).asDataStateFlow() | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| /* | ||
| * Copyright 2025 Mifos Initiative | ||
| * | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
| * | ||
| * See https://github.com/openMF/android-client/blob/master/LICENSE.md | ||
| */ | ||
| package com.mifos.core.network.datamanager | ||
|
|
||
| import com.mifos.core.network.BaseApiManager | ||
| import com.mifos.core.network.model.share.ShareTemplate | ||
| import kotlinx.coroutines.flow.Flow | ||
|
|
||
| class DataManagerShare( | ||
| private val baseApiManager: BaseApiManager, | ||
| ) { | ||
|
|
||
| fun getShareTemplate(clientId: Int): Flow<ShareTemplate> = | ||
| baseApiManager.shareAccountService.shareProductTemplate(clientId) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /* | ||
| * Copyright 2025 Mifos Initiative | ||
| * | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
| * | ||
| * See https://github.com/openMF/android-client/blob/master/LICENSE.md | ||
| */ | ||
| package com.mifos.core.network.model.share | ||
|
|
||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class ProductOption( | ||
| @SerialName("id") | ||
| val id: Int, | ||
|
|
||
| @SerialName("name") | ||
| val name: String, | ||
|
|
||
| @SerialName("shortName") | ||
| val shortName: String, | ||
|
|
||
| @SerialName("totalShares") | ||
| val totalShares: Int, | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /* | ||
| * Copyright 2025 Mifos Initiative | ||
| * | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
| * | ||
| * See https://github.com/openMF/android-client/blob/master/LICENSE.md | ||
| */ | ||
| package com.mifos.core.network.model.share | ||
|
|
||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class ShareTemplate( | ||
| @SerialName("clientId") | ||
| val clientId: Int, | ||
|
|
||
| @SerialName(value = "clientName") | ||
| val clientName: String, | ||
|
|
||
| @SerialName("productOptions") | ||
| val productOptions: List<ProductOption> = emptyList(), | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| /* | ||
| * Copyright 2025 Mifos Initiative | ||
| * | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
| * | ||
| * See https://github.com/openMF/android-client/blob/master/LICENSE.md | ||
| */ | ||
| package com.mifos.core.network.services | ||
|
|
||
| import com.mifos.core.network.model.share.ShareTemplate | ||
| import com.mifos.room.basemodel.APIEndPoint | ||
| import de.jensklingenberg.ktorfit.http.GET | ||
| import de.jensklingenberg.ktorfit.http.Query | ||
| import kotlinx.coroutines.flow.Flow | ||
|
|
||
| interface ShareAccountService { | ||
|
|
||
| @GET("accounts/" + APIEndPoint.SHARE + "/template") | ||
| fun shareProductTemplate( | ||
| @Query("clientId") clientId: Int, | ||
| ): Flow<ShareTemplate> | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,19 +15,24 @@ import androidx.navigation.compose.composable | |
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data object ShareAccountRoute | ||
| data class CreateShareAccountRoute( | ||
| val clientId: Int, | ||
| ) | ||
|
|
||
| fun NavGraphBuilder.shareAccountDestination() { | ||
| composable<ShareAccountRoute> { | ||
| ShareAccountScreen( | ||
| onNavigateBack = {}, | ||
| fun NavGraphBuilder.createShareAccountDestination(navController: NavController) { | ||
| composable<CreateShareAccountRoute> { | ||
| CreateShareAccountScreen( | ||
| onNavigateBack = navController::popBackStack, | ||
| onFinish = {}, | ||
| navController = navController, | ||
| ) | ||
|
Comment on lines
+24
to
28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wire the finish callback to a navigation action. CreateShareAccountScreen(
onNavigateBack = navController::popBackStack,
- onFinish = {},
+ onFinish = { navController.popBackStack() },
navController = navController,
)🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
|
|
||
| fun NavController.navigateToShareAccountRoute() { | ||
| fun NavController.navigateToCreateShareAccountRoute( | ||
| clientId: Int, | ||
| ) { | ||
| this.navigate( | ||
| ShareAccountRoute, | ||
| CreateShareAccountRoute(clientId = clientId), | ||
| ) | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expose optional productId in the share template call.
Without the productId query arg we can only retrieve the bare template (client + product list). The Fineract share template API expects us to pass the selected share product id to receive the product-specific defaults (charges, currency, etc.) that the later Terms/Charges steps rely on. Add an optional productId parameter here and plumb it through the repository/DataManager. (demo.mifos.io)
🤖 Prompt for AI Agents