Skip to content

Commit 8eef36b

Browse files
authored
feat: Share accounts UI (openMF#2495)
1 parent 8b22888 commit 8eef36b

20 files changed

Lines changed: 669 additions & 13 deletions

File tree

core/data/src/commonMain/kotlin/com/mifos/core/data/repository/ClientDetailsRepository.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
package com.mifos.core.data.repository
1111

1212
import com.mifos.core.common.utils.DataState
13+
import com.mifos.core.model.objects.account.share.ShareAccounts
1314
import com.mifos.core.network.model.ClientCloseTemplateResponse
1415
import com.mifos.core.network.model.CollateralItem
1516
import com.mifos.core.network.model.SavingAccountOption
@@ -32,6 +33,8 @@ interface ClientDetailsRepository {
3233

3334
suspend fun getSavingsAccounts(clientId: Int): List<SavingAccountOption>
3435

36+
suspend fun getShareAccounts(clientId: Int): List<ShareAccounts>
37+
3538
suspend fun getClientStaffOptions(clientId: Int): List<StaffOption>
3639

3740
suspend fun getClientCloseTemplate(): DataState<ClientCloseTemplateResponse>

core/data/src/commonMain/kotlin/com/mifos/core/data/repositoryImp/ClientDetailsRepositoryImp.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ package com.mifos.core.data.repositoryImp
1212
import com.mifos.core.common.utils.DataState
1313
import com.mifos.core.data.repository.ClientDetailsRepository
1414
import com.mifos.core.data.util.extractErrorMessage
15+
import com.mifos.core.model.objects.account.share.ShareAccounts
1516
import com.mifos.core.network.datamanager.DataManagerClient
1617
import com.mifos.core.network.model.ClientCloseTemplateResponse
1718
import com.mifos.core.network.model.CollateralItem
@@ -49,6 +50,10 @@ class ClientDetailsRepositoryImp(
4950
return dataManagerClient.getSavingsAccounts(clientId)
5051
}
5152

53+
override suspend fun getShareAccounts(clientId: Int): List<ShareAccounts> {
54+
return dataManagerClient.getClientAccounts(clientId).shareAccounts
55+
}
56+
5257
override suspend fun getClientCloseTemplate(): DataState<ClientCloseTemplateResponse> {
5358
return try {
5459
val res = dataManagerClient.getClientCloseTemplate()

core/database/src/commonMain/kotlin/com/mifos/room/entities/accounts/ClientAccounts.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
package com.mifos.room.entities.accounts
1111

12+
import com.mifos.core.model.objects.account.share.ShareAccounts
1213
import com.mifos.core.model.utils.Parcelable
1314
import com.mifos.core.model.utils.Parcelize
1415
import com.mifos.room.entities.accounts.loans.LoanAccountEntity
@@ -20,6 +21,8 @@ data class ClientAccounts(
2021

2122
var savingsAccounts: List<SavingsAccountEntity> = emptyList(),
2223

24+
var shareAccounts: List<ShareAccounts> = emptyList(),
25+
2326
) : Parcelable {
2427
private fun getSavingsAccounts(wantRecurring: Boolean): List<SavingsAccountEntity> {
2528
val result: MutableList<SavingsAccountEntity> = ArrayList()

core/model/src/commonMain/kotlin/com/mifos/core/model/objects/account/saving/Timeline.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ package com.mifos.core.model.objects.account.saving
1111

1212
import com.mifos.core.model.utils.Parcelable
1313
import com.mifos.core.model.utils.Parcelize
14+
import kotlinx.serialization.Serializable
1415

1516
@Parcelize
17+
@Serializable
1618
data class Timeline(
1719
var submittedOnDate: List<Int?> = ArrayList(),
1820

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/android-client/blob/master/LICENSE.md
9+
*/
10+
package com.mifos.core.model.objects.account.share
11+
12+
import com.mifos.core.model.utils.Parcelable
13+
import com.mifos.core.model.utils.Parcelize
14+
import kotlinx.serialization.Serializable
15+
16+
@Serializable
17+
@Parcelize
18+
data class ShareAccounts(
19+
val id: Int? = null,
20+
val accountNo: String? = null,
21+
val totalApprovedShares: Int? = null,
22+
val totalPendingForApprovalShares: Int? = null,
23+
val shortProductName: String? = null,
24+
val clientId: Int? = null,
25+
val clientName: String? = null,
26+
val productId: Int? = null,
27+
val productName: String? = null,
28+
val status: ShareAccountsStatus? = null,
29+
) : Parcelable
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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.model.objects.account.share
11+
12+
import com.mifos.core.model.utils.Parcelable
13+
import com.mifos.core.model.utils.Parcelize
14+
import kotlinx.serialization.Serializable
15+
16+
@Serializable
17+
@Parcelize
18+
data class ShareAccountsStatus(
19+
val id: Int? = null,
20+
21+
val code: String? = null,
22+
23+
val value: String? = null,
24+
25+
val submittedAndPendingApproval: Boolean? = null,
26+
27+
val approved: Boolean? = null,
28+
29+
val rejected: Boolean? = null,
30+
31+
val active: Boolean? = null,
32+
33+
val closed: Boolean? = null,
34+
) : Parcelable

core/network/src/commonMain/kotlin/com/mifos/core/network/mappers/clients/GetClientsClientIdAccountMapper.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
*/
1010
package com.mifos.core.network.mappers.clients
1111

12+
import com.mifos.core.model.objects.account.share.ShareAccounts
13+
import com.mifos.core.model.objects.account.share.ShareAccountsStatus
1214
import com.mifos.core.network.data.AbstractMapper
1315
import com.mifos.core.network.model.GetClientsClientIdAccountsResponse
1416
import com.mifos.core.network.model.GetClientsLoanAccounts
@@ -108,6 +110,27 @@ object GetClientsClientIdAccountMapper :
108110
loanCycle = it.loanCycle,
109111
)
110112
} ?: emptyList(),
113+
114+
shareAccounts = entity.shareAccounts?.map {
115+
ShareAccounts(
116+
id = it.id,
117+
accountNo = it.accountNo,
118+
productId = it.productId,
119+
productName = it.productName,
120+
clientName = it.clientName,
121+
clientId = it.clientId,
122+
status = ShareAccountsStatus(
123+
id = it.status?.id,
124+
code = it.status?.code,
125+
value = it.status?.value,
126+
submittedAndPendingApproval = it.status?.submittedAndPendingApproval,
127+
approved = it.status?.approved,
128+
rejected = it.status?.rejected,
129+
active = it.status?.active,
130+
closed = it.status?.closed,
131+
),
132+
)
133+
} ?: emptyList(),
111134
)
112135
}
113136

core/network/src/commonMain/kotlin/com/mifos/core/network/model/GetClientsClientIdAccountsResponse.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
package com.mifos.core.network.model
1111

12+
import com.mifos.core.network.model.share.ShareAccountResponse
1213
import kotlinx.serialization.Serializable
1314

1415
/**
@@ -25,4 +26,5 @@ data class GetClientsClientIdAccountsResponse(
2526

2627
val savingsAccounts: Set<GetClientsSavingsAccounts>? = null,
2728

29+
val shareAccounts: Set<ShareAccountResponse>? = null,
2830
)

core/network/src/commonMain/kotlin/com/mifos/core/network/model/GetClientsPageItemsResponse.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
package com.mifos.core.network.model
1111

12+
import com.mifos.core.model.objects.account.share.ShareAccounts
1213
import kotlinx.serialization.Serializable
1314

1415
/**
@@ -55,4 +56,6 @@ data class GetClientsPageItemsResponse(
5556
val staffOptions: List<StaffOption> = emptyList(),
5657

5758
val savingAccountOptions: List<SavingAccountOption> = emptyList(),
59+
60+
val shareAccounts: List<ShareAccounts> = emptyList(),
5861
)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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.network.model.share
11+
12+
import com.mifos.core.model.objects.organisations.Currency
13+
import com.mifos.core.model.utils.Parcelable
14+
import com.mifos.core.model.utils.Parcelize
15+
import com.mifos.room.entities.Timeline
16+
import kotlinx.serialization.Serializable
17+
18+
@Serializable
19+
@Parcelize
20+
data class ShareAccountResponse(
21+
val id: Int? = null,
22+
val accountNo: String? = null,
23+
val totalApprovedShares: Int? = null,
24+
val totalPendingForApprovalShares: Int? = null,
25+
val shortProductName: String? = null,
26+
val clientId: Int? = null,
27+
val clientName: String? = null,
28+
val productId: Int? = null,
29+
val productName: String? = null,
30+
val status: ShareAccountsStatusResponse? = null,
31+
val timeline: Timeline? = null,
32+
val currency: Currency? = null,
33+
) : Parcelable

0 commit comments

Comments
 (0)