diff --git a/core/designsystem/src/main/java/com/mifos/core/designsystem/component/MifosBottomSheet.kt b/core/designsystem/src/main/java/com/mifos/core/designsystem/component/MifosBottomSheet.kt index cac4f8d15aa..051081b9126 100644 --- a/core/designsystem/src/main/java/com/mifos/core/designsystem/component/MifosBottomSheet.kt +++ b/core/designsystem/src/main/java/com/mifos/core/designsystem/component/MifosBottomSheet.kt @@ -24,7 +24,8 @@ import kotlinx.coroutines.launch @Composable fun MifosBottomSheet( content: @Composable () -> Unit, - onDismiss: () -> Unit + onDismiss: () -> Unit, + modifier: Modifier = Modifier, ) { val coroutineScope = rememberCoroutineScope() val modalSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true) @@ -44,14 +45,17 @@ fun MifosBottomSheet( dismissSheet() } - AnimatedVisibility(visible = showBottomSheet) { + AnimatedVisibility( + modifier = modifier, + visible = showBottomSheet, + ) { ModalBottomSheet( containerColor = Color.White, onDismissRequest = { showBottomSheet = false dismissSheet() }, - sheetState = modalSheetState + sheetState = modalSheetState, ) { content() } @@ -61,9 +65,12 @@ fun MifosBottomSheet( @Preview @Composable fun MifosBottomSheetPreview() { - MifosBottomSheet({ - Box { - Modifier.height(100.dp) - } - }, {}) + MifosBottomSheet( + { + Box { + Modifier.height(100.dp) + } + }, + {}, + ) } \ No newline at end of file diff --git a/feature/collection-sheet/src/main/AndroidManifest.xml b/feature/collection-sheet/src/main/AndroidManifest.xml deleted file mode 100644 index a5918e68abc..00000000000 --- a/feature/collection-sheet/src/main/AndroidManifest.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/individual_collection_sheet_details/IndividualCollectionSheetDetailsUiState.kt b/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/individual_collection_sheet_details/IndividualCollectionSheetDetailsUiState.kt deleted file mode 100644 index 474f8616b6d..00000000000 --- a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/individual_collection_sheet_details/IndividualCollectionSheetDetailsUiState.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.mifos.feature.individual_collection_sheet.individual_collection_sheet_details - -/** - * Created by Aditya Gupta on 10/08/23. - */ -sealed class IndividualCollectionSheetDetailsUiState { - - data object Empty : IndividualCollectionSheetDetailsUiState() - - data object Loading : IndividualCollectionSheetDetailsUiState() - - data class Error(val message: Int) : IndividualCollectionSheetDetailsUiState() - - data object SavedSuccessfully : IndividualCollectionSheetDetailsUiState() -} \ No newline at end of file diff --git a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/saved_individual_collection_sheet/ui/SavedIndividualCollectionSheetViewModel.kt b/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/saved_individual_collection_sheet/ui/SavedIndividualCollectionSheetViewModel.kt deleted file mode 100644 index 9b3751d978a..00000000000 --- a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/saved_individual_collection_sheet/ui/SavedIndividualCollectionSheetViewModel.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.mifos.feature.individual_collection_sheet.saved_individual_collection_sheet.ui - -import androidx.lifecycle.ViewModel -import dagger.hilt.android.lifecycle.HiltViewModel -import javax.inject.Inject - -@HiltViewModel -class SavedIndividualCollectionSheetViewModel @Inject constructor() : ViewModel() { - - // Saved Individual Collection Sheet need to be integrated with API. - -} \ No newline at end of file diff --git a/feature/collection-sheet/src/test/java/com/mifos/feature/individual/ExampleUnitTest.kt b/feature/collection-sheet/src/test/java/com/mifos/feature/individual/ExampleUnitTest.kt deleted file mode 100644 index 8d90628ba07..00000000000 --- a/feature/collection-sheet/src/test/java/com/mifos/feature/individual/ExampleUnitTest.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.mifos.feature.individual - -import org.junit.Test - -import org.junit.Assert.* - -/** - * Example local unit test, which will execute on the development machine (host). - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -class ExampleUnitTest { - @Test - fun addition_isCorrect() { - assertEquals(4, 2 + 2) - } -} \ No newline at end of file diff --git a/feature/collection-sheet/.gitignore b/feature/collectionSheet/.gitignore similarity index 100% rename from feature/collection-sheet/.gitignore rename to feature/collectionSheet/.gitignore diff --git a/feature/collection-sheet/build.gradle.kts b/feature/collectionSheet/build.gradle.kts similarity index 65% rename from feature/collection-sheet/build.gradle.kts rename to feature/collectionSheet/build.gradle.kts index c537283a102..fa15349cb42 100644 --- a/feature/collection-sheet/build.gradle.kts +++ b/feature/collectionSheet/build.gradle.kts @@ -1,3 +1,12 @@ +/* + * Copyright 2024 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 + */ plugins { alias(libs.plugins.mifos.android.feature) alias(libs.plugins.mifos.android.library.compose) diff --git a/feature/collection-sheet/consumer-rules.pro b/feature/collectionSheet/consumer-rules.pro similarity index 100% rename from feature/collection-sheet/consumer-rules.pro rename to feature/collectionSheet/consumer-rules.pro diff --git a/feature/collection-sheet/proguard-rules.pro b/feature/collectionSheet/proguard-rules.pro similarity index 100% rename from feature/collection-sheet/proguard-rules.pro rename to feature/collectionSheet/proguard-rules.pro diff --git a/feature/collection-sheet/src/androidTest/java/com/mifos/feature/individual/ExampleInstrumentedTest.kt b/feature/collectionSheet/src/androidTest/java/com/mifos/feature/individual/ExampleInstrumentedTest.kt similarity index 64% rename from feature/collection-sheet/src/androidTest/java/com/mifos/feature/individual/ExampleInstrumentedTest.kt rename to feature/collectionSheet/src/androidTest/java/com/mifos/feature/individual/ExampleInstrumentedTest.kt index 7aacf97b125..02c897437f4 100644 --- a/feature/collection-sheet/src/androidTest/java/com/mifos/feature/individual/ExampleInstrumentedTest.kt +++ b/feature/collectionSheet/src/androidTest/java/com/mifos/feature/individual/ExampleInstrumentedTest.kt @@ -1,13 +1,20 @@ +/* + * Copyright 2024 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.individual -import androidx.test.platform.app.InstrumentationRegistry import androidx.test.ext.junit.runners.AndroidJUnit4 - +import androidx.test.platform.app.InstrumentationRegistry +import junit.framework.TestCase.assertEquals import org.junit.Test import org.junit.runner.RunWith -import org.junit.Assert.* - /** * Instrumented test, which will execute on an Android device. * @@ -21,4 +28,4 @@ class ExampleInstrumentedTest { val appContext = InstrumentationRegistry.getInstrumentation().targetContext assertEquals("com.mifos.feature.individual.test", appContext.packageName) } -} \ No newline at end of file +} diff --git a/feature/collectionSheet/src/main/AndroidManifest.xml b/feature/collectionSheet/src/main/AndroidManifest.xml new file mode 100644 index 00000000000..1dc76da0f7e --- /dev/null +++ b/feature/collectionSheet/src/main/AndroidManifest.xml @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/generate_collection_sheet/GenerateCollectionSheetScreen.kt b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/generateCollectionSheet/GenerateCollectionSheetScreen.kt similarity index 79% rename from feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/generate_collection_sheet/GenerateCollectionSheetScreen.kt rename to feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/generateCollectionSheet/GenerateCollectionSheetScreen.kt index 98a18b89020..4c8471eb12e 100644 --- a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/generate_collection_sheet/GenerateCollectionSheetScreen.kt +++ b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/generateCollectionSheet/GenerateCollectionSheetScreen.kt @@ -1,12 +1,23 @@ +/* + * Copyright 2024 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 + */ @file:OptIn(ExperimentalMaterial3Api::class) -package com.mifos.feature.individual_collection_sheet.generate_collection_sheet +package com.mifos.feature.individualCollectionSheet.generateCollectionSheet import android.widget.Toast import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding @@ -61,11 +72,10 @@ import java.text.SimpleDateFormat import java.util.Locale @Composable -fun GenerateCollectionSheetScreen( +internal fun GenerateCollectionSheetScreen( onBackPressed: () -> Unit, + viewModel: GenerateCollectionSheetViewModel = hiltViewModel(), ) { - - val viewModel: GenerateCollectionSheetViewModel = hiltViewModel() val state by viewModel.generateCollectionSheetUiState.collectAsStateWithLifecycle() val officeList by viewModel.officeListState.collectAsStateWithLifecycle() val staffList by viewModel.staffListState.collectAsStateWithLifecycle() @@ -84,7 +94,6 @@ fun GenerateCollectionSheetScreen( centerDetailsState = centerDetailsState, onBackPressed = onBackPressed, onRetry = { - }, officeList = officeList, staffList = staffList, @@ -111,13 +120,12 @@ fun GenerateCollectionSheetScreen( }, submitCollectionSheet = { centerId, payload -> viewModel.submitCollectionSheet(centerId, payload) - } + }, ) - } @Composable -fun GenerateCollectionSheetScreen( +internal fun GenerateCollectionSheetScreen( state: GenerateCollectionSheetUiState, collectionSheetState: CollectionSheetResponse?, centerDetailsState: List?, @@ -133,22 +141,24 @@ fun GenerateCollectionSheetScreen( loadProductiveCollectionSheet: (Int, CollectionSheetRequestPayload) -> Unit, loadCollectionSheet: (Int, CollectionSheetRequestPayload) -> Unit, submitProductiveCollectionSheet: (Int, ProductiveCollectionSheetPayload) -> Unit, - submitCollectionSheet: (Int, CollectionSheetPayload) -> Unit + modifier: Modifier = Modifier, + submitCollectionSheet: (Int, CollectionSheetPayload) -> Unit, ) { val snackbarHostState = remember { SnackbarHostState() } MifosScaffold( + modifier = modifier, icon = MifosIcons.arrowBack, title = stringResource(id = R.string.feature_collection_sheet_generate_collection_sheet), onBackPressed = onBackPressed, - snackbarHostState = snackbarHostState + snackbarHostState = snackbarHostState, ) { paddingValues -> - Column(modifier = Modifier.padding(paddingValues)) { + Box(modifier = Modifier.padding(paddingValues)) { when (state) { is GenerateCollectionSheetUiState.Error -> MifosSweetError( message = stringResource( - id = state.message - ) + id = state.message, + ), ) { onRetry() } @@ -159,7 +169,7 @@ fun GenerateCollectionSheetScreen( Toast.makeText( LocalContext.current, stringResource(id = R.string.feature_collection_sheet_collection_sheet_submitted), - Toast.LENGTH_SHORT + Toast.LENGTH_SHORT, ).show() onBackPressed() } @@ -168,7 +178,7 @@ fun GenerateCollectionSheetScreen( Toast.makeText( LocalContext.current, stringResource(id = R.string.feature_collection_sheet_productive_sheet_submitted), - Toast.LENGTH_SHORT + Toast.LENGTH_SHORT, ).show() onBackPressed() } @@ -187,7 +197,7 @@ fun GenerateCollectionSheetScreen( loadProductiveCollectionSheet = loadProductiveCollectionSheet, loadCollectionSheet = loadCollectionSheet, submitProductiveCollectionSheet = submitProductiveCollectionSheet, - submitCollectionSheet = submitCollectionSheet + submitCollectionSheet = submitCollectionSheet, ) } } @@ -197,7 +207,7 @@ fun GenerateCollectionSheetScreen( @OptIn(ExperimentalMaterial3Api::class) @Composable -fun GenerateCollectionSheetContent( +private fun GenerateCollectionSheetContent( centerDetailsState: List?, officeList: List, staffList: List, @@ -210,7 +220,8 @@ fun GenerateCollectionSheetContent( loadProductiveCollectionSheet: (Int, CollectionSheetRequestPayload) -> Unit, loadCollectionSheet: (Int, CollectionSheetRequestPayload) -> Unit, submitProductiveCollectionSheet: (Int, ProductiveCollectionSheetPayload) -> Unit, - submitCollectionSheet: (Int, CollectionSheetPayload) -> Unit + modifier: Modifier = Modifier, + submitCollectionSheet: (Int, CollectionSheetPayload) -> Unit, ) { var selectedOffice by remember { mutableStateOf("") } var selectedOfficeId by remember { mutableIntStateOf(0) } @@ -236,12 +247,11 @@ fun GenerateCollectionSheetContent( override fun isSelectableDate(utcTimeMillis: Long): Boolean { return utcTimeMillis >= System.currentTimeMillis() } - } + }, ) var showDatePicker by rememberSaveable { mutableStateOf(false) } var isProductiveResponse by rememberSaveable { mutableStateOf(false) } - LaunchedEffect(centerDetailsState) { centerDetailsState?.let { if (it.isNotEmpty() && it[0].meetingFallCenters?.isNotEmpty() == true) { @@ -251,7 +261,7 @@ fun GenerateCollectionSheetContent( val payload = CollectionSheetRequestPayload().apply { transactionDate = SimpleDateFormat("dd MMMM yyyy", Locale.getDefault()).format( - repaymentDate + repaymentDate, ) this.calendarId = calendarId } @@ -259,7 +269,6 @@ fun GenerateCollectionSheetContent( } } - if (showDatePicker) { DatePickerDialog( onDismissRequest = { @@ -272,236 +281,148 @@ fun GenerateCollectionSheetContent( datePickerState.selectedDateMillis?.let { repaymentDate = it } - } + }, ) { Text(stringResource(id = R.string.feature_collection_sheet_select)) } }, dismissButton = { TextButton( onClick = { showDatePicker = false - } + }, ) { Text(stringResource(id = R.string.feature_collection_sheet_cancel)) } - } - ) - { + }, + ) { DatePicker(state = datePickerState) } } - Spacer(modifier = Modifier.heightIn(16.dp)) + Column(modifier = modifier.fillMaxSize()) { + Spacer(modifier = Modifier.heightIn(16.dp)) - MifosTextFieldDropdown( - value = selectedOffice, - onValueChanged = { - selectedOffice = it - }, - onOptionSelected = { index, value -> - selectedOffice = value - officeList[index].id?.let { - selectedOfficeId = it - onOfficeSelected(it) - } - }, - options = officeList.map { it.name.toString() }, - label = R.string.feature_collection_sheet_office, - readOnly = true - ) - - Spacer(modifier = Modifier.heightIn(8.dp)) - - MifosDatePickerTextField( - value = SimpleDateFormat("dd MMMM yyyy", Locale.getDefault()).format( - repaymentDate - ), - label = R.string.feature_collection_sheet_repayment_date, - openDatePicker = { - showDatePicker = true - } - ) - - Spacer(modifier = Modifier.heightIn(8.dp)) - - - MifosTextFieldDropdown( - value = selectedStaff, - onValueChanged = { - selectedStaff = it - }, - onOptionSelected = { index, value -> - selectedStaff = value - staffList[index].id?.let { - selectedStaffId = it - } - onStaffSelected(selectedOfficeId, selectedStaffId) - }, - options = staffList.map { it.displayName.toString() }, - label = R.string.feature_collection_sheet_staff, - readOnly = true - ) - - Spacer(modifier = Modifier.heightIn(16.dp)) - - - Button( - onClick = { - onCenterDetails( - SimpleDateFormat("dd MMMM yyyy", Locale.getDefault()).format( - repaymentDate - ), selectedOfficeId, selectedStaffId - ) - isProductiveResponse = true - }, - modifier = Modifier - .fillMaxWidth() - .heightIn(44.dp) - .padding(start = 16.dp, end = 16.dp), - contentPadding = PaddingValues(), - colors = ButtonDefaults.buttonColors( - containerColor = if (isSystemInDarkTheme()) BluePrimaryDark else BluePrimary - ) - ) { - Text( - text = stringResource(id = R.string.feature_collection_sheet_productive_collection_sheet), - fontSize = 16.sp + MifosTextFieldDropdown( + value = selectedOffice, + onValueChanged = { + selectedOffice = it + }, + onOptionSelected = { index, value -> + selectedOffice = value + officeList[index].id?.let { + selectedOfficeId = it + onOfficeSelected(it) + } + }, + options = officeList.map { it.name.toString() }, + label = R.string.feature_collection_sheet_office, + readOnly = true, ) - } - - Spacer(modifier = Modifier.heightIn(16.dp)) - - MifosTextFieldDropdown( - value = selectedCenter, - onValueChanged = { - selectedCenter = it - }, - onOptionSelected = { index, value -> - selectedCenter = value - centerList[index].id?.let { - selectedCenterId = it - } - }, - options = centerList.map { it.name.toString() }, - label = R.string.feature_collection_sheet_center, - readOnly = true - ) + Spacer(modifier = Modifier.heightIn(8.dp)) - Spacer(modifier = Modifier.heightIn(8.dp)) - - MifosTextFieldDropdown( - value = selectedGroup, - onValueChanged = { - selectedGroup = it - }, - onOptionSelected = { index, value -> - selectedGroup = value - groupList[index].id?.let { - selectedGroupId = it - } - }, - options = groupList.map { it.name.toString() }, - label = R.string.feature_collection_sheet_group, - readOnly = true - ) + MifosDatePickerTextField( + value = SimpleDateFormat("dd MMMM yyyy", Locale.getDefault()).format( + repaymentDate, + ), + label = R.string.feature_collection_sheet_repayment_date, + openDatePicker = { + showDatePicker = true + }, + ) - Spacer(modifier = Modifier.heightIn(16.dp)) + Spacer(modifier = Modifier.heightIn(8.dp)) - Button( - onClick = { - val payload = CollectionSheetRequestPayload().apply { - transactionDate = SimpleDateFormat("dd MMMM yyyy", Locale.getDefault()).format( - repaymentDate - ) - this.calendarId = calendarId - } - isProductiveResponse = false - loadCollectionSheet(selectedGroupId, payload) - }, - modifier = Modifier - .fillMaxWidth() - .heightIn(44.dp) - .padding(start = 16.dp, end = 16.dp), - contentPadding = PaddingValues(), - colors = ButtonDefaults.buttonColors( - containerColor = if (isSystemInDarkTheme()) BluePrimaryDark else BluePrimary - ) - ) { - Text( - text = stringResource(id = R.string.feature_collection_sheet_generate_collection_sheet), - fontSize = 16.sp + MifosTextFieldDropdown( + value = selectedStaff, + onValueChanged = { + selectedStaff = it + }, + onOptionSelected = { index, value -> + selectedStaff = value + staffList[index].id?.let { + selectedStaffId = it + } + onStaffSelected(selectedOfficeId, selectedStaffId) + }, + options = staffList.map { it.displayName.toString() }, + label = R.string.feature_collection_sheet_staff, + readOnly = true, ) - } - collectionSheetState?.let { collectionSheet -> + Spacer(modifier = Modifier.heightIn(16.dp)) - // TODO The API is currently not working properly, therefore we will implement it later. I have included prior implementation code below in the comment. + Button( + onClick = { + onCenterDetails( + SimpleDateFormat("dd MMMM yyyy", Locale.getDefault()).format( + repaymentDate, + ), + selectedOfficeId, + selectedStaffId, + ) + isProductiveResponse = true + }, + modifier = Modifier + .fillMaxWidth() + .heightIn(44.dp) + .padding(start = 16.dp, end = 16.dp), + contentPadding = PaddingValues(), + colors = ButtonDefaults.buttonColors( + containerColor = if (isSystemInDarkTheme()) BluePrimaryDark else BluePrimary, + ), + ) { + Text( + text = stringResource(id = R.string.feature_collection_sheet_productive_collection_sheet), + fontSize = 16.sp, + ) + } + Spacer(modifier = Modifier.heightIn(16.dp)) MifosTextFieldDropdown( - value = selectedAttendanceType, + value = selectedCenter, onValueChanged = { - selectedAttendanceType = it + selectedCenter = it }, onOptionSelected = { index, value -> - selectedAttendanceType = value - selectedAttendanceTypeId = collectionSheet.attendanceTypeOptions[index].id + selectedCenter = value + centerList[index].id?.let { + selectedCenterId = it + } }, - options = collectionSheet.attendanceTypeOptions.map { it.value.toString() }, - label = R.string.feature_collection_sheet_attendance_type + options = centerList.map { it.name.toString() }, + label = R.string.feature_collection_sheet_center, + readOnly = true, ) + Spacer(modifier = Modifier.heightIn(8.dp)) + MifosTextFieldDropdown( - value = selectedPaymentType, + value = selectedGroup, onValueChanged = { - selectedPaymentType = it + selectedGroup = it }, onOptionSelected = { index, value -> - selectedPaymentType = value - selectedPaymentTypeId = collectionSheet.paymentTypeOptions[index].id + selectedGroup = value + groupList[index].id?.let { + selectedGroupId = it + } }, - options = collectionSheet.paymentTypeOptions.map { it.name }, - label = R.string.feature_collection_sheet_payment_type + options = groupList.map { it.name.toString() }, + label = R.string.feature_collection_sheet_group, + readOnly = true, ) - collectionSheet.loanProducts.forEach { - Text(text = "Loan: " + it.name.toString()) - } - - collectionSheet.savingsProducts.forEach { - Text(text = "Savings: " + it.name.toString()) - } - - collectionSheet.groups.first().clients.forEach { - Text(text = "Client: " + it.clientName + " " + it.clientId) - collectionSheet.loanProducts.forEach { - - } - } + Spacer(modifier = Modifier.heightIn(16.dp)) Button( onClick = { - if (isProductiveResponse) { - val payload = ProductiveCollectionSheetPayload().apply { - this.calendarId = calendarId - this.transactionDate = - SimpleDateFormat("dd MMMM yyyy", Locale.getDefault()).format( - repaymentDate - ) - } - submitProductiveCollectionSheet(selectedCenterId, payload) - } else { - val payload = CollectionSheetPayload().apply { - this.calendarId = calendarId - this.transactionDate = - SimpleDateFormat("dd MMMM yyyy", Locale.getDefault()).format( - repaymentDate - ) - this.actualDisbursementDate = - SimpleDateFormat("dd MMMM yyyy", Locale.getDefault()).format( - repaymentDate - ) - } - submitCollectionSheet(selectedGroupId, payload) + val payload = CollectionSheetRequestPayload().apply { + transactionDate = SimpleDateFormat("dd MMMM yyyy", Locale.getDefault()).format( + repaymentDate, + ) + this.calendarId = calendarId } + isProductiveResponse = false + loadCollectionSheet(selectedGroupId, payload) }, modifier = Modifier .fillMaxWidth() @@ -509,13 +430,100 @@ fun GenerateCollectionSheetContent( .padding(start = 16.dp, end = 16.dp), contentPadding = PaddingValues(), colors = ButtonDefaults.buttonColors( - containerColor = if (isSystemInDarkTheme()) BluePrimaryDark else BluePrimary - ) + containerColor = if (isSystemInDarkTheme()) BluePrimaryDark else BluePrimary, + ), ) { Text( - text = stringResource(id = R.string.feature_collection_sheet_submit_collection_sheet), - fontSize = 16.sp + text = stringResource(id = R.string.feature_collection_sheet_generate_collection_sheet), + fontSize = 16.sp, + ) + } + + collectionSheetState?.let { collectionSheet -> + + // TODO The API is currently not working properly, therefore we will implement it later. + // I have included prior implementation code below in the comment. + + MifosTextFieldDropdown( + value = selectedAttendanceType, + onValueChanged = { + selectedAttendanceType = it + }, + onOptionSelected = { index, value -> + selectedAttendanceType = value + selectedAttendanceTypeId = collectionSheet.attendanceTypeOptions[index].id + }, + options = collectionSheet.attendanceTypeOptions.map { it.value.toString() }, + label = R.string.feature_collection_sheet_attendance_type, ) + + MifosTextFieldDropdown( + value = selectedPaymentType, + onValueChanged = { + selectedPaymentType = it + }, + onOptionSelected = { index, value -> + selectedPaymentType = value + selectedPaymentTypeId = collectionSheet.paymentTypeOptions[index].id + }, + options = collectionSheet.paymentTypeOptions.map { it.name }, + label = R.string.feature_collection_sheet_payment_type, + ) + + collectionSheet.loanProducts.forEach { + Text(text = "Loan: " + it.name.toString()) + } + + collectionSheet.savingsProducts.forEach { + Text(text = "Savings: " + it.name.toString()) + } + + collectionSheet.groups.first().clients.forEach { + Text(text = "Client: " + it.clientName + " " + it.clientId) + collectionSheet.loanProducts.forEach { + } + } + + Button( + onClick = { + if (isProductiveResponse) { + val payload = ProductiveCollectionSheetPayload().apply { + this.calendarId = calendarId + this.transactionDate = + SimpleDateFormat("dd MMMM yyyy", Locale.getDefault()).format( + repaymentDate, + ) + } + submitProductiveCollectionSheet(selectedCenterId, payload) + } else { + val payload = CollectionSheetPayload().apply { + this.calendarId = calendarId + this.transactionDate = + SimpleDateFormat("dd MMMM yyyy", Locale.getDefault()).format( + repaymentDate, + ) + this.actualDisbursementDate = + SimpleDateFormat("dd MMMM yyyy", Locale.getDefault()).format( + repaymentDate, + ) + } + submitCollectionSheet(selectedGroupId, payload) + } + }, + modifier = Modifier + .fillMaxWidth() + .heightIn(44.dp) + .padding(start = 16.dp, end = 16.dp), + contentPadding = PaddingValues(), + colors = ButtonDefaults.buttonColors( + containerColor = if (isSystemInDarkTheme()) BluePrimaryDark else BluePrimary, + ), + ) { + Text( + text = stringResource(id = R.string.feature_collection_sheet_submit_collection_sheet), + fontSize = 16.sp, + ) + } } } } @@ -528,14 +536,14 @@ class GenerateCollectionUiStateProvider : PreviewParameterProvider }, loadCollectionSheet = { _, _ -> }, submitProductiveCollectionSheet = { _, _ -> }, - submitCollectionSheet = { _, _ -> } + submitCollectionSheet = { _, _ -> }, ) } @@ -780,7 +788,6 @@ private fun GenerateCollectionSheetScreenPreview( // binding.btnSubmitProductive.tag = TAG_TYPE_PRODUCTIVE // } - // private fun inflateCollectionTable(collectionSheetResponse: CollectionSheetResponse?) { // //Clear old views in case they are present. // if (binding.tableSheet.childCount > 0) { @@ -960,4 +967,4 @@ private fun GenerateCollectionSheetScreenPreview( // val etBank = EditText(context) // rowBank.addView(etBank) // binding.tableAdditional.addView(rowBank) -// } \ No newline at end of file +// } diff --git a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/generate_collection_sheet/GenerateCollectionSheetUiState.kt b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/generateCollectionSheet/GenerateCollectionSheetUiState.kt similarity index 52% rename from feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/generate_collection_sheet/GenerateCollectionSheetUiState.kt rename to feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/generateCollectionSheet/GenerateCollectionSheetUiState.kt index c1fe210735b..57728b044fd 100644 --- a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/generate_collection_sheet/GenerateCollectionSheetUiState.kt +++ b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/generateCollectionSheet/GenerateCollectionSheetUiState.kt @@ -1,4 +1,13 @@ -package com.mifos.feature.individual_collection_sheet.generate_collection_sheet +/* + * Copyright 2024 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.generateCollectionSheet /** * Created by Aditya Gupta on 12/08/23. @@ -14,4 +23,4 @@ sealed class GenerateCollectionSheetUiState { data object CollectionSheetSuccess : GenerateCollectionSheetUiState() data object ProductiveSheetSuccess : GenerateCollectionSheetUiState() -} \ No newline at end of file +} diff --git a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/generate_collection_sheet/GenerateCollectionSheetViewModel.kt b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/generateCollectionSheet/GenerateCollectionSheetViewModel.kt similarity index 69% rename from feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/generate_collection_sheet/GenerateCollectionSheetViewModel.kt rename to feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/generateCollectionSheet/GenerateCollectionSheetViewModel.kt index 9881f660455..282b7b2f184 100644 --- a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/generate_collection_sheet/GenerateCollectionSheetViewModel.kt +++ b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/generateCollectionSheet/GenerateCollectionSheetViewModel.kt @@ -1,4 +1,13 @@ -package com.mifos.feature.individual_collection_sheet.generate_collection_sheet +/* + * Copyright 2024 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.generateCollectionSheet import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope @@ -40,7 +49,7 @@ class GenerateCollectionSheetViewModel @Inject constructor( private val fetchProductiveCollectionSheetUseCase: FetchProductiveCollectionSheetUseCase, private val fetchCollectionSheetUseCase: FetchCollectionSheetUseCase, private val submitProductiveSheetUseCase: SubmitProductiveSheetUseCase, - private val submitCollectionSheetUseCase: SubmitCollectionSheetUseCase + private val submitCollectionSheetUseCase: SubmitCollectionSheetUseCase, ) : ViewModel() { private val _generateCollectionSheetUiState = @@ -68,19 +77,23 @@ class GenerateCollectionSheetViewModel @Inject constructor( fun loadOffices() = viewModelScope.launch(Dispatchers.IO) { getOfficeListUseCase().collect { result -> when (result) { - is Resource.Error -> _generateCollectionSheetUiState.value = - GenerateCollectionSheetUiState.Error( - R.string.feature_collection_sheet_failed_to_load_office - ) + is Resource.Error -> + _generateCollectionSheetUiState.value = + GenerateCollectionSheetUiState.Error( + R.string.feature_collection_sheet_failed_to_load_office, + ) - is Resource.Loading -> _generateCollectionSheetUiState.value = - GenerateCollectionSheetUiState.Loading + is Resource.Loading -> + _generateCollectionSheetUiState.value = + GenerateCollectionSheetUiState.Loading is Resource.Success -> { _officeListState.value = result.data ?: emptyList() - if (result.data?.isNotEmpty() == true) loadStaffInOffice( - result.data?.get(0)?.id ?: -1 - ) + if (result.data?.isNotEmpty() == true) { + loadStaffInOffice( + result.data?.get(0)?.id ?: -1, + ) + } } } } @@ -89,10 +102,11 @@ class GenerateCollectionSheetViewModel @Inject constructor( fun loadStaffInOffice(officeId: Int) = viewModelScope.launch(Dispatchers.IO) { getStaffInOfficeUseCase(officeId).collect { result -> when (result) { - is Resource.Error -> _generateCollectionSheetUiState.value = - GenerateCollectionSheetUiState.Error( - R.string.feature_collection_sheet_failed_to_load_staff - ) + is Resource.Error -> + _generateCollectionSheetUiState.value = + GenerateCollectionSheetUiState.Error( + R.string.feature_collection_sheet_failed_to_load_staff, + ) is Resource.Loading -> Unit @@ -101,11 +115,11 @@ class GenerateCollectionSheetViewModel @Inject constructor( if (result.data?.isNotEmpty() == true) { loadCentersInOffice( officeId, - result.data?.get(0)?.id ?: -1 + result.data?.get(0)?.id ?: -1, ) loadGroupsInOffice( officeId, - result.data?.get(0)?.id ?: -1 + result.data?.get(0)?.id ?: -1, ) } } @@ -124,10 +138,11 @@ class GenerateCollectionSheetViewModel @Inject constructor( } getCentersInOfficeUseCase(id, params).collect { result -> when (result) { - is Resource.Error -> _generateCollectionSheetUiState.value = - GenerateCollectionSheetUiState.Error( - R.string.feature_collection_sheet_failed_to_load_center - ) + is Resource.Error -> + _generateCollectionSheetUiState.value = + GenerateCollectionSheetUiState.Error( + R.string.feature_collection_sheet_failed_to_load_center, + ) is Resource.Loading -> Unit @@ -148,10 +163,11 @@ class GenerateCollectionSheetViewModel @Inject constructor( getGroupsByOfficeUseCase(office, params).collect { result -> when (result) { - is Resource.Error -> _generateCollectionSheetUiState.value = - GenerateCollectionSheetUiState.Error( - R.string.feature_collection_sheet_failed_to_load_group - ) + is Resource.Error -> + _generateCollectionSheetUiState.value = + GenerateCollectionSheetUiState.Error( + R.string.feature_collection_sheet_failed_to_load_group, + ) is Resource.Loading -> Unit @@ -166,19 +182,22 @@ class GenerateCollectionSheetViewModel @Inject constructor( fun loadCenterDetails( meetingDate: String?, - officeId: Int, staffId: Int + officeId: Int, + staffId: Int, ) = viewModelScope.launch(Dispatchers.IO) { fetchCenterDetailsUseCase( - Constants.DATE_FORMAT_LONG, Constants.LOCALE_EN, + Constants.DATE_FORMAT_LONG, + Constants.LOCALE_EN, meetingDate, officeId, - staffId + staffId, ).collect { result -> when (result) { - is Resource.Error -> _generateCollectionSheetUiState.value = - GenerateCollectionSheetUiState.Error( - R.string.feature_collection_sheet_failed_to_load_center_details - ) + is Resource.Error -> + _generateCollectionSheetUiState.value = + GenerateCollectionSheetUiState.Error( + R.string.feature_collection_sheet_failed_to_load_center_details, + ) is Resource.Loading -> Unit @@ -189,14 +208,15 @@ class GenerateCollectionSheetViewModel @Inject constructor( fun loadProductiveCollectionSheet( centerId: Int, - payload: CollectionSheetRequestPayload? + payload: CollectionSheetRequestPayload?, ) = viewModelScope.launch(Dispatchers.IO) { fetchProductiveCollectionSheetUseCase(centerId, payload).collect { when (it) { - is Resource.Error -> _generateCollectionSheetUiState.value = - GenerateCollectionSheetUiState.Error( - R.string.feature_collection_sheet_failed_to_load_productive_sheet - ) + is Resource.Error -> + _generateCollectionSheetUiState.value = + GenerateCollectionSheetUiState.Error( + R.string.feature_collection_sheet_failed_to_load_productive_sheet, + ) is Resource.Loading -> Unit @@ -207,14 +227,15 @@ class GenerateCollectionSheetViewModel @Inject constructor( fun loadCollectionSheet( groupId: Int, - payload: CollectionSheetRequestPayload? + payload: CollectionSheetRequestPayload?, ) = viewModelScope.launch(Dispatchers.IO) { fetchCollectionSheetUseCase(groupId, payload).collect { when (it) { - is Resource.Error -> _generateCollectionSheetUiState.value = - GenerateCollectionSheetUiState.Error( - R.string.feature_collection_sheet_failed_to_load_collection_sheet - ) + is Resource.Error -> + _generateCollectionSheetUiState.value = + GenerateCollectionSheetUiState.Error( + R.string.feature_collection_sheet_failed_to_load_collection_sheet, + ) is Resource.Loading -> Unit @@ -223,21 +244,23 @@ class GenerateCollectionSheetViewModel @Inject constructor( } } - fun submitProductiveSheet(centerId: Int, payload: ProductiveCollectionSheetPayload?) = viewModelScope.launch(Dispatchers.IO) { submitProductiveSheetUseCase(centerId, payload).collect { when (it) { - is Resource.Error -> _generateCollectionSheetUiState.value = - GenerateCollectionSheetUiState.Error( - R.string.feature_collection_sheet_failed_to_submit_productive_sheet - ) + is Resource.Error -> + _generateCollectionSheetUiState.value = + GenerateCollectionSheetUiState.Error( + R.string.feature_collection_sheet_failed_to_submit_productive_sheet, + ) - is Resource.Loading -> _generateCollectionSheetUiState.value = - GenerateCollectionSheetUiState.Loading + is Resource.Loading -> + _generateCollectionSheetUiState.value = + GenerateCollectionSheetUiState.Loading - is Resource.Success -> _generateCollectionSheetUiState.value = - GenerateCollectionSheetUiState.ProductiveSheetSuccess + is Resource.Success -> + _generateCollectionSheetUiState.value = + GenerateCollectionSheetUiState.ProductiveSheetSuccess } } } @@ -246,21 +269,23 @@ class GenerateCollectionSheetViewModel @Inject constructor( viewModelScope.launch(Dispatchers.IO) { submitCollectionSheetUseCase(groupId, payload).collect { when (it) { - is Resource.Error -> _generateCollectionSheetUiState.value = - GenerateCollectionSheetUiState.Error( - R.string.feature_collection_sheet_failed_to_submit_collection_sheet - ) + is Resource.Error -> + _generateCollectionSheetUiState.value = + GenerateCollectionSheetUiState.Error( + R.string.feature_collection_sheet_failed_to_submit_collection_sheet, + ) - is Resource.Loading -> _generateCollectionSheetUiState.value = - GenerateCollectionSheetUiState.Loading + is Resource.Loading -> + _generateCollectionSheetUiState.value = + GenerateCollectionSheetUiState.Loading - is Resource.Success -> _generateCollectionSheetUiState.value = - GenerateCollectionSheetUiState.CollectionSheetSuccess + is Resource.Success -> + _generateCollectionSheetUiState.value = + GenerateCollectionSheetUiState.CollectionSheetSuccess } } } - companion object { const val LIMIT = "limit" const val ORDER_BY = "orderBy" @@ -269,4 +294,4 @@ class GenerateCollectionSheetViewModel @Inject constructor( const val ORDER_BY_FIELD_NAME = "name" const val STAFF_ID = "staffId" } -} \ No newline at end of file +} diff --git a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/individual_collection_sheet/ui/IndividualCollectionSheetScreen.kt b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/individualCollectionSheet/ui/IndividualCollectionSheetScreen.kt similarity index 72% rename from feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/individual_collection_sheet/ui/IndividualCollectionSheetScreen.kt rename to feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/individualCollectionSheet/ui/IndividualCollectionSheetScreen.kt index 5e42bb66f11..f4f087314e5 100644 --- a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/individual_collection_sheet/ui/IndividualCollectionSheetScreen.kt +++ b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/individualCollectionSheet/ui/IndividualCollectionSheetScreen.kt @@ -1,6 +1,15 @@ +/* + * Copyright 2024 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 + */ @file:OptIn(ExperimentalFoundationApi::class, ExperimentalMaterial3Api::class) -package com.mifos.feature.individual_collection_sheet.individual_collection_sheet.ui +package com.mifos.feature.individualCollectionSheet.individualCollectionSheet.ui import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.layout.Column @@ -19,18 +28,18 @@ import com.mifos.core.designsystem.icon.MifosIcons import com.mifos.core.designsystem.utility.TabContent import com.mifos.core.objects.collectionsheet.IndividualCollectionSheet import com.mifos.feature.collection_sheet.R -import com.mifos.feature.individual_collection_sheet.new_individual_collection_sheet.ui.NewIndividualCollectionSheetScreen -import com.mifos.feature.individual_collection_sheet.saved_individual_collection_sheet.ui.SavedIndividualCollectionSheetCompose +import com.mifos.feature.individualCollectionSheet.newIndividualCollectionSheet.ui.NewIndividualCollectionSheetScreen +import com.mifos.feature.individualCollectionSheet.savedIndividualCollectionSheet.ui.SavedIndividualCollectionSheetCompose @Composable -fun IndividualCollectionSheetScreen( +internal fun IndividualCollectionSheetScreen( onBackPressed: () -> Unit, onDetail: (String, IndividualCollectionSheet) -> Unit, ) { val snackbarHostState = remember { SnackbarHostState() } val pagerState = rememberPagerState( - pageCount = { IndividualCollectionSheetScreenContents.entries.size } + pageCount = { IndividualCollectionSheetScreenContents.entries.size }, ) val tabContents = listOf( @@ -39,17 +48,17 @@ fun IndividualCollectionSheetScreen( }, TabContent(IndividualCollectionSheetScreenContents.SAVED.name) { SavedIndividualCollectionSheetCompose() - } + }, ) MifosScaffold( icon = MifosIcons.arrowBack, title = stringResource(id = R.string.feature_collection_sheet_individual_collection_sheet), onBackPressed = onBackPressed, - snackbarHostState = snackbarHostState + snackbarHostState = snackbarHostState, ) { paddingValues -> Column( - modifier = Modifier.padding(paddingValues) + modifier = Modifier.padding(paddingValues), ) { MifosTabRow(tabContents = tabContents, pagerState = pagerState) } @@ -58,11 +67,11 @@ fun IndividualCollectionSheetScreen( enum class IndividualCollectionSheetScreenContents { NEW, - SAVED + SAVED, } @Preview(showBackground = true) @Composable private fun IndividualCollectionSheetScreenPreview() { IndividualCollectionSheetScreen(onBackPressed = {}, onDetail = { _, _ -> }) -} \ No newline at end of file +} diff --git a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/individual_collection_sheet_details/IndividualCollectionSheetDetailsScreen.kt b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt similarity index 82% rename from feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/individual_collection_sheet_details/IndividualCollectionSheetDetailsScreen.kt rename to feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt index a5bfa6c8010..f9482f0a733 100644 --- a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/individual_collection_sheet_details/IndividualCollectionSheetDetailsScreen.kt +++ b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsScreen.kt @@ -1,6 +1,15 @@ +/* + * Copyright 2024 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 + */ @file:OptIn(ExperimentalFoundationApi::class) -package com.mifos.feature.individual_collection_sheet.individual_collection_sheet_details +package com.mifos.feature.individualCollectionSheet.individualCollectionSheetDetails import android.widget.Toast import androidx.compose.foundation.ExperimentalFoundationApi @@ -64,14 +73,14 @@ import com.mifos.core.objects.collectionsheet.LoanAndClientName import com.mifos.feature.collection_sheet.R @Composable -fun IndividualCollectionSheetDetailsScreen( +internal fun IndividualCollectionSheetDetailsScreen( onBackPressed: () -> Unit, - submit: (Int, IndividualCollectionSheetPayload, List, LoanAndClientName, List, Int) -> Unit + submit: (Int, IndividualCollectionSheetPayload, List, LoanAndClientName, List, Int) -> Unit, + viewModel: IndividualCollectionSheetDetailsViewModel = hiltViewModel(), ) { - - val viewModel: IndividualCollectionSheetDetailsViewModel = hiltViewModel() val state by viewModel.individualCollectionSheetDetailsUiState.collectAsStateWithLifecycle() - val loansAndClientNames = viewModel.filterLoanAndClientNames(viewModel.sheet.clients ?: emptyList()) + val loansAndClientNames = + viewModel.filterLoanAndClientNames(viewModel.sheet.clients ?: emptyList()) IndividualCollectionSheetDetailsScreen( sheet = viewModel.sheet, @@ -82,19 +91,20 @@ fun IndividualCollectionSheetDetailsScreen( submit = submit, onSave = { viewModel.submitIndividualCollectionSheet(it) - } + }, ) } @Composable -fun IndividualCollectionSheetDetailsScreen( +internal fun IndividualCollectionSheetDetailsScreen( sheet: IndividualCollectionSheet, loansAndClientNames: List, state: IndividualCollectionSheetDetailsUiState, onBackPressed: () -> Unit, onRetry: () -> Unit, submit: (Int, IndividualCollectionSheetPayload, List, LoanAndClientName, List, Int) -> Unit, - onSave: (IndividualCollectionSheetPayload) -> Unit + modifier: Modifier = Modifier, + onSave: (IndividualCollectionSheetPayload) -> Unit, ) { val snackbarHostState by remember { mutableStateOf(SnackbarHostState()) } var payload by rememberSaveable { mutableStateOf(IndividualCollectionSheetPayload()) } @@ -110,8 +120,8 @@ fun IndividualCollectionSheetDetailsScreen( BulkRepaymentTransactions( loanCollectionSheet.loanId, loanCollectionSheet.totalDue + - loanCollectionSheet.chargesDue - ) + loanCollectionSheet.chargesDue, + ), ) } } @@ -130,7 +140,7 @@ fun IndividualCollectionSheetDetailsScreen( Toast.makeText( LocalContext.current, stringResource(id = R.string.feature_collection_sheet_save_collection_sheet_success), - Toast.LENGTH_SHORT + Toast.LENGTH_SHORT, ).show() } @@ -138,30 +148,32 @@ fun IndividualCollectionSheetDetailsScreen( } MifosScaffold( + modifier = modifier, icon = MifosIcons.arrowBack, onBackPressed = onBackPressed, title = stringResource(id = R.string.feature_collection_sheet_individual_collection_details), actions = { - IconButton(onClick = { - onSave(payload) - }) { + IconButton( + onClick = { + onSave(payload) + }, + ) { Icon( imageVector = MifosIcons.save, - contentDescription = null + contentDescription = null, ) } }, - snackbarHostState = snackbarHostState + snackbarHostState = snackbarHostState, ) { paddingValues -> Column(modifier = Modifier.padding(paddingValues)) { - if (showLoading) { MifosCircularProgress() } else if (showError) { MifosSweetError( message = stringResource( - id = R.string.feature_collection_sheet_failed_to_save_collection_sheet - ) + id = R.string.feature_collection_sheet_failed_to_save_collection_sheet, + ), ) { onRetry() } @@ -180,10 +192,10 @@ fun IndividualCollectionSheetDetailsScreen( paymentTypeOptions.map { paymentTypeOption -> paymentTypeOption.name.toString() }, loansAndClientNames[index], paymentTypeOptions.toList(), - client.clientId + client.clientId, ) } - } + }, ) } } @@ -194,21 +206,22 @@ fun IndividualCollectionSheetDetailsScreen( } @Composable -fun IndividualCollectionSheetItem( +private fun IndividualCollectionSheetItem( client: ClientCollectionSheet, index: Int, - onClick: () -> Unit + modifier: Modifier = Modifier, + onClick: () -> Unit, ) { OutlinedCard( - modifier = Modifier + modifier = modifier .padding(6.dp) .combinedClickable( onClick = { onClick() }, - onLongClick = {} + onLongClick = {}, ), - colors = CardDefaults.cardColors(White) + colors = CardDefaults.cardColors(White), ) { Row( modifier = Modifier @@ -217,9 +230,9 @@ fun IndividualCollectionSheetItem( start = 16.dp, end = 16.dp, top = 24.dp, - bottom = 24.dp + bottom = 24.dp, ), - verticalAlignment = Alignment.CenterVertically + verticalAlignment = Alignment.CenterVertically, ) { AsyncImage( modifier = Modifier @@ -227,12 +240,12 @@ fun IndividualCollectionSheetItem( .clip(CircleShape) .border(width = 1.dp, LightGray, shape = CircleShape), model = R.drawable.feature_collection_sheet_ic_dp_placeholder, - contentDescription = null + contentDescription = null, ) Column( modifier = Modifier .weight(1f) - .padding(start = 16.dp) + .padding(start = 16.dp), ) { client.clientName?.let { Text( @@ -241,8 +254,8 @@ fun IndividualCollectionSheetItem( fontSize = 16.sp, fontWeight = FontWeight.Normal, fontStyle = FontStyle.Normal, - color = Black - ) + color = Black, + ), ) } Row { @@ -252,8 +265,8 @@ fun IndividualCollectionSheetItem( fontSize = 14.sp, fontWeight = FontWeight.Normal, fontStyle = FontStyle.Normal, - color = Black - ) + color = Black, + ), ) Spacer(modifier = Modifier.width(16.dp)) Text( @@ -262,8 +275,8 @@ fun IndividualCollectionSheetItem( fontSize = 14.sp, fontWeight = FontWeight.Normal, fontStyle = FontStyle.Normal, - color = DarkGray - ) + color = DarkGray, + ), ) } Row { @@ -273,8 +286,8 @@ fun IndividualCollectionSheetItem( fontSize = 14.sp, fontWeight = FontWeight.Normal, fontStyle = FontStyle.Normal, - color = Black - ) + color = Black, + ), ) Spacer(modifier = Modifier.width(16.dp)) Text( @@ -283,27 +296,27 @@ fun IndividualCollectionSheetItem( fontSize = 14.sp, fontWeight = FontWeight.Normal, fontStyle = FontStyle.Normal, - color = DarkGray - ) + color = DarkGray, + ), ) } Text( - text = "${client.loans?.get(index)?.productShortName.toString()} (#${ + text = "${client.loans?.get(index)?.productShortName} (#${ client.loans?.get( - index + index, )?.productShortName })", style = TextStyle( fontSize = 14.sp, fontWeight = FontWeight.Normal, fontStyle = FontStyle.Normal, - color = Black - ) + color = Black, + ), ) } Icon( imageVector = Icons.Rounded.ChevronRight, - contentDescription = null + contentDescription = null, ) } } @@ -316,15 +329,15 @@ class IndividualCollectionSheetDetailsUiStateProvider : get() = sequenceOf( IndividualCollectionSheetDetailsUiState.Error(R.string.feature_collection_sheet_failed_to_save_collection_sheet), IndividualCollectionSheetDetailsUiState.Loading, - IndividualCollectionSheetDetailsUiState.SavedSuccessfully + IndividualCollectionSheetDetailsUiState.SavedSuccessfully, ) - } @Preview(showBackground = true) @Composable private fun IndividualCollectionSheetDetailsScreenPreview( - @PreviewParameter(IndividualCollectionSheetDetailsUiStateProvider::class) state: IndividualCollectionSheetDetailsUiState + @PreviewParameter(IndividualCollectionSheetDetailsUiStateProvider::class) + state: IndividualCollectionSheetDetailsUiState, ) { IndividualCollectionSheetDetailsScreen( sheet = IndividualCollectionSheet(), @@ -333,6 +346,6 @@ private fun IndividualCollectionSheetDetailsScreenPreview( onBackPressed = {}, onRetry = {}, submit = { _, _, _, _, _, _ -> }, - onSave = {} + onSave = {}, ) -} \ No newline at end of file +} diff --git a/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsUiState.kt b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsUiState.kt new file mode 100644 index 00000000000..c64b8d05638 --- /dev/null +++ b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsUiState.kt @@ -0,0 +1,24 @@ +/* + * Copyright 2024 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.individualCollectionSheetDetails + +/** + * Created by Aditya Gupta on 10/08/23. + */ +sealed class IndividualCollectionSheetDetailsUiState { + + data object Empty : IndividualCollectionSheetDetailsUiState() + + data object Loading : IndividualCollectionSheetDetailsUiState() + + data class Error(val message: Int) : IndividualCollectionSheetDetailsUiState() + + data object SavedSuccessfully : IndividualCollectionSheetDetailsUiState() +} diff --git a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/individual_collection_sheet_details/IndividualCollectionSheetDetailsViewModel.kt b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsViewModel.kt similarity index 63% rename from feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/individual_collection_sheet_details/IndividualCollectionSheetDetailsViewModel.kt rename to feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsViewModel.kt index 9f676f86664..75995d97a4e 100644 --- a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/individual_collection_sheet_details/IndividualCollectionSheetDetailsViewModel.kt +++ b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/individualCollectionSheetDetails/IndividualCollectionSheetDetailsViewModel.kt @@ -1,4 +1,13 @@ -package com.mifos.feature.individual_collection_sheet.individual_collection_sheet_details +/* + * Copyright 2024 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.individualCollectionSheetDetails import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel @@ -23,15 +32,15 @@ import javax.inject.Inject @HiltViewModel class IndividualCollectionSheetDetailsViewModel @Inject constructor( private val saveIndividualCollectionSheetUseCase: SaveIndividualCollectionSheetUseCase, - savedStateHandle: SavedStateHandle + savedStateHandle: SavedStateHandle, ) : ViewModel() { - private val arg = savedStateHandle.getStateFlow(key = Constants.INDIVIDUAL_SHEET, initialValue = "" ) - val sheet : IndividualCollectionSheet = Gson().fromJson(arg.value, IndividualCollectionSheet::class.java) + private val arg = savedStateHandle.getStateFlow(key = Constants.INDIVIDUAL_SHEET, initialValue = "") + val sheet: IndividualCollectionSheet = Gson().fromJson(arg.value, IndividualCollectionSheet::class.java) private val _individualCollectionSheetDetailsUiState = MutableStateFlow( - IndividualCollectionSheetDetailsUiState.Empty + IndividualCollectionSheetDetailsUiState.Empty, ) val individualCollectionSheetDetailsUiState = _individualCollectionSheetDetailsUiState.asStateFlow() @@ -40,14 +49,17 @@ class IndividualCollectionSheetDetailsViewModel @Inject constructor( viewModelScope.launch(Dispatchers.IO) { saveIndividualCollectionSheetUseCase(payload).collect { result -> when (result) { - is Resource.Error -> _individualCollectionSheetDetailsUiState.value = - IndividualCollectionSheetDetailsUiState.Error(R.string.feature_collection_sheet_failed_to_save_collection_sheet) + is Resource.Error -> + _individualCollectionSheetDetailsUiState.value = + IndividualCollectionSheetDetailsUiState.Error(R.string.feature_collection_sheet_failed_to_save_collection_sheet) - is Resource.Loading -> _individualCollectionSheetDetailsUiState.value = - IndividualCollectionSheetDetailsUiState.Loading + is Resource.Loading -> + _individualCollectionSheetDetailsUiState.value = + IndividualCollectionSheetDetailsUiState.Loading - is Resource.Success -> _individualCollectionSheetDetailsUiState.value = - IndividualCollectionSheetDetailsUiState.SavedSuccessfully + is Resource.Success -> + _individualCollectionSheetDetailsUiState.value = + IndividualCollectionSheetDetailsUiState.SavedSuccessfully } } } @@ -62,12 +74,12 @@ class IndividualCollectionSheetDetailsViewModel @Inject constructor( LoanAndClientName( loanCollectionSheet, clientCollectionSheet.clientName, - clientCollectionSheet.clientId - ) + clientCollectionSheet.clientId, + ), ) } } } return loansAndClientNames } -} \ No newline at end of file +} diff --git a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/navigation/CollectionSheetNavigation.kt b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetNavigation.kt similarity index 76% rename from feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/navigation/CollectionSheetNavigation.kt rename to feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetNavigation.kt index d804a5a53ec..1761241827b 100644 --- a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/navigation/CollectionSheetNavigation.kt +++ b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetNavigation.kt @@ -1,4 +1,13 @@ -package com.mifos.feature.individual_collection_sheet.navigation +/* + * Copyright 2024 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.navigation import androidx.navigation.NavController import androidx.navigation.NavGraphBuilder @@ -12,12 +21,10 @@ import com.mifos.core.network.model.IndividualCollectionSheetPayload import com.mifos.core.objects.accounts.loan.PaymentTypeOptions import com.mifos.core.objects.collectionsheet.IndividualCollectionSheet import com.mifos.core.objects.collectionsheet.LoanAndClientName -import com.mifos.core.objects.collectionsheet.LoanCollectionSheet -import com.mifos.feature.individual_collection_sheet.generate_collection_sheet.GenerateCollectionSheetScreen -import com.mifos.feature.individual_collection_sheet.individual_collection_sheet.ui.IndividualCollectionSheetScreen -import com.mifos.feature.individual_collection_sheet.individual_collection_sheet_details.IndividualCollectionSheetDetailsScreen -import com.mifos.feature.individual_collection_sheet.payment_details.PaymentDetailsScreenContent -import com.mifos.feature.individual_collection_sheet.payment_details.PaymentDetailsScreenRoute +import com.mifos.feature.individualCollectionSheet.generateCollectionSheet.GenerateCollectionSheetScreen +import com.mifos.feature.individualCollectionSheet.individualCollectionSheet.ui.IndividualCollectionSheetScreen +import com.mifos.feature.individualCollectionSheet.individualCollectionSheetDetails.IndividualCollectionSheetDetailsScreen +import com.mifos.feature.individualCollectionSheet.paymentDetails.PaymentDetailsScreenRoute /** * Created by Pronay Sarker on 20/08/2024 (4:06 PM) @@ -28,19 +35,19 @@ fun NavGraphBuilder.individualCollectionSheetNavGraph( ) { navigation( route = "generate_collection_sheet", - startDestination = CollectionSheetScreens.IndividualCollectionSheetScreen.route + startDestination = CollectionSheetScreens.IndividualCollectionSheetScreen.route, ) { individualCollectionSheetScreen( onBackPressed = onBackPressed, onDetail = { _, sheet -> navController.navigateToIndividualCollectionSheetDetailScreen(sheet) - } + }, ) individualCollectionSheetDetailScreen( onBackPressed = onBackPressed, - submit = navController::navigateToPaymentDetailsScreen + submit = navController::navigateToPaymentDetailsScreen, ) paymentDetailsScreen() @@ -49,41 +56,41 @@ fun NavGraphBuilder.individualCollectionSheetNavGraph( private fun NavGraphBuilder.individualCollectionSheetScreen( onBackPressed: () -> Unit, - onDetail: (String, IndividualCollectionSheet) -> Unit + onDetail: (String, IndividualCollectionSheet) -> Unit, ) { composable( - route = CollectionSheetScreens.IndividualCollectionSheetScreen.route + route = CollectionSheetScreens.IndividualCollectionSheetScreen.route, ) { IndividualCollectionSheetScreen( onBackPressed = onBackPressed, - onDetail = onDetail + onDetail = onDetail, ) } } private fun NavGraphBuilder.individualCollectionSheetDetailScreen( onBackPressed: () -> Unit, - submit: (Int, IndividualCollectionSheetPayload, List, LoanAndClientName, List, Int) -> Unit + submit: (Int, IndividualCollectionSheetPayload, List, LoanAndClientName, List, Int) -> Unit, ) { composable( route = CollectionSheetScreens.IndividualCollectionSheetDetailScreen.route, arguments = listOf( - navArgument(name = Constants.INDIVIDUAL_SHEET, builder = { NavType.StringType }) - ) + navArgument(name = Constants.INDIVIDUAL_SHEET, builder = { NavType.StringType }), + ), ) { IndividualCollectionSheetDetailsScreen( onBackPressed = onBackPressed, - submit = submit + submit = submit, ) } } fun NavGraphBuilder.generateCollectionSheetScreen( - onBackPressed: () -> Unit + onBackPressed: () -> Unit, ) { composable(CollectionSheetScreens.GenerateCollectionSheetScreen.route) { GenerateCollectionSheetScreen( - onBackPressed = onBackPressed + onBackPressed = onBackPressed, ) } } @@ -98,7 +105,7 @@ fun NavGraphBuilder.paymentDetailsScreen() { navArgument(name = Constants.PAYMENT_LIST, builder = { NavType.StringType }), navArgument(name = Constants.LOAN_AND_CLIENT, builder = { NavType.StringType }), navArgument(name = Constants.PAYMENT_OPTIONS, builder = { NavType.StringType }), - ) + ), ) { PaymentDetailsScreenRoute() } @@ -114,7 +121,7 @@ fun NavController.navigateToPaymentDetailsScreen( paymentTypeOptionsName: List, loansAndClientName: LoanAndClientName, paymentTypeOptions: List, - clientId: Int + clientId: Int, ) { val payloadInGsonString = Gson().toJson(payload) val paymentTypeOptionNameInGsonString = Gson().toJson(paymentTypeOptionsName) @@ -128,7 +135,7 @@ fun NavController.navigateToPaymentDetailsScreen( paymentTypeOptionNameInGsonString, loansAndClientNameInGsonString, paymentTypeOptionsInGsonString, - clientId - ) + clientId, + ), ) } diff --git a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/navigation/CollectionSheetScreens.kt b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetScreens.kt similarity index 64% rename from feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/navigation/CollectionSheetScreens.kt rename to feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetScreens.kt index b2da6e0fa6d..bf5a2cb9dc2 100644 --- a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/navigation/CollectionSheetScreens.kt +++ b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/navigation/CollectionSheetScreens.kt @@ -1,12 +1,17 @@ -package com.mifos.feature.individual_collection_sheet.navigation +/* + * Copyright 2024 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.navigation import com.google.gson.Gson import com.mifos.core.common.utils.Constants -import com.mifos.core.objects.accounts.loan.PaymentTypeOptions import com.mifos.core.objects.collectionsheet.IndividualCollectionSheet -import com.mifos.core.objects.collectionsheet.LoanAndClientName -import com.mifos.core.objects.db.CollectionSheet -import com.mifos.feature.individual_collection_sheet.generate_collection_sheet.GenerateCollectionSheetUiState /** * Created by Pronay Sarker on 20/08/2024 (4:11 PM) @@ -20,14 +25,18 @@ sealed class CollectionSheetScreens(val route: String) { CollectionSheetScreens("individual_collection_sheet_route") data object PaymentDetailsScreen : - CollectionSheetScreens("payment_details_route/{${Constants.ADAPTER_POSITION}}/{${Constants.PAYLOAD}}/{${Constants.PAYMENT_LIST}}/{${Constants.LOAN_AND_CLIENT}}/{${Constants.PAYMENT_OPTIONS}}/{${Constants.CLIENT_ID}}") { + CollectionSheetScreens( + "payment_details_route/{${Constants.ADAPTER_POSITION}}/" + + "{${Constants.PAYLOAD}}/{${Constants.PAYMENT_LIST}}/{${Constants.LOAN_AND_CLIENT}}" + + "/{${Constants.PAYMENT_OPTIONS}}/{${Constants.CLIENT_ID}}", + ) { fun argument( position: Int, payload: String, paymentTypeOptionsName: String, loansAndClientName: String, paymentTypeOptions: String, - clientId: Int + clientId: Int, ): String { return "payment_details_route/$position/$payload/$paymentTypeOptionsName/$loansAndClientName/$paymentTypeOptions/$clientId" } @@ -42,4 +51,4 @@ sealed class CollectionSheetScreens(val route: String) { return "individual_collection_sheet_detail/$sheetInGsonString" } } -} \ No newline at end of file +} diff --git a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/new_individual_collection_sheet/ui/NewIndividualCollectionSheetScreen.kt b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/ui/NewIndividualCollectionSheetScreen.kt similarity index 72% rename from feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/new_individual_collection_sheet/ui/NewIndividualCollectionSheetScreen.kt rename to feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/ui/NewIndividualCollectionSheetScreen.kt index df366c2a880..e8767ce52de 100644 --- a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/new_individual_collection_sheet/ui/NewIndividualCollectionSheetScreen.kt +++ b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/ui/NewIndividualCollectionSheetScreen.kt @@ -1,6 +1,15 @@ +/* + * Copyright 2024 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 + */ @file:OptIn(ExperimentalMaterial3Api::class) -package com.mifos.feature.individual_collection_sheet.new_individual_collection_sheet.ui +package com.mifos.feature.individualCollectionSheet.newIndividualCollectionSheet.ui import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.layout.Arrangement @@ -62,9 +71,9 @@ import java.text.SimpleDateFormat import java.util.Locale @Composable -fun NewIndividualCollectionSheetScreen( +internal fun NewIndividualCollectionSheetScreen( viewModel: NewIndividualCollectionSheetViewModel = hiltViewModel(), - onDetail: (String, IndividualCollectionSheet) -> Unit + onDetail: (String, IndividualCollectionSheet) -> Unit, ) { val state = viewModel.newIndividualCollectionSheetUiState.collectAsStateWithLifecycle().value @@ -73,26 +82,27 @@ fun NewIndividualCollectionSheetScreen( getStaffList = { viewModel.getStaffList(it) }, - generateCollection = { _officeId, _staffId, _repaymentDate -> - viewModel.getIndividualCollectionSheet(RequestCollectionSheetPayload().apply { - officeId = _officeId - transactionDate = _repaymentDate - staffId = _staffId - }) + generateCollection = { id, idStaff, date -> + viewModel.getIndividualCollectionSheet( + RequestCollectionSheetPayload().apply { + officeId = id + transactionDate = date + staffId = idStaff + }, + ) }, - onDetail = onDetail + onDetail = onDetail, ) } - @Composable -fun NewIndividualCollectionSheetScreen( +internal fun NewIndividualCollectionSheetScreen( state: NewIndividualCollectionSheetUiState, getStaffList: (Int) -> Unit, generateCollection: (Int, Int, String) -> Unit, - onDetail: (String, IndividualCollectionSheet) -> Unit + modifier: Modifier = Modifier, + onDetail: (String, IndividualCollectionSheet) -> Unit, ) { - val keyboardController = LocalSoftwareKeyboardController.current var selectedOffice by rememberSaveable { mutableStateOf("") } @@ -111,11 +121,11 @@ fun NewIndividualCollectionSheetScreen( override fun isSelectableDate(utcTimeMillis: Long): Boolean { return utcTimeMillis >= System.currentTimeMillis() } - } + }, ) var individualCollectionSheet by rememberSaveable { mutableStateOf( - null + null, ) } @@ -131,8 +141,9 @@ fun NewIndividualCollectionSheetScreen( } MifosScaffold( + modifier = modifier, isAppBarPresent = false, - snackbarHostState = snackbarHostState + snackbarHostState = snackbarHostState, ) { paddingValues -> if (showDatePicker) { DatePickerDialog( @@ -146,18 +157,17 @@ fun NewIndividualCollectionSheetScreen( datePickerState.selectedDateMillis?.let { repaymentDate = it } - } + }, ) { Text(stringResource(id = R.string.feature_collection_sheet_select)) } }, dismissButton = { TextButton( onClick = { showDatePicker = false - } + }, ) { Text(stringResource(id = R.string.feature_collection_sheet_cancel)) } - } - ) - { + }, + ) { DatePicker(state = datePickerState) } } @@ -166,7 +176,7 @@ fun NewIndividualCollectionSheetScreen( content = { CollectionSheetDialogContent( date = SimpleDateFormat("dd MMMM yyyy", Locale.getDefault()).format( - repaymentDate + repaymentDate, ), member = individualCollectionSheet?.clients?.size.toString(), fillNow = { @@ -174,19 +184,21 @@ fun NewIndividualCollectionSheetScreen( individualCollectionSheet?.let { onDetail( SimpleDateFormat("dd MMMM yyyy", Locale.getDefault()).format( - repaymentDate + repaymentDate, ), - it + it, ) } }, onDismiss = { showCollectionSheetDialog = false - }) + }, + ) }, onDismiss = { showCollectionSheetDialog = false - }) + }, + ) } if (state.isLoading) { MifosCircularProgress() @@ -194,22 +206,22 @@ fun NewIndividualCollectionSheetScreen( Column( modifier = Modifier .fillMaxSize() - .padding(paddingValues) + .padding(paddingValues), ) { Text( modifier = Modifier.padding(16.dp), text = stringResource(id = R.string.feature_collection_sheet_generate_new), style = TextStyle( - fontSize = 24.sp - ) + fontSize = 24.sp, + ), ) Text( modifier = Modifier.padding(start = 16.dp, end = 16.dp), text = stringResource(id = R.string.feature_collection_sheet_fill_collection_sheet_message), style = TextStyle( fontSize = 14.sp, - color = Color.Black - ) + color = Color.Black, + ), ) Spacer(modifier = Modifier.height(16.dp)) MifosTextFieldDropdown( @@ -227,17 +239,17 @@ fun NewIndividualCollectionSheetScreen( selectedStaff = "" }, label = R.string.feature_collection_sheet_office, - options = state.officeList.map { it.name.toString() } + options = state.officeList.map { it.name.toString() }, ) Spacer(modifier = Modifier.height(8.dp)) MifosDatePickerTextField( value = SimpleDateFormat("dd MMMM yyyy", Locale.getDefault()).format( - repaymentDate + repaymentDate, ), label = R.string.feature_collection_sheet_repayment_date, openDatePicker = { showDatePicker = true - } + }, ) Spacer(modifier = Modifier.height(8.dp)) MifosTextFieldDropdown( @@ -252,12 +264,12 @@ fun NewIndividualCollectionSheetScreen( selectedStaff = value }, label = R.string.feature_collection_sheet_staff, - options = state.staffList.map { it.displayName.toString() } + options = state.staffList.map { it.displayName.toString() }, ) Row( modifier = Modifier .fillMaxWidth(), - horizontalArrangement = Arrangement.SpaceBetween + horizontalArrangement = Arrangement.SpaceBetween, ) { Button( onClick = { @@ -266,8 +278,8 @@ fun NewIndividualCollectionSheetScreen( officeId, staffId, SimpleDateFormat("dd MMMM yyyy", Locale.getDefault()).format( - repaymentDate - ) + repaymentDate, + ), ) }, modifier = Modifier @@ -276,12 +288,12 @@ fun NewIndividualCollectionSheetScreen( contentPadding = PaddingValues(), // enabled = selectedOffice != "", colors = ButtonDefaults.buttonColors( - containerColor = if (isSystemInDarkTheme()) BluePrimaryDark else BluePrimary - ) + containerColor = if (isSystemInDarkTheme()) BluePrimaryDark else BluePrimary, + ), ) { Text( text = stringResource(id = R.string.feature_collection_sheet_generate), - fontSize = 16.sp + fontSize = 16.sp, ) } Button( @@ -296,12 +308,12 @@ fun NewIndividualCollectionSheetScreen( .padding(16.dp), contentPadding = PaddingValues(), colors = ButtonDefaults.buttonColors( - containerColor = if (isSystemInDarkTheme()) BluePrimaryDark else BluePrimary - ) + containerColor = if (isSystemInDarkTheme()) BluePrimaryDark else BluePrimary, + ), ) { Text( text = stringResource(id = R.string.feature_collection_sheet_clear), - fontSize = 16.sp + fontSize = 16.sp, ) } } @@ -311,98 +323,103 @@ fun NewIndividualCollectionSheetScreen( } @Composable -fun CollectionSheetDialogContent( +private fun CollectionSheetDialogContent( date: String, member: String, fillNow: () -> Unit, - onDismiss: () -> Unit + modifier: Modifier = Modifier, + onDismiss: () -> Unit, ) { - MifosBottomSheet(content = { - Column( - modifier = Modifier - .fillMaxWidth() - .padding(start = 15.dp, end = 16.dp, bottom = 16.dp) - ) { - Text( + MifosBottomSheet( + modifier = modifier, + content = { + Column( modifier = Modifier .fillMaxWidth() - .align(Alignment.CenterHorizontally), - text = stringResource(id = R.string.feature_collection_sheet_found_sheet), - style = TextStyle( - fontSize = 24.sp - ) - ) - Spacer(modifier = Modifier.height(16.dp)) - Text( - text = stringResource(id = R.string.feature_collection_sheet_fill_collection_sheet_message), - style = TextStyle( - fontSize = 16.sp - ) - ) - Spacer(modifier = Modifier.height(16.dp)) - Row { - Text( - text = stringResource(id = R.string.feature_collection_sheet_date), - style = TextStyle( - fontSize = 16.sp, - fontWeight = FontWeight.Bold - ) - ) - Spacer(modifier = Modifier.width(16.dp)) - Text( - text = date, - style = TextStyle( - fontSize = 16.sp, - fontWeight = FontWeight.Normal - ) - ) - } - - Row { + .padding(start = 15.dp, end = 16.dp, bottom = 16.dp), + ) { Text( - text = stringResource(id = R.string.feature_collection_sheet_member), + modifier = Modifier + .fillMaxWidth() + .align(Alignment.CenterHorizontally), + text = stringResource(id = R.string.feature_collection_sheet_found_sheet), style = TextStyle( - fontSize = 16.sp, - fontWeight = FontWeight.Bold - ) + fontSize = 24.sp, + ), ) - Spacer(modifier = Modifier.width(16.dp)) + Spacer(modifier = Modifier.height(16.dp)) Text( - text = member, + text = stringResource(id = R.string.feature_collection_sheet_fill_collection_sheet_message), style = TextStyle( fontSize = 16.sp, - fontWeight = FontWeight.Normal - ) + ), ) - } - Spacer(modifier = Modifier.height(16.dp)) - Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) { - Button( - onClick = fillNow, - colors = ButtonDefaults.buttonColors( - containerColor = if (isSystemInDarkTheme()) BluePrimaryDark else BluePrimary + Spacer(modifier = Modifier.height(16.dp)) + Row { + Text( + text = stringResource(id = R.string.feature_collection_sheet_date), + style = TextStyle( + fontSize = 16.sp, + fontWeight = FontWeight.Bold, + ), ) - ) { + Spacer(modifier = Modifier.width(16.dp)) Text( - text = stringResource(id = R.string.feature_collection_sheet_fill_now), - fontSize = 16.sp + text = date, + style = TextStyle( + fontSize = 16.sp, + fontWeight = FontWeight.Normal, + ), ) } - Spacer(modifier = Modifier.width(16.dp)) - Button( - onClick = onDismiss, - colors = ButtonDefaults.buttonColors( - containerColor = if (isSystemInDarkTheme()) BluePrimaryDark else BluePrimary + + Row { + Text( + text = stringResource(id = R.string.feature_collection_sheet_member), + style = TextStyle( + fontSize = 16.sp, + fontWeight = FontWeight.Bold, + ), ) - ) { + Spacer(modifier = Modifier.width(16.dp)) Text( - text = stringResource(id = R.string.feature_collection_sheet_cancel), - fontSize = 16.sp + text = member, + style = TextStyle( + fontSize = 16.sp, + fontWeight = FontWeight.Normal, + ), ) } + Spacer(modifier = Modifier.height(16.dp)) + Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) { + Button( + onClick = fillNow, + colors = ButtonDefaults.buttonColors( + containerColor = if (isSystemInDarkTheme()) BluePrimaryDark else BluePrimary, + ), + ) { + Text( + text = stringResource(id = R.string.feature_collection_sheet_fill_now), + fontSize = 16.sp, + ) + } + Spacer(modifier = Modifier.width(16.dp)) + Button( + onClick = onDismiss, + colors = ButtonDefaults.buttonColors( + containerColor = if (isSystemInDarkTheme()) BluePrimaryDark else BluePrimary, + ), + ) { + Text( + text = stringResource(id = R.string.feature_collection_sheet_cancel), + fontSize = 16.sp, + ) + } + } } - } - }, onDismiss = onDismiss) + }, + onDismiss = onDismiss, + ) } class NewIndividualCollectionSheetUiStateProvider : @@ -414,21 +431,22 @@ class NewIndividualCollectionSheetUiStateProvider : NewIndividualCollectionSheetUiState(officeList = sampleOfficeList), NewIndividualCollectionSheetUiState(error = "Error Occurred"), NewIndividualCollectionSheetUiState(isLoading = true), - NewIndividualCollectionSheetUiState(individualCollectionSheet = IndividualCollectionSheet()) + NewIndividualCollectionSheetUiState(individualCollectionSheet = IndividualCollectionSheet()), ) } @Preview(showBackground = true) @Composable private fun NewIndividualCollectionSheetPreview( - @PreviewParameter(NewIndividualCollectionSheetUiStateProvider::class) newIndividualCollectionSheetUiState: NewIndividualCollectionSheetUiState + @PreviewParameter(NewIndividualCollectionSheetUiStateProvider::class) + newIndividualCollectionSheetUiState: NewIndividualCollectionSheetUiState, ) { NewIndividualCollectionSheetScreen( state = newIndividualCollectionSheetUiState, getStaffList = {}, generateCollection = { _, _, _ -> }, - onDetail = { _, _ -> } + onDetail = { _, _ -> }, ) } @@ -444,4 +462,4 @@ val sampleOfficeList = List(10) { @Composable private fun CollectionSheetDialogContentPreview() { CollectionSheetDialogContent(date = "19 June 2024", member = "5", fillNow = {}, onDismiss = {}) -} \ No newline at end of file +} diff --git a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/new_individual_collection_sheet/ui/NewIndividualCollectionSheetUiState.kt b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/ui/NewIndividualCollectionSheetUiState.kt similarity index 54% rename from feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/new_individual_collection_sheet/ui/NewIndividualCollectionSheetUiState.kt rename to feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/ui/NewIndividualCollectionSheetUiState.kt index c779c36675a..0cf18bed210 100644 --- a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/new_individual_collection_sheet/ui/NewIndividualCollectionSheetUiState.kt +++ b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/ui/NewIndividualCollectionSheetUiState.kt @@ -1,4 +1,13 @@ -package com.mifos.feature.individual_collection_sheet.new_individual_collection_sheet.ui +/* + * Copyright 2024 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.newIndividualCollectionSheet.ui import com.mifos.core.objects.collectionsheet.IndividualCollectionSheet import com.mifos.core.objects.organisation.Office @@ -17,5 +26,5 @@ data class NewIndividualCollectionSheetUiState( val staffList: List = emptyList(), - val individualCollectionSheet: IndividualCollectionSheet? = null -) \ No newline at end of file + val individualCollectionSheet: IndividualCollectionSheet? = null, +) diff --git a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/new_individual_collection_sheet/ui/NewIndividualCollectionSheetViewModel.kt b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/ui/NewIndividualCollectionSheetViewModel.kt similarity index 85% rename from feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/new_individual_collection_sheet/ui/NewIndividualCollectionSheetViewModel.kt rename to feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/ui/NewIndividualCollectionSheetViewModel.kt index 5e3ca1c6ca4..4af7309e676 100644 --- a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/new_individual_collection_sheet/ui/NewIndividualCollectionSheetViewModel.kt +++ b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/newIndividualCollectionSheet/ui/NewIndividualCollectionSheetViewModel.kt @@ -1,4 +1,13 @@ -package com.mifos.feature.individual_collection_sheet.new_individual_collection_sheet.ui +/* + * Copyright 2024 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.newIndividualCollectionSheet.ui import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope @@ -19,7 +28,7 @@ import javax.inject.Inject class NewIndividualCollectionSheetViewModel @Inject constructor( private val getOfficeListUseCase: GetOfficeListUseCase, private val getStaffInOfficeUseCase: GetStaffInOfficeUseCase, - private val getIndividualCollectionSheetUseCase: GetIndividualCollectionSheetUseCase + private val getIndividualCollectionSheetUseCase: GetIndividualCollectionSheetUseCase, ) : ViewModel() { private val _newIndividualCollectionSheetUiState = @@ -38,14 +47,14 @@ class NewIndividualCollectionSheetViewModel @Inject constructor( is Resource.Error -> { _newIndividualCollectionSheetUiState.value = _newIndividualCollectionSheetUiState.value.copy( - error = result.message + error = result.message, ) } is Resource.Loading -> { _newIndividualCollectionSheetUiState.value = _newIndividualCollectionSheetUiState.value.copy( - isLoading = true + isLoading = true, ) } @@ -53,7 +62,7 @@ class NewIndividualCollectionSheetViewModel @Inject constructor( _newIndividualCollectionSheetUiState.value = _newIndividualCollectionSheetUiState.value.copy( isLoading = false, - officeList = result.data ?: emptyList() + officeList = result.data ?: emptyList(), ) } } @@ -66,18 +75,17 @@ class NewIndividualCollectionSheetViewModel @Inject constructor( is Resource.Error -> { _newIndividualCollectionSheetUiState.value = _newIndividualCollectionSheetUiState.value.copy( - error = result.message + error = result.message, ) } is Resource.Loading -> { - } is Resource.Success -> { _newIndividualCollectionSheetUiState.value = _newIndividualCollectionSheetUiState.value.copy( - staffList = result.data ?: emptyList() + staffList = result.data ?: emptyList(), ) } } @@ -91,22 +99,21 @@ class NewIndividualCollectionSheetViewModel @Inject constructor( is Resource.Error -> { _newIndividualCollectionSheetUiState.value = _newIndividualCollectionSheetUiState.value.copy( - error = result.message + error = result.message, ) } is Resource.Loading -> { - } is Resource.Success -> { _newIndividualCollectionSheetUiState.value = _newIndividualCollectionSheetUiState.value.copy( individualCollectionSheet = result.data - ?: IndividualCollectionSheet() + ?: IndividualCollectionSheet(), ) } } } } -} \ No newline at end of file +} diff --git a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/payment_details/PaymentDetailsScreen.kt b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/paymentDetails/PaymentDetailsScreen.kt similarity index 78% rename from feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/payment_details/PaymentDetailsScreen.kt rename to feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/paymentDetails/PaymentDetailsScreen.kt index f199f64902c..ddf2136ecc2 100644 --- a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/payment_details/PaymentDetailsScreen.kt +++ b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/paymentDetails/PaymentDetailsScreen.kt @@ -1,9 +1,14 @@ -package com.mifos.feature.individual_collection_sheet.payment_details +/* + * Copyright 2024 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.paymentDetails -import android.graphics.drawable.Drawable -import android.util.Log -import androidx.compose.foundation.Image -import androidx.compose.foundation.clickable import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -15,7 +20,6 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults @@ -27,15 +31,12 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.rememberCoroutineScope 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.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.layout.ContentScale -import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontWeight @@ -43,7 +44,6 @@ import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import androidx.core.content.ContentProviderCompat.requireContext import androidx.hilt.navigation.compose.hiltViewModel import coil.compose.AsyncImage import coil.request.ImageResult @@ -53,41 +53,38 @@ import com.mifos.core.designsystem.theme.BluePrimary import com.mifos.core.designsystem.theme.BluePrimaryDark import com.mifos.core.model.BulkRepaymentTransactions import com.mifos.core.network.model.IndividualCollectionSheetPayload -import com.mifos.core.network.utils.ImageLoaderUtils import com.mifos.core.objects.accounts.loan.PaymentTypeOptions import com.mifos.core.objects.collectionsheet.LoanAndClientName -import com.mifos.core.objects.collectionsheet.LoanCollectionSheet import com.mifos.feature.collection_sheet.R -import kotlinx.coroutines.launch /** * Created by Pronay Sarker on 24/08/2024 (4:20 PM) */ @Composable -fun PaymentDetailsScreenRoute(modifier: Modifier = Modifier) { - - val viewModel: PaymentDetailsViewModel = hiltViewModel() - - PaymentDetailsScreenContent( +internal fun PaymentDetailsScreenRoute( + viewModel: PaymentDetailsViewModel = hiltViewModel(), +) { + PaymentsDetailsScreen( clientId = viewModel.clientId, position = viewModel.position, payload = viewModel.individualCollectionSheetPayload, loanAndClientNameItem = viewModel.loanAndClientName, paymentTypeOptionList = viewModel.paymentTypeOptionsName, paymentTypeOptions = viewModel.paymentTypeOptions, - getClientImage = { viewModel.getClientImageUrl(it) } + getClientImage = { viewModel.getClientImageUrl(it) }, ) } @Composable -fun PaymentDetailsScreenContent( +internal fun PaymentsDetailsScreen( clientId: Int, position: Int, payload: IndividualCollectionSheetPayload, loanAndClientNameItem: LoanAndClientName, paymentTypeOptionList: List, paymentTypeOptions: List, - getClientImage: (Int) -> ImageResult? + modifier: Modifier = Modifier, + getClientImage: (Int) -> ImageResult?, ) { val loanCollectionSheetItem = loanAndClientNameItem?.loan val scrollState = rememberScrollState() @@ -95,7 +92,7 @@ fun PaymentDetailsScreenContent( val bulkRepaymentTransactions by rememberSaveable { mutableStateOf(BulkRepaymentTransactions()) } var totalDues: String by rememberSaveable { mutableStateOf( - loanCollectionSheetItem?.totalDue?.toString() ?: "0.0" + loanCollectionSheetItem?.totalDue?.toString() ?: "0.0", ) } var paymentType by rememberSaveable { mutableStateOf("") } @@ -117,7 +114,7 @@ fun PaymentDetailsScreenContent( payload!!.bulkRepaymentTransactions[position] = transaction } - fun cancelAdditional() { //done + fun cancelAdditional() { // done val charge1: Double = if (totalCharges.isNotEmpty()) totalCharges.toDoubleOrNull() ?: 0.0 else 0.0 val charge2: Double = if (totalDues.isNotEmpty()) totalDues.toDoubleOrNull() ?: 0.0 else 0.0 @@ -146,23 +143,33 @@ fun PaymentDetailsScreenContent( if (accountNumber.isNotEmpty()) { bulkRepaymentTransactions.accountNumber = accountNumber - } else isAnyDetailNull = true + } else { + isAnyDetailNull = true + } if (chequeNumber.isNotEmpty()) { bulkRepaymentTransactions.checkNumber = chequeNumber - } else isAnyDetailNull = true + } else { + isAnyDetailNull = true + } if (routingCode.isNotEmpty()) { bulkRepaymentTransactions.routingCode = routingCode - } else isAnyDetailNull = true + } else { + isAnyDetailNull = true + } if (receiptNumber.isNotEmpty()) { bulkRepaymentTransactions.receiptNumber = receiptNumber - } else isAnyDetailNull = true + } else { + isAnyDetailNull = true + } if (bankNumber.isNotEmpty()) { bulkRepaymentTransactions.bankNumber = bankNumber - } else isAnyDetailNull = true + } else { + isAnyDetailNull = true + } if (!isAnyDetailNull) { noPaymentVisibility = false @@ -183,16 +190,17 @@ fun PaymentDetailsScreenContent( } Column( - modifier = Modifier + modifier = modifier .fillMaxSize() - .verticalScroll(scrollState) + .verticalScroll(scrollState), ) { OutlinedCard( modifier = Modifier .fillMaxWidth() - .padding(16.dp), colors = CardDefaults.cardColors( - containerColor = Color.White - ) + .padding(16.dp), + colors = CardDefaults.cardColors( + containerColor = Color.White, + ), ) { Row( modifier = Modifier @@ -204,13 +212,14 @@ fun PaymentDetailsScreenContent( Column( modifier = Modifier .weight(1f) - .padding(end = 16.dp) + .padding(end = 16.dp), ) { Text( text = loanAndClientNameItem?.clientName ?: "This is Tv name", style = TextStyle( - fontSize = 24.sp, fontWeight = FontWeight.Bold - ) + fontSize = 24.sp, + fontWeight = FontWeight.Bold, + ), ) Spacer(modifier = Modifier.height(16.dp)) @@ -219,8 +228,8 @@ fun PaymentDetailsScreenContent( text = "${loanCollectionSheetItem?.productShortName} (#${loanCollectionSheetItem?.accountId})", color = Color.DarkGray.copy(alpha = .7f), style = TextStyle( - fontWeight = FontWeight.Bold - ) + fontWeight = FontWeight.Bold, + ), ) Spacer(modifier = Modifier.height(16.dp)) @@ -231,7 +240,7 @@ fun PaymentDetailsScreenContent( onValueChange = { totalDues = it }, label = stringResource(id = R.string.feature_collection_sheet_total_due), error = null, - keyboardType = KeyboardType.Number + keyboardType = KeyboardType.Number, ) Spacer(modifier = Modifier.height(16.dp)) @@ -239,36 +248,38 @@ fun PaymentDetailsScreenContent( Text( text = stringResource(id = R.string.feature_collection_sheet_total_charges) + " : " + loanCollectionSheetItem?.chargesDue, style = MaterialTheme.typography.bodyLarge, - fontWeight = FontWeight.Bold + fontWeight = FontWeight.Bold, ) } Column( modifier = Modifier .weight(.3f) .fillMaxWidth(), - horizontalAlignment = Alignment.CenterHorizontally + horizontalAlignment = Alignment.CenterHorizontally, ) { AsyncImage( modifier = Modifier.size(60.dp), model = getClientImage(clientId) ?: R.drawable.feature_collection_sheet_ic_dp_placeholder, contentDescription = null, - contentScale = ContentScale.FillBounds + contentScale = ContentScale.FillBounds, ) } } } - Button(modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 16.dp) - .height(50.dp), + Button( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 16.dp) + .height(50.dp), colors = ButtonDefaults.buttonColors( - containerColor = if (isSystemInDarkTheme()) BluePrimaryDark else BluePrimary + containerColor = if (isSystemInDarkTheme()) BluePrimaryDark else BluePrimary, ), onClick = { showAdditionalDetails = !showAdditionalDetails - }) { + }, + ) { Text(text = stringResource(id = R.string.feature_collection_sheet_add_payment_detail)) } @@ -285,12 +296,13 @@ fun PaymentDetailsScreenContent( if (showAdditionalDetails) { OutlinedCard( - modifier = Modifier.padding(horizontal = 16.dp), colors = CardDefaults.cardColors( - containerColor = Color.White - ) + modifier = Modifier.padding(horizontal = 16.dp), + colors = CardDefaults.cardColors( + containerColor = Color.White, + ), ) { Column( - modifier = Modifier.padding(vertical = 16.dp) + modifier = Modifier.padding(vertical = 16.dp), ) { MifosTextFieldDropdown( label = R.string.feature_collection_sheet_payment_type, @@ -301,7 +313,7 @@ fun PaymentDetailsScreenContent( bulkRepaymentTransactions.paymentTypeId = paymentTypeOptions!![index].id }, options = paymentTypeOptionList ?: emptyList(), - readOnly = true + readOnly = true, ) Spacer(modifier = Modifier.height(16.dp)) @@ -310,7 +322,7 @@ fun PaymentDetailsScreenContent( value = accountNumber, onValueChange = { accountNumber = it }, label = stringResource(id = R.string.feature_collection_sheet_account_number), - error = null + error = null, ) Spacer(modifier = Modifier.height(16.dp)) @@ -319,7 +331,7 @@ fun PaymentDetailsScreenContent( value = chequeNumber, onValueChange = { chequeNumber = it }, label = stringResource(id = R.string.feature_collection_sheet_cheque_number), - error = null + error = null, ) Spacer(modifier = Modifier.height(16.dp)) @@ -328,7 +340,7 @@ fun PaymentDetailsScreenContent( value = routingCode, onValueChange = { routingCode = it }, label = stringResource(id = R.string.feature_collection_sheet_routing_code), - error = null + error = null, ) Spacer(modifier = Modifier.height(16.dp)) @@ -337,7 +349,7 @@ fun PaymentDetailsScreenContent( value = receiptNumber, onValueChange = { receiptNumber = it }, label = stringResource(id = R.string.feature_collection_sheet_receipt_number), - error = null + error = null, ) Spacer(modifier = Modifier.height(16.dp)) @@ -346,32 +358,13 @@ fun PaymentDetailsScreenContent( value = bankNumber, onValueChange = { bankNumber = it }, label = stringResource(id = R.string.feature_collection_sheet_bank_number), - error = null + error = null, ) Spacer(modifier = Modifier.height(16.dp)) - Row( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 16.dp), - horizontalArrangement = Arrangement.SpaceBetween - ) { - Button(modifier = Modifier.height(50.dp), - colors = ButtonDefaults.buttonColors( - containerColor = if (isSystemInDarkTheme()) BluePrimaryDark else BluePrimary - ), - onClick = { cancelAdditional() }) { - Text(text = stringResource(id = R.string.feature_collection_sheet_cancel)) - } - - Button(modifier = Modifier.height(50.dp), - colors = ButtonDefaults.buttonColors( - containerColor = if (isSystemInDarkTheme()) BluePrimaryDark else BluePrimary - ), - onClick = { saveAdditional() }) { - Text(text = stringResource(id = R.string.feature_collection_sheet_save)) - } + ButtonRow(cancelAdditional = { cancelAdditional() }) { + saveAdditional() } } } @@ -379,18 +372,51 @@ fun PaymentDetailsScreenContent( } } +@Composable +private fun ButtonRow( + cancelAdditional: () -> Unit, + modifier: Modifier = Modifier, + saveAdditional: () -> Unit, +) { + Row( + modifier = modifier + .fillMaxWidth() + .padding(horizontal = 16.dp), + horizontalArrangement = Arrangement.SpaceBetween, + ) { + Button( + modifier = Modifier.height(50.dp), + colors = ButtonDefaults.buttonColors( + containerColor = if (isSystemInDarkTheme()) BluePrimaryDark else BluePrimary, + ), + onClick = { cancelAdditional() }, + ) { + Text(text = stringResource(id = R.string.feature_collection_sheet_cancel)) + } + + Button( + modifier = Modifier.height(50.dp), + colors = ButtonDefaults.buttonColors( + containerColor = if (isSystemInDarkTheme()) BluePrimaryDark else BluePrimary, + ), + onClick = { saveAdditional() }, + ) { + Text(text = stringResource(id = R.string.feature_collection_sheet_save)) + } + } +} + @Composable @Preview(showBackground = true) -fun PreviewPaymentDetails(modifier: Modifier = Modifier) { - PaymentDetailsScreenContent( +private fun PreviewPaymentDetails(modifier: Modifier = Modifier) { + PaymentsDetailsScreen( + modifier = modifier, clientId = 0, position = 0, payload = IndividualCollectionSheetPayload(), loanAndClientNameItem = LoanAndClientName(id = 2, loan = null, clientName = ""), paymentTypeOptionList = emptyList(), paymentTypeOptions = emptyList(), - getClientImage = { null } + getClientImage = { null }, ) } - - diff --git a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/payment_details/PaymentDetailsViewModel.kt b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/paymentDetails/PaymentDetailsViewModel.kt similarity index 72% rename from feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/payment_details/PaymentDetailsViewModel.kt rename to feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/paymentDetails/PaymentDetailsViewModel.kt index d2a2023280a..8d10150489f 100644 --- a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/payment_details/PaymentDetailsViewModel.kt +++ b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/paymentDetails/PaymentDetailsViewModel.kt @@ -1,4 +1,13 @@ -package com.mifos.feature.individual_collection_sheet.payment_details +/* + * Copyright 2024 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.paymentDetails import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel @@ -18,7 +27,7 @@ import javax.inject.Inject @HiltViewModel class PaymentDetailsViewModel @Inject constructor( private val imageLoaderUtils: ImageLoaderUtils, - savedStateHandle: SavedStateHandle + savedStateHandle: SavedStateHandle, ) : ViewModel() { private val payloadArg = savedStateHandle.getStateFlow(key = Constants.PAYLOAD, initialValue = "") private val paymentListArg = savedStateHandle.getStateFlow(key = Constants.PAYMENT_LIST, initialValue = "") @@ -30,15 +39,16 @@ class PaymentDetailsViewModel @Inject constructor( val clientId = decodedClientId val position = decodedPosition - val individualCollectionSheetPayload: IndividualCollectionSheetPayload = Gson().fromJson(payloadArg.value, IndividualCollectionSheetPayload::class.java) + val individualCollectionSheetPayload: IndividualCollectionSheetPayload = + Gson().fromJson(payloadArg.value, IndividualCollectionSheetPayload::class.java) val paymentTypeOptionsName = Gson().fromJson(paymentListArg.value, Array::class.java).toList() val loanAndClientName: LoanAndClientName = Gson().fromJson(loanAndClientNameArg.value, LoanAndClientName::class.java) val paymentTypeOptions = Gson().fromJson(paymentOptionsArg.value, Array::class.java).toList() - fun getClientImageUrl(clientId: Int) : ImageResult? { - var image : ImageResult? = null - viewModelScope.launch (Dispatchers.IO) { - image = imageLoaderUtils.loadImage(clientId) + fun getClientImageUrl(clientId: Int): ImageResult? { + var image: ImageResult? = null + viewModelScope.launch(Dispatchers.IO) { + image = imageLoaderUtils.loadImage(clientId) } return image } diff --git a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/saved_individual_collection_sheet/ui/SavedIndividualCollectionSheetCompose.kt b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/savedIndividualCollectionSheet/ui/SavedIndividualCollectionSheetCompose.kt similarity index 66% rename from feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/saved_individual_collection_sheet/ui/SavedIndividualCollectionSheetCompose.kt rename to feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/savedIndividualCollectionSheet/ui/SavedIndividualCollectionSheetCompose.kt index c5926fb1dd4..7fb0650616a 100644 --- a/feature/collection-sheet/src/main/java/com/mifos/feature/individual_collection_sheet/saved_individual_collection_sheet/ui/SavedIndividualCollectionSheetCompose.kt +++ b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/savedIndividualCollectionSheet/ui/SavedIndividualCollectionSheetCompose.kt @@ -1,4 +1,13 @@ -package com.mifos.feature.individual_collection_sheet.saved_individual_collection_sheet.ui +/* + * Copyright 2024 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.savedIndividualCollectionSheet.ui import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -18,27 +27,28 @@ import androidx.compose.ui.unit.sp import com.mifos.feature.collection_sheet.R @Composable -fun SavedIndividualCollectionSheetCompose() { - +internal fun SavedIndividualCollectionSheetCompose( + modifier: Modifier = Modifier, +) { // Saved Individual Collection Sheet need to be integrated with API. Scaffold( - modifier = Modifier.fillMaxSize(), - containerColor = Color.White + modifier = modifier.fillMaxSize(), + containerColor = Color.White, ) { paddingValue -> Column( modifier = Modifier .padding(paddingValue) .fillMaxSize(), horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.Center + verticalArrangement = Arrangement.Center, ) { Text( text = stringResource(id = R.string.feature_collection_sheet_no_saved_collection_sheet), style = TextStyle( fontSize = 24.sp, - fontWeight = FontWeight.Medium - ) + fontWeight = FontWeight.Medium, + ), ) } } @@ -48,4 +58,4 @@ fun SavedIndividualCollectionSheetCompose() { @Composable private fun SavedIndividualCollectionSheetComposePreview() { SavedIndividualCollectionSheetCompose() -} \ No newline at end of file +} diff --git a/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/savedIndividualCollectionSheet/ui/SavedIndividualCollectionSheetViewModel.kt b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/savedIndividualCollectionSheet/ui/SavedIndividualCollectionSheetViewModel.kt new file mode 100644 index 00000000000..eeff9199c19 --- /dev/null +++ b/feature/collectionSheet/src/main/java/com/mifos/feature/individualCollectionSheet/savedIndividualCollectionSheet/ui/SavedIndividualCollectionSheetViewModel.kt @@ -0,0 +1,20 @@ +/* + * Copyright 2024 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.savedIndividualCollectionSheet.ui + +import androidx.lifecycle.ViewModel +import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject + +@HiltViewModel +class SavedIndividualCollectionSheetViewModel @Inject constructor() : ViewModel() { + + // Saved Individual Collection Sheet need to be integrated with API. +} diff --git a/feature/collection-sheet/src/main/res/drawable/feature_collection_sheet_ic_dp_placeholder.png b/feature/collectionSheet/src/main/res/drawable/feature_collection_sheet_ic_dp_placeholder.png similarity index 100% rename from feature/collection-sheet/src/main/res/drawable/feature_collection_sheet_ic_dp_placeholder.png rename to feature/collectionSheet/src/main/res/drawable/feature_collection_sheet_ic_dp_placeholder.png diff --git a/feature/collection-sheet/src/main/res/values/strings.xml b/feature/collectionSheet/src/main/res/values/strings.xml similarity index 93% rename from feature/collection-sheet/src/main/res/values/strings.xml rename to feature/collectionSheet/src/main/res/values/strings.xml index abd3cdad754..c9661223da9 100644 --- a/feature/collection-sheet/src/main/res/values/strings.xml +++ b/feature/collectionSheet/src/main/res/values/strings.xml @@ -1,4 +1,13 @@ + No Saved Collection Sheet Please fill in appropriate details to find the collection sheet to generate. diff --git a/feature/collectionSheet/src/test/java/com/mifos/feature/individual/ExampleUnitTest.kt b/feature/collectionSheet/src/test/java/com/mifos/feature/individual/ExampleUnitTest.kt new file mode 100644 index 00000000000..3e66579ed1f --- /dev/null +++ b/feature/collectionSheet/src/test/java/com/mifos/feature/individual/ExampleUnitTest.kt @@ -0,0 +1,25 @@ +/* + * Copyright 2024 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.individual + +import junit.framework.TestCase.assertEquals +import org.junit.Test + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/mifosng-android/src/main/AndroidManifest.xml b/mifosng-android/src/main/AndroidManifest.xml index 79cee3283c7..71104694206 100755 --- a/mifosng-android/src/main/AndroidManifest.xml +++ b/mifosng-android/src/main/AndroidManifest.xml @@ -78,15 +78,6 @@ android:name="android.support.PARENT_ACTIVITY" android:value=".activity.home.HomeActivity" /> - - - { val bundle = Bundle() bundle.putString(Constants.COLLECTION_TYPE, Constants.EXTRA_COLLECTION_INDIVIDUAL) - findNavController(R.id.nav_host_fragment).navigate( - R.id.generateCollectionSheetActivity, - bundle - ) +// findNavController(R.id.nav_host_fragment).navigate( +// R.id.generateCollectionSheetActivity, +// bundle +// ) } R.id.collection_sheet -> { @@ -93,10 +93,10 @@ open class HomeActivity : MifosBaseActivity(), NavigationView.OnNavigationItemSe Constants.COLLECTION_TYPE, Constants.EXTRA_COLLECTION_COLLECTION ) - findNavController(R.id.nav_host_fragment).navigate( - R.id.generateCollectionSheetActivity, - bundle - ) +// findNavController(R.id.nav_host_fragment).navigate( +// R.id.generateCollectionSheetActivity, +// bundle +// ) } R.id.item_settings -> { diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/adapters/CollectionListAdapter.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/adapters/CollectionListAdapter.kt deleted file mode 100644 index 54754ee8f6f..00000000000 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/adapters/CollectionListAdapter.kt +++ /dev/null @@ -1,140 +0,0 @@ -/* - * This project is licensed under the open source MPL V2. - * See https://github.com/openMF/android-client/blob/master/LICENSE.md - */ -package com.mifos.mifosxdroid.adapters - -import android.content.Context -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.BaseExpandableListAdapter -import com.mifos.core.objects.db.Client -import com.mifos.core.objects.db.MifosGroup -import com.mifos.mifosxdroid.databinding.RowCollectionListGroupBinding -import com.mifos.mifosxdroid.databinding.RowCollectionListGroupClientBinding - -/** - * Created by ishankhanna on 17/07/14. - */ -class CollectionListAdapter( - private val context: Context, - private val mifosGroups: List -) : - BaseExpandableListAdapter() { - private val layoutInflater: LayoutInflater = LayoutInflater.from(context) - - init { - for (mifosGroup in mifosGroups) { - for (client in mifosGroup.clients) { - for (loan in client.loans) { - sRepaymentTransactions[loan.loanId] = loan.totalDue - } - } - } - } - - override fun getGroupCount(): Int { - return mifosGroups.size - } - - override fun getChildrenCount(groupPosition: Int): Int { - return mifosGroups[groupPosition].clients.size - } - - override fun getGroup(groupPosition: Int): MifosGroup { - return mifosGroups[groupPosition] - } - - override fun getChild(groupPosition: Int, childPosition: Int): Client { - return mifosGroups[groupPosition].clients[childPosition] - } - - override fun getGroupId(groupPosition: Int): Long { - return 0 - } - - override fun getChildId(groupPosition: Int, childPosition: Int): Long { - return 0 - } - - override fun hasStableIds(): Boolean { - return false - } - - override fun getGroupView( - groupPosition: Int, - isExpanded: Boolean, - convertView: View?, - parent: ViewGroup - ): View { - val binding: RowCollectionListGroupBinding = if (convertView == null) { - RowCollectionListGroupBinding.inflate(layoutInflater, parent, false) - } else { - RowCollectionListGroupBinding.bind(convertView) - } - - val groupTotalDue = calculateGroupTotalDue(groupPosition) - binding.tvGroupName.text = mifosGroups[groupPosition].groupName - binding.tvGroupTotal.text = groupTotalDue.toString() - - return binding.root - } - - override fun getChildView( - groupPosition: Int, - childPosition: Int, - isLastChild: Boolean, - convertView: View?, - parent: ViewGroup - ): View { - val binding: RowCollectionListGroupClientBinding = if (convertView == null) { - RowCollectionListGroupClientBinding.inflate(layoutInflater, parent, false) - } else { - RowCollectionListGroupClientBinding.bind(convertView) - } - - val client = mifosGroups[groupPosition].clients.get(childPosition) - val totalDue = client.let { calculateClientTotalDue(it) } - binding.tvClientId.text = client.clientId.toString() - binding.tvClientName.text = client.clientName - binding.tvClientTotal.text = totalDue.toString() - - val collectionSheetLoanAccountListAdapter = client.loans?.let { - CollectionSheetLoanAccountListAdapter( - context, it, groupPosition, childPosition - ) - } - binding.lvLoans.adapter = collectionSheetLoanAccountListAdapter - - return binding.root - } - - override fun isChildSelectable(groupPosition: Int, childPosition: Int): Boolean { - return true - } - - private fun calculateGroupTotalDue(groupPosition: Int): Double { - var groupTotalDue = 0.0 - for (client in mifosGroups[groupPosition].clients) { - for (loan in client.loans) { - groupTotalDue += sRepaymentTransactions[loan.loanId] ?: 0.0 - } - } - return groupTotalDue - } - - private fun calculateClientTotalDue(client: Client): Double { - var totalDue = 0.0 - for (loan in client.loans) { - totalDue += loan.totalDue - } - return totalDue - } - - companion object { - // Map for RepaymentTransaction - // TODO Check about SparseArray in Android and try to convert Map into SparseArray Implementation - val sRepaymentTransactions: MutableMap = HashMap() - } -} \ No newline at end of file diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/adapters/CollectionSheetLoanAccountListAdapter.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/adapters/CollectionSheetLoanAccountListAdapter.kt deleted file mode 100644 index 12e31427fb8..00000000000 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/adapters/CollectionSheetLoanAccountListAdapter.kt +++ /dev/null @@ -1,80 +0,0 @@ -/* - * This project is licensed under the open source MPL V2. - * See https://github.com/openMF/android-client/blob/master/LICENSE.md - */ -package com.mifos.mifosxdroid.adapters - -import android.content.Context -import android.text.Editable -import android.text.TextWatcher -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.BaseAdapter -import com.mifos.core.objects.db.Loan -import com.mifos.mifosxdroid.databinding.RowCollectionSheetLoanBinding - -/** - * Created by ishankhanna on 21/07/14. - */ -class CollectionSheetLoanAccountListAdapter( - private val context: Context, - private val loans: List, - private val groupPosition: Int, - private val childPosition: Int -) : BaseAdapter() { - - private val inflater: LayoutInflater = LayoutInflater.from(context) - - override fun getCount(): Int { - return loans.size - } - - override fun getItem(position: Int): Loan { - return loans[position] - } - - override fun getItemId(position: Int): Long { - return 0 - } - - override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { - val binding: RowCollectionSheetLoanBinding - val view: View - - if (convertView == null) { - binding = RowCollectionSheetLoanBinding.inflate(inflater, parent, false) - view = binding.root - view.tag = binding - } else { - binding = convertView.tag as RowCollectionSheetLoanBinding - view = convertView - } - - val transactionAmount = - CollectionListAdapter.sRepaymentTransactions[loans[position].loanId] - binding.tvAmountDue.text = loans[position].totalDue.toString() - binding.tvLoanShortname.text = loans[position].productShortName - binding.etAmountPaid.setText(transactionAmount.toString()) - binding.etAmountPaid.addTextChangedListener(object : TextWatcher { - override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {} - - override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {} - - override fun afterTextChanged(s: Editable) { - try { - CollectionListAdapter.sRepaymentTransactions[loans[position] - .loanId] = if (s.toString() == "") 0.00 else s.toString().toDouble() - } catch (e: NumberFormatException) { - CollectionListAdapter.sRepaymentTransactions[loans[position] - .loanId] = 0.00 - } - /* TODO Fix Live update of Amounts - CollectionSheetFragment.refreshFragment(); - binding.etAmountPaid.requestFocus(); - */ - } - }) - return view - } -} \ No newline at end of file diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/adapters/IndividualCollectionSheetDetailsAdapter.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/adapters/IndividualCollectionSheetDetailsAdapter.kt deleted file mode 100644 index ce465ac828e..00000000000 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/adapters/IndividualCollectionSheetDetailsAdapter.kt +++ /dev/null @@ -1,147 +0,0 @@ -package com.mifos.mifosxdroid.adapters - -import android.content.Context -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.ImageView -import android.widget.TextView -import androidx.recyclerview.widget.RecyclerView -import com.mifos.core.model.BulkRepaymentTransactions -import com.mifos.core.objects.accounts.loan.PaymentTypeOptions -import com.mifos.core.objects.collectionsheet.LoanAndClientName -import com.mifos.mifosxdroid.R -import com.mifos.mifosxdroid.databinding.ItemIndividualCollectionSheetBinding -import com.mifos.mifosxdroid.online.collectionsheetindividualdetails.OnRetrieveSheetItemData -import com.mifos.utils.ImageLoaderUtils -import dagger.hilt.android.qualifiers.ActivityContext -import java.util.Locale -import javax.inject.Inject - -/** - * Created by aksh on 21/6/18. - */ -class IndividualCollectionSheetDetailsAdapter @Inject constructor( - @param:ActivityContext private val c: Context, - private val mListener: ListAdapterListener -) : RecyclerView.Adapter() { - private var paymentTypeList: MutableList = mutableListOf() - private var loanAndClientNames: List = emptyList() - private var paymentTypeOptionsList: List = emptyList() - private var sheetItemClickListener: OnRetrieveSheetItemData? = null - fun setSheetItemClickListener(sheetItemClickListener: OnRetrieveSheetItemData?) { - this.sheetItemClickListener = sheetItemClickListener - } - - fun setPaymentTypeOptionsList(paymentTypeOptionsList: List?) { - if (paymentTypeOptionsList != null) { - this.paymentTypeOptionsList = paymentTypeOptionsList - } - } - - fun setPaymentTypeList(paymentTypeList: List?) { - this.paymentTypeList = paymentTypeList as MutableList - this.paymentTypeList.add(c.getString(R.string.payment_type)) - } - - fun setLoans(loanAndClientNameList: List) { - loanAndClientNames = loanAndClientNameList - } - - override fun onCreateViewHolder( - parent: ViewGroup, - viewType: Int - ): ViewHolder { - return ViewHolder( - ItemIndividualCollectionSheetBinding.inflate( - LayoutInflater.from(parent.context), - parent, - false - ) - ) - } - - override fun onBindViewHolder( - holder: ViewHolder, - position: Int - ) { - val loanAndClientNameItem = loanAndClientNames[position] - val loanCollectionSheetItem = loanAndClientNameItem.loan - holder.tvClientName.text = loanAndClientNameItem.clientName - if (loanCollectionSheetItem != null) { - holder.tvProductCode.text = loanCollectionSheetItem - .productShortName?.let { - loanCollectionSheetItem.accountId?.let { it1 -> - concatProductWithAccount( - it, it1 - ) - } - } - } - if (loanCollectionSheetItem?.chargesDue != null) { - holder.etCharges.text = String.format( - Locale.getDefault(), "%f", - loanCollectionSheetItem.chargesDue - ) - } - if (loanCollectionSheetItem?.totalDue != null) { - holder.etTotalDues.text = String.format( - Locale.getDefault(), "%f", - loanCollectionSheetItem.totalDue - ) - } - ImageLoaderUtils.loadImage( - c, loanAndClientNameItem.id, - holder.ivUserPicture - ) - - //Add default value of transaction irrespective of they are 'saved' or 'cancelled' - // manually by the user. - val defaultBulkRepaymentTransaction = BulkRepaymentTransactions() - if (loanCollectionSheetItem != null) { - defaultBulkRepaymentTransaction.loanId = loanCollectionSheetItem.loanId - } - if (loanCollectionSheetItem != null) { - defaultBulkRepaymentTransaction.transactionAmount = - loanCollectionSheetItem.chargesDue + - loanCollectionSheetItem.totalDue - } - } - - private fun concatProductWithAccount(productCode: String, accountNo: String): String { - return "$productCode (#$accountNo)" - } - - override fun getItemCount(): Int { - return loanAndClientNames.size - } - - override fun getItemId(i: Int): Long { - return 0 - } - - interface ListAdapterListener { - fun listItemPosition(position: Int) - } - - inner class ViewHolder(private val binding: ItemIndividualCollectionSheetBinding) : - RecyclerView.ViewHolder(binding.root), View.OnClickListener { - var itemPosition = 0 - - val tvClientName: TextView = binding.tvClientName - var tvProductCode: TextView = binding.tvProductCode - var etCharges: TextView = binding.etCharges - var etTotalDues: TextView = binding.tvTotalDue - var btnAdditional: ImageView = binding.btnAdditionalDetails - var ivUserPicture: ImageView = binding.ivUserPicture - - init { - binding.root.setOnClickListener(this) - } - - override fun onClick(view: View) { - itemPosition = adapterPosition - mListener.listItemPosition(itemPosition) - } - } -} \ No newline at end of file diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/components/Navigation.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/components/Navigation.kt index 6968fedcf5d..09d94609672 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/components/Navigation.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/components/Navigation.kt @@ -29,8 +29,8 @@ import com.mifos.feature.document.navigation.navigateToDocumentListScreen import com.mifos.feature.groups.navigation.groupNavGraph import com.mifos.feature.groups.navigation.navigateToCreateNewGroupScreen import com.mifos.feature.groups.navigation.navigateToGroupDetailsScreen -import com.mifos.feature.individual_collection_sheet.navigation.generateCollectionSheetScreen -import com.mifos.feature.individual_collection_sheet.navigation.individualCollectionSheetNavGraph +import com.mifos.feature.individualCollectionSheet.navigation.generateCollectionSheetScreen +import com.mifos.feature.individualCollectionSheet.navigation.individualCollectionSheetNavGraph import com.mifos.feature.loan.navigation.addLoanAccountScreen import com.mifos.feature.loan.navigation.groupLoanScreen import com.mifos.feature.loan.navigation.loanNavGraph @@ -194,11 +194,11 @@ fun Navigation( ) individualCollectionSheetNavGraph( - onBackPressed = { navController.popBackStack() }, + onBackPressed = navController::popBackStack, navController = navController, ) - generateCollectionSheetScreen(onBackPressed = navController::popBackStack) + generateCollectionSheetScreen ( navController::popBackStack ) dataTableNavGraph( navController = navController, diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/injection/module/RepositoryModule.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/injection/module/RepositoryModule.kt index b130f2838b7..07a2cc7834a 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/injection/module/RepositoryModule.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/injection/module/RepositoryModule.kt @@ -2,8 +2,6 @@ package com.mifos.mifosxdroid.injection.module import com.mifos.core.data.repository.CreateNewClientRepository import com.mifos.core.data.repository.DocumentDialogRepository -import com.mifos.core.data.repository.GroupDetailsRepository -import com.mifos.core.data.repository.GroupsListRepository import com.mifos.core.data.repository.NoteRepository import com.mifos.core.data.repository.OfflineDashboardRepository import com.mifos.core.data.repository.SavingsAccountActivateRepository @@ -21,7 +19,6 @@ import com.mifos.core.data.repository.SyncLoanRepaymentTransactionRepository import com.mifos.core.data.repository.SyncSavingsAccountTransactionRepository import com.mifos.core.data.repository_imp.CreateNewClientRepositoryImp import com.mifos.core.data.repository_imp.DocumentDialogRepositoryImp -import com.mifos.core.data.repository_imp.GroupDetailsRepositoryImp import com.mifos.core.data.repository_imp.NoteRepositoryImp import com.mifos.core.data.repository_imp.OfflineDashboardRepositoryImp import com.mifos.core.data.repository_imp.SavingsAccountActivateRepositoryImp @@ -37,7 +34,6 @@ import com.mifos.core.data.repository_imp.SyncGroupPayloadsRepositoryImp import com.mifos.core.data.repository_imp.SyncGroupsDialogRepositoryImp import com.mifos.core.data.repository_imp.SyncLoanRepaymentTransactionRepositoryImp import com.mifos.core.data.repository_imp.SyncSavingsAccountTransactionRepositoryImp -import com.mifos.core.network.DataManager import com.mifos.core.network.datamanager.DataManagerAuth import com.mifos.core.network.datamanager.DataManagerCenter import com.mifos.core.network.datamanager.DataManagerClient @@ -55,8 +51,6 @@ import com.mifos.mifosxdroid.activity.login.LoginRepository import com.mifos.mifosxdroid.activity.login.LoginRepositoryImp import com.mifos.mifosxdroid.online.centerlist.CenterListRepository import com.mifos.mifosxdroid.online.centerlist.CenterListRepositoryImp -import com.mifos.mifosxdroid.online.collectionsheet.CollectionSheetRepository -import com.mifos.mifosxdroid.online.collectionsheet.CollectionSheetRepositoryImp import dagger.Module import dagger.Provides import dagger.hilt.InstallIn @@ -96,11 +90,6 @@ class RepositoryModule { return SavingsAccountRepositoryImp(dataManagerSavings) } - @Provides - fun providesCollectionSheetRepository(dataManager: DataManager): CollectionSheetRepository { - return CollectionSheetRepositoryImp(dataManager) - } - @Provides fun providesCreateNewClientRepository( dataManagerClient: DataManagerClient, diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/GenerateCollectionSheetActivity.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/GenerateCollectionSheetActivity.kt deleted file mode 100755 index d0b6e4a3bf1..00000000000 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/GenerateCollectionSheetActivity.kt +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This project is licensed under the open source MPL V2. - * See https://github.com/openMF/android-client/blob/master/LICENSE.md - */ -package com.mifos.mifosxdroid.online - -import android.os.Bundle -import android.view.Menu -import androidx.navigation.fragment.NavHostFragment -import com.mifos.core.common.utils.Constants -import com.mifos.core.network.model.IndividualCollectionSheetPayload -import com.mifos.mifosxdroid.R -import com.mifos.mifosxdroid.core.MifosBaseActivity -import com.mifos.mifosxdroid.databinding.ActivityToolbarContainerBinding -//import com.mifos.mifosxdroid.online.collectionsheetindividualdetails.PaymentDetailsFragment.OnPayloadSelectedListener -import dagger.hilt.android.AndroidEntryPoint - -@AndroidEntryPoint -class GenerateCollectionSheetActivity : MifosBaseActivity() -// OnPayloadSelectedListener -{ - - private lateinit var binding: ActivityToolbarContainerBinding - - - var payload: IndividualCollectionSheetPayload? = null - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - binding = ActivityToolbarContainerBinding.inflate(layoutInflater) - setContentView(binding.root) - val navHostFragment = - supportFragmentManager.findFragmentById(R.id.container_nav_host_fragment) as NavHostFragment - showBackButton() - intent?.getStringExtra(Constants.COLLECTION_TYPE)?.let { collectionType -> - if (collectionType == Constants.EXTRA_COLLECTION_INDIVIDUAL) { - navHostFragment.navController.apply { - popBackStack() - navigate(R.id.individualCollectionSheetFragment) - } - } else { - navHostFragment.navController.apply { - popBackStack() - navigate(R.id.generateCollectionSheetFragment) - } - } - } - } - - override fun onCreateOptionsMenu(menu: Menu): Boolean { - return true - } - -// override fun onPayloadSelected(payload: IndividualCollectionSheetPayload?) { -// this.payload = payload -// } -} \ No newline at end of file diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/checkerinbox/CheckerInboxPendingTasksActivity.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/checkerinbox/CheckerInboxPendingTasksActivity.kt index d3c9bc5183b..32ef02c6802 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/checkerinbox/CheckerInboxPendingTasksActivity.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/checkerinbox/CheckerInboxPendingTasksActivity.kt @@ -20,7 +20,7 @@ class CheckerInboxPendingTasksActivity : MifosBaseActivity() { supportFragmentManager.findFragmentById(R.id.container_nav_host_fragment) as NavHostFragment navHostFragment.navController.apply { popBackStack() - navigate(R.id.checkerInboxTasksFragment) +// navigate(R.id.checkerInboxTasksFragment) } } } diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheet/CollectionSheetFragment.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheet/CollectionSheetFragment.kt deleted file mode 100755 index f7c0c2d631b..00000000000 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheet/CollectionSheetFragment.kt +++ /dev/null @@ -1,228 +0,0 @@ -/* - * This project is licensed under the open source MPL V2. - * See https://github.com/openMF/android-client/blob/master/LICENSE.md - */ -package com.mifos.mifosxdroid.online.collectionsheet - -import android.os.Bundle -import android.util.Log -import android.view.* -import android.widget.Toast -import androidx.lifecycle.ViewModelProvider -import com.joanzapata.iconify.IconDrawable -import com.joanzapata.iconify.fonts.MaterialIcons -import com.mifos.core.common.utils.Constants -import com.mifos.core.model.BulkRepaymentTransactions -import com.mifos.core.network.model.CollectionSheetPayload -import com.mifos.core.network.model.Payload -import com.mifos.core.objects.db.CollectionSheet -import com.mifos.core.objects.response.SaveResponse -import com.mifos.mifosxdroid.R -import com.mifos.mifosxdroid.adapters.CollectionListAdapter -import com.mifos.mifosxdroid.core.MifosBaseFragment -import com.mifos.mifosxdroid.databinding.FragmentCollectionSheetBinding -import dagger.hilt.android.AndroidEntryPoint -import retrofit2.HttpException -import java.util.* - -/** - * A simple [Fragment] subclass. - * Use the [CollectionSheetFragment.newInstance] factory method to - * create an instance of this fragment. - */ -@AndroidEntryPoint -class CollectionSheetFragment : MifosBaseFragment() { - val LOG_TAG = javaClass.simpleName - - private lateinit var binding: FragmentCollectionSheetBinding - - private lateinit var viewModel: CollectionSheetViewModel - - private var collectionListAdapter: CollectionListAdapter? = null - private var centerId: Int? = null // Center for which collection sheet is being generated = 0 - private var dateOfCollection: String? = - null // Date of Meeting on which collection has to be done. - private var calendarInstanceId = 0 - - //Called from within the Adapters to show changes when payment amounts are updated - private fun refreshFragment() { - collectionListAdapter!!.notifyDataSetChanged() - } - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - if (arguments != null) { - centerId = requireArguments().getInt(Constants.CENTER_ID) - dateOfCollection = requireArguments().getString(Constants.DATE_OF_COLLECTION) - calendarInstanceId = requireArguments().getInt(Constants.CALENDAR_INSTANCE_ID) - } - setHasOptionsMenu(true) - } - - override fun onCreateView( - inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? - ): View { - // Inflate the layout for this fragment - binding = FragmentCollectionSheetBinding.inflate(inflater, container, false) - viewModel = ViewModelProvider(this)[CollectionSheetViewModel::class.java] - fetchCollectionSheet() - - viewModel.collectionSheetUiState.observe(viewLifecycleOwner) { - when (it) { - is CollectionSheetUiState.ShowCollectionSheet -> { - showCollectionSheet(it.collectionSheet) - } - - is CollectionSheetUiState.ShowCollectionSheetSuccessfullySaved -> { - showCollectionSheetSuccessfullySaved(it.saveResponse) - } - - is CollectionSheetUiState.ShowFailedToSaveCollectionSheet -> { - showFailedToSaveCollectionSheet(it.e) - } - - is CollectionSheetUiState.ShowFetchingError -> { - showFetchingError(it.message) - } - } - } - - return binding.root - } - - override fun onPrepareOptionsMenu(menu: Menu) { - menu.clear() - val mItemSearch = - menu.add(Menu.NONE, MENU_ITEM_SEARCH, Menu.NONE, getString(R.string.search)) - // mItemSearch.setIcon(new IconDrawable(getActivity(), MaterialIcons.md_search) -// .colorRes(Color.WHITE) -// .actionBarSize()); - mItemSearch.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER) - val mItemRefresh = - menu.add(Menu.NONE, MENU_ITEM_REFRESH, Menu.NONE, getString(R.string.refresh)) - mItemRefresh.icon = IconDrawable(activity, MaterialIcons.md_refresh) - .colorRes(R.color.white) - .actionBarSize() - mItemRefresh.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM) - val mItemSave = menu.add(Menu.NONE, MENU_ITEM_SAVE, Menu.NONE, getString(R.string.save)) - mItemSave.icon = IconDrawable(activity, MaterialIcons.md_save) - .colorRes(R.color.white) - .actionBarSize() - mItemSave.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM) - super.onPrepareOptionsMenu(menu) - } - - override fun onOptionsItemSelected(item: MenuItem): Boolean { - when (item.itemId) { - MENU_ITEM_REFRESH -> refreshFragment() - MENU_ITEM_SAVE -> saveCollectionSheet() - MENU_ITEM_SEARCH -> { - } - } - return super.onOptionsItemSelected(item) - } - - private fun fetchCollectionSheet() { - val payload = Payload() - payload.calendarId = calendarInstanceId.toLong() - payload.transactionDate = dateOfCollection - payload.dateFormat = "dd-MM-YYYY" - viewModel.loadCollectionSheet(centerId!!.toLong(), payload) - } - - @Synchronized - fun saveCollectionSheet() { - val collectionSheetPayload = CollectionSheetPayload() - val bulkRepaymentTransactions: MutableList = ArrayList() - val iterator: MutableIterator<*> = - CollectionListAdapter.sRepaymentTransactions.entries.iterator() - while (iterator.hasNext()) { - val repaymentTransaction = iterator.next() as Map.Entry<*, *> - bulkRepaymentTransactions.add( - BulkRepaymentTransactions( - (repaymentTransaction.key as Int?)!!, - (repaymentTransaction.value as Double?)!! - ) - ) - iterator.remove() - } - collectionSheetPayload.bulkRepaymentTransactions = arrayOf() - bulkRepaymentTransactions.toArray(collectionSheetPayload.bulkRepaymentTransactions) - collectionSheetPayload.calendarId = calendarInstanceId.toLong() - collectionSheetPayload.transactionDate = dateOfCollection - collectionSheetPayload.dateFormat = "dd-MM-YYYY" - - //Saving Collection Sheet - centerId?.let { - viewModel.saveCollectionSheet( - it, - collectionSheetPayload - ) - } - } - - private fun showCollectionSheet(collectionSheet: CollectionSheet) { - Log.i(COLLECTION_SHEET_ONLINE, "Received") - val mifosGroups = collectionSheet.groups - collectionListAdapter = CollectionListAdapter(requireActivity(), mifosGroups) - binding.exlvCollectionSheet.setAdapter(collectionListAdapter) - } - - private fun showCollectionSheetSuccessfullySaved(saveResponse: SaveResponse?) { - if (saveResponse != null) { - Toast.makeText( - activity, "Collection Sheet Saved Successfully", - Toast.LENGTH_SHORT - ).show() - } - } - - private fun showFailedToSaveCollectionSheet(response: HttpException) { - if (response.code() == 400 || response.code() == 403) { - //TODO for now, It is commented - //MFErrorParser.parseError(response.response().body()); - } - Toast.makeText( - activity, "Collection Sheet could not be saved.", - Toast.LENGTH_SHORT - ).show() - } - - private fun showFetchingError(s: String?) { - Toast.makeText(activity, s, Toast.LENGTH_SHORT).show() - } - - private fun showProgressbar(b: Boolean) { - if (b) { - showMifosProgressDialog() - } else { - hideMifosProgressDialog() - } - } - - companion object { - const val COLLECTION_SHEET_ONLINE = "Collection Sheet Online" - private const val MENU_ITEM_SEARCH = 2000 - private const val MENU_ITEM_REFRESH = 2001 - private const val MENU_ITEM_SAVE = 2002 - - fun newInstance( - centerId: Int, - dateOfCollection: String?, - calendarInstanceId: Int - ): CollectionSheetFragment { - val fragment = CollectionSheetFragment() - val args = Bundle() - args.putInt(Constants.CENTER_ID, centerId) - args.putString(Constants.DATE_OF_COLLECTION, dateOfCollection) - args.putInt(Constants.CALENDAR_INSTANCE_ID, calendarInstanceId) - fragment.arguments = args - return fragment - } - } -} - -private fun MutableList.toArray(bulkRepaymentTransactions: Array) { - -} diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheet/CollectionSheetRepository.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheet/CollectionSheetRepository.kt deleted file mode 100644 index 33c08415638..00000000000 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheet/CollectionSheetRepository.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.mifos.mifosxdroid.online.collectionsheet - -import com.mifos.core.network.model.CollectionSheetPayload -import com.mifos.core.network.model.Payload -import com.mifos.core.objects.db.CollectionSheet -import com.mifos.core.objects.response.SaveResponse -import rx.Observable - -/** - * Created by Aditya Gupta on 10/08/23. - */ -interface CollectionSheetRepository { - - fun getCollectionSheet(id: Long, payload: Payload?): Observable - - fun saveCollectionSheetAsync( - id: Int, - payload: CollectionSheetPayload? - ): Observable -} \ No newline at end of file diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheet/CollectionSheetRepositoryImp.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheet/CollectionSheetRepositoryImp.kt deleted file mode 100644 index d22dfbbb733..00000000000 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheet/CollectionSheetRepositoryImp.kt +++ /dev/null @@ -1,29 +0,0 @@ -package com.mifos.mifosxdroid.online.collectionsheet - -import com.mifos.core.network.DataManager -import com.mifos.core.network.model.CollectionSheetPayload -import com.mifos.core.network.model.Payload -import com.mifos.core.objects.db.CollectionSheet -import com.mifos.core.objects.response.SaveResponse -import rx.Observable -import javax.inject.Inject - -/** - * Created by Aditya Gupta on 10/08/23. - */ -class CollectionSheetRepositoryImp @Inject constructor(private val dataManager: DataManager) : - CollectionSheetRepository { - - override fun getCollectionSheet(id: Long, payload: Payload?): Observable { - return dataManager.getCollectionSheet(id, payload) - } - - override fun saveCollectionSheetAsync( - id: Int, - payload: CollectionSheetPayload? - ): Observable { - return dataManager.saveCollectionSheetAsync( - id, payload - ) - } -} \ No newline at end of file diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheet/CollectionSheetUiState.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheet/CollectionSheetUiState.kt deleted file mode 100644 index 2c21d20c1d0..00000000000 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheet/CollectionSheetUiState.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.mifos.mifosxdroid.online.collectionsheet - -import com.mifos.core.objects.db.CollectionSheet -import com.mifos.core.objects.response.SaveResponse -import retrofit2.HttpException - -/** - * Created by Aditya Gupta on 10/08/23. - */ -sealed class CollectionSheetUiState { - - data class ShowFetchingError(val message: String) : CollectionSheetUiState() - - data class ShowCollectionSheet(val collectionSheet: CollectionSheet) : CollectionSheetUiState() - - data class ShowFailedToSaveCollectionSheet(val e: HttpException) : CollectionSheetUiState() - - data class ShowCollectionSheetSuccessfullySaved(val saveResponse: SaveResponse?) : - CollectionSheetUiState() -} diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheet/CollectionSheetViewModel.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheet/CollectionSheetViewModel.kt deleted file mode 100644 index 92a90e6db43..00000000000 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheet/CollectionSheetViewModel.kt +++ /dev/null @@ -1,70 +0,0 @@ -package com.mifos.mifosxdroid.online.collectionsheet - -import androidx.lifecycle.LiveData -import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.ViewModel -import com.mifos.core.network.model.CollectionSheetPayload -import com.mifos.core.network.model.Payload -import com.mifos.core.objects.db.CollectionSheet -import com.mifos.core.objects.response.SaveResponse -import dagger.hilt.android.lifecycle.HiltViewModel -import retrofit2.HttpException -import rx.Subscriber -import rx.android.schedulers.AndroidSchedulers -import rx.schedulers.Schedulers -import javax.inject.Inject - -/** - * Created by Aditya Gupta on 10/08/23. - */ -@HiltViewModel -class CollectionSheetViewModel @Inject constructor(private val repository: CollectionSheetRepository) : - ViewModel() { - - private val _collectionSheetUiState = MutableLiveData() - - val collectionSheetUiState: LiveData - get() = _collectionSheetUiState - - - fun loadCollectionSheet(id: Long, payload: Payload?) { - repository.getCollectionSheet(id, payload) - .observeOn(AndroidSchedulers.mainThread()) - .subscribeOn(Schedulers.io()) - .subscribe(object : Subscriber() { - override fun onCompleted() {} - override fun onError(e: Throwable) { - _collectionSheetUiState.value = - CollectionSheetUiState.ShowFetchingError(e.message.toString()) - } - - override fun onNext(collectionSheet: CollectionSheet?) { - _collectionSheetUiState.value = collectionSheet?.let { - CollectionSheetUiState.ShowCollectionSheet( - it - ) - } - } - }) - } - - fun saveCollectionSheet(id: Int, payload: CollectionSheetPayload?) { - repository.saveCollectionSheetAsync(id, payload) - .observeOn(AndroidSchedulers.mainThread()) - .subscribeOn(Schedulers.io()) - .subscribe(object : Subscriber() { - override fun onCompleted() {} - override fun onError(e: Throwable) { - if (e is HttpException) { - _collectionSheetUiState.value = - CollectionSheetUiState.ShowFailedToSaveCollectionSheet(e) - } - } - - override fun onNext(saveResponse: SaveResponse?) { - _collectionSheetUiState.value = - CollectionSheetUiState.ShowCollectionSheetSuccessfullySaved(saveResponse) - } - }) - } -} \ No newline at end of file diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheetindividual/IndividualCollectionSheetFragment.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheetindividual/IndividualCollectionSheetFragment.kt deleted file mode 100644 index d65f1e0859d..00000000000 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheetindividual/IndividualCollectionSheetFragment.kt +++ /dev/null @@ -1,51 +0,0 @@ -package com.mifos.mifosxdroid.online.collectionsheetindividual - -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.compose.ui.platform.ComposeView -import androidx.compose.ui.platform.ViewCompositionStrategy -import androidx.navigation.fragment.findNavController -import com.mifos.core.objects.collectionsheet.IndividualCollectionSheet -import com.mifos.feature.individual_collection_sheet.individual_collection_sheet.ui.IndividualCollectionSheetScreen -import com.mifos.mifosxdroid.core.MifosBaseFragment -import java.text.SimpleDateFormat -import java.util.Locale - -/** - * Created by Tarun on 05-07-2017. - */ -class IndividualCollectionSheetFragment : MifosBaseFragment() { - - - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, savedInstanceState: Bundle? - ): View { - toolbar?.visibility = View.GONE - return ComposeView(requireContext()).apply { - setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) - setContent { - IndividualCollectionSheetScreen(onBackPressed = { - requireActivity().onBackPressed() - }, onDetail = { repaymentDate, individualCollectionSheet -> - getIndividualCollectionSheetDetails(repaymentDate, individualCollectionSheet) - }) - } - } - } - - private fun getIndividualCollectionSheetDetails( - repaymentDate: String, - individualCollectionSheet: IndividualCollectionSheet - ) { - val action = IndividualCollectionSheetFragmentDirections.actionIndividualCollectionSheetFragmentToIndividualCollectionSheetDetailsFragment( - individualCollectionSheet, SimpleDateFormat( - "dd MM yyyy", - Locale.getDefault() - ).format(System.currentTimeMillis()), repaymentDate - ) - findNavController().navigate(action) - } -} diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheetindividualdetails/IndividualCollectionSheetDetailsFragment.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheetindividualdetails/IndividualCollectionSheetDetailsFragment.kt deleted file mode 100644 index bde49117469..00000000000 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheetindividualdetails/IndividualCollectionSheetDetailsFragment.kt +++ /dev/null @@ -1,82 +0,0 @@ -package com.mifos.mifosxdroid.online.collectionsheetindividualdetails - -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.compose.ui.platform.ComposeView -import androidx.navigation.fragment.findNavController -import androidx.navigation.fragment.navArgs -import com.mifos.core.network.model.IndividualCollectionSheetPayload -import com.mifos.core.objects.accounts.loan.PaymentTypeOptions -import com.mifos.core.objects.collectionsheet.IndividualCollectionSheet -import com.mifos.core.objects.collectionsheet.LoanAndClientName -import com.mifos.feature.individual_collection_sheet.individual_collection_sheet_details.IndividualCollectionSheetDetailsScreen -import com.mifos.mifosxdroid.core.MifosBaseFragment -import dagger.hilt.android.AndroidEntryPoint - -/** - * Created by aksh on 20/6/18. - */ -@AndroidEntryPoint -class IndividualCollectionSheetDetailsFragment : MifosBaseFragment() { - - private val arg: IndividualCollectionSheetDetailsFragmentArgs by navArgs() - - private lateinit var sheet: IndividualCollectionSheet -// private lateinit var actualDisbursementDate: String -// private lateinit var transactionDate: String - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - sheet = arg.sheet -// actualDisbursementDate = arg.actualDisbursementDate -// transactionDate = arg.transactionDate - } - - override fun onCreateView( - inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? - ): View { - return ComposeView(requireContext()).apply { - setContent { - IndividualCollectionSheetDetailsScreen( -// sheet = sheet, - onBackPressed = { - findNavController().popBackStack() - }, - submit = { position, payload, paymentTypeOptionsName, loansAndClientName, paymentTypeOptions, clientId -> - showPayment( - position, - payload, - paymentTypeOptionsName, - loansAndClientName, - paymentTypeOptions, - clientId - ) - } - ) - } - } - } - - private fun showPayment( - position: Int, - payload: IndividualCollectionSheetPayload, - paymentTypeOptionsName: List, - loansAndClientName: LoanAndClientName, - paymentTypeOptions: List, - clientId: Int - ) { - val action = - IndividualCollectionSheetDetailsFragmentDirections.actionIndividualCollectionSheetDetailsFragmentToPaymentDetailsFragment( - position, - payload, - paymentTypeOptionsName.toTypedArray(), - loansAndClientName, - paymentTypeOptions.toTypedArray(), - clientId - ) - findNavController().navigate(action) - } -} \ No newline at end of file diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheetindividualdetails/OnRetrieveSheetItemData.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheetindividualdetails/OnRetrieveSheetItemData.kt deleted file mode 100644 index 998ff37d7a1..00000000000 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheetindividualdetails/OnRetrieveSheetItemData.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.mifos.mifosxdroid.online.collectionsheetindividualdetails - -import com.mifos.core.model.BulkRepaymentTransactions - -/** - * Created by aksh on 20/6/18. - */ -interface OnRetrieveSheetItemData { - fun onShowSheetMandatoryItem(transaction: BulkRepaymentTransactions, position: Int) - fun onSaveAdditionalItem(transaction: BulkRepaymentTransactions, position: Int) -} \ No newline at end of file diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheetindividualdetails/PaymentDetailsFragment.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheetindividualdetails/PaymentDetailsFragment.kt deleted file mode 100644 index f735e388d20..00000000000 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/collectionsheetindividualdetails/PaymentDetailsFragment.kt +++ /dev/null @@ -1,235 +0,0 @@ - -package com.mifos.mifosxdroid.online.collectionsheetindividualdetails - -import android.app.Activity -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.AdapterView -import android.widget.AdapterView.OnItemSelectedListener -import android.widget.ArrayAdapter -import androidx.compose.ui.platform.ComposeView -import androidx.compose.ui.platform.ViewCompositionStrategy -import androidx.navigation.fragment.navArgs -import com.mifos.core.model.BulkRepaymentTransactions -import com.mifos.core.network.model.IndividualCollectionSheetPayload -import com.mifos.core.objects.accounts.loan.PaymentTypeOptions -import com.mifos.core.objects.collectionsheet.LoanAndClientName -import com.mifos.feature.individual_collection_sheet.generate_collection_sheet.GenerateCollectionSheetScreen -import com.mifos.feature.individual_collection_sheet.payment_details.PaymentDetailsScreenContent -import com.mifos.mifosxdroid.R -import com.mifos.mifosxdroid.core.MifosBaseFragment -import com.mifos.mifosxdroid.databinding.AddPaymentDetailBinding -import com.mifos.utils.ImageLoaderUtils -import dagger.hilt.android.AndroidEntryPoint -import java.util.Locale - -/** - * Created by aksh on 21/6/18. - */ -@AndroidEntryPoint -class PaymentDetailsFragment : MifosBaseFragment(), View.OnClickListener, OnItemSelectedListener { - - private lateinit var binding: AddPaymentDetailBinding - private val arg: PaymentDetailsFragmentArgs by navArgs() - - private var paymentTypeList: List? = null - private var paymentTypeOptionsList: List? = null - var payload: IndividualCollectionSheetPayload? = null - private var mCallback: OnPayloadSelectedListener? = null - private lateinit var bulkRepaymentTransaction: BulkRepaymentTransactions - private var position = 0 - private var clientId = 0 - private var loanAndClientNameItem: LoanAndClientName? = null - override fun onAttach(activity: Activity) { - super.onAttach(activity) - mCallback = try { - activity as OnPayloadSelectedListener - } catch (e: ClassCastException) { - throw ClassCastException( - activity.toString() - + " must implement OnPayloadSelectedListener" - ) - } - } - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - position = arg.position - loanAndClientNameItem = arg.loanAndClientName - paymentTypeList = arg.paymentTypeList.toList() - payload = arg.payload - paymentTypeOptionsList = arg.paymentTypeOptions.toList() - clientId = arg.clientId - bulkRepaymentTransaction = BulkRepaymentTransactions() - } - - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View { - binding = AddPaymentDetailBinding.inflate(inflater, container, false) - return binding.root - } - - fun showUI() { - val loanCollectionSheetItem = loanAndClientNameItem?.loan - binding.tvName.text = loanAndClientNameItem?.clientName - binding.tvProduct.text = concatProductWithAccount( - loanCollectionSheetItem - ?.productShortName, loanCollectionSheetItem?.accountId - ) - binding.tvTotalCharges.text = String.format( - Locale.getDefault(), "%f", - loanCollectionSheetItem?.chargesDue - ) - binding.etTotalDue.setText( - loanCollectionSheetItem?.totalDue?.let { - String.format(Locale.getDefault(), "%.2f", it) - } - ) - /** - * problem1 - */ - ImageLoaderUtils.loadImage( - requireContext(), clientId, - binding.ivUserPicture - ) - - val defaultBulkRepaymentTransaction = BulkRepaymentTransactions() - if (loanCollectionSheetItem != null) { - defaultBulkRepaymentTransaction.loanId = loanCollectionSheetItem.loanId - } - if (loanCollectionSheetItem != null) { - defaultBulkRepaymentTransaction.transactionAmount = - loanCollectionSheetItem.chargesDue + - loanCollectionSheetItem.totalDue - } - onShowSheetMandatoryItem( - defaultBulkRepaymentTransaction, - position - ) - binding.btnAddPayment.setOnClickListener(this) - } - - private fun concatProductWithAccount(productCode: String?, accountNo: String?): String { - return "$productCode (#$accountNo)" - } - - private fun showAdditional() { - binding.tableAdditionalDetails.visibility = View.VISIBLE - val adapter = ArrayAdapter( - requireActivity(), - android.R.layout.simple_spinner_item, paymentTypeList ?: emptyList() - ) - binding.spPaymentTypeOptions.adapter = adapter - binding.spPaymentTypeOptions.setSelection(paymentTypeList!!.size - 1) - binding.spPaymentTypeOptions.onItemSelectedListener = this - binding.btnSaveAdditional.setOnClickListener(this) - binding.btnCancelAdditional.setOnClickListener(this) - } - - private fun cancelAdditional() { - bulkRepaymentTransaction.loanId = loanAndClientNameItem?.loan!!.loanId - val charge1: Double = if (binding.tvTotalCharges.text.toString().isNotEmpty()) - binding.tvTotalCharges.text.toString().toDouble() else 0.0 - val charge2: Double = if (binding.etTotalDue.text.toString().isNotEmpty() - ) binding.etTotalDue.text.toString().toDouble() else 0.0 - - bulkRepaymentTransaction.transactionAmount = charge1 + charge2 - binding.tableAdditionalDetails.visibility = View.GONE - bulkRepaymentTransaction.paymentTypeId = null - bulkRepaymentTransaction.accountNumber = null - bulkRepaymentTransaction.checkNumber = null - bulkRepaymentTransaction.routingCode = null - bulkRepaymentTransaction.receiptNumber = null - bulkRepaymentTransaction.bankNumber = null - onSaveAdditionalItem(bulkRepaymentTransaction, position) - } - - private fun saveAdditional() { - var isAnyDetailNull = false - bulkRepaymentTransaction.loanId = loanAndClientNameItem?.loan!!.loanId - val charge1: Double = if (binding.tvTotalCharges.text.toString().isNotEmpty()) - binding.tvTotalCharges.text.toString().toDouble() else 0.0 - val charge2: Double = if (binding.etTotalDue.text.toString().isNotEmpty()) { - binding.etTotalDue.text.toString().toDouble() - } else 0.0 - - bulkRepaymentTransaction.transactionAmount = (charge1 + charge2) - - if (binding.etAccountNumber.text.toString().isNotEmpty()) { - bulkRepaymentTransaction.accountNumber = binding.etAccountNumber.text.toString() - } else { - isAnyDetailNull = true - } - if (binding.etChequeNumber.text.toString().isNotEmpty()) { - bulkRepaymentTransaction.checkNumber = binding.etChequeNumber.text.toString() - } else { - isAnyDetailNull = true - } - if (binding.etRoutingCode.text.toString().isNotEmpty()) { - bulkRepaymentTransaction.routingCode = binding.etRoutingCode.text.toString() - } else { - isAnyDetailNull = true - } - if (binding.etReceiptNumber.text.toString().isNotEmpty()) { - bulkRepaymentTransaction.receiptNumber = binding.etReceiptNumber.text.toString() - } else { - isAnyDetailNull = true - } - if (binding.etBankNumber.text.toString().isNotEmpty()) { - bulkRepaymentTransaction.bankNumber = binding.etBankNumber.text.toString() - } else { - isAnyDetailNull = true - } - - if (!isAnyDetailNull) { - binding.noPayment.visibility = View.GONE - } - onSaveAdditionalItem(bulkRepaymentTransaction, position) - binding.tableAdditionalDetails.visibility = View.GONE - } - - override fun onActivityCreated(savedInstanceState: Bundle?) { - super.onActivityCreated(savedInstanceState) - showUI() - } - - private fun onShowSheetMandatoryItem(transaction: BulkRepaymentTransactions, position: Int) { - payload!!.bulkRepaymentTransactions[position] = transaction - } - - private fun onSaveAdditionalItem(transaction: BulkRepaymentTransactions, position: Int) { - payload!!.bulkRepaymentTransactions[position] = transaction - mCallback?.onPayloadSelected(payload) - } - - override fun onClick(view: View) { - when (view.id) { - R.id.btn_add_payment -> if (binding.tableAdditionalDetails.visibility == View.VISIBLE) { - binding.tableAdditionalDetails.visibility = View.GONE - } else if (binding.tableAdditionalDetails.visibility == View.GONE) { - showAdditional() - } - - R.id.btn_cancel_additional -> cancelAdditional() - R.id.btn_save_additional -> saveAdditional() - } - } - - override fun onItemSelected(adapterView: AdapterView<*>?, view: View, i: Int, l: Long) { - if (i != paymentTypeList!!.size - 1) { - bulkRepaymentTransaction.paymentTypeId = paymentTypeOptionsList!![i].id - } else { - bulkRepaymentTransaction.paymentTypeId = null - } - } - - override fun onNothingSelected(adapterView: AdapterView<*>?) {} - interface OnPayloadSelectedListener { - fun onPayloadSelected(payload: IndividualCollectionSheetPayload?) - } -} \ No newline at end of file diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/generatecollectionsheet/GenerateCollectionSheetFragment.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/generatecollectionsheet/GenerateCollectionSheetFragment.kt deleted file mode 100755 index 7f950ebdd2c..00000000000 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/generatecollectionsheet/GenerateCollectionSheetFragment.kt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This project is licensed under the open source MPL V2. - * See https://github.com/openMF/android-client/blob/master/LICENSE.md - */ -package com.mifos.mifosxdroid.online.generatecollectionsheet - -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.appcompat.app.AppCompatActivity -import androidx.compose.ui.platform.ComposeView -import androidx.compose.ui.platform.ViewCompositionStrategy -import com.mifos.feature.individual_collection_sheet.generate_collection_sheet.GenerateCollectionSheetScreen -import com.mifos.mifosxdroid.core.MifosBaseFragment -import dagger.hilt.android.AndroidEntryPoint - -@AndroidEntryPoint -class GenerateCollectionSheetFragment : MifosBaseFragment() { - - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View { - return ComposeView(requireContext()).apply { - setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) - setContent { - GenerateCollectionSheetScreen( - onBackPressed = { - requireActivity().finish() - } - ) - } - } - } - - override fun onResume() { - super.onResume() - (requireActivity() as AppCompatActivity).supportActionBar?.hide() - } - - override fun onStop() { - super.onStop() - (requireActivity() as AppCompatActivity).supportActionBar?.show() - } -} \ No newline at end of file diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/savedcollectionsheetindividual/SavedIndividualCollectionSheetFragment.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/savedcollectionsheetindividual/SavedIndividualCollectionSheetFragment.kt deleted file mode 100644 index 98042b85d2c..00000000000 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/savedcollectionsheetindividual/SavedIndividualCollectionSheetFragment.kt +++ /dev/null @@ -1,28 +0,0 @@ -package com.mifos.mifosxdroid.online.savedcollectionsheetindividual - -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.compose.ui.platform.ComposeView -import androidx.compose.ui.platform.ViewCompositionStrategy -import com.mifos.feature.individual_collection_sheet.saved_individual_collection_sheet.ui.SavedIndividualCollectionSheetCompose -import com.mifos.mifosxdroid.core.MifosBaseFragment - -/** - * Created by aksh on 18/6/18. - */ -class SavedIndividualCollectionSheetFragment : MifosBaseFragment() { - - override fun onCreateView( - inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? - ): View { - return ComposeView(requireContext()).apply { - setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) - setContent { - SavedIndividualCollectionSheetCompose() - } - } - } -} \ No newline at end of file diff --git a/mifosng-android/src/main/res/layout/activity_generate_collection_sheet.xml b/mifosng-android/src/main/res/layout/activity_generate_collection_sheet.xml deleted file mode 100755 index a197a00afe5..00000000000 --- a/mifosng-android/src/main/res/layout/activity_generate_collection_sheet.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - diff --git a/mifosng-android/src/main/res/layout/add_payment_detail.xml b/mifosng-android/src/main/res/layout/add_payment_detail.xml deleted file mode 100644 index ed50090d297..00000000000 --- a/mifosng-android/src/main/res/layout/add_payment_detail.xml +++ /dev/null @@ -1,297 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -