Compare commits
No commits in common. "0234c05e639186639e0096f8683cdae0ea0c3e8d" and "907eab4e72897f4d75bf0d1f8a4bafae4b820f81" have entirely different histories.
0234c05e63
...
907eab4e72
@ -40,8 +40,8 @@ android {
|
||||
dimension = "env"
|
||||
applicationIdSuffix = ".uat"
|
||||
versionNameSuffix = "-UAT"
|
||||
versionCode = 29
|
||||
versionName = "4.7"
|
||||
versionCode = 21
|
||||
versionName = "3.9"
|
||||
buildConfigField("String", "ENV", "\"UAT\"")
|
||||
resValue("string", "app_name", "MOB-UAT")
|
||||
}
|
||||
|
||||
@ -10,28 +10,21 @@ import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.rounded.Backspace
|
||||
import androidx.compose.material.icons.rounded.Backspace
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.ui.draw.shadow
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.mob.utsmyanmar.ui.theme.Color
|
||||
import com.mob.utsmyanmar.ui.theme.MOBPOSTheme
|
||||
import com.mob.utsmyanmar.utils.convertDateString
|
||||
import com.utsmyanmar.paylibs.model.PayDetail
|
||||
import com.utsmyanmar.paylibs.utils.core_utils.SystemParamsOperation
|
||||
|
||||
@Composable
|
||||
internal fun HistoryTransactionCard(
|
||||
@ -51,206 +44,70 @@ internal fun HistoryTransactionCard(
|
||||
colors = CardDefaults.cardColors(containerColor = Color.White)
|
||||
) {
|
||||
Column(modifier = Modifier.padding(16.dp)) {
|
||||
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Text(
|
||||
text = displayTransactionTitle(payDetail),
|
||||
color = Color.LegacyRed,
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
)
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Text(
|
||||
text = "Date & Time",
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
)
|
||||
Text(
|
||||
"${convertDateString(payDetail.transDate.orEmpty())} ${payDetail.transTime.orEmpty()}".trim(),
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.height(4.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("Trace ${payDetail.voucherNo.ifBlank { "-" }}", style = MaterialTheme.typography.bodySmall)
|
||||
Text("RRN ${payDetail.referNo.ifBlank { "-" }}", style = MaterialTheme.typography.bodySmall, color = Color.Gray)
|
||||
Text(
|
||||
text = "Trace No",
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
"${convertDateString(payDetail.transDate)} ${payDetail.transTime}",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = Color.Gray
|
||||
)
|
||||
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 ?: payDetail.authNo).orEmpty().ifBlank { "-" },
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun HistoryTransactionDetailCard(
|
||||
payDetail: PayDetail,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val dateStr = if (!payDetail.transDate.isNullOrBlank()) {
|
||||
convertDateString(payDetail.transDate)
|
||||
} else {
|
||||
payDetail.tradeDate.orEmpty().ifBlank { "-" }
|
||||
}
|
||||
val timeStr = payDetail.transTime.orEmpty().ifBlank { payDetail.tradeTime.orEmpty() }.ifBlank { "-" }
|
||||
val merchantNameStr = payDetail.merchantName?.takeIf { it.isNotBlank() }
|
||||
?: SystemParamsOperation.getInstance().merchantName?.takeIf { it.isNotBlank() }
|
||||
?: "-"
|
||||
val midStr = payDetail.merchantNo?.takeIf { it.isNotBlank() }
|
||||
?: SystemParamsOperation.getInstance().merchantId?.takeIf { it.isNotBlank() }
|
||||
?: "-"
|
||||
val tidStr = payDetail.terminalNo?.takeIf { it.isNotBlank() }
|
||||
?: SystemParamsOperation.getInstance().terminalId?.takeIf { it.isNotBlank() }
|
||||
?: "-"
|
||||
val traceNoStr = payDetail.voucherNo.orEmpty().ifBlank { "-" }
|
||||
val refNoStr = payDetail.referNo.orEmpty().ifBlank { "-" }
|
||||
val aprCodeStr = payDetail.approvalCode?.takeIf { it.isNotBlank() }
|
||||
?: payDetail.authNo?.takeIf { it.isNotBlank() }
|
||||
?: "-"
|
||||
val transTypeStr = displayTransactionTitle(payDetail)
|
||||
val amountStr = displayAmountWithSign(payDetail)
|
||||
val cardTypeStr = payDetail.accountType.orEmpty().ifBlank { "-" }
|
||||
val cleanPan = payDetail.cardNo.orEmpty().replace(" ", "")
|
||||
val cardNoStr = if (cleanPan.length > 10) {
|
||||
cleanPan.take(6) + "*".repeat(cleanPan.length - 10) + cleanPan.takeLast(4)
|
||||
} else if (cleanPan.isNotBlank()) {
|
||||
cleanPan
|
||||
} else {
|
||||
"-"
|
||||
}
|
||||
val statusStr = displayTransactionStatus(payDetail)
|
||||
|
||||
internal fun HistoryTransactionDetailCard(payDetail: PayDetail) {
|
||||
Card(
|
||||
modifier = modifier.fillMaxWidth(),
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
colors = CardDefaults.cardColors(containerColor = Color.White),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
colors = CardDefaults.cardColors(containerColor = Color.White)
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier.padding(16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(10.dp)
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
Text(
|
||||
text = transTypeStr,
|
||||
text = displayTransactionTitle(payDetail),
|
||||
color = Color.LegacyRed,
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
// Text(
|
||||
// text = amountStr,
|
||||
// color = Color.Black,
|
||||
// style = MaterialTheme.typography.titleMedium,
|
||||
// fontWeight = FontWeight.Bold
|
||||
// )
|
||||
}
|
||||
|
||||
HorizontalDivider(
|
||||
modifier = Modifier.padding(vertical = 2.dp),
|
||||
color = Color.Gray.copy(alpha = 0.2f)
|
||||
)
|
||||
|
||||
SummaryLine("Date", dateStr)
|
||||
SummaryLine("Time", timeStr)
|
||||
// SummaryLine("Merchant Name", merchantNameStr)
|
||||
SummaryLine("Mid", midStr)
|
||||
SummaryLine("Tid", tidStr)
|
||||
SummaryLine("Trace No", traceNoStr)
|
||||
SummaryLine("Ref No", refNoStr)
|
||||
SummaryLine("APR Code", aprCodeStr)
|
||||
SummaryLine("Transaction Type", transTypeStr)
|
||||
SummaryLine("Amount", amountStr)
|
||||
SummaryLine("Card Type", cardTypeStr)
|
||||
SummaryLine("Card No", cardNoStr)
|
||||
SummaryLine(
|
||||
label = "Status",
|
||||
value = statusStr,
|
||||
valueColor = when {
|
||||
statusStr.contains("SUCCESS", ignoreCase = true) ||
|
||||
statusStr.contains("Approved", ignoreCase = true) -> Color.Success
|
||||
statusStr.contains("FAIL", ignoreCase = true) ||
|
||||
statusStr.contains("DECLINE", ignoreCase = true) -> Color.Error
|
||||
else -> Color.Black
|
||||
}
|
||||
style = MaterialTheme.typography.titleMedium
|
||||
)
|
||||
SummaryLine("Date", payDetail.tradeDate)
|
||||
SummaryLine("Time", payDetail.tradeTime)
|
||||
SummaryLine("Amount", displayAmountWithSign(payDetail))
|
||||
SummaryLine("Trace No", payDetail.voucherNo)
|
||||
// SummaryLine("Card No", payDetail.cardNo)
|
||||
SummaryLine("Reference No", payDetail.referNo)
|
||||
SummaryLine("Approval Code", payDetail.approvalCode.orEmpty())
|
||||
SummaryLine("Status", displayTransactionStatus(payDetail))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun SummaryLine(
|
||||
label: String,
|
||||
value: String,
|
||||
valueColor: androidx.compose.ui.graphics.Color = Color.Black,
|
||||
) {
|
||||
internal fun SummaryLine(label: String, value: String) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Text(label, color = Color.Gray, style = MaterialTheme.typography.bodyMedium)
|
||||
Text(
|
||||
text = label,
|
||||
color = Color.Gray,
|
||||
value.ifBlank { "-" },
|
||||
style = MaterialTheme.typography.bodyMedium
|
||||
)
|
||||
Text(
|
||||
text = value.ifBlank { "-" },
|
||||
color = valueColor,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
fontWeight = FontWeight.Medium
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -317,7 +174,7 @@ internal fun HistoryNumericKeypad(
|
||||
)
|
||||
) {
|
||||
if (key == "⌫") {
|
||||
Icon(Icons.AutoMirrored.Rounded.Backspace, contentDescription = "Backspace")
|
||||
Icon(Icons.Rounded.Backspace, contentDescription = "Backspace")
|
||||
} else {
|
||||
Text(key, style = MaterialTheme.typography.headlineMedium)
|
||||
}
|
||||
@ -327,89 +184,3 @@ internal fun HistoryNumericKeypad(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal val searchKeys = listOf(
|
||||
listOf("1", "2", "3"),
|
||||
listOf("4", "5", "6"),
|
||||
listOf("7", "8", "9"),
|
||||
listOf("C", "0", "\u232B")
|
||||
)
|
||||
|
||||
@Composable
|
||||
internal fun SearchInputBox(
|
||||
query: String,
|
||||
isFocused: Boolean,
|
||||
onFocus: () -> Unit,
|
||||
label: String = if (isFocused) "Trace or RRN" else "Tap to search by Trace or RRN",
|
||||
onDelete: (() -> Unit)? = null,
|
||||
) {
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable(onClick = onFocus),
|
||||
colors = CardDefaults.cardColors(containerColor = Color.White),
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = if (isFocused) 6.dp else 2.dp)
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 14.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Text(
|
||||
text = label,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = if (isFocused) Color.LegacyRed else Color.Gray
|
||||
)
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Text(
|
||||
text = query.ifEmpty { "_" },
|
||||
color = Color.LegacyRed,
|
||||
style = MaterialTheme.typography.headlineSmall.copy(
|
||||
fontWeight = FontWeight.Bold,
|
||||
letterSpacing = 2.sp
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
if (query.isNotEmpty()) {
|
||||
Card(
|
||||
shape = RoundedCornerShape(18.dp),
|
||||
colors = CardDefaults.cardColors(containerColor = Color.White),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 4.dp),
|
||||
modifier = Modifier
|
||||
.shadow(2.dp, RoundedCornerShape(18.dp))
|
||||
.clickable(enabled = onDelete != null) { onDelete?.invoke() }
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.AutoMirrored.Rounded.Backspace,
|
||||
contentDescription = "Delete",
|
||||
tint = Color.LegacyRed,
|
||||
modifier = Modifier.padding(horizontal = 14.dp, vertical = 12.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(showBackground = true)
|
||||
@Composable
|
||||
private fun HistoryTransactionCardPreview() {
|
||||
MOBPOSTheme {
|
||||
HistoryTransactionCard(
|
||||
payDetail = PayDetail().apply {
|
||||
transDate = "21/09/26"
|
||||
transTime = "14:04:15"
|
||||
voucherNo = "000001"
|
||||
referNo = "123456789012"
|
||||
transType = "SALE"
|
||||
amount = 1500000L
|
||||
},
|
||||
onClick = {}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,17 +55,11 @@ internal fun displayTransactionStatus(payDetail: PayDetail): String {
|
||||
if (payDetail.transactionType == TransactionsType.REVERSAL.value) {
|
||||
return if (payDetail.isNeedReversal) "REVERSAL FAILED" else "REVERSAL SUCCESS"
|
||||
}
|
||||
val code = payDetail.tradeAnswerCode.orEmpty().ifBlank { "-" }
|
||||
return try {
|
||||
POSUtil.getInstance().getResponse(code)
|
||||
} catch (_: Throwable) {
|
||||
if (code == "00") "Approved" else code
|
||||
}
|
||||
return POSUtil.getInstance().getResponse(payDetail.tradeAnswerCode.orEmpty().ifBlank { "-" })
|
||||
}
|
||||
|
||||
internal fun displayTransactionTitle(payDetail: PayDetail): String {
|
||||
val title = payDetail.transType
|
||||
.orEmpty()
|
||||
.ifBlank { "TRANSACTION" }
|
||||
.replace("CASH_OUT", "CASH_ADV", ignoreCase = true)
|
||||
return if (payDetail.transactionType == TransactionsType.REVERSAL.value) {
|
||||
|
||||
@ -159,8 +159,7 @@ fun HistoryRoute(
|
||||
is HistoryDestination.ReviewDetail -> ReviewDetailScreen(
|
||||
viewModel = viewModel,
|
||||
trace = current.trace,
|
||||
onBack = { destination = HistoryDestination.ReviewTrace },
|
||||
onReprint = ::reprintTransaction
|
||||
onBack = { destination = HistoryDestination.ReviewTrace }
|
||||
)
|
||||
|
||||
HistoryDestination.BatchTotal -> BatchTotalScreen(
|
||||
|
||||
@ -21,7 +21,6 @@ class HistoryViewModel @Inject constructor(
|
||||
fun getLastSettlement(): LiveData<List<PayDetail>> =
|
||||
repository.getLastSettlement()
|
||||
|
||||
|
||||
fun getReviewBatchTransaction(batchNo: String): LiveData<List<PayDetail>> =
|
||||
repository.getReviewBatchTransaction(batchNo)
|
||||
|
||||
@ -29,9 +28,5 @@ class HistoryViewModel @Inject constructor(
|
||||
repository.getSmileSummaryTrans(batchNo)
|
||||
|
||||
fun searchTransaction(voucherNo: String): LiveData<PayDetail> =
|
||||
if (voucherNo.length > 6) {
|
||||
repository.searchPayDetail(voucherNo)
|
||||
} else {
|
||||
repository.searchTransaction(voucherNo.padStart(6, '0'))
|
||||
}
|
||||
repository.searchTransaction(voucherNo)
|
||||
}
|
||||
|
||||
@ -39,15 +39,25 @@ import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.shadow
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.mob.utsmyanmar.ui.components.NumericKeypad
|
||||
import com.mob.utsmyanmar.ui.preview.P2Preview
|
||||
import com.mob.utsmyanmar.ui.preview.P3Preview
|
||||
import com.mob.utsmyanmar.ui.theme.Color
|
||||
import com.mob.utsmyanmar.ui.theme.MOBPOSTheme
|
||||
import com.utsmyanmar.paylibs.model.PayDetail
|
||||
import com.utsmyanmar.paylibs.utils.enums.HostType
|
||||
|
||||
private val searchKeys = listOf(
|
||||
listOf("1", "2", "3"),
|
||||
listOf("4", "5", "6"),
|
||||
listOf("7", "8", "9"),
|
||||
listOf("C", "0", "\u232B")
|
||||
)
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun ReprintAnyTransactionScreen(
|
||||
viewModel: HistoryViewModel,
|
||||
@ -56,22 +66,6 @@ fun ReprintAnyTransactionScreen(
|
||||
onReprintTransaction: (PayDetail) -> Unit,
|
||||
) {
|
||||
val allTransactions by viewModel.getTransactionHistory().observeAsState(emptyList())
|
||||
ReprintAnyTransactionContent(
|
||||
allTransactions = allTransactions,
|
||||
hostType = hostType,
|
||||
onBack = onBack,
|
||||
onReprintTransaction = onReprintTransaction
|
||||
)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun ReprintAnyTransactionContent(
|
||||
allTransactions: List<PayDetail>,
|
||||
hostType: HostType,
|
||||
onBack: () -> Unit,
|
||||
onReprintTransaction: (PayDetail) -> Unit,
|
||||
) {
|
||||
var searchQuery by remember { mutableStateOf("") }
|
||||
var isFocused by remember { mutableStateOf(false) }
|
||||
|
||||
@ -121,8 +115,7 @@ fun ReprintAnyTransactionContent(
|
||||
SearchInputBox(
|
||||
query = searchQuery,
|
||||
isFocused = isFocused,
|
||||
onFocus = { isFocused = true },
|
||||
onDelete = { searchQuery = searchQuery.dropLast(1) }
|
||||
onFocus = { isFocused = true }
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
@ -185,45 +178,86 @@ fun ReprintAnyTransactionContent(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Preview(showBackground = true)
|
||||
@Composable
|
||||
private fun ReprintAnyTransactionScreenPreview() {
|
||||
MOBPOSTheme {
|
||||
ReprintAnyTransactionContent(
|
||||
allTransactions = listOf(
|
||||
PayDetail().apply {
|
||||
transDate = "21/09/26"
|
||||
transTime = "14:04:15"
|
||||
merchantName = "UTS Merchant"
|
||||
merchantNo = "100089476209176"
|
||||
terminalNo = "10420257"
|
||||
voucherNo = "000001"
|
||||
referNo = "123456789012"
|
||||
approvalCode = "123456"
|
||||
transType = "SALE"
|
||||
amount = 1500000L
|
||||
accountType = "MPU"
|
||||
cardNo = "9503036867315548"
|
||||
},
|
||||
PayDetail().apply {
|
||||
transDate = "21/09/26"
|
||||
transTime = "15:20:30"
|
||||
merchantName = "UTS Merchant"
|
||||
merchantNo = "100089476209176"
|
||||
terminalNo = "10420257"
|
||||
voucherNo = "000002"
|
||||
referNo = "123456789013"
|
||||
approvalCode = "654321"
|
||||
transType = "SALE"
|
||||
amount = 250000L
|
||||
accountType = "MPU"
|
||||
cardNo = "9503036867319999"
|
||||
private fun SearchInputBox(
|
||||
query: String,
|
||||
isFocused: Boolean,
|
||||
onFocus: () -> Unit,
|
||||
) {
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable(onClick = onFocus),
|
||||
colors = CardDefaults.cardColors(containerColor = Color.White),
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = if (isFocused) 6.dp else 2.dp)
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 14.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Text(
|
||||
text = if (isFocused) "Trace or RRN" else "Tap to search by Trace or RRN",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = if (isFocused) Color.LegacyRed else Color.Gray
|
||||
)
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Text(
|
||||
text = query.ifEmpty { "_" },
|
||||
color = Color.LegacyRed,
|
||||
style = MaterialTheme.typography.headlineSmall.copy(
|
||||
fontWeight = FontWeight.Bold,
|
||||
letterSpacing = 2.sp
|
||||
)
|
||||
)
|
||||
}
|
||||
),
|
||||
hostType = HostType.MPU,
|
||||
onBack = {},
|
||||
onReprintTransaction = {}
|
||||
|
||||
if (query.isNotEmpty()) {
|
||||
Card(
|
||||
shape = RoundedCornerShape(18.dp),
|
||||
colors = CardDefaults.cardColors(containerColor = Color.White),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 4.dp),
|
||||
modifier = Modifier
|
||||
.shadow(2.dp, RoundedCornerShape(18.dp))
|
||||
.clickable { }
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.AutoMirrored.Rounded.Backspace,
|
||||
contentDescription = "Delete",
|
||||
tint = Color.LegacyRed,
|
||||
modifier = Modifier.padding(horizontal = 14.dp, vertical = 12.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@P2Preview
|
||||
@P3Preview
|
||||
@Composable
|
||||
private fun ReprintAnyTransactionScreenPreview() {
|
||||
MOBPOSTheme {
|
||||
Box(modifier = Modifier.height(600.dp)) {
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
colors = CardDefaults.cardColors(containerColor = Color.White)
|
||||
) {
|
||||
Column(modifier = Modifier.padding(16.dp)) {
|
||||
Text(
|
||||
text = "SALE",
|
||||
color = Color.LegacyRed,
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
)
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Text("Trace 000001", style = MaterialTheme.typography.bodySmall)
|
||||
Text("RRN 123456789012", style = MaterialTheme.typography.bodySmall, color = Color.Gray)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,19 +2,10 @@ package com.mob.utsmyanmar.ui.history_functions
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
@ -24,34 +15,16 @@ import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.mob.utsmyanmar.ui.components.appbar.AppBar
|
||||
import com.mob.utsmyanmar.ui.preview.P2Preview
|
||||
import com.mob.utsmyanmar.ui.preview.P3Preview
|
||||
import com.mob.utsmyanmar.ui.theme.Color
|
||||
import com.mob.utsmyanmar.ui.theme.MOBPOSTheme
|
||||
import com.utsmyanmar.paylibs.model.PayDetail
|
||||
|
||||
@Composable
|
||||
fun ReviewDetailScreen(
|
||||
viewModel: HistoryViewModel,
|
||||
trace: String,
|
||||
onBack: () -> Unit,
|
||||
onReprint: ((PayDetail) -> Unit)? = null,
|
||||
) {
|
||||
val transaction by viewModel.searchTransaction(trace).observeAsState()
|
||||
|
||||
ReviewDetailContent(
|
||||
transaction = transaction,
|
||||
onBack = onBack,
|
||||
onReprint = onReprint
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ReviewDetailContent(
|
||||
transaction: PayDetail?,
|
||||
onBack: () -> Unit,
|
||||
onReprint: ((PayDetail) -> Unit)? = null,
|
||||
) {
|
||||
Scaffold(
|
||||
containerColor = Color.IvoryBeige,
|
||||
topBar = {
|
||||
@ -67,28 +40,9 @@ fun ReviewDetailContent(
|
||||
.fillMaxSize()
|
||||
.padding(paddingValues)
|
||||
.padding(16.dp)
|
||||
.verticalScroll(rememberScrollState())
|
||||
) {
|
||||
transaction?.let { payDetail ->
|
||||
HistoryTransactionDetailCard(payDetail)
|
||||
|
||||
if (onReprint != null && isValidForReprint(payDetail)) {
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Button(
|
||||
onClick = { onReprint(prepareReprintPayDetail(payDetail)) },
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(48.dp),
|
||||
shape = RoundedCornerShape(8.dp),
|
||||
colors = ButtonDefaults.buttonColors(containerColor = Color.LegacyRed)
|
||||
) {
|
||||
Text(
|
||||
text = "Reprint",
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
color = Color.White
|
||||
)
|
||||
}
|
||||
}
|
||||
} ?: Box(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentAlignment = Alignment.Center
|
||||
@ -98,68 +52,3 @@ fun ReviewDetailContent(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@P2Preview
|
||||
@P3Preview
|
||||
@Composable
|
||||
private fun ReviewDetailScreenPreview() {
|
||||
MOBPOSTheme {
|
||||
ReviewDetailContent(
|
||||
transaction = PayDetail().apply {
|
||||
transDate = "21/09/26"
|
||||
transTime = "14:04:15"
|
||||
merchantName = "UTS Merchant"
|
||||
merchantNo = "100089476209176"
|
||||
terminalNo = "10420257"
|
||||
voucherNo = "000001"
|
||||
referNo = "123456789012"
|
||||
approvalCode = "123456"
|
||||
transType = "SALE"
|
||||
amount = 1500000L
|
||||
accountType = "MPU"
|
||||
cardNo = "9503036867315548"
|
||||
tradeAnswerCode = "00"
|
||||
},
|
||||
onBack = {}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@P2Preview
|
||||
@P3Preview
|
||||
@Composable
|
||||
private fun ReviewDetailScreenWithReprintPreview() {
|
||||
MOBPOSTheme {
|
||||
ReviewDetailContent(
|
||||
transaction = PayDetail().apply {
|
||||
transDate = "21/09/26"
|
||||
transTime = "14:04:15"
|
||||
merchantName = "UTS Merchant"
|
||||
merchantNo = "100089476209176"
|
||||
terminalNo = "10420257"
|
||||
voucherNo = "000001"
|
||||
referNo = "123456789012"
|
||||
approvalCode = "123456"
|
||||
transType = "SALE"
|
||||
amount = 1500000L
|
||||
accountType = "MPU"
|
||||
cardNo = "9503036867315548"
|
||||
tradeAnswerCode = "00"
|
||||
},
|
||||
onBack = {},
|
||||
onReprint = {}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@P2Preview
|
||||
@P3Preview
|
||||
@Composable
|
||||
private fun ReviewDetailScreenNotFoundPreview() {
|
||||
MOBPOSTheme {
|
||||
ReviewDetailContent(
|
||||
transaction = null,
|
||||
onBack = {}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,20 +1,18 @@
|
||||
package com.mob.utsmyanmar.ui.history_functions
|
||||
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.slideInVertically
|
||||
import androidx.compose.animation.slideOutVertically
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
@ -24,16 +22,16 @@ import androidx.compose.runtime.livedata.observeAsState
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.mob.utsmyanmar.ui.components.NumericKeypad
|
||||
import com.mob.utsmyanmar.ui.components.appbar.AppBar
|
||||
import com.mob.utsmyanmar.ui.preview.P2Preview
|
||||
import com.mob.utsmyanmar.ui.preview.P3Preview
|
||||
import com.mob.utsmyanmar.ui.theme.Color
|
||||
import com.mob.utsmyanmar.ui.theme.MOBPOSTheme
|
||||
import com.utsmyanmar.paylibs.model.PayDetail
|
||||
|
||||
@Composable
|
||||
@ -42,6 +40,7 @@ fun ReviewTraceScreen(
|
||||
onBack: () -> Unit,
|
||||
onNavigateReviewDetail: (String) -> Unit,
|
||||
) {
|
||||
var traceNumber by remember { mutableStateOf("") }
|
||||
var searchedTrace by remember { mutableStateOf("") }
|
||||
var lastNavigatedTrace by remember { mutableStateOf<String?>(null) }
|
||||
|
||||
@ -62,24 +61,6 @@ fun ReviewTraceScreen(
|
||||
onNavigateReviewDetail(matchedTrace)
|
||||
}
|
||||
|
||||
ReviewTraceContent(
|
||||
searchedTrace = searchedTrace,
|
||||
transactionFound = transaction != null,
|
||||
onBack = onBack,
|
||||
onSearch = { query -> searchedTrace = query }
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ReviewTraceContent(
|
||||
searchedTrace: String,
|
||||
transactionFound: Boolean,
|
||||
onBack: () -> Unit,
|
||||
onSearch: (String) -> Unit,
|
||||
) {
|
||||
var traceNumber by remember { mutableStateOf("") }
|
||||
var isFocused by remember { mutableStateOf(true) }
|
||||
|
||||
Scaffold(
|
||||
containerColor = Color.IvoryBeige,
|
||||
topBar = {
|
||||
@ -97,12 +78,12 @@ fun ReviewTraceContent(
|
||||
.padding(16.dp)
|
||||
) {
|
||||
Text(
|
||||
text = if (searchedTrace.isNotBlank() && !transactionFound) {
|
||||
text = if (searchedTrace.isNotBlank() && transaction == null) {
|
||||
"No transaction found for trace $searchedTrace."
|
||||
} else {
|
||||
"Input trace number to review transaction."
|
||||
},
|
||||
color = if (searchedTrace.isNotBlank() && !transactionFound) {
|
||||
color = if (searchedTrace.isNotBlank() && transaction == null) {
|
||||
Color.LegacyRed
|
||||
} else {
|
||||
Color.Black
|
||||
@ -112,66 +93,49 @@ fun ReviewTraceContent(
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
SearchInputBox(
|
||||
query = traceNumber,
|
||||
isFocused = isFocused,
|
||||
onFocus = { isFocused = true },
|
||||
onDelete = { traceNumber = traceNumber.dropLast(1) }
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
colors = CardDefaults.cardColors(containerColor = Color.White)
|
||||
) {
|
||||
Text(
|
||||
text = traceNumber.padStart(6, '0').ifEmpty { "000000" },
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(24.dp),
|
||||
textAlign = TextAlign.Center,
|
||||
style = MaterialTheme.typography.displayMedium.copy(fontSize = 28.sp)
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
AnimatedVisibility(
|
||||
visible = isFocused,
|
||||
enter = slideInVertically(initialOffsetY = { it }),
|
||||
exit = slideOutVertically(targetOffsetY = { it })
|
||||
) {
|
||||
NumericKeypad(
|
||||
keys = searchKeys,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(280.dp)
|
||||
.padding(top = 8.dp),
|
||||
onKeyClick = { key ->
|
||||
when (key) {
|
||||
"C" -> traceNumber = ""
|
||||
"\u232B" -> traceNumber = traceNumber.dropLast(1)
|
||||
else -> if (traceNumber.length < 12) traceNumber += key
|
||||
}
|
||||
HistoryNumericKeypad(
|
||||
onDigit = { digit ->
|
||||
if (traceNumber.length < 6) traceNumber += digit
|
||||
},
|
||||
onBackspace = {
|
||||
if (traceNumber.isNotEmpty()) {
|
||||
traceNumber = traceNumber.dropLast(1)
|
||||
}
|
||||
},
|
||||
onClear = { traceNumber = "" }
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
|
||||
Button(
|
||||
onClick = { onSearch(traceNumber.trim()) },
|
||||
onClick = { searchedTrace = traceNumber.padStart(6, '0') },
|
||||
enabled = traceNumber.isNotBlank(),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(56.dp),
|
||||
shape = RoundedCornerShape(8.dp),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = Color.LegacyRed,
|
||||
contentColor = Color.White
|
||||
)
|
||||
) {
|
||||
Text("Search", style = MaterialTheme.typography.titleMedium)
|
||||
Text("Search")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@P2Preview
|
||||
@P3Preview
|
||||
@Composable
|
||||
private fun ReviewTraceScreenPreview() {
|
||||
MOBPOSTheme {
|
||||
ReviewTraceContent(
|
||||
searchedTrace = "",
|
||||
transactionFound = false,
|
||||
onBack = {},
|
||||
onSearch = {}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ fun SelectHostScreen(
|
||||
.padding(16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(12.dp)
|
||||
) {
|
||||
HostButton("MPU / JCB / UPI") { onSelectHost(HostType.MPU) }
|
||||
HostButton("MPU") { onSelectHost(HostType.MPU) }
|
||||
HostButton("Visa / Master") {
|
||||
if (SystemParamsOperation.getInstance().isEmvEnabled) {
|
||||
onSelectHost(HostType.VISA_MASTER)
|
||||
|
||||
@ -669,22 +669,8 @@ fun AppNavGraph(
|
||||
},
|
||||
onNavigateInputAmount = { navController.popBackStack(Routes.Amount.route, false) },
|
||||
onNavigateProcessing = {},
|
||||
onNavigateEmvTransaction = {
|
||||
navController.navigate(Routes.Processing.route) {
|
||||
popUpTo(Routes.ProcessingCard.route) {
|
||||
inclusive = true
|
||||
}
|
||||
launchSingleTop = true
|
||||
}
|
||||
},
|
||||
onNavigateError = { message ->
|
||||
navController.navigate(Routes.TransactionError.createRoute(false, message)) {
|
||||
popUpTo(Routes.ProcessingCard.route) {
|
||||
inclusive = true
|
||||
}
|
||||
launchSingleTop = true
|
||||
}
|
||||
},
|
||||
onNavigateEmvTransaction = {},
|
||||
onNavigateError = {},
|
||||
onBack = { navController.popBackStack() },
|
||||
onShowDecline = {}
|
||||
)
|
||||
@ -775,7 +761,6 @@ fun AppNavGraph(
|
||||
sharedViewModel = sharedViewModel,
|
||||
transProcessViewModel = transProcessViewModel,
|
||||
settlementViewModel = settlementViewModel,
|
||||
emvTransactionViewModel = hiltViewModel(activity),
|
||||
onTransactionFinished = {
|
||||
tmsSetupViewModel.downloadConfigs(dashboardViewModel::refreshLastSyncTime)
|
||||
},
|
||||
|
||||
@ -22,6 +22,7 @@ import com.utsmyanmar.paylibs.model.PayDetail
|
||||
import com.utsmyanmar.paylibs.model.TradeData
|
||||
import com.utsmyanmar.paylibs.model.enums.TransCVM
|
||||
import com.utsmyanmar.paylibs.utils.POSUtil
|
||||
import com.utsmyanmar.paylibs.utils.core_utils.SystemParamsOperation
|
||||
import com.utsmyanmar.paylibs.utils.enums.TransMenu
|
||||
import com.utsmyanmar.paylibs.utils.params.Params
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
@ -249,10 +250,7 @@ class ProcessingCardViewModel(
|
||||
emvTransactionViewModel.transType.value =
|
||||
sharedViewModel.transactionsType.value
|
||||
|
||||
if (
|
||||
// SystemParamsOperation.getInstance().isEmvEnabled
|
||||
true
|
||||
) {
|
||||
if (SystemParamsOperation.getInstance().isEmvEnabled) {
|
||||
prepareEmvTransaction()
|
||||
sendUiEvent(ProcessingCardUiEvent.NavigateToEmvTransaction)
|
||||
} else {
|
||||
|
||||
@ -4,13 +4,11 @@ import android.R
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.livedata.observeAsState
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.mob.utsmyanmar.model.TransResultStatus
|
||||
import com.mob.utsmyanmar.model.TransactionStatus
|
||||
import com.mob.utsmyanmar.ui.settlement.SettlementViewModel
|
||||
import com.mob.utsmyanmar.viewmodel.SharedViewModel
|
||||
import com.mob.utsmyanmar.viewmodel.EmvTransactionProcessViewModel
|
||||
import com.mob.utsmyanmar.viewmodel.TransProcessViewModel
|
||||
import com.utsmyanmar.paylibs.utils.iso_utils.TransactionsType
|
||||
|
||||
@ -21,7 +19,6 @@ fun ProcessingRoute(
|
||||
sharedViewModel: SharedViewModel,
|
||||
transProcessViewModel: TransProcessViewModel,
|
||||
settlementViewModel: SettlementViewModel,
|
||||
emvTransactionViewModel: EmvTransactionProcessViewModel,
|
||||
onNavigateTransactionResult: () -> Unit,
|
||||
onNavigateSignature: () -> Unit,
|
||||
onNavigateError: (Boolean, String) -> Unit,
|
||||
@ -29,47 +26,12 @@ fun ProcessingRoute(
|
||||
) {
|
||||
|
||||
val transStatus by transProcessViewModel.transResultStatus.collectAsStateWithLifecycle()
|
||||
val emvStatus by emvTransactionViewModel.getTransStatus().observeAsState()
|
||||
|
||||
val state by transProcessViewModel.state.collectAsStateWithLifecycle()
|
||||
|
||||
val settlementStatus by settlementViewModel.uiState.collectAsStateWithLifecycle()
|
||||
|
||||
if (sharedViewModel.isEmvTrans().value == true) {
|
||||
LaunchedEffect(Unit) {
|
||||
emvTransactionViewModel.startProcess()
|
||||
}
|
||||
|
||||
LaunchedEffect(emvStatus) {
|
||||
when (emvStatus) {
|
||||
TransResultStatus.SUCCESS,
|
||||
TransResultStatus.OFFLINE_SUCCESS -> {
|
||||
onTransactionFinished()
|
||||
sharedViewModel.payDetail.value = emvTransactionViewModel.payDetailResult.value
|
||||
onNavigateTransactionResult()
|
||||
}
|
||||
|
||||
TransResultStatus.FAIL,
|
||||
TransResultStatus.OFFLINE_FAILURE -> {
|
||||
onTransactionFinished()
|
||||
sharedViewModel.payDetail.value = emvTransactionViewModel.payDetailResult.value
|
||||
onNavigateTransactionResult()
|
||||
}
|
||||
|
||||
TransResultStatus.NETWORK_ERROR,
|
||||
TransResultStatus.ERROR -> {
|
||||
onTransactionFinished()
|
||||
onNavigateError(
|
||||
false,
|
||||
emvTransactionViewModel.errorCodeMsg.value
|
||||
?: "Something went wrong. Please try again."
|
||||
)
|
||||
}
|
||||
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
} else if(sharedViewModel.transactionsType.value == TransactionsType.SETTLEMENT) {
|
||||
if(sharedViewModel.transactionsType.value == TransactionsType.SETTLEMENT) {
|
||||
LaunchedEffect(Unit) {
|
||||
settlementViewModel.startSettlementProcess()
|
||||
}
|
||||
@ -136,9 +98,7 @@ fun ProcessingRoute(
|
||||
}
|
||||
}
|
||||
|
||||
if (sharedViewModel.isEmvTrans().value == true) {
|
||||
ProcessingScreen(state)
|
||||
} else if(sharedViewModel.transactionsType.value == TransactionsType.SETTLEMENT) {
|
||||
if(sharedViewModel.transactionsType.value == TransactionsType.SETTLEMENT) {
|
||||
ProcessingScreen(settlementStatus.processingState)
|
||||
} else {
|
||||
ProcessingScreen(state)
|
||||
|
||||
@ -25,14 +25,10 @@ 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
|
||||
@ -46,22 +42,6 @@ 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<PayDetail>,
|
||||
onBack: () -> Unit,
|
||||
onStartSettlement: () -> Unit,
|
||||
autoStartSettlement: Boolean = false
|
||||
) {
|
||||
val totalAmount = records.sumOf { it.amount }
|
||||
|
||||
LaunchedEffect(autoStartSettlement, records) {
|
||||
@ -136,7 +116,7 @@ private fun SettlementContent(
|
||||
verticalArrangement = Arrangement.spacedBy(0.dp)
|
||||
) {
|
||||
items(records) { record ->
|
||||
SettlementRecordRow(payDetail = record)
|
||||
SettlementRecordRow(record = record)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -184,87 +164,40 @@ private fun SummaryRow(
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SettlementRecordRow(payDetail: PayDetail) {
|
||||
private fun SettlementRecordRow(record: PayDetail) {
|
||||
Column(modifier = Modifier.padding(horizontal = 16.dp, vertical = 12.dp)) {
|
||||
Spacer(Modifier.height(4.dp))
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Text(
|
||||
text = payDetail.transType
|
||||
.orEmpty()
|
||||
text = record.transType
|
||||
.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 = "Date & Time",
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
)
|
||||
Text(
|
||||
text = "${convertDateString(payDetail.transDate.orEmpty())} ${payDetail.transTime.orEmpty()}".trim().ifBlank { "-" },
|
||||
text = POSUtil.getInstance().getDecimalAmountSeparatorFormat(record.amount),
|
||||
color = Color.Black,
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
|
||||
Text(
|
||||
text = "Amount",
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
text = "Trace ${record.voucherNo.ifBlank { "-" }}",
|
||||
color = Color.Black,
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
Text(
|
||||
text = displayAmountWithSign(payDetail),
|
||||
style = MaterialTheme.typography.titleSmall
|
||||
text = "Card ${maskCardNumber(record.cardNo)}",
|
||||
color = Color.Gray,
|
||||
style = MaterialTheme.typography.bodySmall
|
||||
)
|
||||
}
|
||||
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))
|
||||
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
HorizontalDivider(color = Color.Gray.copy(alpha = 0.25f))
|
||||
}
|
||||
}
|
||||
@ -276,29 +209,3 @@ 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 = {}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,7 +20,6 @@ fun String?.maskCardNumber(): String {
|
||||
return maskedPan.toString()
|
||||
}
|
||||
|
||||
fun convertDateString(dateStr: String?): String {
|
||||
if (dateStr.isNullOrEmpty()) return ""
|
||||
fun convertDateString(dateStr: String): String {
|
||||
return dateStr.replace(Regex("/(\\d{2})$"), "/20$1")
|
||||
}
|
||||
@ -88,7 +88,7 @@ class TMSSetupsImpl : TMSSetups {
|
||||
ops.merchantName = m.name
|
||||
ops.merchantAddress = m.address
|
||||
ops.merchantPhoneNo = m.phone
|
||||
ops.merchantMobileNo = m.mobilePhone.orEmpty()
|
||||
ops.merchantMobileNo = m.mobile_phone
|
||||
}
|
||||
|
||||
siriusResponse.address.takeIf { it.isNotEmpty() }?.let { ops.merchantAddress = it }
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
package com.utsmyanmar.baselib.network.model.sirius;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class SiriusMerchant {
|
||||
|
||||
private String id;
|
||||
@ -18,11 +16,7 @@ public class SiriusMerchant {
|
||||
|
||||
private String mobile;
|
||||
|
||||
@SerializedName(value = "mobilePhone", alternate = {"mobile_phone"})
|
||||
private String mobilePhone;
|
||||
|
||||
public SiriusMerchant() {
|
||||
}
|
||||
private String mobile_phone;
|
||||
|
||||
public SiriusMerchant(String id, String name, String description, String address,String address2,String phone,String mobile) {
|
||||
this.id = id;
|
||||
@ -34,17 +28,6 @@ public class SiriusMerchant {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public SiriusMerchant(String id, String name, String description, String address, String address2, String phone, String mobile, String mobilePhone) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.address = address;
|
||||
this.address2 = address2;
|
||||
this.phone = phone;
|
||||
this.mobile = mobile;
|
||||
this.mobilePhone = mobilePhone;
|
||||
}
|
||||
|
||||
public void setAddress2(String address2) {
|
||||
this.address2 = address2;
|
||||
}
|
||||
@ -69,20 +52,12 @@ public class SiriusMerchant {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public String getMobilePhone() {
|
||||
return mobilePhone != null ? mobilePhone : mobile;
|
||||
}
|
||||
|
||||
public void setMobilePhone(String mobilePhone) {
|
||||
this.mobilePhone = mobilePhone;
|
||||
}
|
||||
|
||||
public String getMobile_phone() {
|
||||
return getMobilePhone();
|
||||
return mobile_phone;
|
||||
}
|
||||
|
||||
public void setMobile_phone(String mobile_phone) {
|
||||
this.mobilePhone = mobile_phone;
|
||||
this.mobile_phone = mobile_phone;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
|
||||
@ -88,33 +88,23 @@ public class BaseErrorCode {
|
||||
}
|
||||
|
||||
public static String getCode(String code) {
|
||||
if (instance == null || (instance.errorCode.isEmpty() && PayLibsUtils.getInstance().context != null)) {
|
||||
instance = new BaseErrorCode();
|
||||
}
|
||||
if (instance == null) instance = new BaseErrorCode();
|
||||
String errorMsg = instance.errorCode.get(code);
|
||||
// return (errorMsg != null ? "RESPONSE CODE"+"(" + code + ")\n ("+errorMsg+")" : getString(R.string.errorOthers));
|
||||
if(code.length() == 2) {
|
||||
if (errorMsg != null) return errorMsg;
|
||||
String defaultError = getString(R.string.errorOthers);
|
||||
return defaultError != null ? defaultError : ("00".equals(code) ? "Approved" : "Others");
|
||||
return (errorMsg != null ? errorMsg : getString(R.string.errorOthers));
|
||||
} else if(code.isEmpty()) {
|
||||
return "NO RESPONSE";
|
||||
} else {
|
||||
if (errorMsg != null) return code + " - "+errorMsg;
|
||||
String defaultError = getString(R.string.errorOthers);
|
||||
return defaultError != null ? code + " - " + defaultError : code + " - Others";
|
||||
return (errorMsg != null ? code + " - "+errorMsg : getString(R.string.errorOthers));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String getErrorMessage(String code) {
|
||||
if (instance == null || (instance.errorCode.isEmpty() && PayLibsUtils.getInstance().context != null)) {
|
||||
instance = new BaseErrorCode();
|
||||
}
|
||||
if (instance == null) instance = new BaseErrorCode();
|
||||
String errorMsg = instance.errorCode.get(code);
|
||||
if (errorMsg != null) return " " + errorMsg + " ";
|
||||
String defaultError = getString(R.string.errorOthers);
|
||||
return " " + (defaultError != null ? defaultError : "Others") + " ";
|
||||
return (errorMsg != null ?" "+ errorMsg+" " :getString(R.string.errorOthers));
|
||||
}
|
||||
|
||||
private static BaseErrorCode instance;
|
||||
@ -127,21 +117,14 @@ public class BaseErrorCode {
|
||||
if (KeyValueSet == null) return;
|
||||
int size = KeyValueSet.length;
|
||||
if (size % 2 == 0)
|
||||
for (int i = 0; i < size; i += 2) {
|
||||
String val = getString((Integer)KeyValueSet[i + 1]);
|
||||
if (val != null) {
|
||||
errorCode.put((String) KeyValueSet[i], val);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < size; i += 2)
|
||||
errorCode.put((String) KeyValueSet[i],getString((Integer)KeyValueSet[i + 1]));
|
||||
else throw new RuntimeException("Error code key value pairs must be even numbers");
|
||||
}
|
||||
|
||||
private Map<String, String> errorCode = new HashMap<>();
|
||||
|
||||
private static String getString(int id) {
|
||||
if (PayLibsUtils.getInstance() == null || PayLibsUtils.getInstance().context == null) {
|
||||
return null;
|
||||
}
|
||||
return PayLibsUtils.getInstance().context.getString(id);
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,6 @@ package com.utsmyanmar.paylibs.utils;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import sunmi.sunmiui.utils.LogUtil;
|
||||
import com.utsmyanmar.paylibs.utils.enums.CardScheme;
|
||||
|
||||
public class CardSchemeUtils {
|
||||
private static final String TAG = "CardSchemeUtil";
|
||||
@ -26,8 +25,19 @@ public class CardSchemeUtils {
|
||||
} else if ("A000000524".equals(group)) {
|
||||
accountType = AccountType.RPC.getValue();
|
||||
} else if ("A000000333".equals(group)) {
|
||||
// Keep the scheme value used by host routing and receipt logic.
|
||||
accountType = CardScheme.UPI.name;
|
||||
if ("A000000333010101".equals(aid)) {
|
||||
|
||||
accountType = AccountType.DD.getValue();
|
||||
} else if ("A000000333010102".equals(aid)) {
|
||||
|
||||
accountType = AccountType.CC.getValue();
|
||||
} else if ("A000000333010103".equals(aid)) {
|
||||
|
||||
accountType = AccountType.SCC.getValue();
|
||||
} else if ("A000000333010101".equals(aid)) {
|
||||
|
||||
accountType = AccountType.EC.getValue();
|
||||
}
|
||||
}
|
||||
LogUtil.d(TAG, "Card accountType = " + accountType);
|
||||
return accountType;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user