card holder align fix
This commit is contained in:
parent
c4f49bc440
commit
1d132c481f
@ -39,7 +39,9 @@ class DashboardViewModel @Inject constructor(
|
|||||||
val isCurrentBusinessSettlement = latestSettlement?.isCurrentBusinessSettlement() == true
|
val isCurrentBusinessSettlement = latestSettlement?.isCurrentBusinessSettlement() == true
|
||||||
_uiState.update {
|
_uiState.update {
|
||||||
it.copy(
|
it.copy(
|
||||||
recentTransactions = payDetails.map { pd -> pd.toRecord() },
|
recentTransactions = payDetails
|
||||||
|
.filterNot { it.isSettlementTransaction() }
|
||||||
|
.map { pd -> pd.toRecord() },
|
||||||
totalSaleCount = payDetails.totalSaleCount(),
|
totalSaleCount = payDetails.totalSaleCount(),
|
||||||
totalSaleAmount = payDetails.totalSaleAmount(),
|
totalSaleAmount = payDetails.totalSaleAmount(),
|
||||||
settlementStatusText = if (isCurrentBusinessSettlement) {
|
settlementStatusText = if (isCurrentBusinessSettlement) {
|
||||||
@ -151,6 +153,11 @@ private fun PayDetail.isSaleTransaction(): Boolean {
|
|||||||
(transactionType == TransactionsType.WAVEPAY.value && qrTransStatus == 1)
|
(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 {
|
private fun formatTypeLabel(raw: String): String = when {
|
||||||
raw.equals("CASH_OUT", ignoreCase = true) -> "CASH_ADV"
|
raw.equals("CASH_OUT", ignoreCase = true) -> "CASH_ADV"
|
||||||
raw.contains("SALE", ignoreCase = true) -> "Sale"
|
raw.contains("SALE", ignoreCase = true) -> "Sale"
|
||||||
|
|||||||
@ -240,6 +240,8 @@ class SettlementViewModel @Inject constructor(
|
|||||||
repository.deletePayDetail(pay)
|
repository.deletePayDetail(pay)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
repository.deleteReversalTransactions()
|
||||||
|
|
||||||
deleteTrans.forEach { pay ->
|
deleteTrans.forEach { pay ->
|
||||||
repository.deletePayDetail(pay)
|
repository.deletePayDetail(pay)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.mob.utsmyanmar.ui.transaction_result
|
package com.mob.utsmyanmar.ui.transaction_result
|
||||||
|
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
|
import androidx.lifecycle.Observer
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.mob.utsmyanmar.model.ecr.ECRResultStatus
|
import com.mob.utsmyanmar.model.ecr.ECRResultStatus
|
||||||
import com.mob.utsmyanmar.utils.CoreUtils
|
import com.mob.utsmyanmar.utils.CoreUtils
|
||||||
@ -47,6 +48,8 @@ class TransactionResultViewModel @Inject constructor(
|
|||||||
|
|
||||||
private var started = false
|
private var started = false
|
||||||
private var resultTimeoutJob: Job? = null
|
private var resultTimeoutJob: Job? = null
|
||||||
|
private var printStatusObserver: Observer<PrintStatus?>? = null
|
||||||
|
private var observedSharedViewModel: SharedViewModel? = null
|
||||||
|
|
||||||
fun onEvent(
|
fun onEvent(
|
||||||
event: TransactionResultEvent,
|
event: TransactionResultEvent,
|
||||||
@ -196,7 +199,11 @@ class TransactionResultViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun observePrintStatus(sharedViewModel: SharedViewModel) {
|
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) {
|
when (status) {
|
||||||
PrintStatus.EMPTY_PAPER_ROLL -> {
|
PrintStatus.EMPTY_PAPER_ROLL -> {
|
||||||
startPrintProcess(sharedViewModel, false)
|
startPrintProcess(sharedViewModel, false)
|
||||||
@ -209,6 +216,18 @@ class TransactionResultViewModel @Inject constructor(
|
|||||||
else -> Unit
|
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(
|
private fun startPrintProcess(
|
||||||
|
|||||||
@ -43,7 +43,7 @@ object MockData {
|
|||||||
cardNo="6244310039574344",
|
cardNo="6244310039574344",
|
||||||
expDate="3011",
|
expDate="3011",
|
||||||
cardScheme="MPU",
|
cardScheme="MPU",
|
||||||
cardHolderName="Htin Kyaw Win",
|
cardHolderName="Nay Nwe Ei Kyaw Phyo",
|
||||||
iccData="6244310039574344=30112011558125900000"
|
iccData="6244310039574344=30112011558125900000"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -78,6 +78,8 @@ class SharedViewModel @Inject constructor(
|
|||||||
val isEmv = SingleLiveEvent<Boolean>()
|
val isEmv = SingleLiveEvent<Boolean>()
|
||||||
|
|
||||||
private val settlementStatus = MutableLiveData<Boolean>()
|
private val settlementStatus = MutableLiveData<Boolean>()
|
||||||
|
private var settlementPrintInProgress = false
|
||||||
|
private var settlementPrintCompletedKey: String? = null
|
||||||
|
|
||||||
private val wavePayStatus = MutableLiveData<Boolean>()
|
private val wavePayStatus = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
@ -428,15 +430,36 @@ class SharedViewModel @Inject constructor(
|
|||||||
onFailure()
|
onFailure()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
val printKey = "${detail.batchNo}:${detail.voucherNo}"
|
||||||
|
|
||||||
|
synchronized(this) {
|
||||||
|
if (settlementPrintCompletedKey == printKey || settlementPrintInProgress) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
settlementPrintInProgress = true
|
||||||
|
}
|
||||||
|
|
||||||
PrintXReceipt.getInstance()
|
PrintXReceipt.getInstance()
|
||||||
.printSmileSettlementReport(detail, object : PrintXStatus {
|
.printSmileSettlementReport(detail, object : PrintXStatus {
|
||||||
|
|
||||||
|
private var callbackHandled = false
|
||||||
|
|
||||||
override fun onSuccess() {
|
override fun onSuccess() {
|
||||||
|
synchronized(this) {
|
||||||
|
if (callbackHandled) return
|
||||||
|
callbackHandled = true
|
||||||
|
settlementPrintInProgress = false
|
||||||
|
settlementPrintCompletedKey = printKey
|
||||||
|
}
|
||||||
onSuccess()
|
onSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFailure() {
|
override fun onFailure() {
|
||||||
|
synchronized(this) {
|
||||||
|
if (callbackHandled) return
|
||||||
|
callbackHandled = true
|
||||||
|
settlementPrintInProgress = false
|
||||||
|
}
|
||||||
onFailure()
|
onFailure()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -37,6 +37,9 @@ public interface PayDetailDao {
|
|||||||
@Delete
|
@Delete
|
||||||
void deletePayDetail(PayDetail payDetail);
|
void deletePayDetail(PayDetail payDetail);
|
||||||
|
|
||||||
|
@Query("DELETE FROM paydetail WHERE transactionType = 10")
|
||||||
|
void deleteReversalTransactions();
|
||||||
|
|
||||||
// 13 = CASH DEPOSIT & 9 = CASH ADVANCE & 14 = FUND TRANSFER
|
// 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")
|
@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();
|
LiveData<List<PayDetail>> getSettlement();
|
||||||
|
|||||||
@ -209,5 +209,9 @@ public class Repository {
|
|||||||
payDetailDao.deletePayDetail(payDetail);
|
payDetailDao.deletePayDetail(payDetail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteReversalTransactions() {
|
||||||
|
payDetailDao.deleteReversalTransactions();
|
||||||
|
}
|
||||||
|
|
||||||
public LiveData<List<PayDetail>> getAllTrans() { return payDetailDao.getAllTrans(); }
|
public LiveData<List<PayDetail>> getAllTrans() { return payDetailDao.getAllTrans(); }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,8 +13,6 @@ import java.text.DecimalFormat;
|
|||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import sunmi.sunmiui.utils.LogUtil;
|
|
||||||
|
|
||||||
public class PrintUtils {
|
public class PrintUtils {
|
||||||
|
|
||||||
public static PrintUtils getInstance() {
|
public static PrintUtils getInstance() {
|
||||||
@ -265,18 +263,18 @@ public class PrintUtils {
|
|||||||
public String processNameSpaceSecondLine(String input) {
|
public String processNameSpaceSecondLine(String input) {
|
||||||
String[] words = input.split(" ");
|
String[] words = input.split(" ");
|
||||||
|
|
||||||
if (input.length() < 15) {
|
if (input.length() < 20) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (words.length == 3 && input.length() > 15) {
|
if (words.length == 3 && input.length() > 20) {
|
||||||
return words[2];
|
return words[2];
|
||||||
} else if (words.length == 2 && input.length() <= 15) {
|
} else if (words.length == 2 && input.length() <= 20) {
|
||||||
return "";
|
return "";
|
||||||
} else if (words.length == 2 && input.length() > 15) {
|
} else if (words.length == 2 && input.length() > 20) {
|
||||||
return words[1];
|
return words[1];
|
||||||
} else {
|
} else {
|
||||||
return input.substring(15);
|
return input.substring(20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user