Compare commits
2 Commits
88a5d064b5
...
9a55fadcf0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a55fadcf0 | ||
|
|
d145cf321f |
@ -51,6 +51,8 @@ public class TransactionSummaryFragment extends DataBindingFragment {
|
|||||||
final Calendar myCalendar = Calendar.getInstance();
|
final Calendar myCalendar = Calendar.getInstance();
|
||||||
final Calendar myCalendar2 = Calendar.getInstance();
|
final Calendar myCalendar2 = Calendar.getInstance();
|
||||||
|
|
||||||
|
ArrayList<PayDetail> filteredLists = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initViewModel() {
|
protected void initViewModel() {
|
||||||
managementViewModel = getFragmentScopeViewModel(ManagementViewModel.class);
|
managementViewModel = getFragmentScopeViewModel(ManagementViewModel.class);
|
||||||
@ -251,13 +253,12 @@ public class TransactionSummaryFragment extends DataBindingFragment {
|
|||||||
Counter refund = new Counter();
|
Counter refund = new Counter();
|
||||||
|
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy HH:mm", Locale.getDefault());
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy HH:mm", Locale.getDefault());
|
||||||
ArrayList<PayDetail> filteredLists = new ArrayList<>();
|
|
||||||
|
|
||||||
// Filter transactions by date
|
|
||||||
for (PayDetail pay : payDetailList) {
|
for (PayDetail pay : payDetailList) {
|
||||||
try {
|
try {
|
||||||
Date transDate = formatter.parse(pay.getTransDate());
|
Date transDate = formatter.parse(pay.getTransDate());
|
||||||
if (yesterday.compareTo(transDate) <= 0) {
|
if ((transDate.after(start) || transDate.equals(start)) &&
|
||||||
|
(transDate.before(end) || transDate.equals(end))) {
|
||||||
filteredLists.add(pay);
|
filteredLists.add(pay);
|
||||||
}
|
}
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
@ -366,7 +367,7 @@ public class TransactionSummaryFragment extends DataBindingFragment {
|
|||||||
private void printReceipt(PayDetail payDetail) {
|
private void printReceipt(PayDetail payDetail) {
|
||||||
try {
|
try {
|
||||||
LogUtil.d(TAG, "Starting receipt print");
|
LogUtil.d(TAG, "Starting receipt print");
|
||||||
PrintXReceipt.getInstance().printSmileSummaryReport(payDetail, sharedViewModel.hostType.getValue(), new PrintXStatus() {
|
PrintXReceipt.getInstance().printSmileSummaryReport(payDetail, filteredLists, sharedViewModel.hostType.getValue(), new PrintXStatus() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
LogUtil.d(TAG, "Receipt printed successfully");
|
LogUtil.d(TAG, "Receipt printed successfully");
|
||||||
|
|||||||
@ -760,6 +760,159 @@ public abstract class BaseXPrint {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TempSummary {
|
||||||
|
int saleCount, voidSaleCount, refundCount, cashOutCount;
|
||||||
|
int qrPayCount, qrRefundCount;
|
||||||
|
int preAuthCompCount, preAuthCompVoidCount;
|
||||||
|
|
||||||
|
long saleAmount, voidSaleAmount, refundAmount, cashOutAmount;
|
||||||
|
long qrPayAmount, qrRefundAmount;
|
||||||
|
long preAuthCompAmount, preAuthCompVoidAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void printTransDetailSummary(PayDetail payDetail, List<PayDetail> list) {
|
||||||
|
|
||||||
|
if (list == null || list.isEmpty()) {
|
||||||
|
printErrorBlock("NO TRANSACTION FOUND");
|
||||||
|
printer.appendPrnStr("\n", fontNormal, AlignEnum.LEFT,false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, TempSummary> currencyMap = new HashMap<>();
|
||||||
|
|
||||||
|
for (PayDetail item : list) {
|
||||||
|
|
||||||
|
if (item == null) continue;
|
||||||
|
|
||||||
|
String currency = item.getCurrencyCode();
|
||||||
|
TempSummary s = currencyMap.get(currency);
|
||||||
|
|
||||||
|
if (s == null) {
|
||||||
|
s = new TempSummary();
|
||||||
|
currencyMap.put(currency, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
String transType = item.getTransType();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isQrDecimalEnabled = SystemParamsOperation.getInstance().isQrDecimalEnable();
|
||||||
|
boolean isDecimalEnabled = SystemParamsOperation.getInstance().getDecimalEnable();
|
||||||
|
|
||||||
|
for (String currency : currencyMap.keySet()) {
|
||||||
|
|
||||||
|
TempSummary data = currencyMap.get(currency);
|
||||||
|
|
||||||
|
printer.appendPrnStr( currencyCodeToText(currency) + " " +"Transactions", fontNormal, AlignEnum.LEFT, false);
|
||||||
|
emptyLine(1);
|
||||||
|
|
||||||
|
printer.appendPrnStr("(COUNT)TRANS", "AMOUNT(" + currencyCodeToText(currency) + ")", fontNormal, false);
|
||||||
|
|
||||||
|
if (data.saleCount > 0) {
|
||||||
|
printer.appendPrnStr("(" + data.saleCount + ")SALES",
|
||||||
|
PrintUtils.getInstance().getSeparatorNumberFormat(data.saleAmount, isDecimalEnabled),
|
||||||
|
fontNormal, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.voidSaleCount > 0) {
|
||||||
|
printer.appendPrnStr("(" + data.voidSaleCount + ")VOID SALES",
|
||||||
|
"- " + PrintUtils.getInstance().getSeparatorNumberFormat(data.voidSaleAmount, isDecimalEnabled),
|
||||||
|
fontNormal, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.cashOutCount > 0) {
|
||||||
|
printer.appendPrnStr("(" + data.cashOutCount + ")CASH OUT",
|
||||||
|
PrintUtils.getInstance().getSeparatorNumberFormat(data.cashOutAmount, isDecimalEnabled),
|
||||||
|
fontNormal, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.refundCount > 0) {
|
||||||
|
printer.appendPrnStr("(" + data.refundCount + ")REFUND",
|
||||||
|
"- " + PrintUtils.getInstance().getSeparatorNumberFormat(data.refundAmount, isDecimalEnabled),
|
||||||
|
fontNormal, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.preAuthCompCount > 0) {
|
||||||
|
printer.appendPrnStr("(" + data.preAuthCompCount + ")PREAUTH COMP",
|
||||||
|
PrintUtils.getInstance().getSeparatorNumberFormat(data.preAuthCompAmount, isDecimalEnabled),
|
||||||
|
fontNormal, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.preAuthCompVoidCount > 0) {
|
||||||
|
printer.appendPrnStr("(" + data.preAuthCompVoidCount + ")VOID PREAUTH COMPLETE",
|
||||||
|
"- " + PrintUtils.getInstance().getSeparatorNumberFormat(data.preAuthCompVoidAmount, isDecimalEnabled),
|
||||||
|
fontNormal, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.qrPayCount > 0) {
|
||||||
|
printer.appendPrnStr("(" + data.qrPayCount + ")QR PAY",
|
||||||
|
PrintUtils.getInstance().getSeparatorNumberFormat(data.qrPayAmount, isQrDecimalEnabled),
|
||||||
|
fontNormal, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.qrRefundCount > 0) {
|
||||||
|
printer.appendPrnStr("(" + data.qrRefundCount + ")QR REFUND",
|
||||||
|
"- " + PrintUtils.getInstance().getSeparatorNumberFormat(data.qrRefundAmount, isQrDecimalEnabled),
|
||||||
|
fontNormal, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
dotBreak();
|
||||||
|
|
||||||
|
long totalAmount =
|
||||||
|
(data.saleAmount + data.cashOutAmount + data.preAuthCompAmount + data.qrPayAmount)
|
||||||
|
- (data.voidSaleAmount + data.refundAmount + data.preAuthCompVoidAmount + data.qrRefundAmount);
|
||||||
|
|
||||||
|
printer.appendPrnStr(currencyCodeToText(currency) + " " + "TOTAL",
|
||||||
|
PrintUtils.getInstance().getSeparatorNumberFormat(totalAmount, isDecimalEnabled),
|
||||||
|
fontNormal, false);
|
||||||
|
|
||||||
|
emptyLine(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* private void backup(){
|
/* private void backup(){
|
||||||
SettleData settleData = payDetail.getSettleDataObj();
|
SettleData settleData = payDetail.getSettleDataObj();
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,8 @@ public interface PrintX {
|
|||||||
|
|
||||||
void printSmileSummaryReport(PayDetail payDetail, HostType hostType, PrintXStatus printXStatus);
|
void printSmileSummaryReport(PayDetail payDetail, HostType hostType, PrintXStatus printXStatus);
|
||||||
|
|
||||||
|
void printSmileSummaryReport(PayDetail payDetail, List<PayDetail> list, HostType hostType, PrintXStatus printXStatus);
|
||||||
|
|
||||||
void printSmileSettlementReport(PayDetail payDetail,PrintXStatus printXStatus);
|
void printSmileSettlementReport(PayDetail payDetail,PrintXStatus printXStatus);
|
||||||
|
|
||||||
void printQRSettlementReport(PayDetail payDetail, List<QRSettleData> list, PrintXStatus printXStatus);
|
void printQRSettlementReport(PayDetail payDetail, List<QRSettleData> list, PrintXStatus printXStatus);
|
||||||
|
|||||||
@ -223,6 +223,8 @@ public class PrintXImpl extends BaseXPrint implements PrintX {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void printDetailReport(PayDetail payDetail, List<PayDetail> lists, HostType hostType,PrintXStatus printXStatus) {
|
public void printDetailReport(PayDetail payDetail, List<PayDetail> lists, HostType hostType,PrintXStatus printXStatus) {
|
||||||
this.callbackStatus = printXStatus;
|
this.callbackStatus = printXStatus;
|
||||||
@ -431,7 +433,6 @@ public class PrintXImpl extends BaseXPrint implements PrintX {
|
|||||||
this.callbackStatus = printXStatus;
|
this.callbackStatus = printXStatus;
|
||||||
try {
|
try {
|
||||||
// LogUtil.d(TAG, payDetail.getSettleDataObj().toString());
|
// LogUtil.d(TAG, payDetail.getSettleDataObj().toString());
|
||||||
|
|
||||||
setHeight(0x12);
|
setHeight(0x12);
|
||||||
printLogo();
|
printLogo();
|
||||||
printMerchantHeader();
|
printMerchantHeader();
|
||||||
@ -447,6 +448,21 @@ public class PrintXImpl extends BaseXPrint implements PrintX {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void printSmileSummaryReport(PayDetail payDetail, List<PayDetail> list, HostType hostType, PrintXStatus printXStatus) {
|
||||||
|
this.callbackStatus = printXStatus;
|
||||||
|
try {
|
||||||
|
setHeight(0x12);
|
||||||
|
printLogo();
|
||||||
|
printMerchantHeader();
|
||||||
|
printTranHeader("SUMMARY REPORT");
|
||||||
|
printTransDetailSummary(payDetail, list);
|
||||||
|
startPrintNex();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void printTerminalConfig(PrintXStatus printXStatus) {
|
public void printTerminalConfig(PrintXStatus printXStatus) {
|
||||||
this.callbackStatus = printXStatus;
|
this.callbackStatus = printXStatus;
|
||||||
|
|||||||
@ -59,6 +59,9 @@ public class PrintXReceipt {
|
|||||||
public void printSmileSummaryReport(PayDetail payDetail, HostType hostType, PrintXStatus printXStatus) {
|
public void printSmileSummaryReport(PayDetail payDetail, HostType hostType, PrintXStatus printXStatus) {
|
||||||
printX.printSmileSummaryReport(payDetail, hostType, printXStatus);
|
printX.printSmileSummaryReport(payDetail, hostType, printXStatus);
|
||||||
}
|
}
|
||||||
|
public void printSmileSummaryReport(PayDetail payDetail,List<PayDetail> list, HostType hostType, PrintXStatus printXStatus) {
|
||||||
|
printX.printSmileSummaryReport(payDetail, list, hostType, printXStatus);
|
||||||
|
}
|
||||||
|
|
||||||
public void printTerminalHostConfig(PrintXStatus printXStatus){
|
public void printTerminalHostConfig(PrintXStatus printXStatus){
|
||||||
printX.printTerminalConfig(printXStatus);
|
printX.printTerminalConfig(printXStatus);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user