fix of summary report bug
This commit is contained in:
parent
2238988846
commit
820dcf9aa6
@ -767,15 +767,169 @@ public abstract class BaseXPrint {
|
||||
|
||||
class TempSummary {
|
||||
int saleCount, voidSaleCount, refundCount, cashOutCount;
|
||||
int preAuthSaleCount, preAuthVoidCount;
|
||||
int qrPayCount, qrRefundCount;
|
||||
int preAuthCompCount, preAuthCompVoidCount;
|
||||
|
||||
long saleAmount, voidSaleAmount, refundAmount, cashOutAmount;
|
||||
long preAuthSaleAmount, preAuthVoidAmount;
|
||||
long qrPayAmount, qrRefundAmount;
|
||||
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) {
|
||||
printTransDetailSummary(payDetail, list, null);
|
||||
}
|
||||
|
||||
protected void printTransDetailSummary(PayDetail payDetail, List<PayDetail> list, HostType hostType) {
|
||||
|
||||
if (list == null || list.isEmpty()) {
|
||||
printErrorBlock("NO TRANSACTION FOUND");
|
||||
@ -788,6 +942,7 @@ public abstract class BaseXPrint {
|
||||
for (PayDetail item : list) {
|
||||
|
||||
if (item == null) continue;
|
||||
if (!matchesSummaryHostType(item, hostType)) continue;
|
||||
|
||||
String currency = item.getCurrencyCode();
|
||||
TempSummary s = currencyMap.get(currency);
|
||||
@ -797,51 +952,13 @@ public abstract class BaseXPrint {
|
||||
currencyMap.put(currency, s);
|
||||
}
|
||||
|
||||
String transType = item.getTransType();
|
||||
long amount = item.getAmount();
|
||||
applyTempSummary(s, item);
|
||||
}
|
||||
|
||||
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();
|
||||
@ -850,6 +967,7 @@ public abstract class BaseXPrint {
|
||||
for (String currency : currencyMap.keySet()) {
|
||||
|
||||
TempSummary data = currencyMap.get(currency);
|
||||
boolean isQrHost = hostType == HostType.QR;
|
||||
|
||||
printer.appendPrnStr( currencyCodeToText(currency) + " " +"Transactions", fontNormal, AlignEnum.LEFT, false);
|
||||
emptyLine(1);
|
||||
@ -857,49 +975,80 @@ public abstract class BaseXPrint {
|
||||
// printer.appendPrnStr("(COUNT)TRANS", "AMOUNT(" + currencyCodeToText(currency) + ")", fontNormal, false);
|
||||
print3ColumnsStringWithAlign("COUNT", "TRANS", "AMOUNT" + "(" + currencyCodeToText(currency) + ")", fontNormal, false);
|
||||
|
||||
if (data.saleCount > 0) {
|
||||
print3ColumnsStringWithAlign("(" + data.saleCount + ")",
|
||||
"SALES",
|
||||
PrintUtils.getInstance().getSeparatorNumberFormat(data.saleAmount, isDecimalEnabled),
|
||||
fontNormal, false);
|
||||
}
|
||||
if (isQrHost) {
|
||||
if (data.qrPayCount > 0) {
|
||||
print3ColumnsStringWithAlign("(" + data.qrPayCount + ")",
|
||||
"QR PAY",
|
||||
PrintUtils.getInstance().getSeparatorNumberFormat(data.qrPayAmount, isQrDecimalEnabled),
|
||||
fontNormal, false);
|
||||
}
|
||||
|
||||
if (data.voidSaleCount > 0) {
|
||||
print3ColumnsStringWithAlign("(" + data.voidSaleCount + ")",
|
||||
"VOID",
|
||||
"- " + PrintUtils.getInstance().getSeparatorNumberFormat(data.voidSaleAmount, isDecimalEnabled),
|
||||
fontNormal, false);
|
||||
}
|
||||
if (data.qrRefundCount > 0) {
|
||||
print3ColumnsStringWithAlign("(" + data.qrRefundCount + ")",
|
||||
"QR REFUND",
|
||||
"- " + PrintUtils.getInstance().getSeparatorNumberFormat(data.qrRefundAmount, isQrDecimalEnabled),
|
||||
fontNormal, false);
|
||||
}
|
||||
} else {
|
||||
if (data.saleCount > 0) {
|
||||
print3ColumnsStringWithAlign("(" + data.saleCount + ")",
|
||||
"SALES",
|
||||
PrintUtils.getInstance().getSeparatorNumberFormat(data.saleAmount, isDecimalEnabled),
|
||||
fontNormal, false);
|
||||
}
|
||||
|
||||
if (data.cashOutCount > 0) {
|
||||
print3ColumnsStringWithAlign("(" + data.cashOutCount + ")",
|
||||
"CASH ADV",
|
||||
PrintUtils.getInstance().getSeparatorNumberFormat(data.cashOutAmount, isDecimalEnabled),
|
||||
fontNormal, false);
|
||||
}
|
||||
if (data.voidSaleCount > 0) {
|
||||
print3ColumnsStringWithAlign("(" + data.voidSaleCount + ")",
|
||||
"VOID",
|
||||
"- " + PrintUtils.getInstance().getSeparatorNumberFormat(data.voidSaleAmount, isDecimalEnabled),
|
||||
fontNormal, false);
|
||||
}
|
||||
|
||||
if (data.refundCount > 0) {
|
||||
print3ColumnsStringWithAlign("(" + data.refundCount + ")",
|
||||
"REFUND",
|
||||
"- " + PrintUtils.getInstance().getSeparatorNumberFormat(data.refundAmount, isDecimalEnabled),
|
||||
fontNormal, false);
|
||||
}
|
||||
if (data.cashOutCount > 0) {
|
||||
print3ColumnsStringWithAlign("(" + data.cashOutCount + ")",
|
||||
"CASH ADV",
|
||||
PrintUtils.getInstance().getSeparatorNumberFormat(data.cashOutAmount, isDecimalEnabled),
|
||||
fontNormal, false);
|
||||
}
|
||||
|
||||
if (data.preAuthCompCount > 0) {
|
||||
print3ColumnsStringWithAlign("(" + data.preAuthCompCount + ")",
|
||||
"PREAUTH COMP",
|
||||
PrintUtils.getInstance().getSeparatorNumberFormat(data.preAuthCompAmount, isDecimalEnabled),
|
||||
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) {
|
||||
print3ColumnsStringWithAlign("(" + data.refundCount + ")",
|
||||
"REFUND",
|
||||
"- " + PrintUtils.getInstance().getSeparatorNumberFormat(data.refundAmount, isDecimalEnabled),
|
||||
fontNormal, false);
|
||||
}
|
||||
|
||||
if (data.preAuthCompCount > 0) {
|
||||
print3ColumnsStringWithAlign("(" + data.preAuthCompCount + ")",
|
||||
"PREAUTH COMP",
|
||||
PrintUtils.getInstance().getSeparatorNumberFormat(data.preAuthCompAmount, isDecimalEnabled),
|
||||
fontNormal, false);
|
||||
}
|
||||
}
|
||||
|
||||
dotBreak();
|
||||
|
||||
long totalAmount =
|
||||
(data.saleAmount + data.cashOutAmount + data.preAuthCompAmount)
|
||||
- (data.voidSaleAmount + data.refundAmount + data.preAuthCompVoidAmount);
|
||||
long totalAmount = isQrHost
|
||||
? data.qrPayAmount - data.qrRefundAmount
|
||||
: (data.saleAmount + data.cashOutAmount + data.preAuthSaleAmount + data.preAuthCompAmount)
|
||||
- (data.voidSaleAmount + data.preAuthVoidAmount + data.refundAmount + data.preAuthCompVoidAmount);
|
||||
|
||||
printer.appendPrnStr( "TOTAL"+ " " + currencyCodeToText(currency),
|
||||
PrintUtils.getInstance().getSeparatorNumberFormat(totalAmount, isDecimalEnabled),
|
||||
PrintUtils.getInstance().getSeparatorNumberFormat(totalAmount, isQrHost ? isQrDecimalEnabled : isDecimalEnabled),
|
||||
fontNormal, false);
|
||||
|
||||
emptyLine(2);
|
||||
|
||||
@ -456,7 +456,7 @@ public class PrintXImpl extends BaseXPrint implements PrintX {
|
||||
printLogo();
|
||||
printMerchantHeader();
|
||||
printTranHeader("SUMMARY REPORT");
|
||||
printTransDetailSummary(payDetail, list);
|
||||
printTransDetailSummary(payDetail, list, hostType);
|
||||
startPrintNex();
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user