The goal of this application is to allow the user to add and view accounting transactions.
It allows the user to add expenses, payments, and to view their current balance.
Additionally, the user is able to view their transactions. If they would like, they can view all transactions, or filter them by payments or expenses.
For now, instead of using a database, each transaction is stores in a file called transactions.csv.
This is the main screen that users will encounter when working with the application.
Users are able to:
- Add an expense
- Add income
- Access the ledger screen
- View their current balance
The ledger is what stores user transactions, whether it be an expense or income. The user is able to view all transactions, only expenses, or only income. Users are able to also view custom pre-defined reports to further fine tune their ability to view transactions.
Custom reports include the ability to search:
Month to Date | Year to Date | Search by Vendor
Previous Month | Previous Year | Custom Search...
Users are able to view the current balance of their ledger
I chose this piece of code because it uses a simple ternary operator, and also easily checks each transaction for whether it satisfies all the filters. As soon as one does not satisfy it, it moves on. Only when it satisfies all the search criteria will it add it to the output.
case 6:
System.out.print("\n-----------------Leave field blank if you do not want to search with that filter-----------------\n");
System.out.println("-----------------------------------Everything is optional----------------------------------------\n");
Map<String, String> filters = new HashMap<>();
System.out.print("Start Date i.e 1999-02-18: ");
String startDateSearch = scanner.hasNextLine() ? scanner.nextLine() : "";
System.out.print("End Date i.e 1997-10-29: ");
String endDateSearch = scanner.hasNextLine() ? scanner.nextLine() : "";
System.out.print("Transaction description: ");
String descriptionSearch = scanner.hasNextLine() ? scanner.nextLine() : "";
System.out.print("Transaction vendor/payer: ");
String vendorSearch = scanner.hasNextLine() ? scanner.nextLine() : "";
System.out.print("Transaction amount: ");
String amountSearch = scanner.hasNextLine() ? scanner.nextLine() : "";
if (!Objects.equals(startDateSearch, "")) {
filters.put("startDateSearch", startDateSearch);
}
if (!Objects.equals(endDateSearch, "")) {
filters.put("endDateSearch", endDateSearch);
}
if (!Objects.equals(descriptionSearch, "")) {
filters.put("descriptionSearch", descriptionSearch);
}
if (!Objects.equals(vendorSearch, "")) {
filters.put("vendorSearch", vendorSearch);
}
if (!Objects.equals(amountSearch, "")) {
filters.put("amountSearch", amountSearch);
}
List<String> filteredLedger = filterSearch(filters);
output.addAll(filteredLedger);
break;