From 3e6a0707d89bb376617a944d8c8d0bf1d83cff56 Mon Sep 17 00:00:00 2001 From: moon <56061215+MgKyawLay@users.noreply.github.com> Date: Mon, 21 Sep 2026 17:26:20 +0630 Subject: [PATCH] settlement's unsettle data fixed --- .../ui/settlement/SettlementScreen.kt | 137 +++++++++++++++--- 1 file changed, 115 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/com/mob/utsmyanmar/ui/settlement/SettlementScreen.kt b/app/src/main/java/com/mob/utsmyanmar/ui/settlement/SettlementScreen.kt index 1e27bfb..b6e2166 100644 --- a/app/src/main/java/com/mob/utsmyanmar/ui/settlement/SettlementScreen.kt +++ b/app/src/main/java/com/mob/utsmyanmar/ui/settlement/SettlementScreen.kt @@ -25,10 +25,14 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.livedata.observeAsState import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.mob.utsmyanmar.ui.components.appbar.AppBar +import com.mob.utsmyanmar.ui.history_functions.displayAmountWithSign import com.mob.utsmyanmar.ui.theme.Color +import com.mob.utsmyanmar.ui.theme.MOBPOSTheme +import com.mob.utsmyanmar.utils.convertDateString import com.mob.utsmyanmar.viewmodel.SharedViewModel import com.utsmyanmar.paylibs.model.PayDetail import com.utsmyanmar.paylibs.utils.POSUtil @@ -42,6 +46,22 @@ fun SettlementScreen( autoStartSettlement: Boolean = false ) { val records by settlementViewMode.getSettlementPOS().observeAsState(emptyList()) + + SettlementContent( + records = records, + onBack = onBack, + onStartSettlement = onStartSettlement, + autoStartSettlement = autoStartSettlement + ) +} + +@Composable +private fun SettlementContent( + records: List, + onBack: () -> Unit, + onStartSettlement: () -> Unit, + autoStartSettlement: Boolean = false +) { val totalAmount = records.sumOf { it.amount } LaunchedEffect(autoStartSettlement, records) { @@ -116,7 +136,7 @@ fun SettlementScreen( verticalArrangement = Arrangement.spacedBy(0.dp) ) { items(records) { record -> - SettlementRecordRow(record = record) + SettlementRecordRow(payDetail = record) } } } @@ -164,40 +184,87 @@ private fun SummaryRow( } @Composable -private fun SettlementRecordRow(record: PayDetail) { +private fun SettlementRecordRow(payDetail: PayDetail) { Column(modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp)) { + Spacer(Modifier.height(4.dp)) + Text( + text = payDetail.transType + .orEmpty() + .ifBlank { "UNKNOWN" } + .replace("CASH_OUT", "CASH_ADV", ignoreCase = true), + color = Color.LegacyRed, + style = MaterialTheme.typography.titleSmall + ) Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween ) { Text( - text = record.transType - .ifBlank { "UNKNOWN" } - .replace("CASH_OUT", "CASH_ADV", ignoreCase = true), - color = Color.LegacyRed, + text = "Date & Time", style = MaterialTheme.typography.titleSmall ) Text( - text = POSUtil.getInstance().getDecimalAmountSeparatorFormat(record.amount), - color = Color.Black, + text = "${convertDateString(payDetail.transDate.orEmpty())} ${payDetail.transTime.orEmpty()}".trim().ifBlank { "-" }, style = MaterialTheme.typography.titleSmall ) } - Spacer(modifier = Modifier.height(4.dp)) - - Text( - text = "Trace ${record.voucherNo.ifBlank { "-" }}", - color = Color.Black, - style = MaterialTheme.typography.bodySmall - ) - Text( - text = "Card ${maskCardNumber(record.cardNo)}", - color = Color.Gray, - style = MaterialTheme.typography.bodySmall - ) - - Spacer(modifier = Modifier.height(12.dp)) + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.SpaceBetween + ) { + Text( + text = "Amount", + style = MaterialTheme.typography.titleSmall + ) + Text( + text = displayAmountWithSign(payDetail), + style = MaterialTheme.typography.titleSmall + ) + } + Spacer(modifier = Modifier.height(4.dp)) + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.SpaceBetween + ) { + Text( + text = "Trace No", + style = MaterialTheme.typography.titleSmall + ) + Text( + text = payDetail.voucherNo.orEmpty().ifBlank { "-" }, + style = MaterialTheme.typography.titleSmall + ) + } + Spacer(modifier = Modifier.height(4.dp)) + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.SpaceBetween + ) { + Text( + text = "Reference No", + style = MaterialTheme.typography.titleSmall + ) + Text( + text = payDetail.referNo.orEmpty().ifBlank { "-" }, + style = MaterialTheme.typography.titleSmall + ) + } + Spacer(modifier = Modifier.height(4.dp)) + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.SpaceBetween + ) { + Text( + text = "Approval Code", + style = MaterialTheme.typography.titleSmall + ) + Text( + text = payDetail.approvalCode.orEmpty().ifBlank { "-" }, + style = MaterialTheme.typography.titleSmall + ) + } + Spacer(Modifier.height(4.dp)) HorizontalDivider(color = Color.Gray.copy(alpha = 0.25f)) } } @@ -209,3 +276,29 @@ private fun maskCardNumber(cardNo: String?): String { val stars = "*".repeat(pan.length - 8) return pan.take(4) + stars + pan.takeLast(4) } + +@Preview(showBackground = true) +@Composable +private fun SettlementScreenPreview() { + val sampleRecords = listOf( + PayDetail().apply { + transType = "SALE" + amount = 150000L + voucherNo = "000001" + cardNo = "9503036867315548" + }, + PayDetail().apply { + transType = "CASH_OUT" + amount = 50000L + voucherNo = "000002" + cardNo = "9503036867311234" + } + ) + MOBPOSTheme { + SettlementContent( + records = sampleRecords, + onBack = {}, + onStartSettlement = {} + ) + } +}