Update TransactionSummaryFragment.java
This commit is contained in:
parent
18eda34bff
commit
cb96ccb7ca
@ -226,10 +226,15 @@ public class TransactionSummaryFragment extends DataBindingFragment {
|
||||
}
|
||||
}
|
||||
|
||||
private SettleData processTransactionData(List<PayDetail> payDetailList, SimpleDateFormat formatter,
|
||||
Date yesterday, Date start, Date end) {
|
||||
private SettleData processTransactionData(List<PayDetail> payDetailList,
|
||||
SimpleDateFormat formatter,
|
||||
Date yesterday,
|
||||
Date start,
|
||||
Date end) {
|
||||
try {
|
||||
// Create a local helper class for readable mutability
|
||||
// ✅ IMPORTANT: clear old data
|
||||
filteredLists.clear();
|
||||
|
||||
class Counter {
|
||||
int count = 0;
|
||||
long amount = 0L;
|
||||
@ -252,37 +257,32 @@ public class TransactionSummaryFragment extends DataBindingFragment {
|
||||
Counter preAuthCompVoid = new Counter();
|
||||
Counter refund = new Counter();
|
||||
|
||||
// ✅ Use ONE consistent format
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy HH:mm", Locale.getDefault());
|
||||
|
||||
|
||||
for (PayDetail pay : payDetailList) {
|
||||
try {
|
||||
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 {
|
||||
// ✅ Combine date + time correctly
|
||||
Date currentDate = sdf.parse(pay.transDate + " " + pay.transTime);
|
||||
|
||||
if ((currentDate.after(start) || currentDate.equals(start)) &&
|
||||
(currentDate.before(end) || currentDate.equals(end))) {
|
||||
if (currentDate == null) continue;
|
||||
|
||||
// ✅ 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 (pay.getTransactionType() == TransactionsType.MMQR.value && pay.getQrTransStatus() == 1) {
|
||||
wave.inc(pay.amount);
|
||||
} else if (pay.getTransactionType() == TransactionsType.MMQR_REFUND.value && pay.getQrTransStatus() == 1) {
|
||||
waveRefund.inc(pay.amount);
|
||||
}
|
||||
|
||||
} else if (sharedViewModel.hostType.getValue() == HostType.MPU) {
|
||||
|
||||
if (pay.getTransactionType() == TransactionsType.VOID.value) {
|
||||
voidTran.inc(pay.amount);
|
||||
} else if (pay.getTransactionType() == TransactionsType.SALE.value) {
|
||||
@ -302,11 +302,14 @@ public class TransactionSummaryFragment extends DataBindingFragment {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (ParseException e) {
|
||||
LogUtil.e(TAG, "Error parsing transaction datetime: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
LogUtil.d(TAG, "Filtered transactions count: " + filteredLists.size());
|
||||
|
||||
return new SettleData(
|
||||
sale.count, sale.amount,
|
||||
wave.count, wave.amount,
|
||||
@ -319,6 +322,7 @@ public class TransactionSummaryFragment extends DataBindingFragment {
|
||||
refund.count, refund.amount,
|
||||
waveRefund.count, waveRefund.amount
|
||||
);
|
||||
|
||||
} catch (Exception e) {
|
||||
LogUtil.e(TAG, "Error processing transaction data: " + e.getMessage());
|
||||
return null;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user