Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug: find-tx-by-customer & duration not shown when add-tx with 1 day #217

Merged
merged 4 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/parser/TransactionParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static void parseFindTxsByCustomer(String userInput) {
System.out.println(FIND_TRANSACTION_BY_CUSTOMER_FORMAT);
return;
}
TransactionList.findTxsByCustomer(words[2].toLowerCase());
TransactionList.findTxsByCustomer(words[2]);
}

public static void parseRemoveTx(String userInput){
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/transaction/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public String getTransactionId() {

private String durationtoString(){
if(duration == 1) {
return " day";
return "1 day";
} else {
return duration + " days";
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/transaction/TransactionList.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,13 @@ public static void findTxsByCustomer(String customer) {
for (Transaction transaction : transactionList) {
// Assert that each transaction is not null
assert transaction != null : "Transaction in the list should not be null.";
if (transaction.getCustomer().toLowerCase().contains(customer)) {
if (transaction.getCustomer().toLowerCase().contains(customer.toLowerCase())) {
found = true;
System.out.println(transaction);
}
}
if (!found) {
System.out.println("none");
System.out.println("None");
}
}
Comment on lines 216 to 226

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


Expand Down
2 changes: 1 addition & 1 deletion src/test/java/transaction/TransactionListTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ void testFindTxsByCustomerNoMatches() {
TransactionList.findTxsByCustomer("Alice Johnson");

String expectedOutput = "Transaction(s) by Alice Johnson found:" + System.lineSeparator() +
"none" + System.lineSeparator();
"None" + System.lineSeparator();
assertEquals(expectedOutput, outContent.toString(), "Should indicate that no transactions was found");
}

Expand Down
Loading