Skip to content

Commit 18d788b

Browse files
refactor: applying share account (#2946)
1 parent cf87c0c commit 18d788b

File tree

8 files changed

+242
-102
lines changed

8 files changed

+242
-102
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ import io.ktor.client.plugins.ClientRequestException
1313
import io.ktor.client.statement.bodyAsText
1414
import kotlinx.coroutines.CoroutineDispatcher
1515
import kotlinx.coroutines.flow.Flow
16+
import kotlinx.coroutines.flow.catch
1617
import kotlinx.coroutines.flow.flowOn
18+
import kotlinx.coroutines.flow.map
1719
import kotlinx.coroutines.withContext
1820
import org.mifos.mobile.core.common.DataState
1921
import org.mifos.mobile.core.common.asDataStateFlow
@@ -32,7 +34,9 @@ class ShareAccountRepositoryImp(
3234

3335
override fun getShareProducts(clientId: Long?): Flow<DataState<Page<ShareProduct>>> {
3436
return dataManager.shareAccountApi.getShareProducts(clientId)
35-
.asDataStateFlow().flowOn(ioDispatcher)
37+
.map { response -> DataState.Success(response) }
38+
.catch { exception -> DataState.Error(exception, exception.message) }
39+
.flowOn(ioDispatcher)
3640
}
3741

3842
override fun getShareProductById(

core/model/src/commonMain/kotlin/org/mifos/mobile/core/model/entity/payload/ShareApplicationPayload.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ data class ShareApplicationPayload(
1919
val submittedDate: String,
2020
val savingsAccountId: Int,
2121
val applicationDate: String,
22-
val locale: String = "en",
23-
val dateFormat: String = "dd MMMM yyyy",
22+
val locale: String,
23+
val dateFormat: String,
2424
val clientId: Long,
2525
)

core/model/src/commonMain/kotlin/org/mifos/mobile/core/model/entity/templates/shareProductDetails/ShareProductDetails.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,12 @@ data class ShareProductDetails(
3535
val minimumActivePeriodForDividendsTypeEnum: EnumOption? = null,
3636
val accountingRule: EnumOption? = null,
3737
val accountingMappings: AccountingMappings? = null,
38+
val clientSavingsAccounts: List<SavingsAccountSummary>? = emptyList(),
39+
) : Parcelable
40+
41+
@Serializable
42+
@Parcelize
43+
data class SavingsAccountSummary(
44+
val id: Int? = null,
45+
val savingsProductName: String? = null,
3846
) : Parcelable

core/model/src/commonMain/kotlin/org/mifos/mobile/core/model/entity/templates/shares/SharePageItem.kt

Lines changed: 0 additions & 37 deletions
This file was deleted.

core/model/src/commonMain/kotlin/org/mifos/mobile/core/model/entity/templates/shares/ShareProduct.kt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@ import org.mifos.mobile.core.model.Parcelize
1616
@Serializable
1717
@Parcelize
1818
data class ShareProduct(
19-
val pageItems: List<SharePageItem>? = null,
20-
val totalFilteredRecords: Int? = null,
19+
val accountingRule: AccountingRule? = null,
20+
val allowDividendCalculationForInactiveClients: Boolean? = null,
21+
val currency: Currency? = null,
22+
val description: String? = null,
23+
val id: Int? = null,
24+
val lockPeriodTypeEnum: LockPeriodTypeEnum? = null,
25+
val lockinPeriod: Int? = null,
26+
val maximumShares: Int? = null,
27+
val minimumActivePeriod: Int? = null,
28+
val minimumActivePeriodForDividendsTypeEnum: MinimumActivePeriodForDividendsTypeEnum? = null,
29+
val minimumShares: Int? = null,
30+
val name: String? = null,
31+
val nominalShares: Int? = null,
32+
val shareCapital: Double? = null,
33+
val shortName: String? = null,
34+
val totalShares: Int? = null,
35+
val totalSharesIssued: Int? = null,
36+
val unitPrice: Double? = null,
2137
) : Parcelable

feature/share-application/src/commonMain/kotlin/org/mifos/mobile/feature/share/application/fillApplication/FillApplicationScreen.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ import mifos_mobile.feature.share_application.generated.resources.Res
3232
import mifos_mobile.feature.share_application.generated.resources.feature_apply_share_error_server
3333
import mifos_mobile.feature.share_application.generated.resources.feature_apply_share_label_currency
3434
import mifos_mobile.feature.share_application.generated.resources.feature_apply_share_label_current_price
35+
import mifos_mobile.feature.share_application.generated.resources.feature_apply_share_label_default_savings_account
3536
import mifos_mobile.feature.share_application.generated.resources.feature_apply_share_label_lockin_frequency
3637
import mifos_mobile.feature.share_application.generated.resources.feature_apply_share_label_lockin_frequency_type
3738
import mifos_mobile.feature.share_application.generated.resources.feature_apply_share_label_minimum_frequency
39+
import mifos_mobile.feature.share_application.generated.resources.feature_apply_share_label_minimum_frequency_type
3840
import mifos_mobile.feature.share_application.generated.resources.feature_apply_share_label_terms
3941
import mifos_mobile.feature.share_application.generated.resources.feature_apply_share_label_total_number_of_shares
4042
import mifos_mobile.feature.share_application.generated.resources.feature_apply_share_section_lockin_period
@@ -226,7 +228,7 @@ internal fun ShareFillApplicationForm(
226228

227229
MifosOutlinedTextField(
228230
value = state.totalNumberOfShares,
229-
onValueChange = { onAction(ShareApplicationAction.CurrentPriceChange(it)) },
231+
onValueChange = { onAction(ShareApplicationAction.TotalNumberOfSharesChange(it)) },
230232
label = stringResource(Res.string.feature_apply_share_label_total_number_of_shares),
231233
shape = DesignToken.shapes.medium,
232234
textStyle = MifosTypography.bodyLarge,
@@ -243,14 +245,14 @@ internal fun ShareFillApplicationForm(
243245
MifosOutlineDropdown(
244246
selectedText = state.defaultSavingsAccountName,
245247
items = state.accountIdNameMap,
246-
enabled = false,
248+
enabled = state.defaultAccounts.isNotEmpty(),
247249
onItemSelected = { id, value ->
248250
onAction(
249251
ShareApplicationAction.DefaultSavingsAccountChange
250252
(id, value),
251253
)
252254
},
253-
label = stringResource(Res.string.feature_apply_share_label_currency),
255+
label = stringResource(Res.string.feature_apply_share_label_default_savings_account),
254256
)
255257

256258
Text(
@@ -278,11 +280,10 @@ internal fun ShareFillApplicationForm(
278280
MifosOutlineDropdown(
279281
selectedText = state.selectedMapFrequencyTypeName,
280282
items = state.mapFrequencyMap,
281-
enabled = false,
282283
onItemSelected = { id, value ->
283284
onAction(ShareApplicationAction.MapFrequencyTypeChange(id, value))
284285
},
285-
label = stringResource(Res.string.feature_apply_share_label_currency),
286+
label = stringResource(Res.string.feature_apply_share_label_minimum_frequency_type),
286287
)
287288

288289
Text(
@@ -293,7 +294,7 @@ internal fun ShareFillApplicationForm(
293294

294295
MifosOutlinedTextField(
295296
value = state.lipFrequency,
296-
onValueChange = { onAction(ShareApplicationAction.MapFrequencyChange(it)) },
297+
onValueChange = { onAction(ShareApplicationAction.LipFrequencyChange(it)) },
297298
label = stringResource(Res.string.feature_apply_share_label_lockin_frequency),
298299
shape = DesignToken.shapes.medium,
299300
textStyle = MifosTypography.bodyLarge,

0 commit comments

Comments
 (0)