From dd57975908f26cd230771b21d9c630731d6d04ca Mon Sep 17 00:00:00 2001 From: riz081 Date: Fri, 8 Aug 2025 15:10:48 +0700 Subject: [PATCH] history --- .../bdkipoc/histori/HistoryActivity.java | 46 +++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/example/bdkipoc/histori/HistoryActivity.java b/app/src/main/java/com/example/bdkipoc/histori/HistoryActivity.java index c76126d..d95977d 100644 --- a/app/src/main/java/com/example/bdkipoc/histori/HistoryActivity.java +++ b/app/src/main/java/com/example/bdkipoc/histori/HistoryActivity.java @@ -156,7 +156,7 @@ public class HistoryActivity extends AppCompatActivity { historyItem.setDate(formatDate(transactionDate)); historyItem.setAmount((long) amountValue); historyItem.setChannelName(formatChannelName(channelCode)); - historyItem.setStatus(status); + historyItem.setStatus(status.toUpperCase()); // Ensure uppercase for consistency historyItem.setReferenceId(referenceId); historyItem.setFullDate(transactionDate); historyItem.setChannelCode(channelCode); @@ -194,17 +194,21 @@ public class HistoryActivity extends AppCompatActivity { JSONObject item = dataArray.getJSONObject(i); String amount = item.getString("amount"); + String status = item.getString("status"); - // Parse amount safely - double amountValue = 0; - try { - amountValue = Double.parseDouble(amount); - } catch (NumberFormatException e) { - amountValue = 0; + // Only count if status is settlement or success + if ("SETTLEMENT".equalsIgnoreCase(status) || "SUCCESS".equalsIgnoreCase(status)) { + // Parse amount safely + double amountValue = 0; + try { + amountValue = Double.parseDouble(amount); + } catch (NumberFormatException e) { + amountValue = 0; + } + + totalAmount += (long) amountValue; + totalTransactions++; } - - totalAmount += (long) amountValue; - totalTransactions++; } final long finalTotalAmount = totalAmount; @@ -509,20 +513,26 @@ class HistoryAdapter extends RecyclerView.Adapter