card holder align fix

This commit is contained in:
moon 2026-09-15 13:50:05 +06:30
parent c4f49bc440
commit 1d132c481f
8 changed files with 66 additions and 10 deletions

View File

@ -39,7 +39,9 @@ class DashboardViewModel @Inject constructor(
val isCurrentBusinessSettlement = latestSettlement?.isCurrentBusinessSettlement() == true
_uiState.update {
it.copy(
recentTransactions = payDetails.map { pd -> pd.toRecord() },
recentTransactions = payDetails
.filterNot { it.isSettlementTransaction() }
.map { pd -> pd.toRecord() },
totalSaleCount = payDetails.totalSaleCount(),
totalSaleAmount = payDetails.totalSaleAmount(),
settlementStatusText = if (isCurrentBusinessSettlement) {
@ -151,6 +153,11 @@ private fun PayDetail.isSaleTransaction(): Boolean {
(transactionType == TransactionsType.WAVEPAY.value && qrTransStatus == 1)
}
private fun PayDetail.isSettlementTransaction(): Boolean {
return transactionType == TransactionsType.SETTLEMENT.value ||
transType?.contains("SETTLEMENT", ignoreCase = true) == true
}
private fun formatTypeLabel(raw: String): String = when {
raw.equals("CASH_OUT", ignoreCase = true) -> "CASH_ADV"
raw.contains("SALE", ignoreCase = true) -> "Sale"

View File

@ -240,6 +240,8 @@ class SettlementViewModel @Inject constructor(
repository.deletePayDetail(pay)
}
repository.deleteReversalTransactions()
deleteTrans.forEach { pay ->
repository.deletePayDetail(pay)
}

View File

@ -1,6 +1,7 @@
package com.mob.utsmyanmar.ui.transaction_result
import androidx.lifecycle.ViewModel
import androidx.lifecycle.Observer
import androidx.lifecycle.viewModelScope
import com.mob.utsmyanmar.model.ecr.ECRResultStatus
import com.mob.utsmyanmar.utils.CoreUtils
@ -47,6 +48,8 @@ class TransactionResultViewModel @Inject constructor(
private var started = false
private var resultTimeoutJob: Job? = null
private var printStatusObserver: Observer<PrintStatus?>? = null
private var observedSharedViewModel: SharedViewModel? = null
fun onEvent(
event: TransactionResultEvent,
@ -196,7 +199,11 @@ class TransactionResultViewModel @Inject constructor(
}
private fun observePrintStatus(sharedViewModel: SharedViewModel) {
sharedViewModel.printXStatus.observeForever { status ->
printStatusObserver?.let { observer ->
observedSharedViewModel?.printXStatus?.removeObserver(observer)
}
printStatusObserver = Observer<PrintStatus?> { status ->
status ?: return@Observer
when (status) {
PrintStatus.EMPTY_PAPER_ROLL -> {
startPrintProcess(sharedViewModel, false)
@ -209,6 +216,18 @@ class TransactionResultViewModel @Inject constructor(
else -> Unit
}
}
observedSharedViewModel = sharedViewModel
sharedViewModel.printXStatus.observeForever(printStatusObserver!!)
}
override fun onCleared() {
resultTimeoutJob?.cancel()
printStatusObserver?.let { observer ->
observedSharedViewModel?.printXStatus?.removeObserver(observer)
}
printStatusObserver = null
observedSharedViewModel = null
super.onCleared()
}
private fun startPrintProcess(

View File

@ -43,7 +43,7 @@ object MockData {
cardNo="6244310039574344",
expDate="3011",
cardScheme="MPU",
cardHolderName="Htin Kyaw Win",
cardHolderName="Nay Nwe Ei Kyaw Phyo",
iccData="6244310039574344=30112011558125900000"
)

View File

@ -78,6 +78,8 @@ class SharedViewModel @Inject constructor(
val isEmv = SingleLiveEvent<Boolean>()
private val settlementStatus = MutableLiveData<Boolean>()
private var settlementPrintInProgress = false
private var settlementPrintCompletedKey: String? = null
private val wavePayStatus = MutableLiveData<Boolean>()
@ -428,15 +430,36 @@ class SharedViewModel @Inject constructor(
onFailure()
return
}
val printKey = "${detail.batchNo}:${detail.voucherNo}"
synchronized(this) {
if (settlementPrintCompletedKey == printKey || settlementPrintInProgress) {
return
}
settlementPrintInProgress = true
}
PrintXReceipt.getInstance()
.printSmileSettlementReport(detail, object : PrintXStatus {
private var callbackHandled = false
override fun onSuccess() {
synchronized(this) {
if (callbackHandled) return
callbackHandled = true
settlementPrintInProgress = false
settlementPrintCompletedKey = printKey
}
onSuccess()
}
override fun onFailure() {
synchronized(this) {
if (callbackHandled) return
callbackHandled = true
settlementPrintInProgress = false
}
onFailure()
}
})

View File

@ -37,6 +37,9 @@ public interface PayDetailDao {
@Delete
void deletePayDetail(PayDetail payDetail);
@Query("DELETE FROM paydetail WHERE transactionType = 10")
void deleteReversalTransactions();
// 13 = CASH DEPOSIT & 9 = CASH ADVANCE & 14 = FUND TRANSFER
@Query("SELECT * FROM paydetail WHERE isSettle = 0 AND transactionType = 13 OR transactionType = 9 AND isSettle = 0 OR transactionType = 14 AND isSettle = 0")
LiveData<List<PayDetail>> getSettlement();

View File

@ -209,5 +209,9 @@ public class Repository {
payDetailDao.deletePayDetail(payDetail);
}
public void deleteReversalTransactions() {
payDetailDao.deleteReversalTransactions();
}
public LiveData<List<PayDetail>> getAllTrans() { return payDetailDao.getAllTrans(); }
}

View File

@ -13,8 +13,6 @@ import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Locale;
import sunmi.sunmiui.utils.LogUtil;
public class PrintUtils {
public static PrintUtils getInstance() {
@ -265,18 +263,18 @@ public class PrintUtils {
public String processNameSpaceSecondLine(String input) {
String[] words = input.split(" ");
if (input.length() < 15) {
if (input.length() < 20) {
return "";
}
if (words.length == 3 && input.length() > 15) {
if (words.length == 3 && input.length() > 20) {
return words[2];
} else if (words.length == 2 && input.length() <= 15) {
} else if (words.length == 2 && input.length() <= 20) {
return "";
} else if (words.length == 2 && input.length() > 15) {
} else if (words.length == 2 && input.length() > 20) {
return words[1];
} else {
return input.substring(15);
return input.substring(20);
}
}
}