amount, date, time fixed in Void Preview
This commit is contained in:
parent
46bf866de7
commit
66c969873e
@ -11,6 +11,9 @@
|
|||||||
|
|
||||||
### version 3.4
|
### version 3.4
|
||||||
* disable display always on
|
* disable display always on
|
||||||
* auto-settlement
|
|
||||||
* show expiry date as "**/**"
|
[//]: # (* auto-settlement)
|
||||||
*
|
* show expiry date as "`**`/`**`"
|
||||||
|
* align the customer name, in paper slip
|
||||||
|
* settlement fixed in both UI and system
|
||||||
|
* amount, date, time fixed in Void Preview
|
||||||
@ -50,7 +50,6 @@ import androidx.compose.ui.draw.clip
|
|||||||
import androidx.compose.ui.draw.rotate
|
import androidx.compose.ui.draw.rotate
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.layout.ContentScale
|
import androidx.compose.ui.layout.ContentScale
|
||||||
import androidx.compose.ui.res.painterResource
|
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
@ -524,26 +523,3 @@ fun Item(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val previewTransactions = listOf(
|
|
||||||
TrnxRecord(
|
|
||||||
1L, "Sale", "MMK 10,000", "**** 1234", "06/10 14:32",
|
|
||||||
isVoided = false, isApproved = true
|
|
||||||
),
|
|
||||||
TrnxRecord(
|
|
||||||
2L, "Void", "MMK 5,500", "**** 5678", "06/10 13:10",
|
|
||||||
isVoided = true, isApproved = false
|
|
||||||
),
|
|
||||||
TrnxRecord(
|
|
||||||
3L, "Refund", "MMK 2,000", "**** 9012", "06/09 09:45",
|
|
||||||
isVoided = false, isApproved = true
|
|
||||||
),
|
|
||||||
TrnxRecord(
|
|
||||||
4L, "Sale", "MMK 30,000", "**** 3456", "06/09 08:00",
|
|
||||||
isVoided = false, isApproved = true
|
|
||||||
),
|
|
||||||
TrnxRecord(
|
|
||||||
5L, "Settlement", "MMK 0", "----", "06/08 18:00",
|
|
||||||
isVoided = false, isApproved = true
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|||||||
@ -55,8 +55,6 @@ import com.mob.utsmyanmar.BuildConfig
|
|||||||
import com.mob.utsmyanmar.R
|
import com.mob.utsmyanmar.R
|
||||||
import com.mob.utsmyanmar.ui.components.appbar.AppBar
|
import com.mob.utsmyanmar.ui.components.appbar.AppBar
|
||||||
import com.mob.utsmyanmar.ui.device_info.DeviceInfoUiState
|
import com.mob.utsmyanmar.ui.device_info.DeviceInfoUiState
|
||||||
import com.mob.utsmyanmar.ui.preview.P2Preview
|
|
||||||
import com.mob.utsmyanmar.ui.preview.P3Preview
|
|
||||||
import com.mob.utsmyanmar.ui.theme.Color
|
import com.mob.utsmyanmar.ui.theme.Color
|
||||||
import com.utsmyanmar.paylibs.sign_on.EchoTestProcess
|
import com.utsmyanmar.paylibs.sign_on.EchoTestProcess
|
||||||
import com.utsmyanmar.paylibs.sign_on.SignOnListener
|
import com.utsmyanmar.paylibs.sign_on.SignOnListener
|
||||||
@ -447,11 +445,3 @@ fun DashboardScreen2(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.N)
|
|
||||||
@P3Preview
|
|
||||||
@P2Preview
|
|
||||||
@Composable
|
|
||||||
fun PreviewDashboardScreen2() {
|
|
||||||
DashboardScreen2(dashboardUiState = DashboardUiState(previewTransactions))
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package com.mob.utsmyanmar.ui.sale_void
|
package com.mob.utsmyanmar.ui.sale_void
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
@ -138,8 +137,8 @@ private fun TransactionDetailsCard(transaction: PayDetail) {
|
|||||||
DetailRow("Card No", transaction.cardNo)
|
DetailRow("Card No", transaction.cardNo)
|
||||||
DetailRow("Reference", transaction.referNo)
|
DetailRow("Reference", transaction.referNo)
|
||||||
DetailRow("Approval", transaction.approvalCode.orEmpty())
|
DetailRow("Approval", transaction.approvalCode.orEmpty())
|
||||||
DetailRow("Date", transaction.tradeDate)
|
DetailRow("Date", transaction.transDate)
|
||||||
DetailRow("Time", transaction.tradeTime)
|
DetailRow("Time", transaction.transTime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -230,34 +230,34 @@ public abstract class BaseXPrint {
|
|||||||
cardType = payDetail.getAccountType().replace(" Ctls","");
|
cardType = payDetail.getAccountType().replace(" Ctls","");
|
||||||
}
|
}
|
||||||
// sunmiPrinterService.printColumnsString(new String[]{"CARD NUM :", PrintUtils.getInstance().cardNumMasking(payDetail.getCardNo())}, new int[]{2, 2}, new int[]{0, 1}, innerResultCallback);
|
// sunmiPrinterService.printColumnsString(new String[]{"CARD NUM :", PrintUtils.getInstance().cardNumMasking(payDetail.getCardNo())}, new int[]{2, 2}, new int[]{0, 1}, innerResultCallback);
|
||||||
sunmiPrinterService.printText("CARD NUMBER : "+ PrintUtils.getInstance().cardNumMasking(payDetail.getCardNo()) + "\n", innerResultCallback);
|
sunmiPrinterService.printText("CARD NUMBER : "+ PrintUtils.getInstance().cardNumMasking(payDetail.getCardNo()) + "\n", innerResultCallback);
|
||||||
|
|
||||||
if(!firstLineName.isEmpty()) {
|
if(!firstLineName.isEmpty()) {
|
||||||
sunmiPrinterService.printText("CARD HOLDER NAME: " + firstLineName + "\n", innerResultCallback);
|
sunmiPrinterService.printText("CARD HOLDER : " + firstLineName + "\n", innerResultCallback);
|
||||||
// sunmiPrinterService.printColumnsString(new String[]{"CARD HOLDER NAME:", firstLineName}, new int[]{2, 2}, new int[]{0, 1}, innerResultCallback);
|
// sunmiPrinterService.printColumnsString(new String[]{"CARD HOLDER NAME:", firstLineName}, new int[]{2, 2}, new int[]{0, 1}, innerResultCallback);
|
||||||
}
|
}
|
||||||
if(!secondLineName.isEmpty()) {
|
if(!secondLineName.isEmpty()) {
|
||||||
sunmiPrinterService.printText(" " + secondLineName + "\n", innerResultCallback);
|
sunmiPrinterService.printText(" " + secondLineName + "\n", innerResultCallback);
|
||||||
// sunmiPrinterService.printColumnsString(new String[]{secondLineName, ""}, new int[]{2, 2}, new int[]{0, 1}, innerResultCallback);
|
// sunmiPrinterService.printColumnsString(new String[]{secondLineName, ""}, new int[]{2, 2}, new int[]{0, 1}, innerResultCallback);
|
||||||
}
|
}
|
||||||
sunmiPrinterService.printText("ENTRY MODE : " + PrintUtils.getInstance().getEntryType(payDetail.getCardType()) + "\n", innerResultCallback);
|
sunmiPrinterService.printText("ENTRY MODE : " + PrintUtils.getInstance().getEntryType(payDetail.getCardType()) + "\n", innerResultCallback);
|
||||||
// sunmiPrinterService.printText("EXPIRY DATE : " + PrintUtils.getInstance().getFormatExpDate(payDetail.getEXPDate()) + "\n", innerResultCallback);
|
// sunmiPrinterService.printText("EXPIRY DATE : " + PrintUtils.getInstance().getFormatExpDate(payDetail.getEXPDate()) + "\n", innerResultCallback);
|
||||||
sunmiPrinterService.printText("EXPIRY DATE : " + "**/**" + "\n", innerResultCallback);
|
sunmiPrinterService.printText("EXPIRY DATE : " + "**/**" + "\n", innerResultCallback);
|
||||||
// sunmiPrinterService.printColumnsString(new String[]{"ENTRY MODE:" + PrintUtils.getInstance().getEntryType(payDetail.getCardType()), "EXPIRY DATE:" + PrintUtils.getInstance().getFormatExpDate(payDetail.getEXPDate())}, new int[]{2, 2}, new int[]{0, 2}, innerResultCallback);
|
// sunmiPrinterService.printColumnsString(new String[]{"ENTRY MODE:" + PrintUtils.getInstance().getEntryType(payDetail.getCardType()), "EXPIRY DATE:" + PrintUtils.getInstance().getFormatExpDate(payDetail.getEXPDate())}, new int[]{2, 2}, new int[]{0, 2}, innerResultCallback);
|
||||||
if (payDetail.getTradeAnswerCode().equals(Constant.ANSWER_CODE_ACCEPT) || payDetail.getTradeAnswerCode().equals(Constant.ANSWER_CODE_APPROVED)) {
|
if (payDetail.getTradeAnswerCode().equals(Constant.ANSWER_CODE_ACCEPT) || payDetail.getTradeAnswerCode().equals(Constant.ANSWER_CODE_APPROVED)) {
|
||||||
sunmiPrinterService.printText("CARD TYPE : " + cardType + "\n", innerResultCallback);
|
sunmiPrinterService.printText("CARD TYPE : " + cardType + "\n", innerResultCallback);
|
||||||
// sunmiPrinterService.printText("APPROVAL CODE : " + cardType + "\n", innerResultCallback);
|
// sunmiPrinterService.printText("APPROVAL CODE : " + cardType + "\n", innerResultCallback);
|
||||||
// sunmiPrinterService.printColumnsString(new String[]{"CARD TYPE:" + cardType, "APPRCODE:" + payDetail.getApprovalCode()}, new int[]{2, 2}, new int[]{0, 2}, innerResultCallback);
|
// sunmiPrinterService.printColumnsString(new String[]{"CARD TYPE:" + cardType, "APPRCODE:" + payDetail.getApprovalCode()}, new int[]{2, 2}, new int[]{0, 2}, innerResultCallback);
|
||||||
} else {
|
} else {
|
||||||
sunmiPrinterService.printText("CARD TYPE : " + cardType + "\n", innerResultCallback);
|
sunmiPrinterService.printText("CARD TYPE : " + cardType + "\n", innerResultCallback);
|
||||||
// sunmiPrinterService.printColumnsString(new String[]{"CARD TYPE:" + cardType, ""}, new int[]{2, 2}, new int[]{0, 2}, innerResultCallback);
|
// sunmiPrinterService.printColumnsString(new String[]{"CARD TYPE:" + cardType, ""}, new int[]{2, 2}, new int[]{0, 2}, innerResultCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(payDetail.getAID() == null || payDetail.getAID().isEmpty()){
|
if(payDetail.getAID() == null || payDetail.getAID().isEmpty()){
|
||||||
sunmiPrinterService.printText("AID : " + MPU_AID + "\n", innerResultCallback);
|
sunmiPrinterService.printText("AID : " + MPU_AID + "\n", innerResultCallback);
|
||||||
// sunmiPrinterService.printColumnsString(new String[]{"AID", ":" + MPU_AID}, new int[]{1, 2}, new int[]{0, 0}, innerResultCallback);
|
// sunmiPrinterService.printColumnsString(new String[]{"AID", ":" + MPU_AID}, new int[]{1, 2}, new int[]{0, 0}, innerResultCallback);
|
||||||
} else {
|
} else {
|
||||||
sunmiPrinterService.printText("AID : " + payDetail.getAID() + "\n" , innerResultCallback);
|
sunmiPrinterService.printText("AID : " + payDetail.getAID() + "\n" , innerResultCallback);
|
||||||
// sunmiPrinterService.printColumnsString(new String[]{"AID", ":" + payDetail.getAID()}, new int[]{1, 2}, new int[]{0, 0}, innerResultCallback);
|
// sunmiPrinterService.printColumnsString(new String[]{"AID", ":" + payDetail.getAID()}, new int[]{1, 2}, new int[]{0, 0}, innerResultCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,8 +265,8 @@ public abstract class BaseXPrint {
|
|||||||
// sunmiPrinterService.printText("TXN ID : " + payDetail.getAID() + "\n" , innerResultCallback);
|
// sunmiPrinterService.printText("TXN ID : " + payDetail.getAID() + "\n" , innerResultCallback);
|
||||||
// sunmiPrinterService.printColumnsString(new String[]{"TXN ID", ":" + payDetail.getReferNo()}, new int[]{1, 2}, new int[]{0, 0}, innerResultCallback);
|
// sunmiPrinterService.printColumnsString(new String[]{"TXN ID", ":" + payDetail.getReferNo()}, new int[]{1, 2}, new int[]{0, 0}, innerResultCallback);
|
||||||
}
|
}
|
||||||
sunmiPrinterService.printText("REF NUM : " + payDetail.getReferNo() + "\n", innerResultCallback);
|
sunmiPrinterService.printText("REF NUM : " + payDetail.getReferNo() + "\n", innerResultCallback);
|
||||||
sunmiPrinterService.printText("TRACE NO : " + payDetail.getVoucherNo() + "\n", innerResultCallback);
|
sunmiPrinterService.printText("TRACE NO : " + payDetail.getVoucherNo() + "\n", innerResultCallback);
|
||||||
// sunmiPrinterService.printColumnsString(new String[]{"REF NUM", ":" + payDetail.getReferNo()}, new int[]{1, 2}, new int[]{0, 0}, innerResultCallback);
|
// sunmiPrinterService.printColumnsString(new String[]{"REF NUM", ":" + payDetail.getReferNo()}, new int[]{1, 2}, new int[]{0, 0}, innerResultCallback);
|
||||||
// sunmiPrinterService.printColumnsString(new String[]{"TRACE No", ":" + payDetail.getVoucherNo()}, new int[]{1, 2}, new int[]{0, 0}, innerResultCallback);
|
// sunmiPrinterService.printColumnsString(new String[]{"TRACE No", ":" + payDetail.getVoucherNo()}, new int[]{1, 2}, new int[]{0, 0}, innerResultCallback);
|
||||||
|
|
||||||
|
|||||||
@ -38,32 +38,33 @@ public class POSUtil {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public POSUtil(){
|
public POSUtil() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public long convertAmount(String amount) {
|
public long convertAmount(String amount) {
|
||||||
long amountValue = 0;
|
long amountValue = 0;
|
||||||
if (amount != null ) {
|
if (amount != null) {
|
||||||
if(amount.contains(",")) {
|
if (amount.contains(",")) {
|
||||||
amount = amount.replace(",","");
|
amount = amount.replace(",", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(amount.contains(".")) {
|
if (amount.contains(".")) {
|
||||||
int index = amount.indexOf('.');
|
int index = amount.indexOf('.');
|
||||||
int len = amount.substring(index+1).length();
|
int len = amount.substring(index + 1).length();
|
||||||
|
|
||||||
String amt = amount.replace(".","");
|
String amt = amount.replace(".", "");
|
||||||
if(len == 0){
|
if (len == 0) {
|
||||||
amountValue = Long.parseLong(amt+"00");
|
amountValue = Long.parseLong(amt + "00");
|
||||||
} else if(len == 1){
|
} else if (len == 1) {
|
||||||
amountValue = Long.parseLong(amt+"0");
|
amountValue = Long.parseLong(amt + "0");
|
||||||
} else {
|
} else {
|
||||||
amountValue = Long.parseLong(amt);
|
amountValue = Long.parseLong(amt);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
amountValue = Long.parseLong(amount+"00");
|
amountValue = Long.parseLong(amount + "00");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -72,15 +73,15 @@ public class POSUtil {
|
|||||||
|
|
||||||
public long convertAmountQR(String amount) {
|
public long convertAmountQR(String amount) {
|
||||||
long amountValue = 0;
|
long amountValue = 0;
|
||||||
if (amount != null ) {
|
if (amount != null) {
|
||||||
if(amount.contains(",")) {
|
if (amount.contains(",")) {
|
||||||
amount = amount.replace(",","");
|
amount = amount.replace(",", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(amount.contains(".")) {
|
if (amount.contains(".")) {
|
||||||
int index = amount.indexOf('.');
|
int index = amount.indexOf('.');
|
||||||
|
|
||||||
amount = amount.substring(0,index);
|
amount = amount.substring(0, index);
|
||||||
amountValue = Long.parseLong(amount);
|
amountValue = Long.parseLong(amount);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -101,21 +102,21 @@ public class POSUtil {
|
|||||||
SimpleDateFormat dfm = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss", Locale.getDefault());
|
SimpleDateFormat dfm = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss", Locale.getDefault());
|
||||||
String currentTime = dfm.format(new Date());
|
String currentTime = dfm.format(new Date());
|
||||||
|
|
||||||
return currentTime.substring(0,10)+" "+currentTime.substring(11,19);
|
return currentTime.substring(0, 10) + " " + currentTime.substring(11, 19);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCurrentDateTimeForQR() {
|
public String getCurrentDateTimeForQR() {
|
||||||
SimpleDateFormat dfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
|
SimpleDateFormat dfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
|
||||||
String currentTime = dfm.format(new Date());
|
String currentTime = dfm.format(new Date());
|
||||||
|
|
||||||
return currentTime.substring(0,10)+" "+currentTime.substring(11,19);
|
return currentTime.substring(0, 10) + " " + currentTime.substring(11, 19);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCardNumMasking(String pan) {
|
public String getCardNumMasking(String pan) {
|
||||||
if(pan != null){
|
if (pan != null) {
|
||||||
StringBuilder PAN = new StringBuilder(pan);
|
StringBuilder PAN = new StringBuilder(pan);
|
||||||
if (pan.length() > 12) {
|
if (pan.length() > 12) {
|
||||||
PAN.replace(6,12,"******");
|
PAN.replace(6, 12, "******");
|
||||||
} else {
|
} else {
|
||||||
// PAN.append("*********");
|
// PAN.append("*********");
|
||||||
PAN.append(" ");
|
PAN.append(" ");
|
||||||
@ -134,7 +135,7 @@ public class POSUtil {
|
|||||||
|
|
||||||
public String getDecimalAmountFormat(long number) {
|
public String getDecimalAmountFormat(long number) {
|
||||||
double decimalNumber = number / 100.0; // Divide by 100 to move decimal point two places to the left
|
double decimalNumber = number / 100.0; // Divide by 100 to move decimal point two places to the left
|
||||||
return String.format(Locale.getDefault(),"%.2f", decimalNumber);
|
return String.format(Locale.getDefault(), "%.2f", decimalNumber);
|
||||||
// DecimalFormat formatter = new DecimalFormat("#,###.##");
|
// DecimalFormat formatter = new DecimalFormat("#,###.##");
|
||||||
// return formatter.format(amt);
|
// return formatter.format(amt);
|
||||||
}
|
}
|
||||||
@ -169,8 +170,12 @@ public class POSUtil {
|
|||||||
return fullPan.substring(0, 6) + "******" + fullPan.substring(fullPan.length() - 4);
|
return fullPan.substring(0, 6) + "******" + fullPan.substring(fullPan.length() - 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String formatAmount(long amount) {
|
public String formatAmount(long amount) {
|
||||||
return String.format("%012d", amount);
|
return String.format(
|
||||||
|
Locale.US,
|
||||||
|
"%,.2f",
|
||||||
|
amount / 100.0
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String responseCodeConverter(String responseCode) {
|
public String responseCodeConverter(String responseCode) {
|
||||||
@ -184,13 +189,13 @@ public class POSUtil {
|
|||||||
public String getCardType(PayDetail payDetail) {
|
public String getCardType(PayDetail payDetail) {
|
||||||
int value = 0;
|
int value = 0;
|
||||||
|
|
||||||
if(payDetail.getAccountType().equals(CardScheme.VISA.name)) {
|
if (payDetail.getAccountType().equals(CardScheme.VISA.name)) {
|
||||||
value = CardScheme.VISA.value;
|
value = CardScheme.VISA.value;
|
||||||
} else if(payDetail.getAccountType().equals(CardScheme.MASTERCARD.name)) {
|
} else if (payDetail.getAccountType().equals(CardScheme.MASTERCARD.name)) {
|
||||||
value = CardScheme.MASTERCARD.value;
|
value = CardScheme.MASTERCARD.value;
|
||||||
} else if(payDetail.getAccountType().equals(CardScheme.UPI.name)) {
|
} else if (payDetail.getAccountType().equals(CardScheme.UPI.name)) {
|
||||||
value = CardScheme.UPI.value;
|
value = CardScheme.UPI.value;
|
||||||
} else if(payDetail.getAccountType().equals(CardScheme.MPU.name)) {
|
} else if (payDetail.getAccountType().equals(CardScheme.MPU.name)) {
|
||||||
value = CardScheme.MPU.value;
|
value = CardScheme.MPU.value;
|
||||||
}
|
}
|
||||||
return String.valueOf(value);
|
return String.valueOf(value);
|
||||||
@ -204,14 +209,14 @@ public class POSUtil {
|
|||||||
value = "07";
|
value = "07";
|
||||||
} else if (AidlConstants.CardType.IC.getValue() == payDetail.getCardType()) { // IC
|
} else if (AidlConstants.CardType.IC.getValue() == payDetail.getCardType()) { // IC
|
||||||
value = "05";
|
value = "05";
|
||||||
} else if (-9 == payDetail.getCardType()){ // Fallback
|
} else if (-9 == payDetail.getCardType()) { // Fallback
|
||||||
value = "08";
|
value = "08";
|
||||||
} else { // Hand-in card number
|
} else { // Hand-in card number
|
||||||
value = "01";
|
value = "01";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(payDetail.getTransCVM() == TransCVM.OFFLINE_PIN) {
|
if (payDetail.getTransCVM() == TransCVM.OFFLINE_PIN) {
|
||||||
value += "9";
|
value += "9";
|
||||||
} else {
|
} else {
|
||||||
if (payDetail.getPINCipher() != null && !payDetail.getPINCipher().trim().isEmpty()) {
|
if (payDetail.getPINCipher() != null && !payDetail.getPINCipher().trim().isEmpty()) {
|
||||||
@ -233,32 +238,32 @@ public class POSUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String checkMinusSign(int transType) {
|
public String checkMinusSign(int transType) {
|
||||||
return (transType == TransactionsType.VOID.value || transType == TransactionsType.REFUND.value || transType == TransactionsType.PRE_AUTH_VOID.value || transType == TransactionsType.PRE_AUTH_COMPLETE_VOID.value) ? "-":"";
|
return (transType == TransactionsType.VOID.value || transType == TransactionsType.REFUND.value || transType == TransactionsType.PRE_AUTH_VOID.value || transType == TransactionsType.PRE_AUTH_COMPLETE_VOID.value) ? "-" : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDecimalAmountVoidFormat(PayDetail payDetail) {
|
public String getDecimalAmountVoidFormat(PayDetail payDetail) {
|
||||||
DecimalFormat formatter = new DecimalFormat("#,###.00");
|
DecimalFormat formatter = new DecimalFormat("#,###.00");
|
||||||
int x = 2;
|
int x = 2;
|
||||||
BigDecimal unscaled = new BigDecimal(payDetail.amount);
|
BigDecimal unscaled = new BigDecimal(payDetail.amount);
|
||||||
BigDecimal scaled = unscaled.scaleByPowerOfTen(-x);
|
BigDecimal scaled = unscaled.scaleByPowerOfTen(-x);
|
||||||
double amounts = Double.parseDouble(scaled.toString());
|
double amounts = Double.parseDouble(scaled.toString());
|
||||||
return payDetail.getTransactionType() == TransactionsType.VOID.value || payDetail.getTransactionType() == TransactionsType.REFUND.value || payDetail.getTransactionType() == TransactionsType.WAVEPAY_REFUND.value ? "-"+formatter.format(amounts) : ""+formatter.format(amounts);
|
return payDetail.getTransactionType() == TransactionsType.VOID.value || payDetail.getTransactionType() == TransactionsType.REFUND.value || payDetail.getTransactionType() == TransactionsType.WAVEPAY_REFUND.value ? "-" + formatter.format(amounts) : "" + formatter.format(amounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTransName(PayDetail payDetail) {
|
public String getTransName(PayDetail payDetail) {
|
||||||
String name = "";
|
String name = "";
|
||||||
if(payDetail.getTransactionType() == 10) {
|
if (payDetail.getTransactionType() == 10) {
|
||||||
name = payDetail.transType.replace('_',' ') + "(Reversal)";
|
name = payDetail.transType.replace('_', ' ') + "(Reversal)";
|
||||||
} else {
|
} else {
|
||||||
name = payDetail.transType.replace('_',' ');
|
name = payDetail.transType.replace('_', ' ');
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int checkQRFailureTransaction(PayDetail payDetail) {
|
public int checkQRFailureTransaction(PayDetail payDetail) {
|
||||||
// return R.color.colorPrimarySmile;
|
// return R.color.colorPrimarySmile;
|
||||||
if(payDetail.getTransactionType() == TransactionsType.WAVEPAY.value) {
|
if (payDetail.getTransactionType() == TransactionsType.WAVEPAY.value) {
|
||||||
if(payDetail.getQrTransStatus() == -1) {
|
if (payDetail.getQrTransStatus() == -1) {
|
||||||
return R.color.colorPrimarySmile;
|
return R.color.colorPrimarySmile;
|
||||||
} else {
|
} else {
|
||||||
return R.color.black;
|
return R.color.black;
|
||||||
@ -271,9 +276,9 @@ public class POSUtil {
|
|||||||
public String getEntryType(int cardType) {
|
public String getEntryType(int cardType) {
|
||||||
|
|
||||||
String entryType = "-";
|
String entryType = "-";
|
||||||
if(AidlConstants.CardType.IC.getValue() == cardType) {
|
if (AidlConstants.CardType.IC.getValue() == cardType) {
|
||||||
entryType = "Chip";
|
entryType = "Chip";
|
||||||
} else if(AidlConstants.CardType.MAGNETIC.getValue() == cardType) {
|
} else if (AidlConstants.CardType.MAGNETIC.getValue() == cardType) {
|
||||||
entryType = "MagStripe";
|
entryType = "MagStripe";
|
||||||
} else if (AidlConstants.CardType.NFC.getValue() == cardType) {
|
} else if (AidlConstants.CardType.NFC.getValue() == cardType) {
|
||||||
entryType = "Wave";
|
entryType = "Wave";
|
||||||
@ -286,29 +291,29 @@ public class POSUtil {
|
|||||||
|
|
||||||
public String interceptCardNo(String cardNo) {
|
public String interceptCardNo(String cardNo) {
|
||||||
|
|
||||||
if(cardNo != null){
|
if (cardNo != null) {
|
||||||
if(cardNo.isEmpty()) {
|
if (cardNo.isEmpty()) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
StringBuilder PAN = new StringBuilder(cardNo);
|
StringBuilder PAN = new StringBuilder(cardNo);
|
||||||
if (cardNo.length() > 12) {
|
if (cardNo.length() > 12) {
|
||||||
PAN.replace(6,12,"******");
|
PAN.replace(6, 12, "******");
|
||||||
} else {
|
} else {
|
||||||
PAN.append("*********");
|
PAN.append("*********");
|
||||||
}
|
}
|
||||||
return PAN.toString();
|
return PAN.toString();
|
||||||
}else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String checkStringViewBatch(TransMenu transMenu) {
|
public String checkStringViewBatch(TransMenu transMenu) {
|
||||||
return transMenu == TransMenu.SETTLEMENT ? "Confirm":"Print Receipt";
|
return transMenu == TransMenu.SETTLEMENT ? "Confirm" : "Print Receipt";
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkMerchantNameLength(String merchantName) {
|
public boolean checkMerchantNameLength(String merchantName) {
|
||||||
if(!TextUtils.equals(merchantName,"")){
|
if (!TextUtils.equals(merchantName, "")) {
|
||||||
return merchantName.length() >= 15;
|
return merchantName.length() >= 15;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@ -324,30 +329,30 @@ public class POSUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getFormatExpDate(String exp) {
|
public String getFormatExpDate(String exp) {
|
||||||
if(exp != null){
|
if (exp != null) {
|
||||||
String EXP = "";
|
String EXP = "";
|
||||||
try{
|
try {
|
||||||
EXP = exp.substring(2,4)+"/";
|
EXP = exp.substring(2, 4) + "/";
|
||||||
EXP = EXP + exp.substring(0,2);
|
EXP = EXP + exp.substring(0, 2);
|
||||||
return EXP;
|
return EXP;
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return EXP;
|
return EXP;
|
||||||
}
|
}
|
||||||
|
|
||||||
}else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String checkCardName(PayDetail payDetail) {
|
public String checkCardName(PayDetail payDetail) {
|
||||||
if(payDetail != null) {
|
if (payDetail != null) {
|
||||||
|
|
||||||
if(payDetail.getTransactionType() == TransactionsType.WAVEPAY.value) {
|
if (payDetail.getTransactionType() == TransactionsType.WAVEPAY.value) {
|
||||||
return payDetail.getCustomerMobile().toUpperCase();
|
return payDetail.getCustomerMobile().toUpperCase();
|
||||||
} else if(payDetail.getTransactionType() == TransactionsType.WAVEPAY_REFUND.value) {
|
} else if (payDetail.getTransactionType() == TransactionsType.WAVEPAY_REFUND.value) {
|
||||||
return "QR PAYMENT";
|
return "QR PAYMENT";
|
||||||
} else {
|
} else {
|
||||||
return payDetail.getAccountType();
|
return payDetail.getAccountType();
|
||||||
}
|
}
|
||||||
@ -357,12 +362,12 @@ public class POSUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String checkRRNorTrnxId(PayDetail payDetail) {
|
public String checkRRNorTrnxId(PayDetail payDetail) {
|
||||||
if(payDetail != null) {
|
if (payDetail != null) {
|
||||||
|
|
||||||
if(payDetail.getTransactionType() == TransactionsType.WAVEPAY.value) {
|
if (payDetail.getTransactionType() == TransactionsType.WAVEPAY.value) {
|
||||||
return payDetail.getQrTransId();
|
return payDetail.getQrTransId();
|
||||||
} else if(payDetail.getTransactionType() == TransactionsType.WAVEPAY_REFUND.value) {
|
} else if (payDetail.getTransactionType() == TransactionsType.WAVEPAY_REFUND.value) {
|
||||||
return payDetail.getReferNo()+"(RRN)";
|
return payDetail.getReferNo() + "(RRN)";
|
||||||
} else {
|
} else {
|
||||||
return payDetail.getReferNo();
|
return payDetail.getReferNo();
|
||||||
}
|
}
|
||||||
@ -372,9 +377,9 @@ public class POSUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String checkTraceOrInvoice(PayDetail payDetail) {
|
public String checkTraceOrInvoice(PayDetail payDetail) {
|
||||||
if(payDetail != null) {
|
if (payDetail != null) {
|
||||||
|
|
||||||
if(payDetail.getTransactionType() == TransactionsType.WAVEPAY.value || payDetail.getTransactionType() == TransactionsType.WAVEPAY_REFUND.value) {
|
if (payDetail.getTransactionType() == TransactionsType.WAVEPAY.value || payDetail.getTransactionType() == TransactionsType.WAVEPAY_REFUND.value) {
|
||||||
return payDetail.getInvoiceNo();
|
return payDetail.getInvoiceNo();
|
||||||
} else {
|
} else {
|
||||||
return payDetail.getVoucherNo();
|
return payDetail.getVoucherNo();
|
||||||
@ -385,31 +390,31 @@ public class POSUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getFormatExpDateDR(String exp) {
|
public String getFormatExpDateDR(String exp) {
|
||||||
if(exp != null && !exp.isEmpty()){
|
if (exp != null && !exp.isEmpty()) {
|
||||||
String EXP = "";
|
String EXP = "";
|
||||||
try{
|
try {
|
||||||
EXP = exp.substring(2,4)+"/";
|
EXP = exp.substring(2, 4) + "/";
|
||||||
EXP = EXP + exp.substring(0,2);
|
EXP = EXP + exp.substring(0, 2);
|
||||||
return EXP;
|
return EXP;
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return EXP;
|
return EXP;
|
||||||
}
|
}
|
||||||
|
|
||||||
}else {
|
} else {
|
||||||
return "**/**";
|
return "**/**";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getISOFormatExpDate(String exp) {
|
public String getISOFormatExpDate(String exp) {
|
||||||
if(exp != null && !exp.isEmpty()) {
|
if (exp != null && !exp.isEmpty()) {
|
||||||
if(exp.length() != 5 ) {
|
if (exp.length() != 5) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
String expDate = "";
|
String expDate = "";
|
||||||
|
|
||||||
expDate = exp.substring(3,5)+exp.substring(0,2);
|
expDate = exp.substring(3, 5) + exp.substring(0, 2);
|
||||||
|
|
||||||
return expDate;
|
return expDate;
|
||||||
} else {
|
} else {
|
||||||
@ -418,7 +423,7 @@ public class POSUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String checkResultCode(String code) {
|
private String checkResultCode(String code) {
|
||||||
if(code.equals(Constant.ANSWER_CODE_ACCEPT) || code.equals(Constant.ANSWER_CODE_APPROVED)){
|
if (code.equals(Constant.ANSWER_CODE_ACCEPT) || code.equals(Constant.ANSWER_CODE_APPROVED)) {
|
||||||
return "Success";
|
return "Success";
|
||||||
} else {
|
} else {
|
||||||
return BaseErrorCode.getErrorMessage(code);
|
return BaseErrorCode.getErrorMessage(code);
|
||||||
@ -427,10 +432,10 @@ public class POSUtil {
|
|||||||
|
|
||||||
@SuppressLint("DefaultLocale")
|
@SuppressLint("DefaultLocale")
|
||||||
public String checkResult(PayDetail payDetail) {
|
public String checkResult(PayDetail payDetail) {
|
||||||
try{
|
try {
|
||||||
if(payDetail.getTradeAnswerCode().equals("00") || payDetail.getTradeAnswerCode().equals("000")){
|
if (payDetail.getTradeAnswerCode().equals("00") || payDetail.getTradeAnswerCode().equals("000")) {
|
||||||
|
|
||||||
if(payDetail.getTransactionType() == TransactionsType.SETTLEMENT.value) {
|
if (payDetail.getTransactionType() == TransactionsType.SETTLEMENT.value) {
|
||||||
return "Success";
|
return "Success";
|
||||||
}
|
}
|
||||||
/* if(payDetail.getAmount() != 0) {
|
/* if(payDetail.getAmount() != 0) {
|
||||||
@ -451,32 +456,31 @@ public class POSUtil {
|
|||||||
|
|
||||||
String currencySign = SystemParamsOperation.getInstance().getCurrencyType().name;
|
String currencySign = SystemParamsOperation.getInstance().getCurrencyType().name;
|
||||||
|
|
||||||
if(payDetail.getTransactionType() == TransactionsType.VOID.value ) {
|
if (payDetail.getTransactionType() == TransactionsType.VOID.value) {
|
||||||
return "Transaction for Amount \n"+getDecimalAmountFormat(payDetail.getAmount()) +" "+currencySign+" Voided.";
|
return "Transaction for Amount \n" + getDecimalAmountFormat(payDetail.getAmount()) + " " + currencySign + " Voided.";
|
||||||
} else if(payDetail.getTransactionType() == TransactionsType.REFUND.value) {
|
} else if (payDetail.getTransactionType() == TransactionsType.REFUND.value) {
|
||||||
return "Transaction for Amount \n"+getDecimalAmountFormat(payDetail.getAmount()) +" "+currencySign+" Refunded.";
|
return "Transaction for Amount \n" + getDecimalAmountFormat(payDetail.getAmount()) + " " + currencySign + " Refunded.";
|
||||||
} else if(payDetail.getTransactionType() == TransactionsType.PRE_AUTH_SALE.value) {
|
} else if (payDetail.getTransactionType() == TransactionsType.PRE_AUTH_SALE.value) {
|
||||||
return "PreAuth for Amount \n"+getDecimalAmountFormat(payDetail.getAmount()) +" "+currencySign+" Approved.";
|
return "PreAuth for Amount \n" + getDecimalAmountFormat(payDetail.getAmount()) + " " + currencySign + " Approved.";
|
||||||
} else if(payDetail.getTransactionType() == TransactionsType.PRE_AUTH_VOID.value) {
|
} else if (payDetail.getTransactionType() == TransactionsType.PRE_AUTH_VOID.value) {
|
||||||
return "PreAuth Cancel for Amount \n"+getDecimalAmountFormat(payDetail.getAmount()) +" "+currencySign+" Approved.";
|
return "PreAuth Cancel for Amount \n" + getDecimalAmountFormat(payDetail.getAmount()) + " " + currencySign + " Approved.";
|
||||||
} else if(payDetail.getTransactionType() == TransactionsType.PRE_AUTH_COMPLETE.value) {
|
} else if (payDetail.getTransactionType() == TransactionsType.PRE_AUTH_COMPLETE.value) {
|
||||||
return "PreAuth Complete for Amount \n"+getDecimalAmountFormat(payDetail.getAmount()) +" "+currencySign+" Approved.";
|
return "PreAuth Complete for Amount \n" + getDecimalAmountFormat(payDetail.getAmount()) + " " + currencySign + " Approved.";
|
||||||
} else if(payDetail.getTransactionType() == TransactionsType.PRE_AUTH_COMPLETE_VOID.value) {
|
} else if (payDetail.getTransactionType() == TransactionsType.PRE_AUTH_COMPLETE_VOID.value) {
|
||||||
return "PreAuth Complete Cancel for Amount \n"+getDecimalAmountFormat(payDetail.getAmount()) +" "+currencySign+" Approved.";
|
return "PreAuth Complete Cancel for Amount \n" + getDecimalAmountFormat(payDetail.getAmount()) + " " + currencySign + " Approved.";
|
||||||
} else if(payDetail.getTransactionType() == TransactionsType.CASH_OUT.value) {
|
} else if (payDetail.getTransactionType() == TransactionsType.CASH_OUT.value) {
|
||||||
long totalAmount = payDetail.getAmount() + payDetail.getAdditionalAmount();
|
long totalAmount = payDetail.getAmount() + payDetail.getAdditionalAmount();
|
||||||
return "Transaction for Amount \n"+getDecimalAmountFormat(totalAmount) +" "+currencySign+" Received.";
|
return "Transaction for Amount \n" + getDecimalAmountFormat(totalAmount) + " " + currencySign + " Received.";
|
||||||
|
} else {
|
||||||
|
return "Transaction for Amount \n" + getDecimalAmountFormat(payDetail.getAmount()) + " " + currencySign + " Received.";
|
||||||
}
|
}
|
||||||
else {
|
} else if (TextUtils.equals(payDetail.getAccountType(), "WALLET")) {
|
||||||
return "Transaction for Amount \n"+getDecimalAmountFormat(payDetail.getAmount()) +" "+currencySign+" Received.";
|
if (payDetail.getQrTransStatus() == 1) {
|
||||||
}
|
return "Transaction for Amount \n" + getDecimalAmountFormat(payDetail.getAmount()) + " MMK Received.";
|
||||||
} else if(TextUtils.equals(payDetail.getAccountType(),"WALLET")) {
|
} else if (payDetail.getQrTransStatus() == 3) {
|
||||||
if(payDetail.getQrTransStatus() == 1) {
|
|
||||||
return "Transaction for Amount \n"+getDecimalAmountFormat(payDetail.getAmount()) +" MMK Received.";
|
|
||||||
} else if(payDetail.getQrTransStatus() == 3){
|
|
||||||
return "Declined \n COMMUNICATION ERROR";
|
return "Declined \n COMMUNICATION ERROR";
|
||||||
} else if(payDetail.getQrTransStatus() == 2) {
|
} else if (payDetail.getQrTransStatus() == 2) {
|
||||||
if(isCurrentDateTimePassed(payDetail.getTransDate(),payDetail.getTransTime())) {
|
if (isCurrentDateTimePassed(payDetail.getTransDate(), payDetail.getTransTime())) {
|
||||||
return "Declined \n expire";
|
return "Declined \n expire";
|
||||||
} else {
|
} else {
|
||||||
return "Declined \n payment credit in-progress";
|
return "Declined \n payment credit in-progress";
|
||||||
@ -484,9 +488,9 @@ public class POSUtil {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// return "Transaction failed";
|
// return "Transaction failed";
|
||||||
if(payDetail.getTransactionType() == TransactionsType.WAVEPAY_REFUND.value) {
|
if (payDetail.getTransactionType() == TransactionsType.WAVEPAY_REFUND.value) {
|
||||||
if(payDetail.getTradeResultDes() != null && !payDetail.getTradeResultDes().isEmpty()) {
|
if (payDetail.getTradeResultDes() != null && !payDetail.getTradeResultDes().isEmpty()) {
|
||||||
return "Declined \n "+payDetail.getTradeResultDes();
|
return "Declined \n " + payDetail.getTradeResultDes();
|
||||||
} else {
|
} else {
|
||||||
return "Declined \n transaction fail";
|
return "Declined \n transaction fail";
|
||||||
}
|
}
|
||||||
@ -496,20 +500,19 @@ public class POSUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return checkResultCode(payDetail.getTradeAnswerCode());
|
return checkResultCode(payDetail.getTradeAnswerCode());
|
||||||
}
|
}
|
||||||
} catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return checkResultCode("");
|
return checkResultCode("");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkBooleanResult(PayDetail payDetail){
|
public boolean checkBooleanResult(PayDetail payDetail) {
|
||||||
try {
|
try {
|
||||||
return TextUtils.equals("00",payDetail.getTradeAnswerCode()) || TextUtils.equals("000",payDetail.getTradeAnswerCode()) || payDetail.getQrTransStatus() == 1;
|
return TextUtils.equals("00", payDetail.getTradeAnswerCode()) || TextUtils.equals("000", payDetail.getTradeAnswerCode()) || payDetail.getQrTransStatus() == 1;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
@ -519,7 +522,7 @@ public class POSUtil {
|
|||||||
|
|
||||||
public Date getCurrentDate() {
|
public Date getCurrentDate() {
|
||||||
String dateFormatPattern = "dd/MM/yy";
|
String dateFormatPattern = "dd/MM/yy";
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat(dateFormatPattern,Locale.getDefault());
|
SimpleDateFormat formatter = new SimpleDateFormat(dateFormatPattern, Locale.getDefault());
|
||||||
|
|
||||||
Date today = new Date();
|
Date today = new Date();
|
||||||
String to = formatter.format(today);
|
String to = formatter.format(today);
|
||||||
@ -535,7 +538,7 @@ public class POSUtil {
|
|||||||
|
|
||||||
public String getCurrentDateString() {
|
public String getCurrentDateString() {
|
||||||
String dateFormatPattern = "dd/MM/yy";
|
String dateFormatPattern = "dd/MM/yy";
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat(dateFormatPattern,Locale.getDefault());
|
SimpleDateFormat formatter = new SimpleDateFormat(dateFormatPattern, Locale.getDefault());
|
||||||
|
|
||||||
Date today = new Date();
|
Date today = new Date();
|
||||||
String to = formatter.format(today);
|
String to = formatter.format(today);
|
||||||
@ -546,7 +549,7 @@ public class POSUtil {
|
|||||||
|
|
||||||
public Date getYesterdayDate() {
|
public Date getYesterdayDate() {
|
||||||
String dateFormatPattern = "dd/MM/yy";
|
String dateFormatPattern = "dd/MM/yy";
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat(dateFormatPattern,Locale.getDefault());
|
SimpleDateFormat formatter = new SimpleDateFormat(dateFormatPattern, Locale.getDefault());
|
||||||
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, -1); // Subtract one day
|
calendar.add(Calendar.DAY_OF_YEAR, -1); // Subtract one day
|
||||||
@ -564,7 +567,7 @@ public class POSUtil {
|
|||||||
|
|
||||||
public Date getLastInputDay(int num) {
|
public Date getLastInputDay(int num) {
|
||||||
String dateFormatPattern = "dd/MM/yy";
|
String dateFormatPattern = "dd/MM/yy";
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat(dateFormatPattern,Locale.getDefault());
|
SimpleDateFormat formatter = new SimpleDateFormat(dateFormatPattern, Locale.getDefault());
|
||||||
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.add(Calendar.DAY_OF_YEAR, -num); // Subtract one day
|
calendar.add(Calendar.DAY_OF_YEAR, -num); // Subtract one day
|
||||||
@ -582,7 +585,7 @@ public class POSUtil {
|
|||||||
|
|
||||||
public Date getDateByString(String date) {
|
public Date getDateByString(String date) {
|
||||||
String dateFormatPattern = "dd/MM/yy";
|
String dateFormatPattern = "dd/MM/yy";
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat(dateFormatPattern,Locale.getDefault());
|
SimpleDateFormat formatter = new SimpleDateFormat(dateFormatPattern, Locale.getDefault());
|
||||||
|
|
||||||
Date outDate;
|
Date outDate;
|
||||||
try {
|
try {
|
||||||
@ -600,8 +603,8 @@ public class POSUtil {
|
|||||||
public String convertDateFormatByDateString(String date) {
|
public String convertDateFormatByDateString(String date) {
|
||||||
String dateFormatPattern = "dd/MM/yy";
|
String dateFormatPattern = "dd/MM/yy";
|
||||||
String convertedDateFormat = "yyyy-MM-dd";
|
String convertedDateFormat = "yyyy-MM-dd";
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat(dateFormatPattern,Locale.getDefault());
|
SimpleDateFormat formatter = new SimpleDateFormat(dateFormatPattern, Locale.getDefault());
|
||||||
SimpleDateFormat convertedFormatter = new SimpleDateFormat(convertedDateFormat,Locale.getDefault());
|
SimpleDateFormat convertedFormatter = new SimpleDateFormat(convertedDateFormat, Locale.getDefault());
|
||||||
|
|
||||||
Date outDate;
|
Date outDate;
|
||||||
try {
|
try {
|
||||||
@ -609,7 +612,7 @@ public class POSUtil {
|
|||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
if(outDate != null) {
|
if (outDate != null) {
|
||||||
return convertedFormatter.format(outDate);
|
return convertedFormatter.format(outDate);
|
||||||
} else {
|
} else {
|
||||||
return convertedDateFormat;
|
return convertedDateFormat;
|
||||||
@ -617,13 +620,13 @@ public class POSUtil {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getDateByTransDateTime(String transDate,String transTime) {
|
public Date getDateByTransDateTime(String transDate, String transTime) {
|
||||||
String dateFormatPattern = "dd/MM/yy HH:mm";
|
String dateFormatPattern = "dd/MM/yy HH:mm";
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat(dateFormatPattern,Locale.getDefault());
|
SimpleDateFormat formatter = new SimpleDateFormat(dateFormatPattern, Locale.getDefault());
|
||||||
|
|
||||||
Date outDate;
|
Date outDate;
|
||||||
try {
|
try {
|
||||||
outDate = formatter.parse(transDate+" "+transTime);
|
outDate = formatter.parse(transDate + " " + transTime);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@ -633,9 +636,9 @@ public class POSUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* For MMQR
|
* For MMQR
|
||||||
* check current date time is passed 5 mins or not*/
|
* check current date time is passed 5 mins or not*/
|
||||||
public boolean isCurrentDateTimePassed(String transDate, String transTime) {
|
public boolean isCurrentDateTimePassed(String transDate, String transTime) {
|
||||||
String dateFormatPattern = "dd/MM/yy HH:mm";
|
String dateFormatPattern = "dd/MM/yy HH:mm";
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat(dateFormatPattern, Locale.getDefault());
|
SimpleDateFormat formatter = new SimpleDateFormat(dateFormatPattern, Locale.getDefault());
|
||||||
@ -664,13 +667,13 @@ public class POSUtil {
|
|||||||
// calendar.add(Calendar.DAY_OF_MONTH, 1);
|
// calendar.add(Calendar.DAY_OF_MONTH, 1);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yy HH:mm",Locale.getDefault());
|
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yy HH:mm", Locale.getDefault());
|
||||||
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yy",Locale.getDefault());
|
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yy", Locale.getDefault());
|
||||||
String formattedDateTime = format.format(calendar.getTime());
|
String formattedDateTime = format.format(calendar.getTime());
|
||||||
|
|
||||||
Date date;
|
Date date;
|
||||||
try {
|
try {
|
||||||
date = formatter.parse(formattedDateTime+" "+time);
|
date = formatter.parse(formattedDateTime + " " + time);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@ -691,8 +694,8 @@ public class POSUtil {
|
|||||||
int year = calendar.get(Calendar.YEAR);
|
int year = calendar.get(Calendar.YEAR);
|
||||||
int month = calendar.get(Calendar.MONTH) + 1; // Months are 0-based
|
int month = calendar.get(Calendar.MONTH) + 1; // Months are 0-based
|
||||||
int day = calendar.get(Calendar.DAY_OF_MONTH);
|
int day = calendar.get(Calendar.DAY_OF_MONTH);
|
||||||
int hour = Integer.parseInt(time.substring(0,2));
|
int hour = Integer.parseInt(time.substring(0, 2));
|
||||||
int minute = Integer.parseInt(time.substring(3,5));
|
int minute = Integer.parseInt(time.substring(3, 5));
|
||||||
|
|
||||||
calendar.set(Calendar.YEAR, year);
|
calendar.set(Calendar.YEAR, year);
|
||||||
calendar.set(Calendar.MONTH, month - 1);
|
calendar.set(Calendar.MONTH, month - 1);
|
||||||
@ -715,17 +718,18 @@ public class POSUtil {
|
|||||||
}
|
}
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkBooleanCardNo(String cardNo) {
|
public boolean checkBooleanCardNo(String cardNo) {
|
||||||
return !cardNo.equals("-");
|
return !cardNo.equals("-");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkNumberField(String amount) {
|
public boolean checkNumberField(String amount) {
|
||||||
LogUtil.d(TAG,"checkNumberField :"+amount);
|
LogUtil.d(TAG, "checkNumberField :" + amount);
|
||||||
|
|
||||||
|
|
||||||
// String regex = "\\d+";
|
// String regex = "\\d+";
|
||||||
String regex = "^-?\\d+$";
|
String regex = "^-?\\d+$";
|
||||||
LogUtil.d(TAG,"checkNumberField regex :"+amount.matches(regex));
|
LogUtil.d(TAG, "checkNumberField regex :" + amount.matches(regex));
|
||||||
return amount.equals(" ") || amount.equals("0") || amount.equals("") || !amount.matches(regex);
|
return amount.equals(" ") || amount.equals("0") || amount.equals("") || !amount.matches(regex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -733,10 +737,10 @@ public class POSUtil {
|
|||||||
return approvalCode.equals(" ") || approvalCode.length() != 6;
|
return approvalCode.equals(" ") || approvalCode.length() != 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int checkVisibilityForConfirm(TransactionsType transactionsType){
|
public int checkVisibilityForConfirm(TransactionsType transactionsType) {
|
||||||
if(transactionsType == TransactionsType.REFUND) {
|
if (transactionsType == TransactionsType.REFUND) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if(transactionsType == TransactionsType.VOID) {
|
} else if (transactionsType == TransactionsType.VOID) {
|
||||||
return 8;
|
return 8;
|
||||||
} else {
|
} else {
|
||||||
return 8;
|
return 8;
|
||||||
@ -745,11 +749,11 @@ public class POSUtil {
|
|||||||
|
|
||||||
public String formatTrace(String inputValue) {
|
public String formatTrace(String inputValue) {
|
||||||
int traceNo = 0;
|
int traceNo = 0;
|
||||||
if(!inputValue.equals("") && !inputValue.equals(" ")){
|
if (!inputValue.equals("") && !inputValue.equals(" ")) {
|
||||||
traceNo = Integer.parseInt(inputValue);
|
traceNo = Integer.parseInt(inputValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
return String.format(Locale.getDefault(),"%06d",traceNo);
|
return String.format(Locale.getDefault(), "%06d", traceNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isOnlyDigit(String input) {
|
private boolean isOnlyDigit(String input) {
|
||||||
@ -761,8 +765,8 @@ public class POSUtil {
|
|||||||
|
|
||||||
long convertedAmount = 0;
|
long convertedAmount = 0;
|
||||||
// need to check is contain decimal or not
|
// need to check is contain decimal or not
|
||||||
if(amount != null && !amount.isEmpty() && isOnlyDigit(amount)) {
|
if (amount != null && !amount.isEmpty() && isOnlyDigit(amount)) {
|
||||||
convertedAmount = Long.parseLong(amount+"00");
|
convertedAmount = Long.parseLong(amount + "00");
|
||||||
}
|
}
|
||||||
return convertedAmount;
|
return convertedAmount;
|
||||||
}
|
}
|
||||||
@ -772,22 +776,22 @@ public class POSUtil {
|
|||||||
long minAmount = convertStringToLong(minAmountStr);
|
long minAmount = convertStringToLong(minAmountStr);
|
||||||
long maxAmount = convertStringToLong(maxAmountStr);
|
long maxAmount = convertStringToLong(maxAmountStr);
|
||||||
|
|
||||||
LogUtil.d(TAG,"Min amount :"+minAmountStr+" - "+minAmount);
|
LogUtil.d(TAG, "Min amount :" + minAmountStr + " - " + minAmount);
|
||||||
LogUtil.d(TAG,"Max amount :"+maxAmountStr+" - "+maxAmount);
|
LogUtil.d(TAG, "Max amount :" + maxAmountStr + " - " + maxAmount);
|
||||||
LogUtil.d(TAG,"Input amount :"+inputAmount+" - "+input);
|
LogUtil.d(TAG, "Input amount :" + inputAmount + " - " + input);
|
||||||
|
|
||||||
if(minAmount > input) {
|
if (minAmount > input) {
|
||||||
return InvalidAmount.BELOW;
|
return InvalidAmount.BELOW;
|
||||||
} else if(maxAmount <= input) {
|
} else if (maxAmount <= input) {
|
||||||
return InvalidAmount.EXCEEDED;
|
return InvalidAmount.EXCEEDED;
|
||||||
} else {
|
} else {
|
||||||
return InvalidAmount.OKAY;
|
return InvalidAmount.OKAY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkVoid(String configTime,String date,String time) {
|
public boolean checkVoid(String configTime, String date, String time) {
|
||||||
Date yesterday = POSUtil.getInstance().getYesterdayConfigDateTime(configTime);
|
Date yesterday = POSUtil.getInstance().getYesterdayConfigDateTime(configTime);
|
||||||
Date transDateTime = POSUtil.getInstance().getDateByTransDateTime(date,time);
|
Date transDateTime = POSUtil.getInstance().getDateByTransDateTime(date, time);
|
||||||
|
|
||||||
Date configDate = POSUtil.getInstance().getDateTime(configTime);
|
Date configDate = POSUtil.getInstance().getDateTime(configTime);
|
||||||
|
|
||||||
@ -796,10 +800,10 @@ public class POSUtil {
|
|||||||
|
|
||||||
Date current = new Date(System.currentTimeMillis());
|
Date current = new Date(System.currentTimeMillis());
|
||||||
|
|
||||||
if(transDate.compareTo(today) == 0 ) {
|
if (transDate.compareTo(today) == 0) {
|
||||||
// trans is today
|
// trans is today
|
||||||
|
|
||||||
if(current.compareTo(configDate) > 0) {
|
if (current.compareTo(configDate) > 0) {
|
||||||
// Trans is today ! config time is passed yet! can't do void!
|
// Trans is today ! config time is passed yet! can't do void!
|
||||||
// return transDateTime.compareTo(configDate) < 0;
|
// return transDateTime.compareTo(configDate) < 0;
|
||||||
return configDate.compareTo(transDateTime) < 0;
|
return configDate.compareTo(transDateTime) < 0;
|
||||||
@ -812,7 +816,7 @@ public class POSUtil {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
Date yest;
|
Date yest;
|
||||||
if(configTime.equals("00:00")) {
|
if (configTime.equals("00:00")) {
|
||||||
yest = configDate;
|
yest = configDate;
|
||||||
} else {
|
} else {
|
||||||
yest = yesterday;
|
yest = yesterday;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user