settlement's unsettle data fixed
This commit is contained in:
parent
4dee4bb6f9
commit
3e6a0707d8
@ -25,10 +25,14 @@ import androidx.compose.runtime.LaunchedEffect
|
|||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.livedata.observeAsState
|
import androidx.compose.runtime.livedata.observeAsState
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
|
||||||
import com.mob.utsmyanmar.ui.components.appbar.AppBar
|
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.Color
|
||||||
|
import com.mob.utsmyanmar.ui.theme.MOBPOSTheme
|
||||||
|
import com.mob.utsmyanmar.utils.convertDateString
|
||||||
import com.mob.utsmyanmar.viewmodel.SharedViewModel
|
import com.mob.utsmyanmar.viewmodel.SharedViewModel
|
||||||
import com.utsmyanmar.paylibs.model.PayDetail
|
import com.utsmyanmar.paylibs.model.PayDetail
|
||||||
import com.utsmyanmar.paylibs.utils.POSUtil
|
import com.utsmyanmar.paylibs.utils.POSUtil
|
||||||
@ -42,6 +46,22 @@ fun SettlementScreen(
|
|||||||
autoStartSettlement: Boolean = false
|
autoStartSettlement: Boolean = false
|
||||||
) {
|
) {
|
||||||
val records by settlementViewMode.getSettlementPOS().observeAsState(emptyList())
|
val records by settlementViewMode.getSettlementPOS().observeAsState(emptyList())
|
||||||
|
|
||||||
|
SettlementContent(
|
||||||
|
records = records,
|
||||||
|
onBack = onBack,
|
||||||
|
onStartSettlement = onStartSettlement,
|
||||||
|
autoStartSettlement = autoStartSettlement
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun SettlementContent(
|
||||||
|
records: List<PayDetail>,
|
||||||
|
onBack: () -> Unit,
|
||||||
|
onStartSettlement: () -> Unit,
|
||||||
|
autoStartSettlement: Boolean = false
|
||||||
|
) {
|
||||||
val totalAmount = records.sumOf { it.amount }
|
val totalAmount = records.sumOf { it.amount }
|
||||||
|
|
||||||
LaunchedEffect(autoStartSettlement, records) {
|
LaunchedEffect(autoStartSettlement, records) {
|
||||||
@ -116,7 +136,7 @@ fun SettlementScreen(
|
|||||||
verticalArrangement = Arrangement.spacedBy(0.dp)
|
verticalArrangement = Arrangement.spacedBy(0.dp)
|
||||||
) {
|
) {
|
||||||
items(records) { record ->
|
items(records) { record ->
|
||||||
SettlementRecordRow(record = record)
|
SettlementRecordRow(payDetail = record)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -164,40 +184,87 @@ private fun SummaryRow(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun SettlementRecordRow(record: PayDetail) {
|
private fun SettlementRecordRow(payDetail: PayDetail) {
|
||||||
Column(modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp)) {
|
Column(modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp)) {
|
||||||
Row(
|
Spacer(Modifier.height(4.dp))
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
horizontalArrangement = Arrangement.SpaceBetween
|
|
||||||
) {
|
|
||||||
Text(
|
Text(
|
||||||
text = record.transType
|
text = payDetail.transType
|
||||||
|
.orEmpty()
|
||||||
.ifBlank { "UNKNOWN" }
|
.ifBlank { "UNKNOWN" }
|
||||||
.replace("CASH_OUT", "CASH_ADV", ignoreCase = true),
|
.replace("CASH_OUT", "CASH_ADV", ignoreCase = true),
|
||||||
color = Color.LegacyRed,
|
color = Color.LegacyRed,
|
||||||
style = MaterialTheme.typography.titleSmall
|
style = MaterialTheme.typography.titleSmall
|
||||||
)
|
)
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween
|
||||||
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = POSUtil.getInstance().getDecimalAmountSeparatorFormat(record.amount),
|
text = "Date & Time",
|
||||||
color = Color.Black,
|
style = MaterialTheme.typography.titleSmall
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = "${convertDateString(payDetail.transDate.orEmpty())} ${payDetail.transTime.orEmpty()}".trim().ifBlank { "-" },
|
||||||
style = MaterialTheme.typography.titleSmall
|
style = MaterialTheme.typography.titleSmall
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(4.dp))
|
Spacer(modifier = Modifier.height(4.dp))
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween
|
||||||
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = "Trace ${record.voucherNo.ifBlank { "-" }}",
|
text = "Amount",
|
||||||
color = Color.Black,
|
style = MaterialTheme.typography.titleSmall
|
||||||
style = MaterialTheme.typography.bodySmall
|
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = "Card ${maskCardNumber(record.cardNo)}",
|
text = displayAmountWithSign(payDetail),
|
||||||
color = Color.Gray,
|
style = MaterialTheme.typography.titleSmall
|
||||||
style = MaterialTheme.typography.bodySmall
|
|
||||||
)
|
)
|
||||||
|
}
|
||||||
Spacer(modifier = Modifier.height(12.dp))
|
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))
|
HorizontalDivider(color = Color.Gray.copy(alpha = 0.25f))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -209,3 +276,29 @@ private fun maskCardNumber(cardNo: String?): String {
|
|||||||
val stars = "*".repeat(pan.length - 8)
|
val stars = "*".repeat(pan.length - 8)
|
||||||
return pan.take(4) + stars + pan.takeLast(4)
|
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 = {}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user