fix of summary report bug
This commit is contained in:
parent
2238988846
commit
820dcf9aa6
@ -767,15 +767,169 @@ public abstract class BaseXPrint {
|
|||||||
|
|
||||||
class TempSummary {
|
class TempSummary {
|
||||||
int saleCount, voidSaleCount, refundCount, cashOutCount;
|
int saleCount, voidSaleCount, refundCount, cashOutCount;
|
||||||
|
int preAuthSaleCount, preAuthVoidCount;
|
||||||
int qrPayCount, qrRefundCount;
|
int qrPayCount, qrRefundCount;
|
||||||
int preAuthCompCount, preAuthCompVoidCount;
|
int preAuthCompCount, preAuthCompVoidCount;
|
||||||
|
|
||||||
long saleAmount, voidSaleAmount, refundAmount, cashOutAmount;
|
long saleAmount, voidSaleAmount, refundAmount, cashOutAmount;
|
||||||
|
long preAuthSaleAmount, preAuthVoidAmount;
|
||||||
long qrPayAmount, qrRefundAmount;
|
long qrPayAmount, qrRefundAmount;
|
||||||
long preAuthCompAmount, preAuthCompVoidAmount;
|
long preAuthCompAmount, preAuthCompVoidAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void applyTempSummary(TempSummary summary, PayDetail item) {
|
||||||
|
int transactionType = item.getTransactionType();
|
||||||
|
long amount = item.getAmount();
|
||||||
|
|
||||||
|
if (transactionType == TransactionsType.SALE.value) {
|
||||||
|
summary.saleCount++;
|
||||||
|
summary.saleAmount += amount;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (transactionType == TransactionsType.VOID.value) {
|
||||||
|
summary.voidSaleCount++;
|
||||||
|
summary.voidSaleAmount += amount;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (transactionType == TransactionsType.REFUND.value) {
|
||||||
|
summary.refundCount++;
|
||||||
|
summary.refundAmount += amount;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (transactionType == TransactionsType.CASH_OUT.value) {
|
||||||
|
summary.cashOutCount++;
|
||||||
|
summary.cashOutAmount += amount;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (transactionType == TransactionsType.PRE_AUTH_SALE.value) {
|
||||||
|
summary.preAuthSaleCount++;
|
||||||
|
summary.preAuthSaleAmount += amount;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (transactionType == TransactionsType.PRE_AUTH_VOID.value) {
|
||||||
|
summary.preAuthVoidCount++;
|
||||||
|
summary.preAuthVoidAmount += amount;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (transactionType == TransactionsType.MMQR.value) {
|
||||||
|
summary.qrPayCount++;
|
||||||
|
summary.qrPayAmount += amount;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (transactionType == TransactionsType.MMQR_REFUND.value) {
|
||||||
|
summary.qrRefundCount++;
|
||||||
|
summary.qrRefundAmount += amount;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (transactionType == TransactionsType.PRE_AUTH_COMPLETE.value) {
|
||||||
|
summary.preAuthCompCount++;
|
||||||
|
summary.preAuthCompAmount += amount;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (transactionType == TransactionsType.PRE_AUTH_COMPLETE_VOID.value) {
|
||||||
|
summary.preAuthCompVoidCount++;
|
||||||
|
summary.preAuthCompVoidAmount += amount;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String transType = item.getTransType() == null ? "" : item.getTransType().trim().toUpperCase(Locale.getDefault());
|
||||||
|
|
||||||
|
switch (transType) {
|
||||||
|
case "SALE":
|
||||||
|
summary.saleCount++;
|
||||||
|
summary.saleAmount += amount;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "VOID SALE":
|
||||||
|
case "VOID_SALE":
|
||||||
|
summary.voidSaleCount++;
|
||||||
|
summary.voidSaleAmount += amount;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "REFUND":
|
||||||
|
summary.refundCount++;
|
||||||
|
summary.refundAmount += amount;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "PRE-AUTH":
|
||||||
|
case "PRE_AUTH_SALE":
|
||||||
|
summary.preAuthSaleCount++;
|
||||||
|
summary.preAuthSaleAmount += amount;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "PREAUTH CANCELLATION":
|
||||||
|
case "PRE_AUTH_VOID":
|
||||||
|
summary.preAuthVoidCount++;
|
||||||
|
summary.preAuthVoidAmount += amount;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "CASH OUT":
|
||||||
|
case "CASH_OUT":
|
||||||
|
case "CASH_ADVANCE":
|
||||||
|
summary.cashOutCount++;
|
||||||
|
summary.cashOutAmount += amount;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "QR_PAY":
|
||||||
|
summary.qrPayCount++;
|
||||||
|
summary.qrPayAmount += amount;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "QR_REFUND":
|
||||||
|
summary.qrRefundCount++;
|
||||||
|
summary.qrRefundAmount += amount;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "PREAUTH COMPLETION":
|
||||||
|
case "PRE_AUTH_COMPLETE":
|
||||||
|
case "PREAUTH_COMP":
|
||||||
|
summary.preAuthCompCount++;
|
||||||
|
summary.preAuthCompAmount += amount;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "VOID PREAUTH COMPLETE":
|
||||||
|
case "PRE_AUTH_COMPLETE_VOID":
|
||||||
|
case "PREAUTH_COMP_VOID":
|
||||||
|
summary.preAuthCompVoidCount++;
|
||||||
|
summary.preAuthCompVoidAmount += amount;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean matchesSummaryHostType(PayDetail item, HostType hostType) {
|
||||||
|
if (hostType == null || item == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int transactionType = item.getTransactionType();
|
||||||
|
|
||||||
|
if (hostType == HostType.QR) {
|
||||||
|
return transactionType == TransactionsType.MMQR.value
|
||||||
|
|| transactionType == TransactionsType.MMQR_REFUND.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hostType == HostType.MPU || hostType == HostType.VISA_MASTER) {
|
||||||
|
return transactionType != TransactionsType.MMQR.value
|
||||||
|
&& transactionType != TransactionsType.MMQR_REFUND.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
protected void printTransDetailSummary(PayDetail payDetail, List<PayDetail> list) {
|
protected void printTransDetailSummary(PayDetail payDetail, List<PayDetail> list) {
|
||||||
|
printTransDetailSummary(payDetail, list, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void printTransDetailSummary(PayDetail payDetail, List<PayDetail> list, HostType hostType) {
|
||||||
|
|
||||||
if (list == null || list.isEmpty()) {
|
if (list == null || list.isEmpty()) {
|
||||||
printErrorBlock("NO TRANSACTION FOUND");
|
printErrorBlock("NO TRANSACTION FOUND");
|
||||||
@ -788,6 +942,7 @@ public abstract class BaseXPrint {
|
|||||||
for (PayDetail item : list) {
|
for (PayDetail item : list) {
|
||||||
|
|
||||||
if (item == null) continue;
|
if (item == null) continue;
|
||||||
|
if (!matchesSummaryHostType(item, hostType)) continue;
|
||||||
|
|
||||||
String currency = item.getCurrencyCode();
|
String currency = item.getCurrencyCode();
|
||||||
TempSummary s = currencyMap.get(currency);
|
TempSummary s = currencyMap.get(currency);
|
||||||
@ -797,51 +952,13 @@ public abstract class BaseXPrint {
|
|||||||
currencyMap.put(currency, s);
|
currencyMap.put(currency, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
String transType = item.getTransType();
|
applyTempSummary(s, item);
|
||||||
long amount = item.getAmount();
|
|
||||||
|
|
||||||
switch (transType) {
|
|
||||||
|
|
||||||
case "SALE":
|
|
||||||
s.saleCount++;
|
|
||||||
s.saleAmount += amount;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "VOID_SALE":
|
|
||||||
s.voidSaleCount++;
|
|
||||||
s.voidSaleAmount += amount;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "REFUND":
|
|
||||||
s.refundCount++;
|
|
||||||
s.refundAmount += amount;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "CASH_OUT":
|
|
||||||
s.cashOutCount++;
|
|
||||||
s.cashOutAmount += amount;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "QR_PAY":
|
|
||||||
s.qrPayCount++;
|
|
||||||
s.qrPayAmount += amount;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "QR_REFUND":
|
|
||||||
s.qrRefundCount++;
|
|
||||||
s.qrRefundAmount += amount;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "PREAUTH_COMP":
|
|
||||||
s.preAuthCompCount++;
|
|
||||||
s.preAuthCompAmount += amount;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "PREAUTH_COMP_VOID":
|
|
||||||
s.preAuthCompVoidCount++;
|
|
||||||
s.preAuthCompVoidAmount += amount;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currencyMap.isEmpty()) {
|
||||||
|
printErrorBlock("NO TRANSACTION FOUND");
|
||||||
|
printer.appendPrnStr("\n", fontNormal, AlignEnum.LEFT,false);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isQrDecimalEnabled = SystemParamsOperation.getInstance().isQrDecimalEnable();
|
boolean isQrDecimalEnabled = SystemParamsOperation.getInstance().isQrDecimalEnable();
|
||||||
@ -850,6 +967,7 @@ public abstract class BaseXPrint {
|
|||||||
for (String currency : currencyMap.keySet()) {
|
for (String currency : currencyMap.keySet()) {
|
||||||
|
|
||||||
TempSummary data = currencyMap.get(currency);
|
TempSummary data = currencyMap.get(currency);
|
||||||
|
boolean isQrHost = hostType == HostType.QR;
|
||||||
|
|
||||||
printer.appendPrnStr( currencyCodeToText(currency) + " " +"Transactions", fontNormal, AlignEnum.LEFT, false);
|
printer.appendPrnStr( currencyCodeToText(currency) + " " +"Transactions", fontNormal, AlignEnum.LEFT, false);
|
||||||
emptyLine(1);
|
emptyLine(1);
|
||||||
@ -857,6 +975,21 @@ public abstract class BaseXPrint {
|
|||||||
// printer.appendPrnStr("(COUNT)TRANS", "AMOUNT(" + currencyCodeToText(currency) + ")", fontNormal, false);
|
// printer.appendPrnStr("(COUNT)TRANS", "AMOUNT(" + currencyCodeToText(currency) + ")", fontNormal, false);
|
||||||
print3ColumnsStringWithAlign("COUNT", "TRANS", "AMOUNT" + "(" + currencyCodeToText(currency) + ")", fontNormal, false);
|
print3ColumnsStringWithAlign("COUNT", "TRANS", "AMOUNT" + "(" + currencyCodeToText(currency) + ")", fontNormal, false);
|
||||||
|
|
||||||
|
if (isQrHost) {
|
||||||
|
if (data.qrPayCount > 0) {
|
||||||
|
print3ColumnsStringWithAlign("(" + data.qrPayCount + ")",
|
||||||
|
"QR PAY",
|
||||||
|
PrintUtils.getInstance().getSeparatorNumberFormat(data.qrPayAmount, isQrDecimalEnabled),
|
||||||
|
fontNormal, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.qrRefundCount > 0) {
|
||||||
|
print3ColumnsStringWithAlign("(" + data.qrRefundCount + ")",
|
||||||
|
"QR REFUND",
|
||||||
|
"- " + PrintUtils.getInstance().getSeparatorNumberFormat(data.qrRefundAmount, isQrDecimalEnabled),
|
||||||
|
fontNormal, false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (data.saleCount > 0) {
|
if (data.saleCount > 0) {
|
||||||
print3ColumnsStringWithAlign("(" + data.saleCount + ")",
|
print3ColumnsStringWithAlign("(" + data.saleCount + ")",
|
||||||
"SALES",
|
"SALES",
|
||||||
@ -878,6 +1011,20 @@ public abstract class BaseXPrint {
|
|||||||
fontNormal, false);
|
fontNormal, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.preAuthSaleCount > 0) {
|
||||||
|
print3ColumnsStringWithAlign("(" + data.preAuthSaleCount + ")",
|
||||||
|
"PRE-AUTH",
|
||||||
|
PrintUtils.getInstance().getSeparatorNumberFormat(data.preAuthSaleAmount, isDecimalEnabled),
|
||||||
|
fontNormal, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.preAuthVoidCount > 0) {
|
||||||
|
print3ColumnsStringWithAlign("(" + data.preAuthVoidCount + ")",
|
||||||
|
"PREAUTH VOID",
|
||||||
|
"- " + PrintUtils.getInstance().getSeparatorNumberFormat(data.preAuthVoidAmount, isDecimalEnabled),
|
||||||
|
fontNormal, false);
|
||||||
|
}
|
||||||
|
|
||||||
if (data.refundCount > 0) {
|
if (data.refundCount > 0) {
|
||||||
print3ColumnsStringWithAlign("(" + data.refundCount + ")",
|
print3ColumnsStringWithAlign("(" + data.refundCount + ")",
|
||||||
"REFUND",
|
"REFUND",
|
||||||
@ -891,15 +1038,17 @@ public abstract class BaseXPrint {
|
|||||||
PrintUtils.getInstance().getSeparatorNumberFormat(data.preAuthCompAmount, isDecimalEnabled),
|
PrintUtils.getInstance().getSeparatorNumberFormat(data.preAuthCompAmount, isDecimalEnabled),
|
||||||
fontNormal, false);
|
fontNormal, false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dotBreak();
|
dotBreak();
|
||||||
|
|
||||||
long totalAmount =
|
long totalAmount = isQrHost
|
||||||
(data.saleAmount + data.cashOutAmount + data.preAuthCompAmount)
|
? data.qrPayAmount - data.qrRefundAmount
|
||||||
- (data.voidSaleAmount + data.refundAmount + data.preAuthCompVoidAmount);
|
: (data.saleAmount + data.cashOutAmount + data.preAuthSaleAmount + data.preAuthCompAmount)
|
||||||
|
- (data.voidSaleAmount + data.preAuthVoidAmount + data.refundAmount + data.preAuthCompVoidAmount);
|
||||||
|
|
||||||
printer.appendPrnStr( "TOTAL"+ " " + currencyCodeToText(currency),
|
printer.appendPrnStr( "TOTAL"+ " " + currencyCodeToText(currency),
|
||||||
PrintUtils.getInstance().getSeparatorNumberFormat(totalAmount, isDecimalEnabled),
|
PrintUtils.getInstance().getSeparatorNumberFormat(totalAmount, isQrHost ? isQrDecimalEnabled : isDecimalEnabled),
|
||||||
fontNormal, false);
|
fontNormal, false);
|
||||||
|
|
||||||
emptyLine(2);
|
emptyLine(2);
|
||||||
|
|||||||
@ -456,7 +456,7 @@ public class PrintXImpl extends BaseXPrint implements PrintX {
|
|||||||
printLogo();
|
printLogo();
|
||||||
printMerchantHeader();
|
printMerchantHeader();
|
||||||
printTranHeader("SUMMARY REPORT");
|
printTranHeader("SUMMARY REPORT");
|
||||||
printTransDetailSummary(payDetail, list);
|
printTransDetailSummary(payDetail, list, hostType);
|
||||||
startPrintNex();
|
startPrintNex();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user