Skip to content

Commit ec227fc

Browse files
authored
Implement Charges Step for New Recurring Deposits Account Flow (#2554)
1 parent 57c25d3 commit ec227fc

File tree

15 files changed

+505
-122
lines changed

15 files changed

+505
-122
lines changed

core/database/src/commonMain/kotlin/com/mifos/room/entities/templates/recurringDeposit/RecurringDepositAccountTemplate.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ data class RecurringDepositAccountTemplate(
4444
val adjustAdvanceTowardsFuturePayments: Boolean? = null,
4545
val allowWithdrawal: Boolean? = null,
4646
@IgnoredOnParcel val chargeOptions: List<ChargeOption>? = null,
47-
// val charges: List<Any?>? = null,
4847
val clientId: Int? = null,
4948
val clientName: String? = null,
5049
@IgnoredOnParcel val currency: Currency? = null,

core/model/src/commonMain/kotlin/com/mifos/core/model/objects/payloads/RecurringDepositAccountPayload.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import kotlinx.serialization.Serializable
1313

1414
@Serializable
1515
data class RecurringDepositAccountPayload(
16-
// val charges: List<Any>? = null,
16+
val charges: List<ChargeItem>? = null,
1717
val adjustAdvanceTowardsFuturePayments: Boolean? = null,
1818
val allowWithdrawal: Boolean? = null,
1919
val clientId: Int? = null,
@@ -39,3 +39,9 @@ data class RecurringDepositAccountPayload(
3939
val recurringFrequencyType: Int? = null,
4040
val submittedOnDate: String? = null,
4141
)
42+
43+
@Serializable
44+
data class ChargeItem(
45+
val chargeId: Int? = null,
46+
val amount: Double? = null,
47+
)

feature/client/src/commonMain/composeResources/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@
583583
<string name="feature_share_account_charge_edit_charge">Edit Charge</string>
584584
<string name="feature_share_account_charge_add">Add</string>
585585
<string name="feature_share_account_charge_btn_add_new">Add</string>
586+
<string name="feature_share_account_charge_click_on_add_new">Click on Add New to Add Charge</string>
586587

587588

588589
<!-- Handle Error-->

feature/client/src/commonMain/kotlin/com/mifos/feature/client/createShareAccount/CreateShareAccountScreen.kt

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import androidclient.feature.client.generated.resources.feature_share_account_ba
1414
import androidclient.feature.client.generated.resources.feature_share_account_charge_add
1515
import androidclient.feature.client.generated.resources.feature_share_account_charge_add_new_charge
1616
import androidclient.feature.client.generated.resources.feature_share_account_charge_btn_add_new
17+
import androidclient.feature.client.generated.resources.feature_share_account_charge_click_on_add_new
1718
import androidclient.feature.client.generated.resources.feature_share_account_charge_edit_charge
1819
import androidclient.feature.client.generated.resources.feature_share_account_charge_view_charges
1920
import androidclient.feature.client.generated.resources.feature_share_account_charges
@@ -48,6 +49,7 @@ import com.mifos.core.ui.components.Actions
4849
import com.mifos.core.ui.components.AddChargeBottomSheet
4950
import com.mifos.core.ui.components.MifosActionsChargeListingComponent
5051
import com.mifos.core.ui.components.MifosBreadcrumbNavBar
52+
import com.mifos.core.ui.components.MifosEmptyCard
5153
import com.mifos.core.ui.components.MifosProgressIndicator
5254
import com.mifos.core.ui.components.MifosProgressIndicatorOverlay
5355
import com.mifos.core.ui.components.MifosStepper
@@ -118,6 +120,7 @@ fun CreateShareAccountDialog(
118120
onAction = onAction,
119121
)
120122
}
123+
121124
is CreateShareAccountState.DialogState.SuccessResponseStatus -> {
122125
LaunchedEffect(state.launchEffectKey) {
123126
snackbarHostState.showSnackbar(
@@ -132,6 +135,7 @@ fun CreateShareAccountDialog(
132135
}
133136
}
134137
}
138+
135139
null -> Unit
136140
}
137141
}
@@ -287,35 +291,42 @@ private fun ShowChargesDialog(
287291
text = stringResource(Res.string.feature_share_account_charge_view_charges),
288292
style = MifosTypography.titleMediumEmphasized,
289293
)
290-
state.addedCharges.forEachIndexed { index, charge ->
291-
val chargesValue = state.chargeOptions
292-
.firstOrNull { it.id == charge.chargeId }
293-
MifosActionsChargeListingComponent(
294-
chargeTitle = chargesValue?.name ?: "",
295-
type = chargesValue?.chargeCalculationType?.value ?: "",
296-
collectedOn = chargesValue?.chargeTimeType?.value ?: "",
297-
amount = charge.amount.toString(),
298-
onActionClicked = { action ->
299-
when (action) {
300-
is Actions.Delete -> {
301-
onAction(
302-
CreateShareAccountAction.DeleteChargeFromSelectedCharges(
303-
index,
304-
),
305-
)
306-
}
294+
if (state.addedCharges.isNotEmpty()) {
295+
state.addedCharges.forEachIndexed { index, charge ->
296+
val chargesValue = state.chargeOptions
297+
.firstOrNull { it.id == charge.chargeId }
298+
MifosActionsChargeListingComponent(
299+
chargeTitle = chargesValue?.name ?: "",
300+
type = chargesValue?.chargeCalculationType?.value ?: "",
301+
collectedOn = chargesValue?.chargeTimeType?.value ?: "",
302+
amount = charge.amount.toString(),
303+
onActionClicked = { action ->
304+
when (action) {
305+
is Actions.Delete -> {
306+
expandedIndex = -1
307+
onAction(
308+
CreateShareAccountAction.DeleteChargeFromSelectedCharges(
309+
index,
310+
),
311+
)
312+
}
307313

308-
is Actions.Edit -> {
309-
onAction(CreateShareAccountAction.EditChargeDialog(index))
310-
}
314+
is Actions.Edit -> {
315+
onAction(CreateShareAccountAction.EditChargeDialog(index))
316+
}
311317

312-
else -> {}
313-
}
314-
},
315-
isExpanded = expandedIndex == index,
316-
onExpandToggle = {
317-
expandedIndex = if (expandedIndex == index) -1 else index
318-
},
318+
else -> {}
319+
}
320+
},
321+
isExpanded = expandedIndex == index,
322+
onExpandToggle = {
323+
expandedIndex = if (expandedIndex == index) -1 else index
324+
},
325+
)
326+
}
327+
} else {
328+
MifosEmptyCard(
329+
msg = stringResource(Res.string.feature_share_account_charge_click_on_add_new),
319330
)
320331
}
321332
}

feature/client/src/commonMain/kotlin/com/mifos/feature/client/createShareAccount/pages/ChargesPage.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fun ChargesPage(
4949
modifier: Modifier = Modifier,
5050
onAction: (CreateShareAccountAction) -> Unit,
5151
) {
52-
Column(modifier = Modifier.fillMaxSize()) {
52+
Column(modifier = Modifier.fillMaxSize().padding(bottom = DesignToken.padding.large)) {
5353
Column(
5454
modifier = modifier.weight(1f).verticalScroll(rememberScrollState()),
5555
) {

feature/client/src/commonMain/kotlin/com/mifos/feature/client/createShareAccount/pages/TermsPage.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ fun TermsPage(
138138
onValueChange = {
139139
onAction(CreateShareAccountAction.OnTotalSharesChange(it))
140140
},
141-
label = stringResource(Res.string.feature_share_account_terms_total_shares),
141+
label = stringResource(Res.string.feature_share_account_terms_total_shares) + "*",
142142
config = MifosTextFieldConfig(
143143
keyboardOptions = KeyboardOptions(
144144
keyboardType = KeyboardType.Number,
@@ -162,7 +162,7 @@ fun TermsPage(
162162
options = state.savingsAccountOptions.map {
163163
it.accountNo + (it.savingsProductName?.let { name -> " - $name" }.orEmpty())
164164
},
165-
label = stringResource(Res.string.feature_share_account_terms_default_savings_account),
165+
label = stringResource(Res.string.feature_share_account_terms_default_savings_account) + "*",
166166
errorMessage = state.savingsAccountError?.let { stringResource(it) },
167167
)
168168

feature/loan/src/commonMain/composeResources/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@
221221
<string name="amount">Amount</string>
222222
<string name="type">Type</string>
223223
<string name="collected_on">Collected On</string>
224+
<string name="click_on_add_new">Click on Add New to Add Charge</string>
225+
224226

225227
<!-- Repayment Schedule -->
226228
<string name="repayment_schedule">Repayment Schedule</string>

feature/loan/src/commonMain/kotlin/com/mifos/feature/loan/newLoanAccount/NewLoanAccountScreen.kt

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import androidclient.feature.loan.generated.resources.add_new
1515
import androidclient.feature.loan.generated.resources.add_new_charge
1616
import androidclient.feature.loan.generated.resources.add_new_collateral
1717
import androidclient.feature.loan.generated.resources.back
18+
import androidclient.feature.loan.generated.resources.click_on_add_new
1819
import androidclient.feature.loan.generated.resources.collateral
1920
import androidclient.feature.loan.generated.resources.edit_charge
2021
import androidclient.feature.loan.generated.resources.feature_loan_cancel
@@ -63,6 +64,7 @@ import com.mifos.core.ui.components.Actions
6364
import com.mifos.core.ui.components.AddChargeBottomSheet
6465
import com.mifos.core.ui.components.MifosActionsChargeListingComponent
6566
import com.mifos.core.ui.components.MifosBreadcrumbNavBar
67+
import com.mifos.core.ui.components.MifosEmptyCard
6668
import com.mifos.core.ui.components.MifosListingComponentOutline
6769
import com.mifos.core.ui.components.MifosListingRowItem
6870
import com.mifos.core.ui.components.MifosProgressIndicator
@@ -393,7 +395,7 @@ private fun AddNewChargeDialog(
393395
} else {
394396
stringResource(Res.string.add)
395397
},
396-
dismissText = stringResource(Res.string.feature_loan_cancel),
398+
dismissText = stringResource(Res.string.back),
397399
showDatePicker = state.showChargesDatePick,
398400
selectedChargeName = if (state.chooseChargeIndex == -1) {
399401
""
@@ -481,34 +483,41 @@ private fun ShowChargesDialog(
481483
)
482484
}
483485
} else {
484-
state.addedCharges.forEachIndexed { index, it ->
485-
MifosActionsChargeListingComponent(
486-
chargeTitle = it.name.toString(),
487-
type = it.type.toString(),
488-
date = it.date,
489-
collectedOn = it.collectedOn,
490-
amount = it.amount.toString(),
491-
onActionClicked = { action ->
492-
when (action) {
493-
is Actions.Delete -> {
494-
onAction(
495-
NewLoanAccountAction.DeleteChargeFromSelectedCharges(
496-
index,
497-
),
498-
)
499-
}
486+
if (state.addedCharges.isNotEmpty()) {
487+
state.addedCharges.forEachIndexed { index, it ->
488+
MifosActionsChargeListingComponent(
489+
chargeTitle = it.name.toString(),
490+
type = it.type.toString(),
491+
date = it.date,
492+
collectedOn = it.collectedOn,
493+
amount = it.amount.toString(),
494+
onActionClicked = { action ->
495+
when (action) {
496+
is Actions.Delete -> {
497+
expandedIndex = -1
498+
onAction(
499+
NewLoanAccountAction.DeleteChargeFromSelectedCharges(
500+
index,
501+
),
502+
)
503+
}
500504

501-
is Actions.Edit -> {
502-
onAction(NewLoanAccountAction.EditChargeDialog(index))
503-
}
505+
is Actions.Edit -> {
506+
onAction(NewLoanAccountAction.EditChargeDialog(index))
507+
}
504508

505-
else -> {}
506-
}
507-
},
508-
isExpanded = expandedIndex == index,
509-
onExpandToggle = {
510-
expandedIndex = if (expandedIndex == index) -1 else index
511-
},
509+
else -> {}
510+
}
511+
},
512+
isExpanded = expandedIndex == index,
513+
onExpandToggle = {
514+
expandedIndex = if (expandedIndex == index) -1 else index
515+
},
516+
)
517+
}
518+
} else {
519+
MifosEmptyCard(
520+
msg = stringResource(Res.string.click_on_add_new),
512521
)
513522
}
514523
}

feature/recurringDeposit/src/commonMain/composeResources/values/feature_recurring_deposit_string.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,13 @@
6262
<string name="feature_recurring_deposit_yes">Yes</string>
6363
<string name="feature_recurring_deposit_no">No</string>
6464
<string name="feature_recurring_deposit_empty_date">Empty Date</string>
65+
<string name="feature_recurring_deposit_add_new_charge">Add New Charge</string>
66+
<string name="feature_recurring_deposit_active_charge">Active Charge</string>
67+
<string name="feature_recurring_deposit_btn_add_new">Add New</string>
68+
<string name="feature_recurring_deposit_amount">Amount</string>
69+
<string name="feature_recurring_deposit_collected_on">Collected On</string>
70+
<string name="feature_recurring_deposit_btn_add">Add</string>
71+
<string name="feature_recurring_deposit_edit_charge">Edit Charge</string>
72+
<string name="feature_recurring_deposit_view_charge">View Charges</string>
73+
<string name="feature_recurring_deposit_click_on_add_new">Click on Add New to Add Charge</string>
6574
</resources>

feature/recurringDeposit/src/commonMain/kotlin/com/mifos/feature/recurringDeposit/newRecurringDepositAccount/RecurringAccountScreen.kt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ import com.mifos.core.ui.components.MifosStepper
3232
import com.mifos.core.ui.components.Step
3333
import com.mifos.core.ui.util.EventsEffect
3434
import com.mifos.feature.recurringDeposit.newRecurringDepositAccount.RecurringAccountAction.NavigateToStep
35+
import com.mifos.feature.recurringDeposit.newRecurringDepositAccount.pages.AddNewChargeDialog
3536
import com.mifos.feature.recurringDeposit.newRecurringDepositAccount.pages.ChargesPage
3637
import com.mifos.feature.recurringDeposit.newRecurringDepositAccount.pages.DetailsPage
3738
import com.mifos.feature.recurringDeposit.newRecurringDepositAccount.pages.InterestPage
3839
import com.mifos.feature.recurringDeposit.newRecurringDepositAccount.pages.RateChart
3940
import com.mifos.feature.recurringDeposit.newRecurringDepositAccount.pages.SettingPage
41+
import com.mifos.feature.recurringDeposit.newRecurringDepositAccount.pages.ShowChargesDialog
4042
import com.mifos.feature.recurringDeposit.newRecurringDepositAccount.pages.TermsPage
4143
import org.jetbrains.compose.resources.stringResource
4244
import org.koin.compose.viewmodel.koinViewModel
@@ -83,6 +85,21 @@ fun RecurringAccountDialog(
8385
onAction = onAction,
8486
)
8587
}
88+
is RecurringAccountState.DialogState.AddNewCharge -> {
89+
AddNewChargeDialog(
90+
state = state,
91+
isEdit = state.dialogState.edit,
92+
onAction = onAction,
93+
index = state.dialogState.index,
94+
)
95+
}
96+
97+
RecurringAccountState.DialogState.ShowCharges -> {
98+
ShowChargesDialog(
99+
state = state,
100+
onAction = onAction,
101+
)
102+
}
86103
null -> Unit
87104
}
88105
}
@@ -121,7 +138,8 @@ private fun RecurringAccountScaffold(
121138
},
122139
Step(name = stringResource(Res.string.feature_recurring_deposit_step_charges)) {
123140
ChargesPage(
124-
onNext = { onAction(RecurringAccountAction.OnNextPress) },
141+
state = state,
142+
onAction = onAction,
125143
)
126144
},
127145
)

0 commit comments

Comments
 (0)