Skip to content

Commit e26c8a6

Browse files
feat: additional details for share account application (#2943)
1 parent d02f5e5 commit e26c8a6

File tree

20 files changed

+1757
-20
lines changed

20 files changed

+1757
-20
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ internal fun NavGraphBuilder.authenticatedGraph(
197197

198198
shareApplicationNavGraph(
199199
navController = navController,
200+
navigateToStatusScreen = navController::navigateToStatusAfterUpdate,
201+
navigateToAuthenticateScreen = navController::navigateToVerifyPasscodeScreen,
200202
)
201203

202204
passcodeDestination(

core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/ShareAccountRepository.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@ package org.mifos.mobile.core.data.repository
1212
import kotlinx.coroutines.flow.Flow
1313
import org.mifos.mobile.core.common.DataState
1414
import org.mifos.mobile.core.model.entity.Page
15-
import org.mifos.mobile.core.model.entity.templates.shareProduct.ShareDetails
15+
import org.mifos.mobile.core.model.entity.payload.ShareApplicationPayload
16+
import org.mifos.mobile.core.model.entity.templates.shareProductDetails.ShareProductDetails
1617
import org.mifos.mobile.core.model.entity.templates.shares.ShareProduct
1718

1819
interface ShareAccountRepository {
1920

2021
fun getShareProducts(clientId: Long?): Flow<DataState<Page<ShareProduct>>>
2122

22-
fun getShareProductById(productId: Long, clientId: String?): Flow<DataState<ShareDetails>>
23+
fun getShareProductById(productId: Long, clientId: Long?): Flow<DataState<ShareProductDetails>>
24+
25+
suspend fun submitShareApplication(
26+
payload: ShareApplicationPayload?,
27+
): DataState<String>
2328
}

core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/ShareAccountRepositoryImp.kt

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,19 @@
99
*/
1010
package org.mifos.mobile.core.data.repositoryImpl
1111

12+
import io.ktor.client.plugins.ClientRequestException
13+
import io.ktor.client.statement.bodyAsText
1214
import kotlinx.coroutines.CoroutineDispatcher
1315
import kotlinx.coroutines.flow.Flow
1416
import kotlinx.coroutines.flow.flowOn
17+
import kotlinx.coroutines.withContext
1518
import org.mifos.mobile.core.common.DataState
1619
import org.mifos.mobile.core.common.asDataStateFlow
1720
import org.mifos.mobile.core.data.repository.ShareAccountRepository
21+
import org.mifos.mobile.core.data.util.extractErrorMessage
1822
import org.mifos.mobile.core.model.entity.Page
19-
import org.mifos.mobile.core.model.entity.templates.shareProduct.ShareDetails
23+
import org.mifos.mobile.core.model.entity.payload.ShareApplicationPayload
24+
import org.mifos.mobile.core.model.entity.templates.shareProductDetails.ShareProductDetails
2025
import org.mifos.mobile.core.model.entity.templates.shares.ShareProduct
2126
import org.mifos.mobile.core.network.DataManager
2227

@@ -32,9 +37,22 @@ class ShareAccountRepositoryImp(
3237

3338
override fun getShareProductById(
3439
productId: Long,
35-
clientId: String?,
36-
): Flow<DataState<ShareDetails>> {
40+
clientId: Long?,
41+
): Flow<DataState<ShareProductDetails>> {
3742
return dataManager.shareAccountApi.getShareProductById(productId, clientId)
3843
.asDataStateFlow().flowOn(ioDispatcher)
3944
}
45+
46+
override suspend fun submitShareApplication(payload: ShareApplicationPayload?): DataState<String> {
47+
return withContext(ioDispatcher) {
48+
try {
49+
val response =
50+
dataManager.shareAccountApi.submitShareApplication(payload)
51+
DataState.Success(response.bodyAsText())
52+
} catch (e: ClientRequestException) {
53+
val errorMessage = extractErrorMessage(e.response)
54+
DataState.Error(Exception(errorMessage), null)
55+
}
56+
}
57+
}
4058
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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/mobile-mobile/blob/master/LICENSE.md
9+
*/
10+
package org.mifos.mobile.core.model.entity.payload
11+
12+
import kotlinx.serialization.Serializable
13+
14+
@Serializable
15+
data class ShareApplicationPayload(
16+
val productId: Int,
17+
val unitPrice: Double,
18+
val requestedShares: Int,
19+
val submittedDate: String,
20+
val savingsAccountId: Int,
21+
val applicationDate: String,
22+
val locale: String = "en",
23+
val dateFormat: String = "dd MMMM yyyy",
24+
val clientId: Long,
25+
)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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/mobile-mobile/blob/master/LICENSE.md
9+
*/
10+
package org.mifos.mobile.core.model.entity.templates.shareProductDetails
11+
12+
import kotlinx.serialization.Serializable
13+
import org.mifos.mobile.core.model.Parcelable
14+
import org.mifos.mobile.core.model.Parcelize
15+
16+
@Parcelize
17+
@Serializable
18+
data class AccountingItem(
19+
val id: Int? = null,
20+
val name: String? = null,
21+
val glCode: String? = null,
22+
) : Parcelable
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/mobile-mobile/blob/master/LICENSE.md
9+
*/
10+
package org.mifos.mobile.core.model.entity.templates.shareProductDetails
11+
12+
import kotlinx.serialization.Serializable
13+
import org.mifos.mobile.core.model.Parcelable
14+
import org.mifos.mobile.core.model.Parcelize
15+
16+
@Parcelize
17+
@Serializable
18+
data class AccountingMappings(
19+
val shareReferenceId: AccountingItem? = null,
20+
val incomeFromFeeAccountId: AccountingItem? = null,
21+
val shareEquityId: AccountingItem? = null,
22+
val shareSuspenseId: AccountingItem? = null,
23+
) : Parcelable
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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/mobile-mobile/blob/master/LICENSE.md
9+
*/
10+
package org.mifos.mobile.core.model.entity.templates.shareProductDetails
11+
12+
import kotlinx.serialization.Serializable
13+
import org.mifos.mobile.core.model.Parcelable
14+
import org.mifos.mobile.core.model.Parcelize
15+
16+
@Parcelize
17+
@Serializable
18+
data class Charge(
19+
val id: Int? = null,
20+
val name: String? = null,
21+
val active: Boolean? = null,
22+
val penalty: Boolean? = null,
23+
val currency: Currency? = null,
24+
val amount: Double? = null,
25+
val chargeTimeType: EnumOption? = null,
26+
val chargeAppliesTo: EnumOption? = null,
27+
val chargeCalculationType: EnumOption? = null,
28+
val chargePaymentMode: EnumOption? = null,
29+
) : Parcelable
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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/mobile-mobile/blob/master/LICENSE.md
9+
*/
10+
package org.mifos.mobile.core.model.entity.templates.shareProductDetails
11+
12+
import kotlinx.serialization.Serializable
13+
import org.mifos.mobile.core.model.Parcelable
14+
import org.mifos.mobile.core.model.Parcelize
15+
16+
@Parcelize
17+
@Serializable
18+
data class Currency(
19+
val code: String? = null,
20+
val name: String? = null,
21+
val decimalPlaces: Int? = null,
22+
val inMultiplesOf: Int? = null,
23+
val displaySymbol: String? = null,
24+
val nameCode: String? = null,
25+
val displayLabel: String? = null,
26+
) : Parcelable
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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/mobile-mobile/blob/master/LICENSE.md
9+
*/
10+
package org.mifos.mobile.core.model.entity.templates.shareProductDetails
11+
12+
import kotlinx.serialization.Serializable
13+
import org.mifos.mobile.core.model.Parcelable
14+
import org.mifos.mobile.core.model.Parcelize
15+
16+
@Parcelize
17+
@Serializable
18+
data class EnumOption(
19+
val id: Int? = null,
20+
val code: String? = null,
21+
val value: String? = null,
22+
) : Parcelable
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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/mobile-mobile/blob/master/LICENSE.md
9+
*/
10+
package org.mifos.mobile.core.model.entity.templates.shareProductDetails
11+
12+
import kotlinx.serialization.Serializable
13+
import org.mifos.mobile.core.model.Parcelable
14+
import org.mifos.mobile.core.model.Parcelize
15+
16+
@Parcelize
17+
@Serializable
18+
data class MarketPrice(
19+
val id: Int? = null,
20+
val fromDate: String? = null,
21+
val shareValue: Double? = null,
22+
) : Parcelable

0 commit comments

Comments
 (0)