Merge branch 'merge_latest_SIT' of https://hub.utsmyanmar.com/Kyaw_Min_Khant/KBZ-POS into merge_latest_SIT

This commit is contained in:
MooN 2025-12-09 16:07:37 +06:30
commit 97014377a8
15 changed files with 177 additions and 20 deletions

File diff suppressed because one or more lines are too long

View File

@ -166,7 +166,7 @@ public class TransactionResultFragment extends DataBindingFragment implements Da
if (isNonApprovedTrade(payDetail) && isNonWavepayTransaction(transactionType)) { if (isNonApprovedTrade(payDetail) && isNonWavepayTransaction(transactionType)) {
startPrintProcess(false); startPrintProcess(false);
isCardInside(); isCardInside();
} else if (transactionType == TransactionsType.SETTLEMENT) { } else if (transactionType == TransactionsType.SETTLEMENT || transactionType == TransactionsType.MMQR_SETTLEMENT) {
handleSettlementTransaction(siriusReq); handleSettlementTransaction(siriusReq);
} else if (isWavePayNonSuccessTransaction(transactionType, payDetail)) { } else if (isWavePayNonSuccessTransaction(transactionType, payDetail)) {
// startPrintProcess(false); // startPrintProcess(false);
@ -208,7 +208,7 @@ public class TransactionResultFragment extends DataBindingFragment implements Da
private void handleSettlementTransaction(SiriusRequest siriusReq) { private void handleSettlementTransaction(SiriusRequest siriusReq) {
startPrintProcess(true); startPrintProcess(true);
downloadParameters(siriusReq, TMSUpdate.UPDATE); downloadParameters(siriusReq, TMSUpdate.UPDATE);
showSuccessDialog(getResourceString(R.string.txt_configs_are_updated)); // showSuccessDialog(getResourceString(R.string.txt_configs_are_updated));
navigateToMainScreen(); navigateToMainScreen();
} }

View File

@ -302,14 +302,20 @@ public class QRTransactionFragment extends DataBindingFragment implements DataBi
* trans is success !*/ * trans is success !*/
// String transStatus = response.getTransactionStatus(); // String transStatus = response.getTransactionStatus();
// String transTime = response.getResponse().; // String transTime = response.getResponse().;
if(response.getResponse().getWalletIdentifier() != null) {
payDetail.setCustomerMobile(response.getResponse().getWalletIdentifier());
} else {
payDetail.setCustomerMobile("KBZ PAY");
}
payDetail.setCustomerMobile("KBZ PAY"); payDetail.setTC(response.getResponse().getTradeStatus());
payDetail.setQrReferNo(refLabel); payDetail.setQrReferNo(refLabel);
payDetail.setQrTransId(response.getResponse().getMmOrderId()); payDetail.setQrTransId(response.getResponse().getMmOrderId());
payDetail.setReferNo(refLabel); payDetail.setReferNo(refLabel);
payDetail.setApprovalCode(response.getResponse().getMmOrderId()); payDetail.setApprovalCode(response.getResponse().getMmOrderId());
payDetail.setQrTransStatus(1); payDetail.setQrTransStatus(1);
payDetail.setOriginalTransDate(response.getResponse().getPaySuccessTime()); payDetail.setTradeDateAndTime(response.getResponse().getPaySuccessTime());
retrievedUpdatePayDetail(refLabel, payDetail,false); retrievedUpdatePayDetail(refLabel, payDetail,false);

View File

@ -140,13 +140,15 @@ public class QRRefundProcessFragment extends DataBindingFragment {
String refundAmount = response.getResponse().getRefundAmount(); String refundAmount = response.getResponse().getRefundAmount();
String dateTime = SystemDateTime.getTodayDateFormat() + " " + SystemDateTime.getTodayTimeFormat(); String dateTime = SystemDateTime.getTodayDateFormat() + " " + SystemDateTime.getTodayTimeFormat();
payDetail.setTC(response.getResponse().getRefundStatus());
payDetail.setAmount(refundAmount == null ? 0 : POSUtil.getInstance().convertAmount(refundAmount)); payDetail.setAmount(refundAmount == null ? 0 : POSUtil.getInstance().convertAmount(refundAmount));
payDetail.setOriginalTransDate(dateTime); payDetail.setOriginalTransDate(dateTime);
payDetail.setQrTransStatus(1); payDetail.setQrTransStatus(1);
payDetail.setQrReferNo(referenceNo); payDetail.setQrReferNo(referenceNo);
payDetail.setReferNo(referenceNo); payDetail.setReferNo(referenceNo);
payDetail.setIsCanceled(true); payDetail.setIsCanceled(true);
payDetail.setCustomerMobile(response.getResponse().getWalletIdentifier());
payDetail.setTradeDateAndTime(response.getResponse().getRefundTime());
EReceiptRequest request = EReceiptUtil.getInstance().generateQRRefundReceipt(sharedViewModel.payDetail.getValue(), TransResultStatus.SUCCESS); EReceiptRequest request = EReceiptUtil.getInstance().generateQRRefundReceipt(sharedViewModel.payDetail.getValue(), TransResultStatus.SUCCESS);
sharedViewModel.pushReceipt(request); sharedViewModel.pushReceipt(request);

View File

@ -154,7 +154,6 @@ public class QRSettlementTransactionFragment extends DataBindingFragment impleme
settlementViewModel.isNoData.setValue(false); settlementViewModel.isNoData.setValue(false);
} }
// Set settlement data for display
setupSettlementDisplayData(); setupSettlementDisplayData();
} else { } else {
@ -198,6 +197,11 @@ public class QRSettlementTransactionFragment extends DataBindingFragment impleme
payDetail.setTransactionType(TransactionsType.MMQR_SETTLEMENT.value); payDetail.setTransactionType(TransactionsType.MMQR_SETTLEMENT.value);
payDetail.setTransType(TransactionsType.MMQR_SETTLEMENT.name); payDetail.setTransType(TransactionsType.MMQR_SETTLEMENT.name);
payDetail.setAmount(totalAmount); payDetail.setAmount(totalAmount);
payDetail.setTradeAnswerCode("000");
sharedViewModel.insertPayDetail(payDetail);
sharedViewModel.setAmount(String.valueOf(qrSaleAmount - qrRefundAmount));
sharedViewModel.payDetail.setValue(payDetail); sharedViewModel.payDetail.setValue(payDetail);
sharedViewModel.payDetails.setValue(qrTransactionsList); sharedViewModel.payDetails.setValue(qrTransactionsList);
} }
@ -209,8 +213,11 @@ public class QRSettlementTransactionFragment extends DataBindingFragment impleme
} }
private void navigateToResult() { private void navigateToResult() {
routeId = R.id.action_QRSettlementTransactionFragment_to_transactionResultFragment; delayFunctionCall(()->{
safeNavigateToRouteId(); routeId = R.id.action_QRSettlementTransactionFragment_to_transactionResultFragment;
safeNavigateToRouteId();
},500);
} }
private void updateData() { private void updateData() {
@ -238,7 +245,6 @@ public class QRSettlementTransactionFragment extends DataBindingFragment impleme
public void onConfirm() { public void onConfirm() {
if (!qrTransactionsList.isEmpty()) { if (!qrTransactionsList.isEmpty()) {
for (PayDetail payDetail : qrTransactionsList) { for (PayDetail payDetail : qrTransactionsList) {
// Mark as settled or delete based on your business logic
settlementViewModel.deletePayDetail(payDetail); settlementViewModel.deletePayDetail(payDetail);
} }

View File

@ -391,7 +391,7 @@ public class SettlementTransactionFragment extends DataBindingFragment implement
settlementViewModel.startSettlementProcess(); settlementViewModel.startSettlementProcess();
showLoadingDialog("Sending ..."); showLoadingDialog("Sending ...");
} else if(sharedViewModel.getTransMenu().getValue() == TransMenu.REVIEW_BATCH) { } else if(sharedViewModel.getTransMenu().getValue() == TransMenu.REVIEW_BATCH) {
sharedViewModel.startPrintProcessSettlement(); sharedViewModel.startPrintSettlement();
} else if(sharedViewModel.getTransMenu().getValue() == TransMenu.LAST_SETTLEMENT) { } else if(sharedViewModel.getTransMenu().getValue() == TransMenu.LAST_SETTLEMENT) {
routeId = R.id.action_settlementTransactionFragment_to_reprintReceiptFragment; routeId = R.id.action_settlementTransactionFragment_to_reprintReceiptFragment;
safeNavigateToRouteId(); safeNavigateToRouteId();

View File

@ -4,6 +4,12 @@ import org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;
/** /**
* Example local unit test, which will execute on the development machine (host). * Example local unit test, which will execute on the development machine (host).
* *
@ -16,5 +22,25 @@ public class ExampleUnitTest {
} }
public static String formatTimestampToGMT630(long timestampMillis) {
ZoneId gmt630Zone = ZoneId.of("+06:30");
String pattern = "d MMM yyyy hh:mm a";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern, Locale.US);
Instant instant = Instant.ofEpochSecond(timestampMillis);
ZonedDateTime zonedDateTime = instant.atZone(gmt630Zone);
return zonedDateTime.format(formatter);
}
@Test
public void testTimeStamp() {
long timestamp = 1765228580;
String dateTime = formatTimestampToGMT630(timestamp);
System.out.println("Formatted Date and Time: " + dateTime);
}
} }

View File

@ -242,6 +242,9 @@ public class KPayQRQueryRequest {
@SerializedName("sign_type") @SerializedName("sign_type")
private String signType; private String signType;
@SerializedName("Wallet_identifier")
private String walletIdentifier;
public Response() { public Response() {
} }
@ -307,6 +310,8 @@ public class KPayQRQueryRequest {
public String getPaySuccessTime() { return paySuccessTime; } public String getPaySuccessTime() { return paySuccessTime; }
public String getWalletIdentifier() { return walletIdentifier; }
public void setPaySuccessTime(String paySuccessTime) { this.paySuccessTime = paySuccessTime; } public void setPaySuccessTime(String paySuccessTime) { this.paySuccessTime = paySuccessTime; }
public void setMmOrderId(String mmOrderId) { this.mmOrderId = mmOrderId;} public void setMmOrderId(String mmOrderId) { this.mmOrderId = mmOrderId;}
@ -350,6 +355,10 @@ public class KPayQRQueryRequest {
public void setSignType(String signType) { public void setSignType(String signType) {
this.signType = signType; this.signType = signType;
} }
public void setWalletIdentifier(String walletIdentifier) {
this.walletIdentifier = walletIdentifier;
}
} }
public boolean checkResponse() { public boolean checkResponse() {

View File

@ -289,6 +289,9 @@ public class KPayRefund {
@SerializedName("refund_currency") @SerializedName("refund_currency")
private String refundCurrency; private String refundCurrency;
@SerializedName("Wallet_identifier")
private String walletIdentifier;
public RefundResp() { public RefundResp() {
} }
@ -366,6 +369,8 @@ public class KPayRefund {
return refundCurrency; return refundCurrency;
} }
public String getWalletIdentifier() {return walletIdentifier; }
public void setMsg(String msg) { public void setMsg(String msg) {
this.msg = msg; this.msg = msg;
} }
@ -421,6 +426,10 @@ public class KPayRefund {
public void setRefundCurrency(String refundCurrency) { public void setRefundCurrency(String refundCurrency) {
this.refundCurrency = refundCurrency; this.refundCurrency = refundCurrency;
} }
public void setWalletIdentifier(String walletIdentifier) {
this.walletIdentifier = walletIdentifier;
}
} }
} }

Binary file not shown.

View File

@ -11,6 +11,10 @@ import com.sunmi.pay.hardware.aidl.AidlConstants;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale; import java.util.Locale;
import com.utsmyanmar.paylibs.utils.LogUtil; import com.utsmyanmar.paylibs.utils.LogUtil;
@ -222,6 +226,31 @@ public class PrintUtils {
return formatter.format(amounts); return formatter.format(amounts);
} }
public String getSeparatorOnlyNumberFormat(long amount) {
if (amount == 0) return "0";
DecimalFormat formatter = new DecimalFormat("#,###");
int x = 2;
BigDecimal unscaled = new BigDecimal(amount);
BigDecimal scaled = unscaled.scaleByPowerOfTen(-x);
double amounts = Double.parseDouble(scaled.toString());
return formatter.format(amounts);
}
public String formatTimestamp(long timestampMillis) {
ZoneId gmt630Zone = ZoneId.of("+06:30");
String pattern = "d MMM yyyy hh:mm a";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern, Locale.US);
Instant instant = Instant.ofEpochSecond(timestampMillis);
ZonedDateTime zonedDateTime = instant.atZone(gmt630Zone);
return zonedDateTime.format(formatter);
}
public String getCardHolderName(String cardHolderName) { public String getCardHolderName(String cardHolderName) {
if (cardHolderName != null) { if (cardHolderName != null) {
return cardHolderName.replaceAll("\\s{2,}", "").trim(); return cardHolderName.replaceAll("\\s{2,}", "").trim();

View File

@ -43,6 +43,7 @@ import java.util.stream.Collectors;
import io.reactivex.rxjava3.core.Observable; import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.disposables.Disposable; import io.reactivex.rxjava3.disposables.Disposable;
import com.utsmyanmar.paylibs.utils.LogUtil; import com.utsmyanmar.paylibs.utils.LogUtil;
public abstract class BaseXPrint { public abstract class BaseXPrint {
@ -82,9 +83,6 @@ public abstract class BaseXPrint {
protected FontEntity fontBig = new FontEntity(DotMatrixFontEnum.CH_SONG_24X24, DotMatrixFontEnum.ASC_SONG_12X24, false, true); protected FontEntity fontBig = new FontEntity(DotMatrixFontEnum.CH_SONG_24X24, DotMatrixFontEnum.ASC_SONG_12X24, false, true);
public static byte[] boldOn() { public static byte[] boldOn() {
byte[] result = new byte[3]; byte[] result = new byte[3];
result[0] = 0x1B; result[0] = 0x1B;
@ -109,8 +107,9 @@ public abstract class BaseXPrint {
// LogUtil.d(TAG, Arrays.toString(returnText)); // LogUtil.d(TAG, Arrays.toString(returnText));
// printer.setTypeface(Typeface.DEFAULT); // printer.setTypeface(Typeface.DEFAULT);
Resources resources = PayLibsUtils.getInstance().context.getResources(); Resources resources = PayLibsUtils.getInstance().context.getResources();
printer.setTypeface(Typeface.createFromAsset(PayLibsUtils.getInstance().context.getAssets(), "rubik_medium.ttf")); printer.setTypeface(Typeface.createFromAsset(PayLibsUtils.getInstance().context.getAssets(), "consolas.ttf"));
printer.setGray(getGrayLevel()); printer.setGray(getGrayLevel());
} }
private GrayLevelEnum getGrayLevel() { private GrayLevelEnum getGrayLevel() {
@ -186,6 +185,11 @@ public abstract class BaseXPrint {
} }
protected void dashBreakEnding() {
printer.appendPrnStr("--------X----------X----------", fontNormal, AlignEnum.LEFT);
}
protected void breakingLine() { protected void breakingLine() {
printer.appendPrnStr("******************************", fontNormal, AlignEnum.LEFT); printer.appendPrnStr("******************************", fontNormal, AlignEnum.LEFT);
@ -589,6 +593,10 @@ public abstract class BaseXPrint {
printer.printColumnsString(new String[]{"TOTAL(MMK)", countStringFormat(totalCount), PrintUtils.getInstance().getSeparatorNumberFormat(totalAmount)}, new int[]{3, 1, 2}, new int[]{0, 1, 2}, innerResultCallback); printer.printColumnsString(new String[]{"TOTAL(MMK)", countStringFormat(totalCount), PrintUtils.getInstance().getSeparatorNumberFormat(totalAmount)}, new int[]{3, 1, 2}, new int[]{0, 1, 2}, innerResultCallback);
}*/ }*/
protected void printString(String text) {
printer.appendPrnStr(text, fontNormal, AlignEnum.LEFT);
}
protected void print2ColumnsString(String first, String second) { protected void print2ColumnsString(String first, String second) {
printer.appendPrnStr(first + " " + second, fontNormal, AlignEnum.LEFT); printer.appendPrnStr(first + " " + second, fontNormal, AlignEnum.LEFT);
} }
@ -681,6 +689,39 @@ public abstract class BaseXPrint {
emptyLine(2); emptyLine(2);
}
protected void printQRSettlementTransDetail(List<PayDetail> lists) {
long totalAmount = 0;
long refundTotal = 0;
for (PayDetail pay : lists) {
printString("Trans Id: " + pay.getQrTransId());
printString("Status : " + pay.getTC());
printString("Date : " + PrintUtils.getInstance().formatTimestamp(Long.parseLong(pay.getTradeDateAndTime())));
printString("Amount : " + "MMK " + PrintUtils.getInstance().getSeparatorOnlyNumberFormat(pay.getAmount()));
if (pay.getTransactionType() == TransactionsType.MMQR_REFUND.value) {
refundTotal += pay.getAmount();
} else {
totalAmount += pay.getAmount();
}
emptyLine(1);
}
dashBreak();
print2ColumnsString("Refund Total:MMK", PrintUtils.getInstance().getSeparatorOnlyNumberFormat(refundTotal));
dashBreak();
print2ColumnsString("Sale Total:MMK", PrintUtils.getInstance().getSeparatorOnlyNumberFormat(totalAmount));
dashBreakEnding();
emptyLine(2);
} }
private void printErrorBlock(String msg) { private void printErrorBlock(String msg) {
@ -729,8 +770,6 @@ public abstract class BaseXPrint {
printer.appendPrnStr(cvmText, fontBold, AlignEnum.CENTER); printer.appendPrnStr(cvmText, fontBold, AlignEnum.CENTER);
// if (payDetail.getIsFreeSign()) { // if (payDetail.getIsFreeSign()) {
// printer.printText("NO SIGNATURE REQUIRED", innerResultCallback); // printer.printText("NO SIGNATURE REQUIRED", innerResultCallback);
// } else { // } else {
@ -849,7 +888,7 @@ public abstract class BaseXPrint {
protected void startPrintNex() { protected void startPrintNex() {
if(printer.getStatus() != SdkResult.Success) { if (printer.getStatus() != SdkResult.Success) {
callbackStatus.onFailure(); callbackStatus.onFailure();
} }

View File

@ -41,7 +41,7 @@ public class PrintXImpl extends BaseXPrint implements PrintX {
SimpleDateFormat dfm = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss", Locale.getDefault()); SimpleDateFormat dfm = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss", Locale.getDefault());
currentTime = dfm.format(new Date()); currentTime = dfm.format(new Date());
BitmapFactory.Options opts = new BitmapFactory.Options(); BitmapFactory.Options opts = new BitmapFactory.Options();
bitmap = BitmapFactory.decodeResource(resources, R.drawable.print_kbz_logo, opts); bitmap = BitmapFactory.decodeResource(resources, R.drawable.print_kbz_logo_new, opts);
} }
@ -214,7 +214,7 @@ public class PrintXImpl extends BaseXPrint implements PrintX {
printLogo(); printLogo();
printMerchantHeader(); printMerchantHeader();
printTransHeader(payDetail); printTransHeader(payDetail);
printTransDetailReport(list,HostType.QR); printQRSettlementTransDetail(list);
printTransFooterSummary(); printTransFooterSummary();
emptyLine(1); emptyLine(1);

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -4,6 +4,8 @@ import org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import com.utsmyanmar.paylibs.print.PrintUtils;
/** /**
* Example local unit test, which will execute on the development machine (host). * Example local unit test, which will execute on the development machine (host).
* *
@ -14,4 +16,14 @@ public class ExampleUnitTest {
public void addition_isCorrect() { public void addition_isCorrect() {
assertEquals(4, 2 + 2); assertEquals(4, 2 + 2);
} }
@Test
public void testSeparatorOnlyNumberFormat() {
long num = 500000;
String converted = PrintUtils.getInstance().getSeparatorOnlyNumberFormat(num);
System.out.println("Converted Number: " + converted);
}
} }