Compare commits

..

No commits in common. "8b49927b79560481e156cdfb3fdbaaaadd904e33" and "4a2a7fca67e10c01bee5d1606bd01a200f08c497" have entirely different histories.

2 changed files with 22 additions and 26 deletions

View File

@ -226,15 +226,10 @@ public class TransactionSummaryFragment extends DataBindingFragment {
} }
} }
private SettleData processTransactionData(List<PayDetail> payDetailList, private SettleData processTransactionData(List<PayDetail> payDetailList, SimpleDateFormat formatter,
SimpleDateFormat formatter, Date yesterday, Date start, Date end) {
Date yesterday,
Date start,
Date end) {
try { try {
// IMPORTANT: clear old data // Create a local helper class for readable mutability
filteredLists.clear();
class Counter { class Counter {
int count = 0; int count = 0;
long amount = 0L; long amount = 0L;
@ -257,32 +252,37 @@ public class TransactionSummaryFragment extends DataBindingFragment {
Counter preAuthCompVoid = new Counter(); Counter preAuthCompVoid = new Counter();
Counter refund = new Counter(); Counter refund = new Counter();
// Use ONE consistent format
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy HH:mm", Locale.getDefault()); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy HH:mm", Locale.getDefault());
for (PayDetail pay : payDetailList) { for (PayDetail pay : payDetailList) {
try { try {
// Combine date + time correctly Date transDate = formatter.parse(pay.getTransDate());
if ((transDate.after(start) || transDate.equals(start)) &&
(transDate.before(end) || transDate.equals(end))) {
filteredLists.add(pay);
}
} catch (ParseException e) {
LogUtil.e(TAG, "Error parsing transaction date: " + e.getMessage());
}
}
LogUtil.d(TAG, "Filtered transactions count: " + filteredLists.size());
// Process filtered transactions
for (PayDetail pay : filteredLists) {
try {
Date currentDate = sdf.parse(pay.transDate + " " + pay.transTime); Date currentDate = sdf.parse(pay.transDate + " " + pay.transTime);
if (currentDate == null) continue; if ((currentDate.after(start) || currentDate.equals(start)) &&
(currentDate.before(end) || currentDate.equals(end))) {
// Correct inclusive range check
if (!currentDate.before(start) && !currentDate.after(end)) {
// Keep filtered list for printing
filteredLists.add(pay);
if (sharedViewModel.hostType.getValue() == HostType.QR) { if (sharedViewModel.hostType.getValue() == HostType.QR) {
if (pay.getTransactionType() == TransactionsType.MMQR.value && pay.getQrTransStatus() == 1) { if (pay.getTransactionType() == TransactionsType.MMQR.value && pay.getQrTransStatus() == 1) {
wave.inc(pay.amount); wave.inc(pay.amount);
} else if (pay.getTransactionType() == TransactionsType.MMQR_REFUND.value && pay.getQrTransStatus() == 1) { } else if (pay.getTransactionType() == TransactionsType.MMQR_REFUND.value && pay.getQrTransStatus() == 1) {
waveRefund.inc(pay.amount); waveRefund.inc(pay.amount);
} }
} else if (sharedViewModel.hostType.getValue() == HostType.MPU) { } else if (sharedViewModel.hostType.getValue() == HostType.MPU) {
if (pay.getTransactionType() == TransactionsType.VOID.value) { if (pay.getTransactionType() == TransactionsType.VOID.value) {
voidTran.inc(pay.amount); voidTran.inc(pay.amount);
} else if (pay.getTransactionType() == TransactionsType.SALE.value) { } else if (pay.getTransactionType() == TransactionsType.SALE.value) {
@ -302,14 +302,11 @@ public class TransactionSummaryFragment extends DataBindingFragment {
} }
} }
} }
} catch (ParseException e) { } catch (ParseException e) {
LogUtil.e(TAG, "Error parsing transaction datetime: " + e.getMessage()); LogUtil.e(TAG, "Error parsing transaction datetime: " + e.getMessage());
} }
} }
LogUtil.d(TAG, "Filtered transactions count: " + filteredLists.size());
return new SettleData( return new SettleData(
sale.count, sale.amount, sale.count, sale.amount,
wave.count, wave.amount, wave.count, wave.amount,
@ -322,7 +319,6 @@ public class TransactionSummaryFragment extends DataBindingFragment {
refund.count, refund.amount, refund.count, refund.amount,
waveRefund.count, waveRefund.amount waveRefund.count, waveRefund.amount
); );
} catch (Exception e) { } catch (Exception e) {
LogUtil.e(TAG, "Error processing transaction data: " + e.getMessage()); LogUtil.e(TAG, "Error processing transaction data: " + e.getMessage());
return null; return null;

View File

@ -524,7 +524,7 @@ public abstract class BaseXPrint {
printer.appendPrnStr("BTH NO:" + batchNum, fontNormal, AlignEnum.LEFT,false); printer.appendPrnStr("BTH NO:" + batchNum, fontNormal, AlignEnum.LEFT,false);
} else { } else {
// printer.printColumnsString(new String[]{"BATCH NO :" + batchNum, "INV NO: " + invoiceNo}, new int[]{2, 2}, new int[]{0, 2}, null); // printer.printColumnsString(new String[]{"BATCH NO :" + batchNum, "INV NO: " + invoiceNo}, new int[]{2, 2}, new int[]{0, 2}, null);
printer.appendPrnStr("BTH NO:" + batchNum + " INV NO:" + invoiceNo, fontNormal, AlignEnum.LEFT,false); printer.appendPrnStr("BTH NO:" + batchNum + " TRACE NO:" + traceNo, fontNormal, AlignEnum.LEFT,false);
} }
// printer.appendPrnStr("\n", fontNormal, AlignEnum.LEFT,false); // printer.appendPrnStr("\n", fontNormal, AlignEnum.LEFT,false);