settlement fixed
This commit is contained in:
parent
70f2913989
commit
c4f49bc440
@ -2,6 +2,7 @@ package com.mob.utsmyanmar.ui.navigation
|
|||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
@ -842,7 +843,9 @@ fun AppNavGraph(
|
|||||||
},
|
},
|
||||||
onShowError = {},
|
onShowError = {},
|
||||||
onShowSuccess = {},
|
onShowSuccess = {},
|
||||||
onShowPrinterDialog = {}
|
onShowPrinterDialog = { message ->
|
||||||
|
Toast.makeText(activity, message, Toast.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -82,6 +82,7 @@ class SettlementViewModel @Inject constructor(
|
|||||||
|
|
||||||
private var flag = false
|
private var flag = false
|
||||||
private var errorFlag = false
|
private var errorFlag = false
|
||||||
|
private var settlementApproved = false
|
||||||
private var isSecondCall = false
|
private var isSecondCall = false
|
||||||
private var batchIndex = 0
|
private var batchIndex = 0
|
||||||
|
|
||||||
@ -269,6 +270,10 @@ class SettlementViewModel @Inject constructor(
|
|||||||
private fun requestOnlineProcessSettlement() {
|
private fun requestOnlineProcessSettlement() {
|
||||||
val state = _uiState.value
|
val state = _uiState.value
|
||||||
|
|
||||||
|
// Keep the local batch until this request receives an approved response.
|
||||||
|
settlementApproved = false
|
||||||
|
errorFlag = false
|
||||||
|
|
||||||
val hostName = HostName.MPU
|
val hostName = HostName.MPU
|
||||||
val field60 = SystemParamsOperation.getInstance().getCurrentBatchNum()
|
val field60 = SystemParamsOperation.getInstance().getCurrentBatchNum()
|
||||||
|
|
||||||
@ -407,15 +412,23 @@ class SettlementViewModel @Inject constructor(
|
|||||||
when {
|
when {
|
||||||
resultStr == Constant.ANSWER_CODE_ACCEPT ||
|
resultStr == Constant.ANSWER_CODE_ACCEPT ||
|
||||||
resultStr == Constant.ANSWER_CODE_APPROVED -> {
|
resultStr == Constant.ANSWER_CODE_APPROVED -> {
|
||||||
|
settlementApproved = true
|
||||||
currentPayDetail.isNeedReversal = false
|
currentPayDetail.isNeedReversal = false
|
||||||
}
|
}
|
||||||
|
|
||||||
resultStr == "95" || resultStr == "095" -> {
|
resultStr == "95" || resultStr == "095" -> {
|
||||||
|
settlementApproved = false
|
||||||
currentPayDetail.isNeedReversal = !flag
|
currentPayDetail.isNeedReversal = !flag
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
settlementApproved = false
|
||||||
|
currentPayDetail.isNeedReversal = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
errorFlag = true
|
errorFlag = true
|
||||||
|
settlementApproved = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,13 +460,12 @@ class SettlementViewModel @Inject constructor(
|
|||||||
flag = false
|
flag = false
|
||||||
batchIndex = 0
|
batchIndex = 0
|
||||||
|
|
||||||
updateDB()
|
if (!errorFlag && settlementApproved) {
|
||||||
insertPayDetail(currentPayDetail)
|
updateDB()
|
||||||
|
insertPayDetail(currentPayDetail)
|
||||||
if (errorFlag) {
|
|
||||||
postStatus(TransactionStatus.ON_ERROR)
|
|
||||||
} else {
|
|
||||||
postStatus(TransactionStatus.ON_SUCCESS)
|
postStatus(TransactionStatus.ON_SUCCESS)
|
||||||
|
} else {
|
||||||
|
postStatus(TransactionStatus.ON_ERROR)
|
||||||
}
|
}
|
||||||
|
|
||||||
_uiState.update {
|
_uiState.update {
|
||||||
|
|||||||
@ -220,7 +220,16 @@ class TransactionResultViewModel @Inject constructor(
|
|||||||
|
|
||||||
override fun paperRollIsReady() {
|
override fun paperRollIsReady() {
|
||||||
if (isSettlement) {
|
if (isSettlement) {
|
||||||
sharedViewModel.startPrintProcessSettlement()
|
sharedViewModel.startPrintProcessSettlement(
|
||||||
|
onSuccess = ::navigateMain,
|
||||||
|
onFailure = {
|
||||||
|
sendUiEvent(
|
||||||
|
TransactionResultUiEvent.ShowPrinterDialog(
|
||||||
|
"Settlement report printing failed"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
sharedViewModel.startPrintProcess()
|
sharedViewModel.startPrintProcess()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -419,17 +419,25 @@ class SharedViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun startPrintProcessSettlement() {
|
fun startPrintProcessSettlement(
|
||||||
|
onSuccess: () -> Unit,
|
||||||
|
onFailure: () -> Unit
|
||||||
|
) {
|
||||||
|
|
||||||
val detail = payDetail.value ?: return
|
val detail = payDetail.value ?: run {
|
||||||
|
onFailure()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
PrintXReceipt.getInstance()
|
PrintXReceipt.getInstance()
|
||||||
.printSmileSettlementReport(detail, object : PrintXStatus {
|
.printSmileSettlementReport(detail, object : PrintXStatus {
|
||||||
|
|
||||||
override fun onSuccess() {
|
override fun onSuccess() {
|
||||||
|
onSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFailure() {
|
override fun onFailure() {
|
||||||
|
onFailure()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user