-
Notifications
You must be signed in to change notification settings - Fork 655
Collection Sheet Enhancement #2406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: kmp-impl
Are you sure you want to change the base?
Changes from 9 commits
acda6fd
e87f0c5
a6e63b8
568038a
5832ff9
5cc2a65
93c9e8f
f9676ba
ff585b1
a276755
82d87fd
447d1eb
48ec51b
d652cf4
6f2288d
4829298
84a5543
f2d6dca
3cbb9c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,13 +59,13 @@ import com.mifos.core.designsystem.icon.MifosIcons | |
| import com.mifos.core.model.objects.account.loan.PaymentTypeOptions | ||
| import com.mifos.core.model.objects.collectionsheets.LoanAndClientName | ||
| import com.mifos.core.network.model.IndividualCollectionSheetPayload | ||
| import com.mifos.core.ui.util.DevicePreview | ||
| import com.mifos.room.entities.collectionsheet.ClientCollectionSheet | ||
| import com.mifos.room.entities.collectionsheet.IndividualCollectionSheet | ||
| import com.mifos.room.entities.noncore.BulkRepaymentTransactions | ||
| import kotlinx.coroutines.launch | ||
| import org.jetbrains.compose.resources.painterResource | ||
| import org.jetbrains.compose.resources.stringResource | ||
| import org.jetbrains.compose.ui.tooling.preview.Preview | ||
| import org.koin.compose.viewmodel.koinViewModel | ||
|
|
||
| @Composable | ||
|
|
@@ -210,6 +210,8 @@ private fun IndividualCollectionSheetItem( | |
| modifier: Modifier = Modifier, | ||
| onClick: () -> Unit, | ||
| ) { | ||
| val loan = client.loans?.getOrNull(index) | ||
|
||
|
|
||
| OutlinedCard( | ||
| modifier = modifier | ||
| .padding(6.dp) | ||
|
|
@@ -246,18 +248,16 @@ private fun IndividualCollectionSheetItem( | |
| Text( | ||
| text = it, | ||
| style = MaterialTheme.typography.bodyLarge, | ||
|
|
||
| ) | ||
| } | ||
| Row { | ||
| Text( | ||
| text = stringResource(Res.string.feature_collection_sheet_total_due), | ||
| style = MaterialTheme.typography.bodyMedium, | ||
|
|
||
| ) | ||
| Spacer(modifier = Modifier.width(16.dp)) | ||
| Text( | ||
| text = client.loans?.get(index)?.totalDue.toString(), | ||
| text = (loan?.totalDue ?: 0).toString(), | ||
|
||
| style = MaterialTheme.typography.bodyMedium, | ||
| ) | ||
| } | ||
|
|
@@ -268,18 +268,16 @@ private fun IndividualCollectionSheetItem( | |
| ) | ||
| Spacer(modifier = Modifier.width(16.dp)) | ||
| Text( | ||
| text = client.loans?.get(index)?.chargesDue.toString(), | ||
| text = (loan?.chargesDue ?: 0).toString(), | ||
| style = MaterialTheme.typography.bodyMedium, | ||
| ) | ||
| } | ||
| if (loan?.productShortName != null) { | ||
| Text( | ||
| text = "${loan.productShortName} (#${loan.productShortName})", | ||
| style = MaterialTheme.typography.bodyMedium, | ||
| ) | ||
| } | ||
| Text( | ||
| text = "${client.loans?.get(index)?.productShortName} (#${ | ||
| client.loans?.get( | ||
| index, | ||
| )?.productShortName | ||
| })", | ||
| style = MaterialTheme.typography.bodyMedium, | ||
| ) | ||
| } | ||
| Icon( | ||
| imageVector = MifosIcons.ArrowForward, | ||
|
|
@@ -289,7 +287,7 @@ private fun IndividualCollectionSheetItem( | |
| } | ||
| } | ||
|
|
||
| @DevicePreview | ||
| @Preview | ||
| @Composable | ||
| private fun IndividualCollectionSheetDetailsScreenEmptyPreview() { | ||
| IndividualCollectionSheetDetailsScreen( | ||
|
|
@@ -303,7 +301,7 @@ private fun IndividualCollectionSheetDetailsScreenEmptyPreview() { | |
| ) | ||
| } | ||
|
|
||
| @DevicePreview | ||
| @Preview | ||
| @Composable | ||
| private fun IndividualCollectionSheetDetailsScreenErrorPreview() { | ||
| IndividualCollectionSheetDetailsScreen( | ||
|
|
@@ -317,7 +315,7 @@ private fun IndividualCollectionSheetDetailsScreenErrorPreview() { | |
| ) | ||
| } | ||
|
|
||
| @DevicePreview | ||
| @Preview | ||
| @Composable | ||
| private fun IndividualCollectionSheetDetailsScreenLoadingPreview() { | ||
| IndividualCollectionSheetDetailsScreen( | ||
|
|
@@ -331,7 +329,7 @@ private fun IndividualCollectionSheetDetailsScreenLoadingPreview() { | |
| ) | ||
| } | ||
|
|
||
| @DevicePreview | ||
| @Preview | ||
| @Composable | ||
| private fun IndividualCollectionSheetDetailsScreenSuccessPreview() { | ||
| IndividualCollectionSheetDetailsScreen( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,12 +66,12 @@ import com.mifos.core.designsystem.component.MifosDatePickerTextField | |
| import com.mifos.core.designsystem.component.MifosScaffold | ||
| import com.mifos.core.designsystem.component.MifosTextFieldDropdown | ||
| import com.mifos.core.network.model.RequestCollectionSheetPayload | ||
| import com.mifos.core.ui.util.DevicePreview | ||
| import com.mifos.room.entities.collectionsheet.IndividualCollectionSheet | ||
| import com.mifos.room.entities.organisation.OfficeEntity | ||
| import com.mifos.room.entities.organisation.StaffEntity | ||
| import kotlinx.datetime.Clock | ||
| import org.jetbrains.compose.resources.stringResource | ||
| import org.jetbrains.compose.ui.tooling.preview.Preview | ||
| import org.koin.compose.viewmodel.koinViewModel | ||
|
|
||
| @Composable | ||
|
|
@@ -120,7 +120,11 @@ internal fun NewIndividualCollectionSheetScreen( | |
| var showCollectionSheetDialog by rememberSaveable { mutableStateOf(false) } | ||
|
|
||
| var showDatePicker by rememberSaveable { mutableStateOf(false) } | ||
| var repaymentDate by rememberSaveable { mutableLongStateOf(Clock.System.now().toEpochMilliseconds()) } | ||
| var repaymentDate by rememberSaveable { | ||
| mutableLongStateOf( | ||
| Clock.System.now().toEpochMilliseconds(), | ||
| ) | ||
| } | ||
| val datePickerState = rememberDatePickerState( | ||
| initialSelectedDateMillis = repaymentDate, | ||
| selectableDates = object : SelectableDates { | ||
|
|
@@ -229,12 +233,24 @@ internal fun NewIndividualCollectionSheetScreen( | |
| selectedStaff = "" | ||
| }, | ||
| onOptionSelected = { index, value -> | ||
| state.officeList[index].id.let { | ||
| getStaffList(it) | ||
| officeId = it | ||
| println("DEBUG: Office selection - Index: $index, List size: ${state.officeList.size}, Value: $value") | ||
|
||
| try { | ||
| if (index >= 0 && index < state.officeList.size) { | ||
| val selectedOfficeEntity = state.officeList[index] | ||
| selectedOfficeEntity.id?.let { | ||
| getStaffList(it) | ||
| officeId = it | ||
| } | ||
| selectedOffice = value | ||
| selectedStaff = "" | ||
| println("DEBUG: Office selection successful") | ||
| } else { | ||
| println("DEBUG: Office index out of bounds: $index for size ${state.officeList.size}") | ||
| } | ||
| } catch (e: Exception) { | ||
| println("DEBUG: Error in office selection: ${e.message}") | ||
| println("DEBUG: Full error: ${e.stackTraceToString()}") | ||
| } | ||
| selectedOffice = value | ||
| selectedStaff = "" | ||
| }, | ||
| label = stringResource(Res.string.feature_collection_sheet_office), | ||
| options = state.officeList.map { it.name.toString() }, | ||
|
|
@@ -254,10 +270,21 @@ internal fun NewIndividualCollectionSheetScreen( | |
| selectedStaff = it | ||
| }, | ||
| onOptionSelected = { index, value -> | ||
| state.staffList[index].id?.let { | ||
| staffId = it | ||
| try { | ||
| if (index >= 0 && index < state.staffList.size) { | ||
|
||
| val selectedStaffEntity = state.staffList[index] | ||
| selectedStaffEntity.id?.let { | ||
| staffId = it | ||
| } | ||
| selectedStaff = value | ||
| println("DEBUG: Staff selection successful") | ||
| } else { | ||
| println("DEBUG: Staff index out of bounds: $index for size ${state.staffList.size}") | ||
| } | ||
| } catch (e: Exception) { | ||
| println("DEBUG: Error in staff selection: ${e.message}") | ||
| println("DEBUG: Full error: ${e.stackTraceToString()}") | ||
| } | ||
| selectedStaff = value | ||
| }, | ||
| label = stringResource(Res.string.feature_collection_sheet_staff), | ||
| options = state.staffList.map { it.displayName.toString() }, | ||
|
|
@@ -388,7 +415,7 @@ private fun CollectionSheetDialogContent( | |
| ) | ||
| } | ||
|
|
||
| @DevicePreview | ||
| @Preview | ||
| @Composable | ||
| private fun NewIndividualCollectionSheetPreview() { | ||
| Column { | ||
|
|
@@ -438,7 +465,7 @@ val sampleOfficeList = List(10) { | |
| OfficeEntity(id = it, name = "Name") | ||
| } | ||
|
|
||
| @DevicePreview | ||
| @Preview | ||
| @Composable | ||
| private fun CollectionSheetDialogContentPreview() { | ||
| CollectionSheetDialogContent(date = "19 June 2024", member = "5", fillNow = {}, onDismiss = {}) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this as u already defined in
dependencies {}blockThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i mentioned remove it from
commonMainbut keep thedependencies{}:KMP wizardthis way it is done by default maybe they have sth in mind where in future the previews will work for all platform if we have it here