Skip to content

Commit 9e45f31

Browse files
authored
Documentation Added for feature/client-charge (#2980)
1 parent 2bcafd7 commit 9e45f31

File tree

8 files changed

+144
-32
lines changed

8 files changed

+144
-32
lines changed

feature/client-charge/src/commonMain/kotlin/org/mifos/mobile/feature/charge/chargeDetails/ChargeDetailScreen.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ import org.mifos.mobile.core.ui.component.MifosPoweredCard
5050
import org.mifos.mobile.core.ui.utils.EventsEffect
5151
import mifos_mobile.core.ui.generated.resources.Res as uiRes
5252

53+
/**
54+
* ChargeDetailScreen is a composable function that displays the details of a charge.
55+
*
56+
* @param onNavigateBack A lambda function that is called when the user navigates back.
57+
* @param modifier Modifier for the composable.
58+
* @param viewModel The ChargeDetailsViewModel for the screen.
59+
*/
5360
@Composable
5461
internal fun ChargeDetailScreen(
5562
onNavigateBack: () -> Unit,
@@ -110,6 +117,13 @@ internal fun ChargeDetailScreen(
110117
)
111118
}
112119

120+
/**
121+
* ChargeDetailsPaidComponent is a composable function that displays the details of a paid charge.
122+
*
123+
* @param refNo Reference number of the charge.
124+
* @param paidOn Date when the charge was paid.
125+
* @param modifier Modifier for the composable.
126+
*/
113127
@Composable
114128
fun ChargeDetailsPaidComponent(
115129
refNo: String,
@@ -153,6 +167,13 @@ fun ChargeDetailsPaidComponent(
153167
}
154168
}
155169

170+
/**
171+
* ChargeDetailsUnPaidComponent is a composable function that displays the details of an unpaid charge.
172+
*
173+
* @param amountPaidOn Date when the charge was paid.
174+
* @param onPayOutStanding A lambda function that is called when the user pays the outstanding amount.
175+
* @param modifier Modifier for the composable.
176+
*/
156177
@Composable
157178
fun ChargeDetailsUnPaidComponent(
158179
amountPaidOn: String,

feature/client-charge/src/commonMain/kotlin/org/mifos/mobile/feature/charge/chargeDetails/ChargeDetailsRoute.kt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,19 @@ import kotlinx.serialization.Serializable
1717
import org.mifos.mobile.core.common.DateHelper
1818
import org.mifos.mobile.core.model.entity.Charge
1919
import org.mifos.mobile.core.ui.composableWithStayTransitions
20-
20+
/**
21+
* Route for the Charges Details Screen.
22+
*
23+
* @param title Title of the charge.
24+
* @param date Date of the charge.
25+
* @param due Due amount of the charge.
26+
* @param paid Paid amount of the charge.
27+
* @param waived Waived amount of the charge.
28+
* @param outstanding Outstanding amount of the charge.
29+
* @param refNo Reference number of the charge.
30+
* @param paidOn Date when the charge was paid.
31+
* @param isPaid Whether the charge is paid or not.
32+
*/
2133
@Serializable
2234
data class ChargesDetailsRoute(
2335
val title: String = "",
@@ -41,6 +53,11 @@ fun NavGraphBuilder.chargesDetailsDestination(onNavigateBack: () -> Unit) {
4153

4254
// TODO: last charge paid On , needed that.
4355
// TODO: Add reference No instead of chargeId
56+
/**
57+
* Navigates to the Charges Details Screen.
58+
*
59+
* @param charge Charge object containing the details of the charge.
60+
*/
4461
fun NavController.navigateToChargesDetailsScreen(charge: Charge) {
4562
this.navigate(
4663
ChargesDetailsRoute(

feature/client-charge/src/commonMain/kotlin/org/mifos/mobile/feature/charge/chargeDetails/ChargeDetailsViewModel.kt

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ import mifos_mobile.feature.client_charge.generated.resources.waived
2121
import org.jetbrains.compose.resources.StringResource
2222
import org.mifos.mobile.core.ui.utils.BaseViewModel
2323

24+
/**
25+
* ChargeDetailsViewModel is a view model that handles the logic for the Charge Details Screen.
26+
*
27+
* @param savedStateHandle SavedStateHandle for the view model.
28+
*/
2429
internal class ChargeDetailsViewModel(
2530
savedStateHandle: SavedStateHandle,
2631
) : BaseViewModel<ChargeDetailsState, ChargeDetailsEvent, ChargeDetailsAction>(
@@ -42,7 +47,11 @@ internal class ChargeDetailsViewModel(
4247
)
4348
},
4449
) {
45-
50+
/**
51+
* Handles the actions for the Charge Details Screen.
52+
*
53+
* @param action The action to be handled.
54+
*/
4655
override fun handleAction(action: ChargeDetailsAction) {
4756
when (action) {
4857
ChargeDetailsAction.NavigateBack -> {
@@ -56,17 +65,36 @@ internal class ChargeDetailsViewModel(
5665
}
5766
}
5867

68+
/**
69+
* ChargeDetailsState is a data class that represents the state of the Charge Details Screen.
70+
*
71+
* @param details Map of charge details.
72+
* @param isPaid Boolean indicating if the charge is paid.
73+
* @param refNo Reference number of the charge.
74+
* @param paidOn Date when the charge was paid.
75+
*/
5976
data class ChargeDetailsState(
6077
val details: Map<StringResource, String> = emptyMap(),
6178
val isPaid: Boolean = false,
6279
val refNo: String = "",
6380
val paidOn: String = "",
6481
)
6582

83+
/**
84+
* ChargeDetailsEvent is a sealed interface that represents the events for the Charge Details Screen.
85+
*
86+
* @param NavigateBack Navigates back to the previous screen.
87+
*/
6688
sealed interface ChargeDetailsEvent {
6789
data object NavigateBack : ChargeDetailsEvent
6890
}
6991

92+
/**
93+
* ChargeDetailsAction is a sealed interface that represents the actions for the Charge Details Screen.
94+
*
95+
* @param NavigateBack Navigates back to the previous screen.
96+
* @param PayOutStanding Pays the outstanding amount of the charge.
97+
*/
7098
sealed interface ChargeDetailsAction {
7199
data object NavigateBack : ChargeDetailsAction
72100
data object PayOutStanding : ChargeDetailsAction

feature/client-charge/src/commonMain/kotlin/org/mifos/mobile/feature/charge/charges/ClientChargeRoute.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,37 @@ import kotlinx.serialization.Serializable
1717
import org.mifos.mobile.core.model.entity.Charge
1818
import org.mifos.mobile.core.ui.composableWithPushTransitions
1919

20+
/**
21+
* ClientChargesRoute is a data class that represents the route for the Client Charges Screen.
22+
*
23+
* @param chargeType Type of the charge.
24+
* @param chargeTypeId ID of the charge.
25+
*/
2026
@Serializable
2127
data class ClientChargesRoute(
2228
val chargeType: String,
2329
val chargeTypeId: Long? = null,
2430
)
2531

32+
/**
33+
* Navigates to the Client Charges Screen.
34+
*
35+
* @param chargeType Type of the charge.
36+
* @param chargeTypeId ID of the charge.
37+
*/
2638
fun NavController.navigateToClientChargeScreen(
2739
chargeType: String,
2840
chargeTypeId: Long?,
2941
) {
3042
this.navigate(ClientChargesRoute(chargeType, chargeTypeId))
3143
}
3244

45+
/**
46+
* Composable function that displays the Client Charges Screen.
47+
*
48+
* @param onNavigateBack A lambda function that is called when the user navigates back.
49+
* @param navigateToChargeDetailsScreen A lambda function that is called when the user clicks on a charge.
50+
*/
3351
fun NavGraphBuilder.clientChargesScreen(
3452
onNavigateBack: () -> Unit,
3553
navigateToChargeDetailsScreen: (charge: Charge) -> Unit,

feature/client-charge/src/commonMain/kotlin/org/mifos/mobile/feature/charge/charges/ClientChargeScreen.kt

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,14 @@ import org.mifos.mobile.core.ui.component.MifosProgressIndicator
4444
import org.mifos.mobile.core.ui.utils.EventsEffect
4545
import org.mifos.mobile.core.ui.utils.ScreenUiState
4646
import org.mifos.mobile.feature.charge.components.ClientChargeItem
47-
47+
/**
48+
* Composable function that displays the Client Charges Screen.
49+
*
50+
* @param navigateBack A lambda function that is called when the user navigates back.
51+
* @param onChargeClick A lambda function that is called when the user clicks on a charge.
52+
* @param modifier Modifier to be applied to the layout.
53+
* @param viewModel ViewModel that provides the state and actions for the screen.
54+
*/
4855
@Composable
4956
internal fun ClientChargeScreen(
5057
navigateBack: () -> Unit,
@@ -87,6 +94,13 @@ internal fun ClientChargeScreen(
8794
)
8895
}
8996

97+
/**
98+
* Composable function that displays the Client Charges Screen.
99+
*
100+
* @param state State of the screen.
101+
* @param modifier Modifier to be applied to the layout.
102+
* @param onAction A lambda function that is called when the user performs an action.
103+
*/
90104
@Composable
91105
private fun ClientChargeScreen(
92106
state: ClientChargeState,
@@ -149,6 +163,13 @@ private fun ClientChargeScreen(
149163
}
150164
}
151165

166+
/**
167+
* Composable function that displays the content of the Client Charges Screen.
168+
*
169+
* @param chargesList List of charges to be displayed.
170+
* @param onChargeClick A lambda function that is called when the user clicks on a charge.
171+
* @param modifier Modifier to be applied to the layout.
172+
*/
152173
@Composable
153174
private fun ClientChargeContent(
154175
chargesList: List<Charge>,
@@ -164,6 +185,12 @@ private fun ClientChargeContent(
164185
}
165186
}
166187

188+
/**
189+
* Composable function that displays the dialogs of the Client Charges Screen.
190+
*
191+
* @param dialogState Dialog state used for showing loading or error.
192+
* @param onDismissRequest A lambda function that is called when the user dismisses the dialog.
193+
*/
167194
@Composable
168195
private fun ClientChargeDialogs(
169196
dialogState: ClientChargeState.DialogState?,

feature/client-charge/src/commonMain/kotlin/org/mifos/mobile/feature/charge/charges/ClientChargeViewModel.kt

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ internal class ClientChargeViewModel(
125125
}
126126
}
127127

128+
/**
129+
* Handles the result of the network status.
130+
*
131+
* @param isOnline Boolean indicating if the network is online.
132+
*/
128133
private fun handleNetworkResult(isOnline: Boolean) {
129134
updateState {
130135
it.copy(networkStatus = isOnline)
@@ -146,6 +151,10 @@ internal class ClientChargeViewModel(
146151
}
147152
}
148153

154+
/**
155+
* Retries loading charges if the network is available.
156+
* If the network is not available, it sets the UI state to Network.
157+
*/
149158
private fun retry() {
150159
viewModelScope.launch {
151160
if (!state.networkStatus) {
@@ -304,67 +313,47 @@ data class ClientChargeState(
304313

305314
/**
306315
* UI events emitted from the ViewModel to be handled by the UI layer.
316+
*
317+
* @property ShowToast Shows a toast message.
318+
* @property Navigate Navigates to the charge creation screen.
319+
* @property OnChargeClick Triggered when a user clicks on a charge item.
307320
*/
308321
sealed interface ClientChargeEvent {
309-
/**
310-
* Shows a toast message.
311-
* @param message Message to display.
312-
*/
313322
data class ShowToast(val message: String) : ClientChargeEvent
314323

315-
/** Navigates to the charge creation screen. */
316324
data object Navigate : ClientChargeEvent
317325

318-
/**
319-
* Triggered when a charge item is clicked.
320-
* @param charge The clicked charge.
321-
*/
322326
data class OnChargeClick(val charge: Charge) : ClientChargeEvent
323327
}
324328

325329
/**
326330
* Actions dispatched from the UI or internal processes.
331+
*
332+
* @property RefreshCharges Refreshes the list of charges.
333+
* @property OnNavigate Navigates to the charge creation screen.
334+
* @property OnDismissDialog Dismisses any open dialog (error/loading).
335+
* @property OnChargeClick Triggered when a user clicks on a charge item.
327336
*/
328337
sealed interface ClientChargeAction {
329338

330-
/** Refreshes the list of charges. */
331339
data object RefreshCharges : ClientChargeAction
332340

333-
/** Navigates to the charge creation screen. */
334341
data object OnNavigate : ClientChargeAction
335342

336-
/** Dismisses any open dialog (error/loading). */
337343
data object OnDismissDialog : ClientChargeAction
338344

339-
/**
340-
* Triggered when a user clicks on a charge item.
341-
* @param charge The clicked charge.
342-
*/
343345
data class OnChargeClick(val charge: Charge) : ClientChargeAction
344346

345-
/** Receive the network status */
346347
data class ReceiveNetworkResult(val isOnline: Boolean) : ClientChargeAction
347348

348-
/** Action to trigger to refetch the charges */
349349
data object Retry : ClientChargeAction
350350

351-
/**
352-
* Internal actions used by the ViewModel.
353-
*/
354351
sealed class Internal : ClientChargeAction {
355352

356-
/**
357-
* Result from fetching loan or savings charges.
358-
* @param result DataState containing a list of charges.
359-
*/
360353
data class ReceiveLoanOrSavingsChargesResult(
361354
val result: DataState<List<Charge>>,
362355
) : Internal()
363356

364-
/**
365-
* Result from fetching client charges.
366-
* @param result DataState containing a paginated response.
367-
*/
368357
data class ReceiveClientChargesResult(
369358
val result: DataState<Page<Charge>>,
370359
) : Internal()

feature/client-charge/src/commonMain/kotlin/org/mifos/mobile/feature/charge/components/ClientChargeItem.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ import org.mifos.mobile.core.designsystem.theme.MifosMobileTheme
4141
import org.mifos.mobile.core.designsystem.theme.MifosTypography
4242
import org.mifos.mobile.core.model.entity.Charge
4343

44+
/**
45+
* Composable function that displays a charge item.
46+
*
47+
* @param charge The charge to be displayed.
48+
* @param onChargeClick A lambda function that is called when the user clicks on a charge.
49+
* @param modifier Modifier to be applied to the layout.
50+
*/
4451
@Composable
4552
fun ClientChargeItem(
4653
charge: Charge,

feature/client-charge/src/commonMain/kotlin/org/mifos/mobile/feature/charge/navigation/ClientChargesNavGraph.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ import org.mifos.mobile.feature.charge.charges.clientChargesScreen
2525
@Serializable
2626
data object ClientChargesNavGraphRoute
2727

28+
/**
29+
* Navigation graph for the Client Charges Screen.
30+
*
31+
* @param navController The NavController to be used for navigation.
32+
*/
2833
fun NavGraphBuilder.clientChargeNavGraph(
2934
navController: NavController,
3035
// navigateBack: () -> Unit,

0 commit comments

Comments
 (0)