From acda6fd840b4de5819bacc2f8ce2db18a6f29a7b Mon Sep 17 00:00:00 2001 From: Aditya3815 Date: Mon, 16 Jun 2025 21:53:43 +0530 Subject: [PATCH 01/13] start collection-sheet enhancement --- feature/collectionSheet/build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/feature/collectionSheet/build.gradle.kts b/feature/collectionSheet/build.gradle.kts index 8f7c9bf599..bdff03f317 100644 --- a/feature/collectionSheet/build.gradle.kts +++ b/feature/collectionSheet/build.gradle.kts @@ -13,6 +13,7 @@ plugins { alias(libs.plugins.kotlin.serialization) } + android { namespace = "com.mifos.feature.collection_sheet" } From e87f0c53cbd51dae45880659347a8aa76a24a872 Mon Sep 17 00:00:00 2001 From: Aditya3815 Date: Tue, 17 Jun 2025 01:36:36 +0530 Subject: [PATCH 02/13] Add Preview dependencies and annotation DevicePreview to Preview --- feature/collectionSheet/build.gradle.kts | 5 +++++ .../IndividualCollectionSheetScreen.kt | 3 ++- .../IndividualCollectionSheetDetailsScreen.kt | 9 +++++---- .../NewIndividualCollectionSheetScreen.kt | 5 +++-- .../paymentDetails/PaymentDetailsScreen.kt | 3 ++- .../SavedIndividualCollectionSheetCompose.kt | 3 ++- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/feature/collectionSheet/build.gradle.kts b/feature/collectionSheet/build.gradle.kts index bdff03f317..30a0b80d33 100644 --- a/feature/collectionSheet/build.gradle.kts +++ b/feature/collectionSheet/build.gradle.kts @@ -26,6 +26,7 @@ kotlin { implementation(compose.ui) implementation(projects.core.domain) implementation(libs.kotlinx.serialization.json) + implementation(compose.components.uiToolingPreview) implementation(libs.coil.core) implementation(libs.coil.kt) @@ -33,4 +34,8 @@ kotlin { } } +} + +dependencies { + debugImplementation(compose.uiTooling) } \ No newline at end of file diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheet/IndividualCollectionSheetScreen.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheet/IndividualCollectionSheetScreen.kt index 74b23639ab..dd9ed7e296 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheet/IndividualCollectionSheetScreen.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheet/IndividualCollectionSheetScreen.kt @@ -30,6 +30,7 @@ import com.mifos.feature.individualCollectionSheet.newIndividualCollectionSheet. import com.mifos.feature.individualCollectionSheet.savedIndividualCollectionSheet.SavedIndividualCollectionSheetCompose import com.mifos.room.entities.collectionsheet.IndividualCollectionSheet import org.jetbrains.compose.resources.stringResource +import org.jetbrains.compose.ui.tooling.preview.Preview @Composable internal fun IndividualCollectionSheetScreen( @@ -69,7 +70,7 @@ enum class IndividualCollectionSheetScreenContents { SAVED, } -@DevicePreview +@Preview @Composable private fun IndividualCollectionSheetScreenPreview() { IndividualCollectionSheetScreen(onBackPressed = {}, onDetail = { _, _ -> }) diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt index c2194d573b..275ba1687f 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt @@ -66,6 +66,7 @@ import com.mifos.room.entities.noncore.BulkRepaymentTransactions import kotlinx.coroutines.launch import org.jetbrains.compose.resources.painterResource import org.jetbrains.compose.resources.stringResource +import org.jetbrains.compose.ui.tooling.preview.Preview import org.koin.compose.viewmodel.koinViewModel @Composable @@ -289,7 +290,7 @@ private fun IndividualCollectionSheetItem( } } -@DevicePreview +@Preview @Composable private fun IndividualCollectionSheetDetailsScreenEmptyPreview() { IndividualCollectionSheetDetailsScreen( @@ -303,7 +304,7 @@ private fun IndividualCollectionSheetDetailsScreenEmptyPreview() { ) } -@DevicePreview +@Preview @Composable private fun IndividualCollectionSheetDetailsScreenErrorPreview() { IndividualCollectionSheetDetailsScreen( @@ -317,7 +318,7 @@ private fun IndividualCollectionSheetDetailsScreenErrorPreview() { ) } -@DevicePreview +@Preview @Composable private fun IndividualCollectionSheetDetailsScreenLoadingPreview() { IndividualCollectionSheetDetailsScreen( @@ -331,7 +332,7 @@ private fun IndividualCollectionSheetDetailsScreenLoadingPreview() { ) } -@DevicePreview +@Preview @Composable private fun IndividualCollectionSheetDetailsScreenSuccessPreview() { IndividualCollectionSheetDetailsScreen( diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt index 7ff2500e44..145dacf45b 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt @@ -72,6 +72,7 @@ import com.mifos.room.entities.organisation.OfficeEntity import com.mifos.room.entities.organisation.StaffEntity import kotlinx.datetime.Clock import org.jetbrains.compose.resources.stringResource +import org.jetbrains.compose.ui.tooling.preview.Preview import org.koin.compose.viewmodel.koinViewModel @Composable @@ -388,7 +389,7 @@ private fun CollectionSheetDialogContent( ) } -@DevicePreview +@Preview @Composable private fun NewIndividualCollectionSheetPreview() { Column { @@ -438,7 +439,7 @@ val sampleOfficeList = List(10) { OfficeEntity(id = it, name = "Name") } -@DevicePreview +@Preview @Composable private fun CollectionSheetDialogContentPreview() { CollectionSheetDialogContent(date = "19 June 2024", member = "5", fillNow = {}, onDismiss = {}) diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/paymentDetails/PaymentDetailsScreen.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/paymentDetails/PaymentDetailsScreen.kt index 9018b9d606..1ea4679ecf 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/paymentDetails/PaymentDetailsScreen.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/paymentDetails/PaymentDetailsScreen.kt @@ -62,6 +62,7 @@ import com.mifos.core.network.model.IndividualCollectionSheetPayload import com.mifos.core.ui.util.DevicePreview import com.mifos.room.entities.noncore.BulkRepaymentTransactions import org.jetbrains.compose.resources.stringResource +import org.jetbrains.compose.ui.tooling.preview.Preview import org.koin.compose.viewmodel.koinViewModel @Composable @@ -385,7 +386,7 @@ private fun MifosButtonRow( } @Composable -@DevicePreview +@Preview private fun PreviewPaymentDetails(modifier: Modifier = Modifier) { PaymentsDetailsScreen( modifier = modifier, diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/savedIndividualCollectionSheet/SavedIndividualCollectionSheetCompose.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/savedIndividualCollectionSheet/SavedIndividualCollectionSheetCompose.kt index b9fa65b409..19bebbef45 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/savedIndividualCollectionSheet/SavedIndividualCollectionSheetCompose.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/savedIndividualCollectionSheet/SavedIndividualCollectionSheetCompose.kt @@ -26,6 +26,7 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.sp import com.mifos.core.ui.util.DevicePreview import org.jetbrains.compose.resources.stringResource +import org.jetbrains.compose.ui.tooling.preview.Preview @Composable internal fun SavedIndividualCollectionSheetCompose( @@ -55,7 +56,7 @@ internal fun SavedIndividualCollectionSheetCompose( } } -@DevicePreview +@Preview @Composable private fun SavedIndividualCollectionSheetComposePreview() { SavedIndividualCollectionSheetCompose() From a6e63b810b4d67605bd30e151325ed078ba6fa2e Mon Sep 17 00:00:00 2001 From: Aditya3815 Date: Tue, 17 Jun 2025 12:01:16 +0530 Subject: [PATCH 03/13] Index 1 out of bounds for length 1 resolved --- .../dependencies/demoDebugRuntimeClasspath.txt | 3 +++ .../dependencies/prodDebugRuntimeClasspath.txt | 3 +++ .../IndividualCollectionSheetScreen.kt | 1 - .../IndividualCollectionSheetDetailsScreen.kt | 1 - .../NewIndividualCollectionSheetScreen.kt | 17 +++++++++++++---- .../paymentDetails/PaymentDetailsScreen.kt | 1 - .../SavedIndividualCollectionSheetCompose.kt | 1 - 7 files changed, 19 insertions(+), 8 deletions(-) diff --git a/cmp-android/dependencies/demoDebugRuntimeClasspath.txt b/cmp-android/dependencies/demoDebugRuntimeClasspath.txt index 5f11ef53c3..b727cc3dbc 100644 --- a/cmp-android/dependencies/demoDebugRuntimeClasspath.txt +++ b/cmp-android/dependencies/demoDebugRuntimeClasspath.txt @@ -285,6 +285,9 @@ org.jetbrains.compose.ui:ui-backhandler:1.8.0-alpha03 org.jetbrains.compose.ui:ui-geometry:1.7.3 org.jetbrains.compose.ui:ui-graphics:1.7.3 org.jetbrains.compose.ui:ui-text:1.7.3 +org.jetbrains.compose.ui:ui-tooling-data:1.7.0-rc01 +org.jetbrains.compose.ui:ui-tooling-preview:1.7.0-rc01 +org.jetbrains.compose.ui:ui-tooling:1.7.0-rc01 org.jetbrains.compose.ui:ui-unit:1.7.3 org.jetbrains.compose.ui:ui-util:1.8.0-alpha03 org.jetbrains.compose.ui:ui:1.7.3 diff --git a/cmp-android/dependencies/prodDebugRuntimeClasspath.txt b/cmp-android/dependencies/prodDebugRuntimeClasspath.txt index 5f11ef53c3..b727cc3dbc 100644 --- a/cmp-android/dependencies/prodDebugRuntimeClasspath.txt +++ b/cmp-android/dependencies/prodDebugRuntimeClasspath.txt @@ -285,6 +285,9 @@ org.jetbrains.compose.ui:ui-backhandler:1.8.0-alpha03 org.jetbrains.compose.ui:ui-geometry:1.7.3 org.jetbrains.compose.ui:ui-graphics:1.7.3 org.jetbrains.compose.ui:ui-text:1.7.3 +org.jetbrains.compose.ui:ui-tooling-data:1.7.0-rc01 +org.jetbrains.compose.ui:ui-tooling-preview:1.7.0-rc01 +org.jetbrains.compose.ui:ui-tooling:1.7.0-rc01 org.jetbrains.compose.ui:ui-unit:1.7.3 org.jetbrains.compose.ui:ui-util:1.8.0-alpha03 org.jetbrains.compose.ui:ui:1.7.3 diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheet/IndividualCollectionSheetScreen.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheet/IndividualCollectionSheetScreen.kt index dd9ed7e296..8bbab7e244 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheet/IndividualCollectionSheetScreen.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheet/IndividualCollectionSheetScreen.kt @@ -25,7 +25,6 @@ import androidx.compose.ui.Modifier import com.mifos.core.designsystem.component.MifosScaffold import com.mifos.core.designsystem.component.MifosTabRow import com.mifos.core.designsystem.utility.TabContent -import com.mifos.core.ui.util.DevicePreview import com.mifos.feature.individualCollectionSheet.newIndividualCollectionSheet.NewIndividualCollectionSheetScreen import com.mifos.feature.individualCollectionSheet.savedIndividualCollectionSheet.SavedIndividualCollectionSheetCompose import com.mifos.room.entities.collectionsheet.IndividualCollectionSheet diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt index 275ba1687f..801cb8c54e 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt @@ -59,7 +59,6 @@ import com.mifos.core.designsystem.icon.MifosIcons import com.mifos.core.model.objects.account.loan.PaymentTypeOptions import com.mifos.core.model.objects.collectionsheets.LoanAndClientName import com.mifos.core.network.model.IndividualCollectionSheetPayload -import com.mifos.core.ui.util.DevicePreview import com.mifos.room.entities.collectionsheet.ClientCollectionSheet import com.mifos.room.entities.collectionsheet.IndividualCollectionSheet import com.mifos.room.entities.noncore.BulkRepaymentTransactions diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt index 145dacf45b..59390989b7 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt @@ -66,7 +66,6 @@ import com.mifos.core.designsystem.component.MifosDatePickerTextField import com.mifos.core.designsystem.component.MifosScaffold import com.mifos.core.designsystem.component.MifosTextFieldDropdown import com.mifos.core.network.model.RequestCollectionSheetPayload -import com.mifos.core.ui.util.DevicePreview import com.mifos.room.entities.collectionsheet.IndividualCollectionSheet import com.mifos.room.entities.organisation.OfficeEntity import com.mifos.room.entities.organisation.StaffEntity @@ -121,7 +120,11 @@ internal fun NewIndividualCollectionSheetScreen( var showCollectionSheetDialog by rememberSaveable { mutableStateOf(false) } var showDatePicker by rememberSaveable { mutableStateOf(false) } - var repaymentDate by rememberSaveable { mutableLongStateOf(Clock.System.now().toEpochMilliseconds()) } + var repaymentDate by rememberSaveable { + mutableLongStateOf( + Clock.System.now().toEpochMilliseconds(), + ) + } val datePickerState = rememberDatePickerState( initialSelectedDateMillis = repaymentDate, selectableDates = object : SelectableDates { @@ -230,7 +233,10 @@ internal fun NewIndividualCollectionSheetScreen( selectedStaff = "" }, onOptionSelected = { index, value -> - state.officeList[index].id.let { + println("Office selection - Index: $index, List size: ${state.officeList.size}, Value: $value") + val selectedOfficeEntity = + state.officeList.find { it.name.toString() == value } + selectedOfficeEntity?.id?.let { getStaffList(it) officeId = it } @@ -255,7 +261,10 @@ internal fun NewIndividualCollectionSheetScreen( selectedStaff = it }, onOptionSelected = { index, value -> - state.staffList[index].id?.let { + println("Staff selection - Index: $index, List size: ${state.staffList.size}, Value: $value") + val selectedStaffEntity = + state.staffList.find { it.displayName.toString() == value } + selectedStaffEntity?.id?.let { staffId = it } selectedStaff = value diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/paymentDetails/PaymentDetailsScreen.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/paymentDetails/PaymentDetailsScreen.kt index 1ea4679ecf..e4d669fe2c 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/paymentDetails/PaymentDetailsScreen.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/paymentDetails/PaymentDetailsScreen.kt @@ -59,7 +59,6 @@ import com.mifos.core.designsystem.component.MifosTextFieldDropdown import com.mifos.core.model.objects.account.loan.PaymentTypeOptions import com.mifos.core.model.objects.collectionsheets.LoanAndClientName import com.mifos.core.network.model.IndividualCollectionSheetPayload -import com.mifos.core.ui.util.DevicePreview import com.mifos.room.entities.noncore.BulkRepaymentTransactions import org.jetbrains.compose.resources.stringResource import org.jetbrains.compose.ui.tooling.preview.Preview diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/savedIndividualCollectionSheet/SavedIndividualCollectionSheetCompose.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/savedIndividualCollectionSheet/SavedIndividualCollectionSheetCompose.kt index 19bebbef45..9e23bd9715 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/savedIndividualCollectionSheet/SavedIndividualCollectionSheetCompose.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/savedIndividualCollectionSheet/SavedIndividualCollectionSheetCompose.kt @@ -24,7 +24,6 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.sp -import com.mifos.core.ui.util.DevicePreview import org.jetbrains.compose.resources.stringResource import org.jetbrains.compose.ui.tooling.preview.Preview From 5832ff9111fdd2ca2e59b54a753f2e248646d6fa Mon Sep 17 00:00:00 2001 From: Aditya3815 Date: Tue, 24 Jun 2025 15:08:21 +0530 Subject: [PATCH 04/13] updated --- .../com/mifos/core/common/utils/Constants.kt | 1 + .../collectionsheets/LoanCollectionSheet.kt | 1 + .../composeResources/values/strings.xml | 12 + .../di/CollectionSheetModule.kt | 2 + .../GenerateCollectionSheetScreen.kt | 3 + .../IndividualCollectionSheetDetailScreen.kt | 579 ++++++++++++++++++ .../IndividualCollectionSheetDetailUiState.kt | 41 ++ ...ndividualCollectionSheetDetailViewModel.kt | 35 ++ .../navigation/CollectionSheetNavigation.kt | 66 +- .../navigation/CollectionSheetScreens.kt | 12 + .../NewIndividualCollectionSheetScreen.kt | 278 +++++---- 11 files changed, 900 insertions(+), 130 deletions(-) create mode 100644 feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetail/IndividualCollectionSheetDetailScreen.kt create mode 100644 feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetail/IndividualCollectionSheetDetailUiState.kt create mode 100644 feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetail/IndividualCollectionSheetDetailViewModel.kt diff --git a/core/common/src/commonMain/kotlin/com/mifos/core/common/utils/Constants.kt b/core/common/src/commonMain/kotlin/com/mifos/core/common/utils/Constants.kt index 4439a59355..52013b38ac 100644 --- a/core/common/src/commonMain/kotlin/com/mifos/core/common/utils/Constants.kt +++ b/core/common/src/commonMain/kotlin/com/mifos/core/common/utils/Constants.kt @@ -54,6 +54,7 @@ object Constants { const val SAVINGS_ACCOUNT_TRANSACTION_DEPOSIT = "Deposit" const val SAVINGS_ACCOUNT_TRANSACTION_WITHDRAWAL = "Withdrawal" const val DATA_TABLE_REGISTERED_NAME = "dataTableRegisteredName" + const val INDIVIDUAL_SHEET_DATE = "individual_sheet_date" const val CENTER_ID = "centerId" const val GROUP_ID = "groupId" const val GROUP_NAME = "groupName" diff --git a/core/model/src/commonMain/kotlin/com/mifos/core/model/objects/collectionsheets/LoanCollectionSheet.kt b/core/model/src/commonMain/kotlin/com/mifos/core/model/objects/collectionsheets/LoanCollectionSheet.kt index 210a3bd076..27b7dcdade 100644 --- a/core/model/src/commonMain/kotlin/com/mifos/core/model/objects/collectionsheets/LoanCollectionSheet.kt +++ b/core/model/src/commonMain/kotlin/com/mifos/core/model/objects/collectionsheets/LoanCollectionSheet.kt @@ -27,5 +27,6 @@ data class LoanCollectionSheet( val productId: Double? = null, val totalDue: Double = 0.0, val chargesDue: Double = 0.0, + val feeDue: Double = 0.0, val productShortName: String? = null, ) : Parcelable diff --git a/feature/collectionSheet/src/commonMain/composeResources/values/strings.xml b/feature/collectionSheet/src/commonMain/composeResources/values/strings.xml index c9661223da..90b0fe2084 100644 --- a/feature/collectionSheet/src/commonMain/composeResources/values/strings.xml +++ b/feature/collectionSheet/src/commonMain/composeResources/values/strings.xml @@ -39,6 +39,8 @@ Receipt Number Bank Number Save + Due Collections + Due Savings Collections Collection Details @@ -64,4 +66,14 @@ Productive Sheet Submitted Successfully Collection Sheet Submitted Successfully + Loan Account # + Product Name + Client Name + Charges + Actions + Add Payment + Deposit Account + Savings Account # + Account ID + \ No newline at end of file diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/di/CollectionSheetModule.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/di/CollectionSheetModule.kt index c5c77f57c5..d98a2457ea 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/di/CollectionSheetModule.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/di/CollectionSheetModule.kt @@ -10,6 +10,7 @@ package com.mifos.feature.individualCollectionSheet.di import com.mifos.feature.individualCollectionSheet.generateCollectionSheet.GenerateCollectionSheetViewModel +import com.mifos.feature.individualCollectionSheet.individualCollectionSheetDetail.IndividualCollectionSheetDetailViewModel import com.mifos.feature.individualCollectionSheet.individualCollectionSheetDetails.IndividualCollectionSheetDetailsViewModel import com.mifos.feature.individualCollectionSheet.newIndividualCollectionSheet.NewIndividualCollectionSheetViewModel import com.mifos.feature.individualCollectionSheet.paymentDetails.PaymentDetailsViewModel @@ -23,4 +24,5 @@ val CollectionSheetModule = module { viewModelOf(::NewIndividualCollectionSheetViewModel) viewModelOf(::PaymentDetailsViewModel) viewModelOf(::SavedIndividualCollectionSheetViewModel) + viewModelOf(::IndividualCollectionSheetDetailViewModel) } diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/generateCollectionSheet/GenerateCollectionSheetScreen.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/generateCollectionSheet/GenerateCollectionSheetScreen.kt index e20c7ed613..1e6c95efd3 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/generateCollectionSheet/GenerateCollectionSheetScreen.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/generateCollectionSheet/GenerateCollectionSheetScreen.kt @@ -38,6 +38,7 @@ import androidx.compose.material3.DatePicker import androidx.compose.material3.DatePickerDialog import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextFieldDefaults.contentPadding import androidx.compose.material3.SelectableDates import androidx.compose.material3.SnackbarHostState import androidx.compose.material3.Text @@ -56,6 +57,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle +import co.touchlab.kermit.Logger import com.mifos.core.common.utils.DateHelper import com.mifos.core.designsystem.component.MifosButton import com.mifos.core.designsystem.component.MifosCircularProgress @@ -355,6 +357,7 @@ private fun GenerateCollectionSheetContent( selectedStaffId, ) isProductiveResponse = true + Logger.d("Productive Collection Sheet") }, modifier = Modifier .fillMaxWidth() diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetail/IndividualCollectionSheetDetailScreen.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetail/IndividualCollectionSheetDetailScreen.kt new file mode 100644 index 0000000000..ac6b5b62a8 --- /dev/null +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetail/IndividualCollectionSheetDetailScreen.kt @@ -0,0 +1,579 @@ +/* + * Copyright 2025 Mifos Initiative + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * See https://github.com/openMF/android-client/blob/master/LICENSE.md + */ +package com.mifos.feature.individualCollectionSheet.individualCollectionSheetDetail + +import androidclient.feature.collectionsheet.generated.resources.Res +import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_actions +import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_add_payment +import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_charges +import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_client_name +import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_deposit_account +import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_due_collections +import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_due_savings_collections +import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_individual_collection_sheet +import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_loan_account +import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_product_name +import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_savings_account +import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_total_due +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.items +import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.SnackbarHostState +import androidx.compose.material3.Tab +import androidx.compose.material3.TabRow +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.dp +import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.mifos.core.designsystem.component.MifosButton +import com.mifos.core.designsystem.component.MifosCircularProgress +import com.mifos.core.designsystem.component.MifosScaffold +import com.mifos.room.entities.collectionsheet.IndividualCollectionSheet +import org.jetbrains.compose.resources.stringResource +import org.jetbrains.compose.ui.tooling.preview.Preview +import org.koin.compose.viewmodel.koinViewModel +import kotlin.math.roundToInt + +@Composable +internal fun IndividualCollectionSheetDetailScreen( + repaymentDate: String, + collectionSheet: IndividualCollectionSheet, + viewmodel: IndividualCollectionSheetDetailViewModel = koinViewModel(), + onAddPayment: (LoanCollectionItem) -> Unit = {}, + onAddSavingsPayment: (SavingsCollectionItem) -> Unit = {}, +) { + val state = viewmodel.individualCollectionSheetDetailUiState.collectAsStateWithLifecycle().value + + LaunchedEffect(collectionSheet) { + println("DEBUG: LaunchedEffect triggered with collectionSheet") + try { + viewmodel.setCollectionSheetData(repaymentDate, collectionSheet) + println("DEBUG: ViewModel data set successfully") + } catch (e: Exception) { + println("DEBUG: Error in LaunchedEffect: ${e.message}") + println("DEBUG: Full error: ${e.stackTraceToString()}") + } + } + + IndividualCollectionSheetDetailScreen( + state = state, + onAddPayment = onAddPayment, + onAddSavingsPayment = onAddSavingsPayment, + ) +} + +@Composable +internal fun IndividualCollectionSheetDetailScreen( + state: IndividualCollectionSheetDetailUiState, + modifier: Modifier = Modifier, + onAddPayment: (LoanCollectionItem) -> Unit = {}, + onAddSavingsPayment: (SavingsCollectionItem) -> Unit = {}, +) { + val snackbarHostState = remember { SnackbarHostState() } + var selectedTabIndex by rememberSaveable { mutableIntStateOf(0) } + + LaunchedEffect(key1 = state.error) { + state.error?.let { snackbarHostState.showSnackbar(it) } + } + + MifosScaffold( + modifier = modifier, + snackbarHostState = snackbarHostState, + topBar = { + Text( + modifier = Modifier.padding(16.dp), + text = stringResource(Res.string.feature_collection_sheet_individual_collection_sheet), + style = MaterialTheme.typography.titleLarge, + ) + }, + ) { paddingValues -> + if (state.isLoading) { + MifosCircularProgress() + } else { + Column( + modifier = Modifier + .fillMaxSize() + .padding(paddingValues), + ) { + ParametersSection( + repaymentDate = state.repaymentDate, + modifier = Modifier.padding(16.dp), + ) + + val tabs = listOf( + stringResource(Res.string.feature_collection_sheet_due_collections), + stringResource(Res.string.feature_collection_sheet_due_savings_collections), + ) + + TabRow( + selectedTabIndex = selectedTabIndex, + modifier = Modifier.fillMaxWidth(), + ) { + tabs.forEachIndexed { index, title -> + Tab( + selected = selectedTabIndex == index, + onClick = { selectedTabIndex = index }, + text = { + Text( + text = title, + style = MaterialTheme.typography.bodyMedium, + ) + }, + ) + } + } + + when (selectedTabIndex) { + 0 -> { + state.collectionSheet?.let { collectionSheet -> + DueCollectionsContent( + collectionSheet = collectionSheet, + onAddPayment = onAddPayment, + modifier = Modifier.weight(1f), + ) + } + } + 1 -> { + state.collectionSheet?.let { collectionSheet -> + DueSavingsCollectionsContent( + collectionSheet = collectionSheet, + onAddSavingsPayment = onAddSavingsPayment, + modifier = Modifier.weight(1f), + ) + } + } + } + } + } + } +} + +@Composable +private fun ParametersSection( + repaymentDate: String, + modifier: Modifier = Modifier, +) { + Card( + modifier = modifier.fillMaxWidth(), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.primaryContainer, + ), + ) { + Column( + modifier = Modifier.padding(16.dp), + ) { + Text( + text = "Parameters", + style = MaterialTheme.typography.titleMedium, + fontWeight = FontWeight.Bold, + ) + Spacer(modifier = Modifier.height(8.dp)) + Text( + text = "Repayment Date: $repaymentDate", + style = MaterialTheme.typography.bodyMedium, + ) + } + } +} + +@Composable +private fun DueCollectionsContent( + collectionSheet: IndividualCollectionSheet, + onAddPayment: (LoanCollectionItem) -> Unit, + modifier: Modifier = Modifier, +) { + val loanItems = remember(collectionSheet) { + try { + collectionSheet.clients?.flatMap { client -> + println("DEBUG: Processing client: ${client.clientName}, loans count: ${client.loans?.size}") + client.loans?.mapIndexed { index, loan -> + println("DEBUG: Processing loan $index: ${loan.loanId}") + val totalDue = (loan.chargesDue ?: 0.0) + (loan.feeDue ?: 0.0) + LoanCollectionItem( + loanId = loan.loanId ?: 0, + accountId = loan.accountId ?: "", + clientName = "${client.clientName}(${client.clientId})", + productName = "${loan.productShortName ?: ""}(${loan.loanId ?: 0})", + totalDue = totalDue, + charges = loan.chargesDue ?: 0.0, + principalDue = loan.principalDue ?: 0.0, + interestDue = loan.interestDue ?: 0.0, + feeDue = loan.feeDue ?: 0.0, + currencySymbol = loan.currency?.displaySymbol ?: "$", + ) + } ?: emptyList() + } ?: emptyList() + } catch (e: Exception) { + println("DEBUG: Error processing loan items: ${e.message}") + e.printStackTrace() + emptyList() + } + } + + LazyColumn( + modifier = modifier.padding(16.dp), + verticalArrangement = Arrangement.spacedBy(8.dp), + ) { + item { + DueCollectionsHeader() + } + + items(loanItems) { loanItem -> + DueCollectionItemCard( + loanItem = loanItem, + onAddPayment = onAddPayment, + ) + } + + if (loanItems.isEmpty()) { + item { + Box( + modifier = Modifier + .fillMaxWidth() + .padding(32.dp), + contentAlignment = Alignment.Center, + ) { + Text( + text = "No due collections found", + style = MaterialTheme.typography.bodyLarge, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } + } + } + } +} + +@Composable +private fun DueCollectionsHeader() { + Card( + modifier = Modifier.fillMaxWidth(), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surface, + ), + elevation = CardDefaults.cardElevation(defaultElevation = 2.dp), + ) { + Row( + modifier = Modifier + .fillMaxWidth() + .padding(12.dp), + horizontalArrangement = Arrangement.SpaceBetween, + ) { + Text( + text = stringResource(Res.string.feature_collection_sheet_loan_account), + style = MaterialTheme.typography.labelMedium, + fontWeight = FontWeight.Bold, + modifier = Modifier.weight(1f), + ) + Text( + text = stringResource(Res.string.feature_collection_sheet_product_name), + style = MaterialTheme.typography.labelMedium, + fontWeight = FontWeight.Bold, + modifier = Modifier.weight(1f), + textAlign = TextAlign.Center, + ) + Text( + text = stringResource(Res.string.feature_collection_sheet_client_name), + style = MaterialTheme.typography.labelMedium, + fontWeight = FontWeight.Bold, + modifier = Modifier.weight(1f), + textAlign = TextAlign.Center, + ) + Text( + text = stringResource(Res.string.feature_collection_sheet_total_due), + style = MaterialTheme.typography.labelMedium, + fontWeight = FontWeight.Bold, + modifier = Modifier.weight(1f), + textAlign = TextAlign.Center, + ) + Text( + text = stringResource(Res.string.feature_collection_sheet_charges), + style = MaterialTheme.typography.labelMedium, + fontWeight = FontWeight.Bold, + modifier = Modifier.weight(1f), + textAlign = TextAlign.Center, + ) + Text( + text = stringResource(Res.string.feature_collection_sheet_actions), + style = MaterialTheme.typography.labelMedium, + fontWeight = FontWeight.Bold, + modifier = Modifier.weight(1f), + textAlign = TextAlign.Center, + ) + } + } +} + +@Composable +private fun DueCollectionItemCard( + loanItem: LoanCollectionItem, + onAddPayment: (LoanCollectionItem) -> Unit, +) { + Card( + modifier = Modifier.fillMaxWidth(), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + ), + ) { + Row( + modifier = Modifier + .fillMaxWidth() + .padding(12.dp), + horizontalArrangement = Arrangement.SpaceBetween, + verticalAlignment = Alignment.CenterVertically, + ) { + Text( + text = loanItem.accountId, + style = MaterialTheme.typography.bodySmall, + modifier = Modifier.weight(1f), + ) + Text( + text = loanItem.productName, + style = MaterialTheme.typography.bodySmall, + modifier = Modifier.weight(1f), + textAlign = TextAlign.Center, + ) + Text( + text = loanItem.clientName, + style = MaterialTheme.typography.bodySmall, + modifier = Modifier.weight(1f), + textAlign = TextAlign.Center, + ) + Text( + text = "${loanItem.currencySymbol}${loanItem.totalDue.roundToInt()}", + style = MaterialTheme.typography.bodySmall, + modifier = Modifier.weight(1f), + textAlign = TextAlign.Center, + ) + Text( + text = "${loanItem.currencySymbol}${{loanItem.charges.roundToInt()}}", + style = MaterialTheme.typography.bodySmall, + modifier = Modifier.weight(1f), + textAlign = TextAlign.Center, + ) + MifosButton( + onClick = { onAddPayment(loanItem) }, + modifier = Modifier.weight(1f), + ) { + Text( + text = stringResource(Res.string.feature_collection_sheet_add_payment), + style = MaterialTheme.typography.labelSmall, + ) + } + } + } +} + +@Composable +private fun DueSavingsCollectionsContent( + collectionSheet: IndividualCollectionSheet, + onAddSavingsPayment: (SavingsCollectionItem) -> Unit, + modifier: Modifier = Modifier, +) { + val savingsItems = remember(collectionSheet) { + collectionSheet.clients?.flatMap { client -> + client.savings?.map { savings -> + SavingsCollectionItem( + clientName = "${client.clientName}(${client.clientId})", + depositAccountType = savings.depositAccountType ?: "", + savingsAccountId = "", + productName = "", + totalDue = 0.0, + currencySymbol = "$", + ) + } ?: emptyList() + } ?: emptyList() + } + + LazyColumn( + modifier = modifier.padding(16.dp), + verticalArrangement = Arrangement.spacedBy(8.dp), + ) { + item { + DueSavingsCollectionsHeader() + } + + items(savingsItems) { savingsItem -> + DueSavingsCollectionItemCard( + savingsItem = savingsItem, + onAddSavingsPayment = onAddSavingsPayment, + ) + } + + if (savingsItems.isEmpty()) { + item { + Box( + modifier = Modifier + .fillMaxWidth() + .padding(32.dp), + contentAlignment = Alignment.Center, + ) { + Text( + text = "No due savings collections found", + style = MaterialTheme.typography.bodyLarge, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } + } + } + } +} + +@Composable +private fun DueSavingsCollectionsHeader() { + Card( + modifier = Modifier.fillMaxWidth(), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surface, + ), + elevation = CardDefaults.cardElevation(defaultElevation = 2.dp), + ) { + Row( + modifier = Modifier + .fillMaxWidth() + .padding(12.dp), + horizontalArrangement = Arrangement.SpaceBetween, + ) { + Text( + text = stringResource(Res.string.feature_collection_sheet_deposit_account), + style = MaterialTheme.typography.labelMedium, + fontWeight = FontWeight.Bold, + modifier = Modifier.weight(1f), + ) + Text( + text = stringResource(Res.string.feature_collection_sheet_savings_account), + style = MaterialTheme.typography.labelMedium, + fontWeight = FontWeight.Bold, + modifier = Modifier.weight(1f), + textAlign = TextAlign.Center, + ) + Text( + text = stringResource(Res.string.feature_collection_sheet_product_name), + style = MaterialTheme.typography.labelMedium, + fontWeight = FontWeight.Bold, + modifier = Modifier.weight(1f), + textAlign = TextAlign.Center, + ) + Text( + text = stringResource(Res.string.feature_collection_sheet_client_name), + style = MaterialTheme.typography.labelMedium, + fontWeight = FontWeight.Bold, + modifier = Modifier.weight(1f), + textAlign = TextAlign.Center, + ) + Text( + text = stringResource(Res.string.feature_collection_sheet_total_due), + style = MaterialTheme.typography.labelMedium, + fontWeight = FontWeight.Bold, + modifier = Modifier.weight(1f), + textAlign = TextAlign.Center, + ) + Text( + text = stringResource(Res.string.feature_collection_sheet_actions), + style = MaterialTheme.typography.labelMedium, + fontWeight = FontWeight.Bold, + modifier = Modifier.weight(1f), + textAlign = TextAlign.Center, + ) + } + } +} + +@Composable +private fun DueSavingsCollectionItemCard( + savingsItem: SavingsCollectionItem, + onAddSavingsPayment: (SavingsCollectionItem) -> Unit, +) { + Card( + modifier = Modifier.fillMaxWidth(), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + ), + ) { + Row( + modifier = Modifier + .fillMaxWidth() + .padding(12.dp), + horizontalArrangement = Arrangement.SpaceBetween, + verticalAlignment = Alignment.CenterVertically, + ) { + Text( + text = savingsItem.depositAccountType, + style = MaterialTheme.typography.bodySmall, + modifier = Modifier.weight(1f), + ) + Text( + text = "0", + style = MaterialTheme.typography.bodySmall, + modifier = Modifier.weight(1f), + textAlign = TextAlign.Center, + ) + Text( + text = "0", + style = MaterialTheme.typography.bodySmall, + modifier = Modifier.weight(1f), + textAlign = TextAlign.Center, + ) + Text( + text = savingsItem.clientName, + style = MaterialTheme.typography.bodySmall, + modifier = Modifier.weight(1f), + textAlign = TextAlign.Center, + ) + Text( + text = "${savingsItem.currencySymbol}${savingsItem.totalDue.roundToInt()}", + style = MaterialTheme.typography.bodySmall, + modifier = Modifier.weight(1f), + textAlign = TextAlign.Center, + ) + MifosButton( + onClick = { onAddSavingsPayment(savingsItem) }, + modifier = Modifier.weight(1f), + ) { + Text( + text = stringResource(Res.string.feature_collection_sheet_add_payment), + style = MaterialTheme.typography.labelSmall, + ) + } + } + } +} + +@Preview +@Composable +private fun IndividualCollectionSheetDetailPreview() { + IndividualCollectionSheetDetailScreen( + state = IndividualCollectionSheetDetailUiState( + repaymentDate = "26-06-2025", + collectionSheet = IndividualCollectionSheet(), + ), + ) +} diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetail/IndividualCollectionSheetDetailUiState.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetail/IndividualCollectionSheetDetailUiState.kt new file mode 100644 index 0000000000..e6b93e3bde --- /dev/null +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetail/IndividualCollectionSheetDetailUiState.kt @@ -0,0 +1,41 @@ +/* + * Copyright 2025 Mifos Initiative + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * See https://github.com/openMF/android-client/blob/master/LICENSE.md + */ +package com.mifos.feature.individualCollectionSheet.individualCollectionSheetDetail + +import com.mifos.room.entities.collectionsheet.IndividualCollectionSheet + +data class IndividualCollectionSheetDetailUiState( + val isLoading: Boolean = false, + val error: String? = null, + val collectionSheet: IndividualCollectionSheet? = null, + val repaymentDate: String = "", +) + +data class LoanCollectionItem( + val loanId: Int, + val accountId: String, + val clientName: String, + val productName: String, + val totalDue: Double, + val charges: Double, + val principalDue: Double, + val interestDue: Double, + val feeDue: Double, + val currencySymbol: String, +) + +data class SavingsCollectionItem( + val clientName: String, + val depositAccountType: String, + val savingsAccountId: String = "", + val productName: String = "", + val totalDue: Double = 0.0, + val currencySymbol: String = "$", +) diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetail/IndividualCollectionSheetDetailViewModel.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetail/IndividualCollectionSheetDetailViewModel.kt new file mode 100644 index 0000000000..07bff816b7 --- /dev/null +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetail/IndividualCollectionSheetDetailViewModel.kt @@ -0,0 +1,35 @@ +/* + * Copyright 2025 Mifos Initiative + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * See https://github.com/openMF/android-client/blob/master/LICENSE.md + */ +package com.mifos.feature.individualCollectionSheet.individualCollectionSheetDetail + +import androidx.lifecycle.ViewModel +import com.mifos.room.entities.collectionsheet.IndividualCollectionSheet +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.asStateFlow + +class IndividualCollectionSheetDetailViewModel : ViewModel() { + + private val uiStateInternal = MutableStateFlow(IndividualCollectionSheetDetailUiState()) + val individualCollectionSheetDetailUiState = uiStateInternal.asStateFlow() + + fun setCollectionSheetData(repaymentDate: String, collectionSheet: IndividualCollectionSheet) { + updateUiState { + it.copy( + repaymentDate = repaymentDate, + collectionSheet = collectionSheet, + isLoading = false, + ) + } + } + + private inline fun updateUiState(update: (IndividualCollectionSheetDetailUiState) -> IndividualCollectionSheetDetailUiState) { + uiStateInternal.value = update(uiStateInternal.value) + } +} diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetNavigation.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetNavigation.kt index 905534f332..9cd1d967fd 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetNavigation.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetNavigation.kt @@ -21,7 +21,9 @@ import com.mifos.core.model.objects.collectionsheets.LoanAndClientName import com.mifos.core.network.model.IndividualCollectionSheetPayload import com.mifos.feature.individualCollectionSheet.generateCollectionSheet.GenerateCollectionSheetScreen import com.mifos.feature.individualCollectionSheet.individualCollectionSheet.IndividualCollectionSheetScreen +import com.mifos.feature.individualCollectionSheet.individualCollectionSheetDetail.IndividualCollectionSheetDetailScreen import com.mifos.feature.individualCollectionSheet.individualCollectionSheetDetails.IndividualCollectionSheetDetailsScreen +import com.mifos.feature.individualCollectionSheet.newIndividualCollectionSheet.NewIndividualCollectionSheetScreen import com.mifos.feature.individualCollectionSheet.paymentDetails.PaymentDetailsScreenRoute import com.mifos.room.entities.collectionsheet.IndividualCollectionSheet import kotlinx.serialization.Serializable @@ -34,8 +36,19 @@ fun NavGraphBuilder.individualCollectionSheetNavGraph( ) { navigation( route = "generate_collection_sheet", - startDestination = CollectionSheetScreens.IndividualCollectionSheetScreen.route, + startDestination = CollectionSheetScreens.NewIndividualCollectionSheetScreen.route, ) { + newIndividualCollectionSheetScreen( + onBackPressed = onBackPressed, + onDetail = { date, sheet -> + navController.navigateToNewIndividualCollectionSheetDetailScreen(date, sheet) + }, + ) + + newIndividualCollectionSheetDetailScreen( + onBackPressed = onBackPressed, + ) + individualCollectionSheetScreen( onBackPressed = onBackPressed, onDetail = { _, sheet -> @@ -52,6 +65,51 @@ fun NavGraphBuilder.individualCollectionSheetNavGraph( paymentDetailsScreen() } } +private fun NavGraphBuilder.newIndividualCollectionSheetScreen( + onBackPressed: () -> Unit, + onDetail: (String, IndividualCollectionSheet) -> Unit, +) { + composable( + route = CollectionSheetScreens.NewIndividualCollectionSheetScreen.route, + ) { + NewIndividualCollectionSheetScreen( + onDetail = onDetail, + ) + } +} + +private fun NavGraphBuilder.newIndividualCollectionSheetDetailScreen( + onBackPressed: () -> Unit, +) { + composable( + route = CollectionSheetScreens.NewIndividualCollectionSheetDetailScreen.route, + arguments = listOf( + navArgument(name = Constants.INDIVIDUAL_SHEET_DATE) { + type = NavType.StringType + }, + navArgument(name = Constants.INDIVIDUAL_SHEET) { + type = NavType.StringType + }, + ), + ) { backStackEntry -> + val dateString = backStackEntry.arguments?.getString(Constants.INDIVIDUAL_SHEET_DATE) ?: "" + val sheetJson = backStackEntry.arguments?.getString(Constants.INDIVIDUAL_SHEET) ?: "" + + val collectionSheet = Json.decodeFromString(sheetJson) + IndividualCollectionSheetDetailScreen( + repaymentDate = dateString, + collectionSheet = collectionSheet, + onAddPayment = { loanItem -> + // TODO: Implement payment functionality + println("Add payment for loan: ${loanItem.loanId}") + }, + onAddSavingsPayment = { savingsItem -> + // TODO: Implement savings payment functionality + println("Add savings payment for: ${savingsItem.clientName}") + }, + ) + } +} private fun NavGraphBuilder.individualCollectionSheetScreen( onBackPressed: () -> Unit, @@ -106,6 +164,12 @@ fun NavGraphBuilder.paymentDetailsScreen() { PaymentDetailsScreenRoute() } } +fun NavController.navigateToNewIndividualCollectionSheetDetailScreen( + date: String, + sheet: IndividualCollectionSheet, +) { + navigate(CollectionSheetScreens.NewIndividualCollectionSheetDetailScreen.argument(date, sheet)) +} fun NavController.navigateToIndividualCollectionSheetDetailScreen(sheet: IndividualCollectionSheet) { navigate(CollectionSheetScreens.IndividualCollectionSheetDetailScreen.argument(sheet)) diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetScreens.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetScreens.kt index 393fc98c87..881f11f4c8 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetScreens.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetScreens.kt @@ -25,6 +25,18 @@ sealed class CollectionSheetScreens(val route: String) { data object IndividualCollectionSheetScreen : CollectionSheetScreens("individual_collection_sheet_route") + data object NewIndividualCollectionSheetScreen : + CollectionSheetScreens("new_individual_collection_sheet_route") + + data object NewIndividualCollectionSheetDetailScreen : + CollectionSheetScreens("new_individual_collection_sheet_detail/{${Constants.INDIVIDUAL_SHEET_DATE}}/{${Constants.INDIVIDUAL_SHEET}}") { + + fun argument(date: String, sheet: IndividualCollectionSheet): String { + val sheetInGsonString = Json.encodeToString(sheet) + return "new_individual_collection_sheet_detail/$date/$sheetInGsonString" + } + } + data object PaymentDetailsScreen : CollectionSheetScreens("payment_details_route/{${Constants.PAYMENT_DETAILS_ARGS}}") { diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt index 59390989b7..d594d0ceae 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt @@ -14,13 +14,9 @@ package com.mifos.feature.individualCollectionSheet.newIndividualCollectionSheet import androidclient.feature.collectionsheet.generated.resources.Res import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_cancel import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_clear -import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_date import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_fill_collection_sheet_message -import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_fill_now -import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_found_sheet import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_generate import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_generate_new -import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_member import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_office import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_repayment_date import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_select @@ -34,7 +30,6 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.width import androidx.compose.material3.DatePicker import androidx.compose.material3.DatePickerDialog import androidx.compose.material3.ExperimentalMaterial3Api @@ -53,13 +48,11 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalSoftwareKeyboardController import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.mifos.core.common.utils.DateHelper -import com.mifos.core.designsystem.component.MifosBottomSheet import com.mifos.core.designsystem.component.MifosButton import com.mifos.core.designsystem.component.MifosCircularProgress import com.mifos.core.designsystem.component.MifosDatePickerTextField @@ -117,7 +110,7 @@ internal fun NewIndividualCollectionSheetScreen( var staffId by rememberSaveable { mutableIntStateOf(0) } val snackbarHostState = remember { SnackbarHostState() } - var showCollectionSheetDialog by rememberSaveable { mutableStateOf(false) } +// var showCollectionSheetDialog by rememberSaveable { mutableStateOf(false) } var showDatePicker by rememberSaveable { mutableStateOf(false) } var repaymentDate by rememberSaveable { @@ -146,7 +139,16 @@ internal fun NewIndividualCollectionSheetScreen( LaunchedEffect(key1 = state.individualCollectionSheet) { state.individualCollectionSheet?.let { individualCollectionSheet = it - showCollectionSheetDialog = true + try { + onDetail( + DateHelper.getDateAsStringFromLong(repaymentDate), + it, + ) + println("DEBUG: Navigation successful") + } catch (e: Exception) { + println("DEBUG: Navigation failed: ${e.message}") + e.printStackTrace() + } } } @@ -182,31 +184,31 @@ internal fun NewIndividualCollectionSheetScreen( DatePicker(state = datePickerState) } } - if (showCollectionSheetDialog) { - MifosBottomSheet( - content = { - CollectionSheetDialogContent( - date = DateHelper.getDateAsStringFromLong(repaymentDate), - member = individualCollectionSheet?.clients?.size.toString(), - fillNow = { - showCollectionSheetDialog = false - individualCollectionSheet?.let { - onDetail( - DateHelper.getDateAsStringFromLong(repaymentDate), - it, - ) - } - }, - onDismiss = { - showCollectionSheetDialog = false - }, - ) - }, - onDismiss = { - showCollectionSheetDialog = false - }, - ) - } +// if (showCollectionSheetDialog) { +// MifosBottomSheet( +// content = { +// CollectionSheetDialogContent( +// date = DateHelper.getDateAsStringFromLong(repaymentDate), +// member = individualCollectionSheet?.clients?.size.toString(), +// fillNow = { +// showCollectionSheetDialog = false +// individualCollectionSheet?.let { +// onDetail( +// DateHelper.getDateAsStringFromLong(repaymentDate), +// it, +// ) +// } +// }, +// onDismiss = { +// showCollectionSheetDialog = false +// }, +// ) +// }, +// onDismiss = { +// showCollectionSheetDialog = false +// }, +// ) +// } if (state.isLoading) { MifosCircularProgress() } else { @@ -233,15 +235,24 @@ internal fun NewIndividualCollectionSheetScreen( selectedStaff = "" }, onOptionSelected = { index, value -> - println("Office selection - Index: $index, List size: ${state.officeList.size}, Value: $value") - val selectedOfficeEntity = - state.officeList.find { it.name.toString() == value } - selectedOfficeEntity?.id?.let { - getStaffList(it) - officeId = it + println("DEBUG: Office selection - Index: $index, List size: ${state.officeList.size}, Value: $value") + try { + if (index >= 0 && index < state.officeList.size) { + val selectedOfficeEntity = state.officeList[index] + selectedOfficeEntity.id?.let { + getStaffList(it) + officeId = it + } + selectedOffice = value + selectedStaff = "" + println("DEBUG: Office selection successful") + } else { + println("DEBUG: Office index out of bounds: $index for size ${state.officeList.size}") + } + } catch (e: Exception) { + println("DEBUG: Error in office selection: ${e.message}") + println("DEBUG: Full error: ${e.stackTraceToString()}") } - selectedOffice = value - selectedStaff = "" }, label = stringResource(Res.string.feature_collection_sheet_office), options = state.officeList.map { it.name.toString() }, @@ -262,12 +273,21 @@ internal fun NewIndividualCollectionSheetScreen( }, onOptionSelected = { index, value -> println("Staff selection - Index: $index, List size: ${state.staffList.size}, Value: $value") - val selectedStaffEntity = - state.staffList.find { it.displayName.toString() == value } - selectedStaffEntity?.id?.let { - staffId = it + try { + if (index >= 0 && index < state.staffList.size) { + val selectedStaffEntity = state.staffList[index] + selectedStaffEntity.id?.let { + staffId = it + } + selectedStaff = value + println("DEBUG: Staff selection successful") + } else { + println("DEBUG: Staff index out of bounds: $index for size ${state.staffList.size}") + } + } catch (e: Exception) { + println("DEBUG: Error in staff selection: ${e.message}") + println("DEBUG: Full error: ${e.stackTraceToString()}") } - selectedStaff = value }, label = stringResource(Res.string.feature_collection_sheet_staff), options = state.staffList.map { it.displayName.toString() }, @@ -320,83 +340,83 @@ internal fun NewIndividualCollectionSheetScreen( } } -@Composable -private fun CollectionSheetDialogContent( - date: String, - member: String, - fillNow: () -> Unit, - modifier: Modifier = Modifier, - onDismiss: () -> Unit, -) { - MifosBottomSheet( - modifier = modifier, - content = { - Column( - modifier = Modifier - .fillMaxWidth() - .padding(start = 16.dp, end = 16.dp, bottom = 16.dp), - ) { - Text( - modifier = Modifier - .fillMaxWidth() - .align(Alignment.CenterHorizontally), - text = stringResource(Res.string.feature_collection_sheet_found_sheet), - style = MaterialTheme.typography.titleLarge, - ) - Spacer(modifier = Modifier.height(16.dp)) - Text( - text = stringResource(Res.string.feature_collection_sheet_fill_collection_sheet_message), - style = MaterialTheme.typography.bodyLarge, - ) - Spacer(modifier = Modifier.height(16.dp)) - Row { - Text( - text = stringResource(Res.string.feature_collection_sheet_date), - style = MaterialTheme.typography.bodyLarge, - ) - Spacer(modifier = Modifier.width(16.dp)) - Text( - text = date, - style = MaterialTheme.typography.bodyLarge, - ) - } - - Row { - Text( - text = stringResource(Res.string.feature_collection_sheet_member), - style = MaterialTheme.typography.bodyLarge, - ) - Spacer(modifier = Modifier.width(16.dp)) - Text( - text = member, - style = MaterialTheme.typography.bodyLarge, - ) - } - Spacer(modifier = Modifier.height(16.dp)) - Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) { - MifosButton( - onClick = fillNow, - ) { - Text( - text = stringResource(Res.string.feature_collection_sheet_fill_now), - style = MaterialTheme.typography.bodyLarge, - ) - } - Spacer(modifier = Modifier.width(16.dp)) - MifosButton( - onClick = onDismiss, - ) { - Text( - text = stringResource(Res.string.feature_collection_sheet_cancel), - style = MaterialTheme.typography.bodyLarge, - ) - } - } - } - }, - onDismiss = onDismiss, - ) -} +// @Composable +// private fun CollectionSheetDialogContent( +// date: String, +// member: String, +// fillNow: () -> Unit, +// modifier: Modifier = Modifier, +// onDismiss: () -> Unit, +// ) { +// MifosBottomSheet( +// modifier = modifier, +// content = { +// Column( +// modifier = Modifier +// .fillMaxWidth() +// .padding(start = 16.dp, end = 16.dp, bottom = 16.dp), +// ) { +// Text( +// modifier = Modifier +// .fillMaxWidth() +// .align(Alignment.CenterHorizontally), +// text = stringResource(Res.string.feature_collection_sheet_found_sheet), +// style = MaterialTheme.typography.titleLarge, +// ) +// Spacer(modifier = Modifier.height(16.dp)) +// Text( +// text = stringResource(Res.string.feature_collection_sheet_fill_collection_sheet_message), +// style = MaterialTheme.typography.bodyLarge, +// ) +// Spacer(modifier = Modifier.height(16.dp)) +// Row { +// Text( +// text = stringResource(Res.string.feature_collection_sheet_date), +// style = MaterialTheme.typography.bodyLarge, +// ) +// Spacer(modifier = Modifier.width(16.dp)) +// Text( +// text = date, +// style = MaterialTheme.typography.bodyLarge, +// ) +// } +// +// Row { +// Text( +// text = stringResource(Res.string.feature_collection_sheet_member), +// style = MaterialTheme.typography.bodyLarge, +// ) +// Spacer(modifier = Modifier.width(16.dp)) +// Text( +// text = member, +// style = MaterialTheme.typography.bodyLarge, +// ) +// } +// Spacer(modifier = Modifier.height(16.dp)) +// Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) { +// MifosButton( +// onClick = fillNow, +// ) { +// Text( +// text = stringResource(Res.string.feature_collection_sheet_fill_now), +// style = MaterialTheme.typography.bodyLarge, +// ) +// } +// Spacer(modifier = Modifier.width(16.dp)) +// MifosButton( +// onClick = onDismiss, +// ) { +// Text( +// text = stringResource(Res.string.feature_collection_sheet_cancel), +// style = MaterialTheme.typography.bodyLarge, +// ) +// } +// } +// } +// }, +// onDismiss = onDismiss, +// ) +// } @Preview @Composable @@ -448,8 +468,8 @@ val sampleOfficeList = List(10) { OfficeEntity(id = it, name = "Name") } -@Preview -@Composable -private fun CollectionSheetDialogContentPreview() { - CollectionSheetDialogContent(date = "19 June 2024", member = "5", fillNow = {}, onDismiss = {}) -} +// @Preview +// @Composable +// private fun CollectionSheetDialogContentPreview() { +// CollectionSheetDialogContent(date = "19 June 2024", member = "5", fillNow = {}, onDismiss = {}) +// } From 93c9e8f4d5c0dede65c7b0528785dc02aea63194 Mon Sep 17 00:00:00 2001 From: Aditya3815 Date: Wed, 25 Jun 2025 22:59:57 +0530 Subject: [PATCH 05/13] Complete --- .../IndividualCollectionSheetDetailsScreen.kt | 14 +++++--------- .../paymentDetails/PaymentDetailsScreen.kt | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt index 801cb8c54e..dc385784d2 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt @@ -210,6 +210,8 @@ private fun IndividualCollectionSheetItem( modifier: Modifier = Modifier, onClick: () -> Unit, ) { + val loan = client.loans?.getOrNull(index) + OutlinedCard( modifier = modifier .padding(6.dp) @@ -246,18 +248,16 @@ private fun IndividualCollectionSheetItem( Text( text = it, style = MaterialTheme.typography.bodyLarge, - ) } Row { Text( text = stringResource(Res.string.feature_collection_sheet_total_due), style = MaterialTheme.typography.bodyMedium, - ) Spacer(modifier = Modifier.width(16.dp)) Text( - text = client.loans?.get(index)?.totalDue.toString(), + text = loan?.totalDue.toString(), style = MaterialTheme.typography.bodyMedium, ) } @@ -268,16 +268,12 @@ private fun IndividualCollectionSheetItem( ) Spacer(modifier = Modifier.width(16.dp)) Text( - text = client.loans?.get(index)?.chargesDue.toString(), + text = loan?.chargesDue.toString(), style = MaterialTheme.typography.bodyMedium, ) } Text( - text = "${client.loans?.get(index)?.productShortName} (#${ - client.loans?.get( - index, - )?.productShortName - })", + text = "${loan?.productShortName} (#${loan?.productShortName})", style = MaterialTheme.typography.bodyMedium, ) } diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/paymentDetails/PaymentDetailsScreen.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/paymentDetails/PaymentDetailsScreen.kt index 2f5f8701df..6fb8f3d858 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/paymentDetails/PaymentDetailsScreen.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/paymentDetails/PaymentDetailsScreen.kt @@ -383,7 +383,7 @@ private fun MifosButtonRow( } @Composable -@Preview +@DevicePreview private fun PreviewPaymentDetails(modifier: Modifier = Modifier) { PaymentsDetailsScreen( modifier = modifier, From f9676ba0f9523e97028ab845b1687ebafcfaa596 Mon Sep 17 00:00:00 2001 From: Aditya3815 Date: Thu, 26 Jun 2025 00:22:04 +0530 Subject: [PATCH 06/13] complete 2 --- .../com/mifos/core/common/utils/Constants.kt | 1 - .../collectionsheets/LoanCollectionSheet.kt | 1 - .../composeResources/values/strings.xml | 13 - .../di/CollectionSheetModule.kt | 2 - .../GenerateCollectionSheetScreen.kt | 3 - .../IndividualCollectionSheetDetailScreen.kt | 579 ------------------ .../IndividualCollectionSheetDetailUiState.kt | 41 -- ...ndividualCollectionSheetDetailViewModel.kt | 35 -- .../navigation/CollectionSheetNavigation.kt | 67 +- .../navigation/CollectionSheetScreens.kt | 12 - .../NewIndividualCollectionSheetScreen.kt | 235 ++++--- 11 files changed, 117 insertions(+), 872 deletions(-) delete mode 100644 feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetail/IndividualCollectionSheetDetailScreen.kt delete mode 100644 feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetail/IndividualCollectionSheetDetailUiState.kt delete mode 100644 feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetail/IndividualCollectionSheetDetailViewModel.kt diff --git a/core/common/src/commonMain/kotlin/com/mifos/core/common/utils/Constants.kt b/core/common/src/commonMain/kotlin/com/mifos/core/common/utils/Constants.kt index 52013b38ac..4439a59355 100644 --- a/core/common/src/commonMain/kotlin/com/mifos/core/common/utils/Constants.kt +++ b/core/common/src/commonMain/kotlin/com/mifos/core/common/utils/Constants.kt @@ -54,7 +54,6 @@ object Constants { const val SAVINGS_ACCOUNT_TRANSACTION_DEPOSIT = "Deposit" const val SAVINGS_ACCOUNT_TRANSACTION_WITHDRAWAL = "Withdrawal" const val DATA_TABLE_REGISTERED_NAME = "dataTableRegisteredName" - const val INDIVIDUAL_SHEET_DATE = "individual_sheet_date" const val CENTER_ID = "centerId" const val GROUP_ID = "groupId" const val GROUP_NAME = "groupName" diff --git a/core/model/src/commonMain/kotlin/com/mifos/core/model/objects/collectionsheets/LoanCollectionSheet.kt b/core/model/src/commonMain/kotlin/com/mifos/core/model/objects/collectionsheets/LoanCollectionSheet.kt index 27b7dcdade..210a3bd076 100644 --- a/core/model/src/commonMain/kotlin/com/mifos/core/model/objects/collectionsheets/LoanCollectionSheet.kt +++ b/core/model/src/commonMain/kotlin/com/mifos/core/model/objects/collectionsheets/LoanCollectionSheet.kt @@ -27,6 +27,5 @@ data class LoanCollectionSheet( val productId: Double? = null, val totalDue: Double = 0.0, val chargesDue: Double = 0.0, - val feeDue: Double = 0.0, val productShortName: String? = null, ) : Parcelable diff --git a/feature/collectionSheet/src/commonMain/composeResources/values/strings.xml b/feature/collectionSheet/src/commonMain/composeResources/values/strings.xml index 90b0fe2084..446d7badd5 100644 --- a/feature/collectionSheet/src/commonMain/composeResources/values/strings.xml +++ b/feature/collectionSheet/src/commonMain/composeResources/values/strings.xml @@ -39,8 +39,6 @@ Receipt Number Bank Number Save - Due Collections - Due Savings Collections Collection Details @@ -65,15 +63,4 @@ Productive Collection Sheet Productive Sheet Submitted Successfully Collection Sheet Submitted Successfully - - Loan Account # - Product Name - Client Name - Charges - Actions - Add Payment - Deposit Account - Savings Account # - Account ID - \ No newline at end of file diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/di/CollectionSheetModule.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/di/CollectionSheetModule.kt index d98a2457ea..c5c77f57c5 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/di/CollectionSheetModule.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/di/CollectionSheetModule.kt @@ -10,7 +10,6 @@ package com.mifos.feature.individualCollectionSheet.di import com.mifos.feature.individualCollectionSheet.generateCollectionSheet.GenerateCollectionSheetViewModel -import com.mifos.feature.individualCollectionSheet.individualCollectionSheetDetail.IndividualCollectionSheetDetailViewModel import com.mifos.feature.individualCollectionSheet.individualCollectionSheetDetails.IndividualCollectionSheetDetailsViewModel import com.mifos.feature.individualCollectionSheet.newIndividualCollectionSheet.NewIndividualCollectionSheetViewModel import com.mifos.feature.individualCollectionSheet.paymentDetails.PaymentDetailsViewModel @@ -24,5 +23,4 @@ val CollectionSheetModule = module { viewModelOf(::NewIndividualCollectionSheetViewModel) viewModelOf(::PaymentDetailsViewModel) viewModelOf(::SavedIndividualCollectionSheetViewModel) - viewModelOf(::IndividualCollectionSheetDetailViewModel) } diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/generateCollectionSheet/GenerateCollectionSheetScreen.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/generateCollectionSheet/GenerateCollectionSheetScreen.kt index 1e6c95efd3..e20c7ed613 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/generateCollectionSheet/GenerateCollectionSheetScreen.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/generateCollectionSheet/GenerateCollectionSheetScreen.kt @@ -38,7 +38,6 @@ import androidx.compose.material3.DatePicker import androidx.compose.material3.DatePickerDialog import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.OutlinedTextFieldDefaults.contentPadding import androidx.compose.material3.SelectableDates import androidx.compose.material3.SnackbarHostState import androidx.compose.material3.Text @@ -57,7 +56,6 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle -import co.touchlab.kermit.Logger import com.mifos.core.common.utils.DateHelper import com.mifos.core.designsystem.component.MifosButton import com.mifos.core.designsystem.component.MifosCircularProgress @@ -357,7 +355,6 @@ private fun GenerateCollectionSheetContent( selectedStaffId, ) isProductiveResponse = true - Logger.d("Productive Collection Sheet") }, modifier = Modifier .fillMaxWidth() diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetail/IndividualCollectionSheetDetailScreen.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetail/IndividualCollectionSheetDetailScreen.kt deleted file mode 100644 index ac6b5b62a8..0000000000 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetail/IndividualCollectionSheetDetailScreen.kt +++ /dev/null @@ -1,579 +0,0 @@ -/* - * Copyright 2025 Mifos Initiative - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * See https://github.com/openMF/android-client/blob/master/LICENSE.md - */ -package com.mifos.feature.individualCollectionSheet.individualCollectionSheetDetail - -import androidclient.feature.collectionsheet.generated.resources.Res -import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_actions -import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_add_payment -import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_charges -import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_client_name -import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_deposit_account -import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_due_collections -import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_due_savings_collections -import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_individual_collection_sheet -import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_loan_account -import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_product_name -import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_savings_account -import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_total_due -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.items -import androidx.compose.material3.Card -import androidx.compose.material3.CardDefaults -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.SnackbarHostState -import androidx.compose.material3.Tab -import androidx.compose.material3.TabRow -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableIntStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.saveable.rememberSaveable -import androidx.compose.runtime.setValue -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.unit.dp -import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.mifos.core.designsystem.component.MifosButton -import com.mifos.core.designsystem.component.MifosCircularProgress -import com.mifos.core.designsystem.component.MifosScaffold -import com.mifos.room.entities.collectionsheet.IndividualCollectionSheet -import org.jetbrains.compose.resources.stringResource -import org.jetbrains.compose.ui.tooling.preview.Preview -import org.koin.compose.viewmodel.koinViewModel -import kotlin.math.roundToInt - -@Composable -internal fun IndividualCollectionSheetDetailScreen( - repaymentDate: String, - collectionSheet: IndividualCollectionSheet, - viewmodel: IndividualCollectionSheetDetailViewModel = koinViewModel(), - onAddPayment: (LoanCollectionItem) -> Unit = {}, - onAddSavingsPayment: (SavingsCollectionItem) -> Unit = {}, -) { - val state = viewmodel.individualCollectionSheetDetailUiState.collectAsStateWithLifecycle().value - - LaunchedEffect(collectionSheet) { - println("DEBUG: LaunchedEffect triggered with collectionSheet") - try { - viewmodel.setCollectionSheetData(repaymentDate, collectionSheet) - println("DEBUG: ViewModel data set successfully") - } catch (e: Exception) { - println("DEBUG: Error in LaunchedEffect: ${e.message}") - println("DEBUG: Full error: ${e.stackTraceToString()}") - } - } - - IndividualCollectionSheetDetailScreen( - state = state, - onAddPayment = onAddPayment, - onAddSavingsPayment = onAddSavingsPayment, - ) -} - -@Composable -internal fun IndividualCollectionSheetDetailScreen( - state: IndividualCollectionSheetDetailUiState, - modifier: Modifier = Modifier, - onAddPayment: (LoanCollectionItem) -> Unit = {}, - onAddSavingsPayment: (SavingsCollectionItem) -> Unit = {}, -) { - val snackbarHostState = remember { SnackbarHostState() } - var selectedTabIndex by rememberSaveable { mutableIntStateOf(0) } - - LaunchedEffect(key1 = state.error) { - state.error?.let { snackbarHostState.showSnackbar(it) } - } - - MifosScaffold( - modifier = modifier, - snackbarHostState = snackbarHostState, - topBar = { - Text( - modifier = Modifier.padding(16.dp), - text = stringResource(Res.string.feature_collection_sheet_individual_collection_sheet), - style = MaterialTheme.typography.titleLarge, - ) - }, - ) { paddingValues -> - if (state.isLoading) { - MifosCircularProgress() - } else { - Column( - modifier = Modifier - .fillMaxSize() - .padding(paddingValues), - ) { - ParametersSection( - repaymentDate = state.repaymentDate, - modifier = Modifier.padding(16.dp), - ) - - val tabs = listOf( - stringResource(Res.string.feature_collection_sheet_due_collections), - stringResource(Res.string.feature_collection_sheet_due_savings_collections), - ) - - TabRow( - selectedTabIndex = selectedTabIndex, - modifier = Modifier.fillMaxWidth(), - ) { - tabs.forEachIndexed { index, title -> - Tab( - selected = selectedTabIndex == index, - onClick = { selectedTabIndex = index }, - text = { - Text( - text = title, - style = MaterialTheme.typography.bodyMedium, - ) - }, - ) - } - } - - when (selectedTabIndex) { - 0 -> { - state.collectionSheet?.let { collectionSheet -> - DueCollectionsContent( - collectionSheet = collectionSheet, - onAddPayment = onAddPayment, - modifier = Modifier.weight(1f), - ) - } - } - 1 -> { - state.collectionSheet?.let { collectionSheet -> - DueSavingsCollectionsContent( - collectionSheet = collectionSheet, - onAddSavingsPayment = onAddSavingsPayment, - modifier = Modifier.weight(1f), - ) - } - } - } - } - } - } -} - -@Composable -private fun ParametersSection( - repaymentDate: String, - modifier: Modifier = Modifier, -) { - Card( - modifier = modifier.fillMaxWidth(), - colors = CardDefaults.cardColors( - containerColor = MaterialTheme.colorScheme.primaryContainer, - ), - ) { - Column( - modifier = Modifier.padding(16.dp), - ) { - Text( - text = "Parameters", - style = MaterialTheme.typography.titleMedium, - fontWeight = FontWeight.Bold, - ) - Spacer(modifier = Modifier.height(8.dp)) - Text( - text = "Repayment Date: $repaymentDate", - style = MaterialTheme.typography.bodyMedium, - ) - } - } -} - -@Composable -private fun DueCollectionsContent( - collectionSheet: IndividualCollectionSheet, - onAddPayment: (LoanCollectionItem) -> Unit, - modifier: Modifier = Modifier, -) { - val loanItems = remember(collectionSheet) { - try { - collectionSheet.clients?.flatMap { client -> - println("DEBUG: Processing client: ${client.clientName}, loans count: ${client.loans?.size}") - client.loans?.mapIndexed { index, loan -> - println("DEBUG: Processing loan $index: ${loan.loanId}") - val totalDue = (loan.chargesDue ?: 0.0) + (loan.feeDue ?: 0.0) - LoanCollectionItem( - loanId = loan.loanId ?: 0, - accountId = loan.accountId ?: "", - clientName = "${client.clientName}(${client.clientId})", - productName = "${loan.productShortName ?: ""}(${loan.loanId ?: 0})", - totalDue = totalDue, - charges = loan.chargesDue ?: 0.0, - principalDue = loan.principalDue ?: 0.0, - interestDue = loan.interestDue ?: 0.0, - feeDue = loan.feeDue ?: 0.0, - currencySymbol = loan.currency?.displaySymbol ?: "$", - ) - } ?: emptyList() - } ?: emptyList() - } catch (e: Exception) { - println("DEBUG: Error processing loan items: ${e.message}") - e.printStackTrace() - emptyList() - } - } - - LazyColumn( - modifier = modifier.padding(16.dp), - verticalArrangement = Arrangement.spacedBy(8.dp), - ) { - item { - DueCollectionsHeader() - } - - items(loanItems) { loanItem -> - DueCollectionItemCard( - loanItem = loanItem, - onAddPayment = onAddPayment, - ) - } - - if (loanItems.isEmpty()) { - item { - Box( - modifier = Modifier - .fillMaxWidth() - .padding(32.dp), - contentAlignment = Alignment.Center, - ) { - Text( - text = "No due collections found", - style = MaterialTheme.typography.bodyLarge, - color = MaterialTheme.colorScheme.onSurfaceVariant, - ) - } - } - } - } -} - -@Composable -private fun DueCollectionsHeader() { - Card( - modifier = Modifier.fillMaxWidth(), - colors = CardDefaults.cardColors( - containerColor = MaterialTheme.colorScheme.surface, - ), - elevation = CardDefaults.cardElevation(defaultElevation = 2.dp), - ) { - Row( - modifier = Modifier - .fillMaxWidth() - .padding(12.dp), - horizontalArrangement = Arrangement.SpaceBetween, - ) { - Text( - text = stringResource(Res.string.feature_collection_sheet_loan_account), - style = MaterialTheme.typography.labelMedium, - fontWeight = FontWeight.Bold, - modifier = Modifier.weight(1f), - ) - Text( - text = stringResource(Res.string.feature_collection_sheet_product_name), - style = MaterialTheme.typography.labelMedium, - fontWeight = FontWeight.Bold, - modifier = Modifier.weight(1f), - textAlign = TextAlign.Center, - ) - Text( - text = stringResource(Res.string.feature_collection_sheet_client_name), - style = MaterialTheme.typography.labelMedium, - fontWeight = FontWeight.Bold, - modifier = Modifier.weight(1f), - textAlign = TextAlign.Center, - ) - Text( - text = stringResource(Res.string.feature_collection_sheet_total_due), - style = MaterialTheme.typography.labelMedium, - fontWeight = FontWeight.Bold, - modifier = Modifier.weight(1f), - textAlign = TextAlign.Center, - ) - Text( - text = stringResource(Res.string.feature_collection_sheet_charges), - style = MaterialTheme.typography.labelMedium, - fontWeight = FontWeight.Bold, - modifier = Modifier.weight(1f), - textAlign = TextAlign.Center, - ) - Text( - text = stringResource(Res.string.feature_collection_sheet_actions), - style = MaterialTheme.typography.labelMedium, - fontWeight = FontWeight.Bold, - modifier = Modifier.weight(1f), - textAlign = TextAlign.Center, - ) - } - } -} - -@Composable -private fun DueCollectionItemCard( - loanItem: LoanCollectionItem, - onAddPayment: (LoanCollectionItem) -> Unit, -) { - Card( - modifier = Modifier.fillMaxWidth(), - colors = CardDefaults.cardColors( - containerColor = MaterialTheme.colorScheme.surfaceVariant, - ), - ) { - Row( - modifier = Modifier - .fillMaxWidth() - .padding(12.dp), - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically, - ) { - Text( - text = loanItem.accountId, - style = MaterialTheme.typography.bodySmall, - modifier = Modifier.weight(1f), - ) - Text( - text = loanItem.productName, - style = MaterialTheme.typography.bodySmall, - modifier = Modifier.weight(1f), - textAlign = TextAlign.Center, - ) - Text( - text = loanItem.clientName, - style = MaterialTheme.typography.bodySmall, - modifier = Modifier.weight(1f), - textAlign = TextAlign.Center, - ) - Text( - text = "${loanItem.currencySymbol}${loanItem.totalDue.roundToInt()}", - style = MaterialTheme.typography.bodySmall, - modifier = Modifier.weight(1f), - textAlign = TextAlign.Center, - ) - Text( - text = "${loanItem.currencySymbol}${{loanItem.charges.roundToInt()}}", - style = MaterialTheme.typography.bodySmall, - modifier = Modifier.weight(1f), - textAlign = TextAlign.Center, - ) - MifosButton( - onClick = { onAddPayment(loanItem) }, - modifier = Modifier.weight(1f), - ) { - Text( - text = stringResource(Res.string.feature_collection_sheet_add_payment), - style = MaterialTheme.typography.labelSmall, - ) - } - } - } -} - -@Composable -private fun DueSavingsCollectionsContent( - collectionSheet: IndividualCollectionSheet, - onAddSavingsPayment: (SavingsCollectionItem) -> Unit, - modifier: Modifier = Modifier, -) { - val savingsItems = remember(collectionSheet) { - collectionSheet.clients?.flatMap { client -> - client.savings?.map { savings -> - SavingsCollectionItem( - clientName = "${client.clientName}(${client.clientId})", - depositAccountType = savings.depositAccountType ?: "", - savingsAccountId = "", - productName = "", - totalDue = 0.0, - currencySymbol = "$", - ) - } ?: emptyList() - } ?: emptyList() - } - - LazyColumn( - modifier = modifier.padding(16.dp), - verticalArrangement = Arrangement.spacedBy(8.dp), - ) { - item { - DueSavingsCollectionsHeader() - } - - items(savingsItems) { savingsItem -> - DueSavingsCollectionItemCard( - savingsItem = savingsItem, - onAddSavingsPayment = onAddSavingsPayment, - ) - } - - if (savingsItems.isEmpty()) { - item { - Box( - modifier = Modifier - .fillMaxWidth() - .padding(32.dp), - contentAlignment = Alignment.Center, - ) { - Text( - text = "No due savings collections found", - style = MaterialTheme.typography.bodyLarge, - color = MaterialTheme.colorScheme.onSurfaceVariant, - ) - } - } - } - } -} - -@Composable -private fun DueSavingsCollectionsHeader() { - Card( - modifier = Modifier.fillMaxWidth(), - colors = CardDefaults.cardColors( - containerColor = MaterialTheme.colorScheme.surface, - ), - elevation = CardDefaults.cardElevation(defaultElevation = 2.dp), - ) { - Row( - modifier = Modifier - .fillMaxWidth() - .padding(12.dp), - horizontalArrangement = Arrangement.SpaceBetween, - ) { - Text( - text = stringResource(Res.string.feature_collection_sheet_deposit_account), - style = MaterialTheme.typography.labelMedium, - fontWeight = FontWeight.Bold, - modifier = Modifier.weight(1f), - ) - Text( - text = stringResource(Res.string.feature_collection_sheet_savings_account), - style = MaterialTheme.typography.labelMedium, - fontWeight = FontWeight.Bold, - modifier = Modifier.weight(1f), - textAlign = TextAlign.Center, - ) - Text( - text = stringResource(Res.string.feature_collection_sheet_product_name), - style = MaterialTheme.typography.labelMedium, - fontWeight = FontWeight.Bold, - modifier = Modifier.weight(1f), - textAlign = TextAlign.Center, - ) - Text( - text = stringResource(Res.string.feature_collection_sheet_client_name), - style = MaterialTheme.typography.labelMedium, - fontWeight = FontWeight.Bold, - modifier = Modifier.weight(1f), - textAlign = TextAlign.Center, - ) - Text( - text = stringResource(Res.string.feature_collection_sheet_total_due), - style = MaterialTheme.typography.labelMedium, - fontWeight = FontWeight.Bold, - modifier = Modifier.weight(1f), - textAlign = TextAlign.Center, - ) - Text( - text = stringResource(Res.string.feature_collection_sheet_actions), - style = MaterialTheme.typography.labelMedium, - fontWeight = FontWeight.Bold, - modifier = Modifier.weight(1f), - textAlign = TextAlign.Center, - ) - } - } -} - -@Composable -private fun DueSavingsCollectionItemCard( - savingsItem: SavingsCollectionItem, - onAddSavingsPayment: (SavingsCollectionItem) -> Unit, -) { - Card( - modifier = Modifier.fillMaxWidth(), - colors = CardDefaults.cardColors( - containerColor = MaterialTheme.colorScheme.surfaceVariant, - ), - ) { - Row( - modifier = Modifier - .fillMaxWidth() - .padding(12.dp), - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically, - ) { - Text( - text = savingsItem.depositAccountType, - style = MaterialTheme.typography.bodySmall, - modifier = Modifier.weight(1f), - ) - Text( - text = "0", - style = MaterialTheme.typography.bodySmall, - modifier = Modifier.weight(1f), - textAlign = TextAlign.Center, - ) - Text( - text = "0", - style = MaterialTheme.typography.bodySmall, - modifier = Modifier.weight(1f), - textAlign = TextAlign.Center, - ) - Text( - text = savingsItem.clientName, - style = MaterialTheme.typography.bodySmall, - modifier = Modifier.weight(1f), - textAlign = TextAlign.Center, - ) - Text( - text = "${savingsItem.currencySymbol}${savingsItem.totalDue.roundToInt()}", - style = MaterialTheme.typography.bodySmall, - modifier = Modifier.weight(1f), - textAlign = TextAlign.Center, - ) - MifosButton( - onClick = { onAddSavingsPayment(savingsItem) }, - modifier = Modifier.weight(1f), - ) { - Text( - text = stringResource(Res.string.feature_collection_sheet_add_payment), - style = MaterialTheme.typography.labelSmall, - ) - } - } - } -} - -@Preview -@Composable -private fun IndividualCollectionSheetDetailPreview() { - IndividualCollectionSheetDetailScreen( - state = IndividualCollectionSheetDetailUiState( - repaymentDate = "26-06-2025", - collectionSheet = IndividualCollectionSheet(), - ), - ) -} diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetail/IndividualCollectionSheetDetailUiState.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetail/IndividualCollectionSheetDetailUiState.kt deleted file mode 100644 index e6b93e3bde..0000000000 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetail/IndividualCollectionSheetDetailUiState.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2025 Mifos Initiative - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * See https://github.com/openMF/android-client/blob/master/LICENSE.md - */ -package com.mifos.feature.individualCollectionSheet.individualCollectionSheetDetail - -import com.mifos.room.entities.collectionsheet.IndividualCollectionSheet - -data class IndividualCollectionSheetDetailUiState( - val isLoading: Boolean = false, - val error: String? = null, - val collectionSheet: IndividualCollectionSheet? = null, - val repaymentDate: String = "", -) - -data class LoanCollectionItem( - val loanId: Int, - val accountId: String, - val clientName: String, - val productName: String, - val totalDue: Double, - val charges: Double, - val principalDue: Double, - val interestDue: Double, - val feeDue: Double, - val currencySymbol: String, -) - -data class SavingsCollectionItem( - val clientName: String, - val depositAccountType: String, - val savingsAccountId: String = "", - val productName: String = "", - val totalDue: Double = 0.0, - val currencySymbol: String = "$", -) diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetail/IndividualCollectionSheetDetailViewModel.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetail/IndividualCollectionSheetDetailViewModel.kt deleted file mode 100644 index 07bff816b7..0000000000 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetail/IndividualCollectionSheetDetailViewModel.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2025 Mifos Initiative - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * See https://github.com/openMF/android-client/blob/master/LICENSE.md - */ -package com.mifos.feature.individualCollectionSheet.individualCollectionSheetDetail - -import androidx.lifecycle.ViewModel -import com.mifos.room.entities.collectionsheet.IndividualCollectionSheet -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.asStateFlow - -class IndividualCollectionSheetDetailViewModel : ViewModel() { - - private val uiStateInternal = MutableStateFlow(IndividualCollectionSheetDetailUiState()) - val individualCollectionSheetDetailUiState = uiStateInternal.asStateFlow() - - fun setCollectionSheetData(repaymentDate: String, collectionSheet: IndividualCollectionSheet) { - updateUiState { - it.copy( - repaymentDate = repaymentDate, - collectionSheet = collectionSheet, - isLoading = false, - ) - } - } - - private inline fun updateUiState(update: (IndividualCollectionSheetDetailUiState) -> IndividualCollectionSheetDetailUiState) { - uiStateInternal.value = update(uiStateInternal.value) - } -} diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetNavigation.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetNavigation.kt index 9cd1d967fd..897dd58dad 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetNavigation.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetNavigation.kt @@ -21,13 +21,10 @@ import com.mifos.core.model.objects.collectionsheets.LoanAndClientName import com.mifos.core.network.model.IndividualCollectionSheetPayload import com.mifos.feature.individualCollectionSheet.generateCollectionSheet.GenerateCollectionSheetScreen import com.mifos.feature.individualCollectionSheet.individualCollectionSheet.IndividualCollectionSheetScreen -import com.mifos.feature.individualCollectionSheet.individualCollectionSheetDetail.IndividualCollectionSheetDetailScreen import com.mifos.feature.individualCollectionSheet.individualCollectionSheetDetails.IndividualCollectionSheetDetailsScreen -import com.mifos.feature.individualCollectionSheet.newIndividualCollectionSheet.NewIndividualCollectionSheetScreen import com.mifos.feature.individualCollectionSheet.paymentDetails.PaymentDetailsScreenRoute import com.mifos.room.entities.collectionsheet.IndividualCollectionSheet import kotlinx.serialization.Serializable -import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json fun NavGraphBuilder.individualCollectionSheetNavGraph( @@ -36,19 +33,8 @@ fun NavGraphBuilder.individualCollectionSheetNavGraph( ) { navigation( route = "generate_collection_sheet", - startDestination = CollectionSheetScreens.NewIndividualCollectionSheetScreen.route, + startDestination = CollectionSheetScreens.IndividualCollectionSheetScreen.route, ) { - newIndividualCollectionSheetScreen( - onBackPressed = onBackPressed, - onDetail = { date, sheet -> - navController.navigateToNewIndividualCollectionSheetDetailScreen(date, sheet) - }, - ) - - newIndividualCollectionSheetDetailScreen( - onBackPressed = onBackPressed, - ) - individualCollectionSheetScreen( onBackPressed = onBackPressed, onDetail = { _, sheet -> @@ -65,51 +51,6 @@ fun NavGraphBuilder.individualCollectionSheetNavGraph( paymentDetailsScreen() } } -private fun NavGraphBuilder.newIndividualCollectionSheetScreen( - onBackPressed: () -> Unit, - onDetail: (String, IndividualCollectionSheet) -> Unit, -) { - composable( - route = CollectionSheetScreens.NewIndividualCollectionSheetScreen.route, - ) { - NewIndividualCollectionSheetScreen( - onDetail = onDetail, - ) - } -} - -private fun NavGraphBuilder.newIndividualCollectionSheetDetailScreen( - onBackPressed: () -> Unit, -) { - composable( - route = CollectionSheetScreens.NewIndividualCollectionSheetDetailScreen.route, - arguments = listOf( - navArgument(name = Constants.INDIVIDUAL_SHEET_DATE) { - type = NavType.StringType - }, - navArgument(name = Constants.INDIVIDUAL_SHEET) { - type = NavType.StringType - }, - ), - ) { backStackEntry -> - val dateString = backStackEntry.arguments?.getString(Constants.INDIVIDUAL_SHEET_DATE) ?: "" - val sheetJson = backStackEntry.arguments?.getString(Constants.INDIVIDUAL_SHEET) ?: "" - - val collectionSheet = Json.decodeFromString(sheetJson) - IndividualCollectionSheetDetailScreen( - repaymentDate = dateString, - collectionSheet = collectionSheet, - onAddPayment = { loanItem -> - // TODO: Implement payment functionality - println("Add payment for loan: ${loanItem.loanId}") - }, - onAddSavingsPayment = { savingsItem -> - // TODO: Implement savings payment functionality - println("Add savings payment for: ${savingsItem.clientName}") - }, - ) - } -} private fun NavGraphBuilder.individualCollectionSheetScreen( onBackPressed: () -> Unit, @@ -164,12 +105,6 @@ fun NavGraphBuilder.paymentDetailsScreen() { PaymentDetailsScreenRoute() } } -fun NavController.navigateToNewIndividualCollectionSheetDetailScreen( - date: String, - sheet: IndividualCollectionSheet, -) { - navigate(CollectionSheetScreens.NewIndividualCollectionSheetDetailScreen.argument(date, sheet)) -} fun NavController.navigateToIndividualCollectionSheetDetailScreen(sheet: IndividualCollectionSheet) { navigate(CollectionSheetScreens.IndividualCollectionSheetDetailScreen.argument(sheet)) diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetScreens.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetScreens.kt index 881f11f4c8..393fc98c87 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetScreens.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetScreens.kt @@ -25,18 +25,6 @@ sealed class CollectionSheetScreens(val route: String) { data object IndividualCollectionSheetScreen : CollectionSheetScreens("individual_collection_sheet_route") - data object NewIndividualCollectionSheetScreen : - CollectionSheetScreens("new_individual_collection_sheet_route") - - data object NewIndividualCollectionSheetDetailScreen : - CollectionSheetScreens("new_individual_collection_sheet_detail/{${Constants.INDIVIDUAL_SHEET_DATE}}/{${Constants.INDIVIDUAL_SHEET}}") { - - fun argument(date: String, sheet: IndividualCollectionSheet): String { - val sheetInGsonString = Json.encodeToString(sheet) - return "new_individual_collection_sheet_detail/$date/$sheetInGsonString" - } - } - data object PaymentDetailsScreen : CollectionSheetScreens("payment_details_route/{${Constants.PAYMENT_DETAILS_ARGS}}") { diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt index d594d0ceae..9ac3b194ca 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt @@ -14,9 +14,13 @@ package com.mifos.feature.individualCollectionSheet.newIndividualCollectionSheet import androidclient.feature.collectionsheet.generated.resources.Res import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_cancel import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_clear +import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_date import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_fill_collection_sheet_message +import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_fill_now +import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_found_sheet import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_generate import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_generate_new +import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_member import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_office import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_repayment_date import androidclient.feature.collectionsheet.generated.resources.feature_collection_sheet_select @@ -30,6 +34,7 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width import androidx.compose.material3.DatePicker import androidx.compose.material3.DatePickerDialog import androidx.compose.material3.ExperimentalMaterial3Api @@ -48,11 +53,13 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalSoftwareKeyboardController import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.mifos.core.common.utils.DateHelper +import com.mifos.core.designsystem.component.MifosBottomSheet import com.mifos.core.designsystem.component.MifosButton import com.mifos.core.designsystem.component.MifosCircularProgress import com.mifos.core.designsystem.component.MifosDatePickerTextField @@ -110,7 +117,7 @@ internal fun NewIndividualCollectionSheetScreen( var staffId by rememberSaveable { mutableIntStateOf(0) } val snackbarHostState = remember { SnackbarHostState() } -// var showCollectionSheetDialog by rememberSaveable { mutableStateOf(false) } + var showCollectionSheetDialog by rememberSaveable { mutableStateOf(false) } var showDatePicker by rememberSaveable { mutableStateOf(false) } var repaymentDate by rememberSaveable { @@ -139,16 +146,7 @@ internal fun NewIndividualCollectionSheetScreen( LaunchedEffect(key1 = state.individualCollectionSheet) { state.individualCollectionSheet?.let { individualCollectionSheet = it - try { - onDetail( - DateHelper.getDateAsStringFromLong(repaymentDate), - it, - ) - println("DEBUG: Navigation successful") - } catch (e: Exception) { - println("DEBUG: Navigation failed: ${e.message}") - e.printStackTrace() - } + showCollectionSheetDialog = true } } @@ -184,31 +182,31 @@ internal fun NewIndividualCollectionSheetScreen( DatePicker(state = datePickerState) } } -// if (showCollectionSheetDialog) { -// MifosBottomSheet( -// content = { -// CollectionSheetDialogContent( -// date = DateHelper.getDateAsStringFromLong(repaymentDate), -// member = individualCollectionSheet?.clients?.size.toString(), -// fillNow = { -// showCollectionSheetDialog = false -// individualCollectionSheet?.let { -// onDetail( -// DateHelper.getDateAsStringFromLong(repaymentDate), -// it, -// ) -// } -// }, -// onDismiss = { -// showCollectionSheetDialog = false -// }, -// ) -// }, -// onDismiss = { -// showCollectionSheetDialog = false -// }, -// ) -// } + if (showCollectionSheetDialog) { + MifosBottomSheet( + content = { + CollectionSheetDialogContent( + date = DateHelper.getDateAsStringFromLong(repaymentDate), + member = individualCollectionSheet?.clients?.size.toString(), + fillNow = { + showCollectionSheetDialog = false + individualCollectionSheet?.let { + onDetail( + DateHelper.getDateAsStringFromLong(repaymentDate), + it, + ) + } + }, + onDismiss = { + showCollectionSheetDialog = false + }, + ) + }, + onDismiss = { + showCollectionSheetDialog = false + }, + ) + } if (state.isLoading) { MifosCircularProgress() } else { @@ -272,7 +270,6 @@ internal fun NewIndividualCollectionSheetScreen( selectedStaff = it }, onOptionSelected = { index, value -> - println("Staff selection - Index: $index, List size: ${state.staffList.size}, Value: $value") try { if (index >= 0 && index < state.staffList.size) { val selectedStaffEntity = state.staffList[index] @@ -340,83 +337,83 @@ internal fun NewIndividualCollectionSheetScreen( } } -// @Composable -// private fun CollectionSheetDialogContent( -// date: String, -// member: String, -// fillNow: () -> Unit, -// modifier: Modifier = Modifier, -// onDismiss: () -> Unit, -// ) { -// MifosBottomSheet( -// modifier = modifier, -// content = { -// Column( -// modifier = Modifier -// .fillMaxWidth() -// .padding(start = 16.dp, end = 16.dp, bottom = 16.dp), -// ) { -// Text( -// modifier = Modifier -// .fillMaxWidth() -// .align(Alignment.CenterHorizontally), -// text = stringResource(Res.string.feature_collection_sheet_found_sheet), -// style = MaterialTheme.typography.titleLarge, -// ) -// Spacer(modifier = Modifier.height(16.dp)) -// Text( -// text = stringResource(Res.string.feature_collection_sheet_fill_collection_sheet_message), -// style = MaterialTheme.typography.bodyLarge, -// ) -// Spacer(modifier = Modifier.height(16.dp)) -// Row { -// Text( -// text = stringResource(Res.string.feature_collection_sheet_date), -// style = MaterialTheme.typography.bodyLarge, -// ) -// Spacer(modifier = Modifier.width(16.dp)) -// Text( -// text = date, -// style = MaterialTheme.typography.bodyLarge, -// ) -// } -// -// Row { -// Text( -// text = stringResource(Res.string.feature_collection_sheet_member), -// style = MaterialTheme.typography.bodyLarge, -// ) -// Spacer(modifier = Modifier.width(16.dp)) -// Text( -// text = member, -// style = MaterialTheme.typography.bodyLarge, -// ) -// } -// Spacer(modifier = Modifier.height(16.dp)) -// Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) { -// MifosButton( -// onClick = fillNow, -// ) { -// Text( -// text = stringResource(Res.string.feature_collection_sheet_fill_now), -// style = MaterialTheme.typography.bodyLarge, -// ) -// } -// Spacer(modifier = Modifier.width(16.dp)) -// MifosButton( -// onClick = onDismiss, -// ) { -// Text( -// text = stringResource(Res.string.feature_collection_sheet_cancel), -// style = MaterialTheme.typography.bodyLarge, -// ) -// } -// } -// } -// }, -// onDismiss = onDismiss, -// ) -// } +@Composable +private fun CollectionSheetDialogContent( + date: String, + member: String, + fillNow: () -> Unit, + modifier: Modifier = Modifier, + onDismiss: () -> Unit, +) { + MifosBottomSheet( + modifier = modifier, + content = { + Column( + modifier = Modifier + .fillMaxWidth() + .padding(start = 16.dp, end = 16.dp, bottom = 16.dp), + ) { + Text( + modifier = Modifier + .fillMaxWidth() + .align(Alignment.CenterHorizontally), + text = stringResource(Res.string.feature_collection_sheet_found_sheet), + style = MaterialTheme.typography.titleLarge, + ) + Spacer(modifier = Modifier.height(16.dp)) + Text( + text = stringResource(Res.string.feature_collection_sheet_fill_collection_sheet_message), + style = MaterialTheme.typography.bodyLarge, + ) + Spacer(modifier = Modifier.height(16.dp)) + Row { + Text( + text = stringResource(Res.string.feature_collection_sheet_date), + style = MaterialTheme.typography.bodyLarge, + ) + Spacer(modifier = Modifier.width(16.dp)) + Text( + text = date, + style = MaterialTheme.typography.bodyLarge, + ) + } + + Row { + Text( + text = stringResource(Res.string.feature_collection_sheet_member), + style = MaterialTheme.typography.bodyLarge, + ) + Spacer(modifier = Modifier.width(16.dp)) + Text( + text = member, + style = MaterialTheme.typography.bodyLarge, + ) + } + Spacer(modifier = Modifier.height(16.dp)) + Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) { + MifosButton( + onClick = fillNow, + ) { + Text( + text = stringResource(Res.string.feature_collection_sheet_fill_now), + style = MaterialTheme.typography.bodyLarge, + ) + } + Spacer(modifier = Modifier.width(16.dp)) + MifosButton( + onClick = onDismiss, + ) { + Text( + text = stringResource(Res.string.feature_collection_sheet_cancel), + style = MaterialTheme.typography.bodyLarge, + ) + } + } + } + }, + onDismiss = onDismiss, + ) +} @Preview @Composable @@ -468,8 +465,8 @@ val sampleOfficeList = List(10) { OfficeEntity(id = it, name = "Name") } -// @Preview -// @Composable -// private fun CollectionSheetDialogContentPreview() { -// CollectionSheetDialogContent(date = "19 June 2024", member = "5", fillNow = {}, onDismiss = {}) -// } +@Preview +@Composable +private fun CollectionSheetDialogContentPreview() { + CollectionSheetDialogContent(date = "19 June 2024", member = "5", fillNow = {}, onDismiss = {}) +} From ff585b18e1ca830ec1fac691f4c24822eaeb48f1 Mon Sep 17 00:00:00 2001 From: Aditya3815 Date: Thu, 26 Jun 2025 00:30:38 +0530 Subject: [PATCH 07/13] Collection Sheet Enhancement Complete --- .../IndividualCollectionSheetDetailsScreen.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt index dc385784d2..c7052bb9a9 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt @@ -257,7 +257,7 @@ private fun IndividualCollectionSheetItem( ) Spacer(modifier = Modifier.width(16.dp)) Text( - text = loan?.totalDue.toString(), + text = (loan?.totalDue ?: 0).toString(), style = MaterialTheme.typography.bodyMedium, ) } @@ -268,14 +268,16 @@ private fun IndividualCollectionSheetItem( ) Spacer(modifier = Modifier.width(16.dp)) Text( - text = loan?.chargesDue.toString(), + text = (loan?.chargesDue ?: 0).toString(), + style = MaterialTheme.typography.bodyMedium, + ) + } + if (loan?.productShortName != null) { + Text( + text = "${loan.productShortName} (#${loan.productShortName})", style = MaterialTheme.typography.bodyMedium, ) } - Text( - text = "${loan?.productShortName} (#${loan?.productShortName})", - style = MaterialTheme.typography.bodyMedium, - ) } Icon( imageVector = MifosIcons.ArrowForward, From a276755dc7f612767ca473cc67248dd7b01e2ba7 Mon Sep 17 00:00:00 2001 From: Aditya3815 Date: Thu, 26 Jun 2025 02:07:22 +0530 Subject: [PATCH 08/13] Index removed as parameter instead directly passing loan Removed duplicate depndencies from build.gradle.kts change the Int to Double type 0 -> 0.0 --- feature/collectionSheet/build.gradle.kts | 4 -- .../IndividualCollectionSheetDetailsScreen.kt | 19 +++++---- .../NewIndividualCollectionSheetScreen.kt | 41 +++++-------------- 3 files changed, 21 insertions(+), 43 deletions(-) diff --git a/feature/collectionSheet/build.gradle.kts b/feature/collectionSheet/build.gradle.kts index 30a0b80d33..fab066f293 100644 --- a/feature/collectionSheet/build.gradle.kts +++ b/feature/collectionSheet/build.gradle.kts @@ -34,8 +34,4 @@ kotlin { } } -} - -dependencies { - debugImplementation(compose.uiTooling) } \ No newline at end of file diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt index c7052bb9a9..2bec0220fa 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt @@ -30,6 +30,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.shape.CircleShape import androidx.compose.material3.Icon @@ -58,6 +59,7 @@ import com.mifos.core.designsystem.component.MifosSweetError import com.mifos.core.designsystem.icon.MifosIcons import com.mifos.core.model.objects.account.loan.PaymentTypeOptions import com.mifos.core.model.objects.collectionsheets.LoanAndClientName +import com.mifos.core.model.objects.collectionsheets.LoanCollectionSheet import com.mifos.core.network.model.IndividualCollectionSheetPayload import com.mifos.room.entities.collectionsheet.ClientCollectionSheet import com.mifos.room.entities.collectionsheet.IndividualCollectionSheet @@ -178,17 +180,17 @@ internal fun IndividualCollectionSheetDetailsScreen( } else { LazyColumn { sheet.clients?.toList()?.let { - itemsIndexed(it) { index, client -> + items(it.zip(loansAndClientNames)) { (client, loanAndClientName) -> IndividualCollectionSheetItem( client = client, - index = index, + loan = loanAndClientName.loan, onClick = { sheet.paymentTypeOptions?.let { paymentTypeOptions -> submit( - index, + 0, payload, - paymentTypeOptions.map { paymentTypeOption -> paymentTypeOption.name.toString() }, - loansAndClientNames[index], + paymentTypeOptions.map { it.name.toString() }, + loanAndClientName, paymentTypeOptions.toList(), client.clientId, ) @@ -206,11 +208,10 @@ internal fun IndividualCollectionSheetDetailsScreen( @Composable private fun IndividualCollectionSheetItem( client: ClientCollectionSheet, - index: Int, + loan: LoanCollectionSheet?, modifier: Modifier = Modifier, onClick: () -> Unit, ) { - val loan = client.loans?.getOrNull(index) OutlinedCard( modifier = modifier @@ -257,7 +258,7 @@ private fun IndividualCollectionSheetItem( ) Spacer(modifier = Modifier.width(16.dp)) Text( - text = (loan?.totalDue ?: 0).toString(), + text = (loan?.totalDue ?: 0.0).toString(), style = MaterialTheme.typography.bodyMedium, ) } @@ -268,7 +269,7 @@ private fun IndividualCollectionSheetItem( ) Spacer(modifier = Modifier.width(16.dp)) Text( - text = (loan?.chargesDue ?: 0).toString(), + text = (loan?.chargesDue ?: 0.0).toString(), style = MaterialTheme.typography.bodyMedium, ) } diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt index 9ac3b194ca..26a778f9fa 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt @@ -233,24 +233,15 @@ internal fun NewIndividualCollectionSheetScreen( selectedStaff = "" }, onOptionSelected = { index, value -> - println("DEBUG: Office selection - Index: $index, List size: ${state.officeList.size}, Value: $value") - try { - if (index >= 0 && index < state.officeList.size) { - val selectedOfficeEntity = state.officeList[index] - selectedOfficeEntity.id?.let { - getStaffList(it) - officeId = it - } - selectedOffice = value - selectedStaff = "" - println("DEBUG: Office selection successful") - } else { - println("DEBUG: Office index out of bounds: $index for size ${state.officeList.size}") + state.officeList.getOrNull(index)?.let { selectedOfficeEntity -> + selectedOfficeEntity.id.let { + getStaffList(it) + officeId = it } - } catch (e: Exception) { - println("DEBUG: Error in office selection: ${e.message}") - println("DEBUG: Full error: ${e.stackTraceToString()}") + selectedOffice = selectedOfficeEntity.name.toString() + selectedStaff = "" } + }, label = stringResource(Res.string.feature_collection_sheet_office), options = state.officeList.map { it.name.toString() }, @@ -270,21 +261,11 @@ internal fun NewIndividualCollectionSheetScreen( selectedStaff = it }, onOptionSelected = { index, value -> - try { - if (index >= 0 && index < state.staffList.size) { - val selectedStaffEntity = state.staffList[index] - selectedStaffEntity.id?.let { - staffId = it - } - selectedStaff = value - println("DEBUG: Staff selection successful") - } else { - println("DEBUG: Staff index out of bounds: $index for size ${state.staffList.size}") - } - } catch (e: Exception) { - println("DEBUG: Error in staff selection: ${e.message}") - println("DEBUG: Full error: ${e.stackTraceToString()}") + val selectedStaffEntity = state.staffList[index] + selectedStaffEntity.id?.let { + staffId = it } + selectedStaff = value }, label = stringResource(Res.string.feature_collection_sheet_staff), options = state.staffList.map { it.displayName.toString() }, From 48ec51b0457490b6aa9980cd32e1e3c21eb75577 Mon Sep 17 00:00:00 2001 From: revanthkumarJ Date: Thu, 3 Jul 2025 21:32:09 +0530 Subject: [PATCH 09/13] updated --- feature/collectionSheet/build.gradle.kts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/feature/collectionSheet/build.gradle.kts b/feature/collectionSheet/build.gradle.kts index fab066f293..818cf86129 100644 --- a/feature/collectionSheet/build.gradle.kts +++ b/feature/collectionSheet/build.gradle.kts @@ -13,7 +13,6 @@ plugins { alias(libs.plugins.kotlin.serialization) } - android { namespace = "com.mifos.feature.collection_sheet" } @@ -34,4 +33,8 @@ kotlin { } } +} + +dependencies { + debugImplementation(compose.uiTooling) } \ No newline at end of file From d652cf405e6442904c90a84cb70545effeae1adf Mon Sep 17 00:00:00 2001 From: revanthkumarJ Date: Fri, 4 Jul 2025 18:54:48 +0530 Subject: [PATCH 10/13] updated --- .../navigation/navigation/HomeDestinationsScreen.kt | 10 +++++----- .../NewIndividualCollectionSheetScreen.kt | 7 ++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cmp-navigation/src/commonMain/kotlin/cmp/navigation/navigation/HomeDestinationsScreen.kt b/cmp-navigation/src/commonMain/kotlin/cmp/navigation/navigation/HomeDestinationsScreen.kt index 0fe302366a..0daae86a9d 100644 --- a/cmp-navigation/src/commonMain/kotlin/cmp/navigation/navigation/HomeDestinationsScreen.kt +++ b/cmp-navigation/src/commonMain/kotlin/cmp/navigation/navigation/HomeDestinationsScreen.kt @@ -61,11 +61,11 @@ sealed class HomeDestinationsScreen( icon = MifosIcons.Assignment, ) - data object CollectionSheetScreen : HomeDestinationsScreen( - title = "Collection Sheet", - route = "generate_collection_sheet", - icon = MifosIcons.Assignment, - ) +// data object CollectionSheetScreen : HomeDestinationsScreen( +// title = "Collection Sheet", +// route = "generate_collection_sheet", +// icon = MifosIcons.Assignment, +// ) data object RunReportsScreen : HomeDestinationsScreen( title = "Run Reports", diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt index 26a778f9fa..c79da98162 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt @@ -58,6 +58,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalSoftwareKeyboardController import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.mifos.core.common.utils.Constants import com.mifos.core.common.utils.DateHelper import com.mifos.core.designsystem.component.MifosBottomSheet import com.mifos.core.designsystem.component.MifosButton @@ -92,8 +93,8 @@ internal fun NewIndividualCollectionSheetScreen( officeId = id transactionDate = date staffId = idStaff - locale = "en" - dateFormat = "dd-MM-yyyy" + locale = Constants.LOCALE_EN + dateFormat = DateHelper.SHORT_MONTH }, ) }, @@ -129,7 +130,7 @@ internal fun NewIndividualCollectionSheetScreen( initialSelectedDateMillis = repaymentDate, selectableDates = object : SelectableDates { override fun isSelectableDate(utcTimeMillis: Long): Boolean { - return utcTimeMillis >= Clock.System.now().toEpochMilliseconds() + return utcTimeMillis <= Clock.System.now().toEpochMilliseconds() } }, ) From 6f2288df85de88dc777547fd2b2a3aab5bf461f7 Mon Sep 17 00:00:00 2001 From: revanthkumarJ Date: Fri, 4 Jul 2025 20:21:09 +0530 Subject: [PATCH 11/13] updated --- .../navigation/HomeDestinationsScreen.kt | 10 +-- .../IndividualCollectionSheetScreen.kt | 2 +- ...dividualCollectionSheetDetailsViewModel.kt | 7 ++ .../navigation/CollectionSheetNavigation.kt | 4 +- .../NewIndividualCollectionSheetScreen.kt | 71 ++++++++----------- 5 files changed, 45 insertions(+), 49 deletions(-) diff --git a/cmp-navigation/src/commonMain/kotlin/cmp/navigation/navigation/HomeDestinationsScreen.kt b/cmp-navigation/src/commonMain/kotlin/cmp/navigation/navigation/HomeDestinationsScreen.kt index 0daae86a9d..0fe302366a 100644 --- a/cmp-navigation/src/commonMain/kotlin/cmp/navigation/navigation/HomeDestinationsScreen.kt +++ b/cmp-navigation/src/commonMain/kotlin/cmp/navigation/navigation/HomeDestinationsScreen.kt @@ -61,11 +61,11 @@ sealed class HomeDestinationsScreen( icon = MifosIcons.Assignment, ) -// data object CollectionSheetScreen : HomeDestinationsScreen( -// title = "Collection Sheet", -// route = "generate_collection_sheet", -// icon = MifosIcons.Assignment, -// ) + data object CollectionSheetScreen : HomeDestinationsScreen( + title = "Collection Sheet", + route = "generate_collection_sheet", + icon = MifosIcons.Assignment, + ) data object RunReportsScreen : HomeDestinationsScreen( title = "Run Reports", diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheet/IndividualCollectionSheetScreen.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheet/IndividualCollectionSheetScreen.kt index 8bbab7e244..da26ffc888 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheet/IndividualCollectionSheetScreen.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheet/IndividualCollectionSheetScreen.kt @@ -34,7 +34,7 @@ import org.jetbrains.compose.ui.tooling.preview.Preview @Composable internal fun IndividualCollectionSheetScreen( onBackPressed: () -> Unit, - onDetail: (String, IndividualCollectionSheet) -> Unit, + onDetail: (IndividualCollectionSheet) -> Unit, ) { val snackbarHostState = remember { SnackbarHostState() } diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsViewModel.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsViewModel.kt index 53e45085d8..98acb5d141 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsViewModel.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsViewModel.kt @@ -14,6 +14,7 @@ import androidclient.feature.collectionsheet.generated.resources.feature_collect import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import co.touchlab.kermit.Logger import com.mifos.core.common.utils.Constants import com.mifos.core.common.utils.DataState import com.mifos.core.domain.useCases.SaveIndividualCollectionSheetUseCase @@ -40,6 +41,12 @@ class IndividualCollectionSheetDetailsViewModel( IndividualCollectionSheet() } + init { + Logger.e("Revanth"){ + sheet.toString() + } + } + @Suppress("ktlint:standard:property-naming") private val uiStateInternal = MutableStateFlow( IndividualCollectionSheetDetailsUiState.Empty, diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetNavigation.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetNavigation.kt index 897dd58dad..1329eb9143 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetNavigation.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetNavigation.kt @@ -37,7 +37,7 @@ fun NavGraphBuilder.individualCollectionSheetNavGraph( ) { individualCollectionSheetScreen( onBackPressed = onBackPressed, - onDetail = { _, sheet -> + onDetail = { sheet -> navController.navigateToIndividualCollectionSheetDetailScreen(sheet) }, @@ -54,7 +54,7 @@ fun NavGraphBuilder.individualCollectionSheetNavGraph( private fun NavGraphBuilder.individualCollectionSheetScreen( onBackPressed: () -> Unit, - onDetail: (String, IndividualCollectionSheet) -> Unit, + onDetail: (IndividualCollectionSheet) -> Unit, ) { composable( route = CollectionSheetScreens.IndividualCollectionSheetScreen.route, diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt index c79da98162..19eeb21b72 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/NewIndividualCollectionSheetScreen.kt @@ -73,12 +73,14 @@ import com.mifos.room.entities.organisation.StaffEntity import kotlinx.datetime.Clock import org.jetbrains.compose.resources.stringResource import org.jetbrains.compose.ui.tooling.preview.Preview +import org.jetbrains.compose.ui.tooling.preview.PreviewParameter +import org.jetbrains.compose.ui.tooling.preview.PreviewParameterProvider import org.koin.compose.viewmodel.koinViewModel @Composable internal fun NewIndividualCollectionSheetScreen( viewModel: NewIndividualCollectionSheetViewModel = koinViewModel(), - onDetail: (String, IndividualCollectionSheet) -> Unit, + onDetail: (IndividualCollectionSheet) -> Unit, ) { val state = viewModel.newIndividualCollectionSheetUiState.collectAsStateWithLifecycle().value @@ -108,7 +110,7 @@ internal fun NewIndividualCollectionSheetScreen( getStaffList: (Int) -> Unit, generateCollection: (Int, Int, String) -> Unit, modifier: Modifier = Modifier, - onDetail: (String, IndividualCollectionSheet) -> Unit, + onDetail: (IndividualCollectionSheet) -> Unit, ) { val keyboardController = LocalSoftwareKeyboardController.current @@ -193,7 +195,6 @@ internal fun NewIndividualCollectionSheetScreen( showCollectionSheetDialog = false individualCollectionSheet?.let { onDetail( - DateHelper.getDateAsStringFromLong(repaymentDate), it, ) } @@ -246,6 +247,7 @@ internal fun NewIndividualCollectionSheetScreen( }, label = stringResource(Res.string.feature_collection_sheet_office), options = state.officeList.map { it.name.toString() }, + readOnly = true ) Spacer(modifier = Modifier.height(8.dp)) MifosDatePickerTextField( @@ -270,6 +272,7 @@ internal fun NewIndividualCollectionSheetScreen( }, label = stringResource(Res.string.feature_collection_sheet_staff), options = state.staffList.map { it.displayName.toString() }, + readOnly = true ) Row( modifier = Modifier @@ -397,46 +400,32 @@ private fun CollectionSheetDialogContent( ) } +class NewIndividualCollectionSheetUiStateProvider : + PreviewParameterProvider { + + override val values: Sequence + get() = sequenceOf( + NewIndividualCollectionSheetUiState(staffList = sampleStaffList), + NewIndividualCollectionSheetUiState(officeList = sampleOfficeList), + NewIndividualCollectionSheetUiState(error = "Error Occurred"), + NewIndividualCollectionSheetUiState(isLoading = true), + NewIndividualCollectionSheetUiState(individualCollectionSheet = IndividualCollectionSheet()), + ) +} + @Preview @Composable -private fun NewIndividualCollectionSheetPreview() { - Column { - NewIndividualCollectionSheetScreen( - state = NewIndividualCollectionSheetUiState(staffList = sampleStaffList), - getStaffList = {}, - generateCollection = { _, _, _ -> - }, - onDetail = { _, _ -> }, - ) - NewIndividualCollectionSheetScreen( - state = NewIndividualCollectionSheetUiState(officeList = sampleOfficeList), - getStaffList = {}, - generateCollection = { _, _, _ -> - }, - onDetail = { _, _ -> }, - ) - NewIndividualCollectionSheetScreen( - state = NewIndividualCollectionSheetUiState(error = "Error Occurred"), - getStaffList = {}, - generateCollection = { _, _, _ -> - }, - onDetail = { _, _ -> }, - ) - NewIndividualCollectionSheetScreen( - state = NewIndividualCollectionSheetUiState(isLoading = true), - getStaffList = {}, - generateCollection = { _, _, _ -> - }, - onDetail = { _, _ -> }, - ) - NewIndividualCollectionSheetScreen( - state = NewIndividualCollectionSheetUiState(individualCollectionSheet = IndividualCollectionSheet()), - getStaffList = {}, - generateCollection = { _, _, _ -> - }, - onDetail = { _, _ -> }, - ) - } +private fun NewIndividualCollectionSheetPreview( + @PreviewParameter(NewIndividualCollectionSheetUiStateProvider::class) + newIndividualCollectionSheetUiState: NewIndividualCollectionSheetUiState, +) { + NewIndividualCollectionSheetScreen( + state = newIndividualCollectionSheetUiState, + getStaffList = {}, + generateCollection = { _, _, _ -> + }, + onDetail = { _ -> }, + ) } val sampleStaffList = List(10) { From 4829298ac0fd8d936d6fc559d0fc26d64a437066 Mon Sep 17 00:00:00 2001 From: revanthkumarJ Date: Fri, 4 Jul 2025 20:30:33 +0530 Subject: [PATCH 12/13] updated --- .../IndividualCollectionSheetScreen.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheet/IndividualCollectionSheetScreen.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheet/IndividualCollectionSheetScreen.kt index da26ffc888..7d14e73d2c 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheet/IndividualCollectionSheetScreen.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheet/IndividualCollectionSheetScreen.kt @@ -72,5 +72,5 @@ enum class IndividualCollectionSheetScreenContents { @Preview @Composable private fun IndividualCollectionSheetScreenPreview() { - IndividualCollectionSheetScreen(onBackPressed = {}, onDetail = { _, _ -> }) + IndividualCollectionSheetScreen(onBackPressed = {}, onDetail = { _ -> }) } From 84a55430e5895fc6c5415bd1366ff55d8833bcff Mon Sep 17 00:00:00 2001 From: revanthkumarJ Date: Sat, 5 Jul 2025 18:18:06 +0530 Subject: [PATCH 13/13] updated --- .../IndividualCollectionSheetDetailsScreen.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt index 2bec0220fa..6739789baa 100644 --- a/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt +++ b/feature/collectionSheet/src/commonMain/kotlin/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt @@ -180,14 +180,14 @@ internal fun IndividualCollectionSheetDetailsScreen( } else { LazyColumn { sheet.clients?.toList()?.let { - items(it.zip(loansAndClientNames)) { (client, loanAndClientName) -> + itemsIndexed(it.zip(loansAndClientNames)) { index,(client, loanAndClientName) -> IndividualCollectionSheetItem( client = client, loan = loanAndClientName.loan, onClick = { sheet.paymentTypeOptions?.let { paymentTypeOptions -> submit( - 0, + index, payload, paymentTypeOptions.map { it.name.toString() }, loanAndClientName,