last settlement changed
This commit is contained in:
parent
ee297e8e77
commit
5beea4afdd
@ -3,10 +3,12 @@ package com.utsmm.kbz.ui.management;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.Observer;
|
||||
|
||||
import com.github.gcacace.signaturepad.BR;
|
||||
@ -42,6 +44,7 @@ public class ReprintReceiptFragment extends DataBindingFragment {
|
||||
private static final String TAG = ReprintReceiptFragment.class.getSimpleName();
|
||||
|
||||
private PayDetail payDetail;
|
||||
private List<QRSettleData> lastQrSettleData;
|
||||
private ObjectAnimator slideUpAnimator;
|
||||
private View printingCard;
|
||||
|
||||
@ -165,7 +168,12 @@ public class ReprintReceiptFragment extends DataBindingFragment {
|
||||
transType = "";
|
||||
}
|
||||
payDetail.setTransType(transType + "(REPRINT)");
|
||||
|
||||
if (payDetail.getTransactionType() == TransactionsType.SETTLEMENT.value) {
|
||||
observeLastQrSettlement(payDetail);
|
||||
} else {
|
||||
checkPaperExists(payDetail);
|
||||
}
|
||||
// managementViewModel.payDetail.observe(getViewLifecycleOwner(), new Observer<PayDetail>() {
|
||||
// @Override
|
||||
// public void onChanged(PayDetail pay) {
|
||||
@ -185,12 +193,41 @@ public class ReprintReceiptFragment extends DataBindingFragment {
|
||||
// });
|
||||
}
|
||||
|
||||
private void observeLastQrSettlement(PayDetail settlePayDetail) {
|
||||
lastQrSettleData = null;
|
||||
LiveData<List<PayDetail>> liveData = managementViewModel.getLastSettlementQR(SystemParamsOperation.getInstance().getCurrentSerialNum());
|
||||
liveData.observe(getViewLifecycleOwner(), new Observer<List<PayDetail>>() {
|
||||
@Override
|
||||
public void onChanged(List<PayDetail> qrSettlements) {
|
||||
liveData.removeObserver(this);
|
||||
if (qrSettlements != null) {
|
||||
for (int i = qrSettlements.size() - 1; i >= 0; i--) {
|
||||
PayDetail qrSettle = qrSettlements.get(i);
|
||||
if (qrSettle != null
|
||||
&& qrSettle.getTransactionType() == TransactionsType.MMQR_SETTLEMENT.value
|
||||
&& TextUtils.equals(qrSettle.getBatchNo(), settlePayDetail.getBatchNo())
|
||||
&& qrSettle.getQrSettleData() != null
|
||||
&& !qrSettle.getQrSettleData().isEmpty()) {
|
||||
lastQrSettleData = qrSettle.getQrSettleData();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
checkPaperExists(settlePayDetail);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void printReceipt(PayDetail payDetail) {
|
||||
|
||||
if (payDetail.getTransactionType() == TransactionsType.MMQR_SETTLEMENT.value) {
|
||||
|
||||
PrintXReceipt.getInstance().printQRSettlementReport(payDetail, payDetail.getQrSettleData(), printXStatus);
|
||||
|
||||
} else if (lastQrSettleData != null && !lastQrSettleData.isEmpty()) {
|
||||
|
||||
PrintXReceipt.getInstance().printSmileSettlementReport(payDetail, lastQrSettleData, printXStatus);
|
||||
|
||||
} else {
|
||||
PrintXReceipt.getInstance().printSmileSettlementReport(payDetail, printXStatus);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user