File tree Expand file tree Collapse file tree
test/java/nustorage/logic/commands Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,11 +52,15 @@ Format: `sell_inventory i/ITEM n/NUMBER`
5252
5353
5454### List inventory records: ` list_inventory `
55-
56- Adds and stores finance records into finance records
55+ Shows the items in the current Inventory
5756
5857Format: ` list_inventory `
5958
59+ ### List inventory records: ` view_inventory_records `
60+ Shows the movement of inventory
61+
62+ Format: ` view_inventory_records `
63+
6064
6165### Add finance records: ` add_finance `
6266Adds and stores finance records into finance records
Original file line number Diff line number Diff line change 1+ package nustorage .logic .commands ;
2+
3+ import static java .util .Objects .requireNonNull ;
4+
5+ import nustorage .logic .commands .exceptions .CommandException ;
6+ import nustorage .model .Model ;
7+
8+ public class ListFinanceRecordsCommand extends Command {
9+
10+ public static final String COMMAND_WORD = "list_finance" ;
11+
12+ public static final String MESSAGE_SUCCESS = "Listed all finance records:\n %1$s" ;
13+
14+ public static final String MESSAGE_EMPTY_LIST = "No finance records listed" ;
15+
16+ @ Override
17+ public CommandResult execute (Model model ) throws CommandException {
18+ requireNonNull (model );
19+ if (model .viewFinanceRecords ().isEmpty ()) {
20+ return new CommandResult (MESSAGE_EMPTY_LIST );
21+ }
22+ return new CommandResult (String .format (MESSAGE_SUCCESS , model .viewFinanceRecords ()));
23+ }
24+ }
Original file line number Diff line number Diff line change 1919import nustorage .logic .commands .HelpCommand ;
2020import nustorage .logic .commands .ListCommand ;
2121import nustorage .logic .commands .ListInventoryCommand ;
22+ import nustorage .logic .commands .ListFinanceRecordsCommand ;
2223import nustorage .logic .parser .exceptions .ParseException ;
2324
2425/**
@@ -68,6 +69,9 @@ public Command parseCommand(String userInput) throws ParseException {
6869 case DeleteCommand .COMMAND_WORD :
6970 return new DeleteCommandParser ().parse (arguments );
7071
72+ case ListFinanceRecordsCommand .COMMAND_WORD :
73+ return new ListFinanceRecordsCommand ();
74+
7175 case ClearCommand .COMMAND_WORD :
7276 return new ClearCommand ();
7377
Original file line number Diff line number Diff line change @@ -21,6 +21,10 @@ public FinanceAccount(List<FinanceRecord> financeRecords) {
2121 this .financeRecords = financeRecords ;
2222 }
2323
24+ public List <FinanceRecord > getFinanceRecords () {
25+ return this .financeRecords ;
26+ }
27+
2428 public void addRecord (FinanceRecord record ) {
2529 financeRecords .add (record );
2630 }
@@ -59,6 +63,10 @@ public List<FinanceRecord> filterRecords (Predicate<FinanceRecord> filter) {
5963 return financeRecords .stream ().filter (filter ).collect (Collectors .toList ());
6064 }
6165
66+ public boolean isEmpty () {
67+ return financeRecords .isEmpty ();
68+ }
69+
6270 @ Override
6371 public String toString () {
6472 return financeRecords .stream ()
Original file line number Diff line number Diff line change 11package nustorage .model ;
22
33import java .nio .file .Path ;
4+ import java .util .List ;
45import java .util .Optional ;
56import java .util .function .Predicate ;
67
@@ -41,6 +42,8 @@ public interface Model {
4142
4243 void addFinanceRecord (FinanceRecord newRecord );
4344
45+ List <FinanceRecord > viewFinanceRecords ();
46+
4447 Optional <FinanceRecord > deleteFinanceRecord (Index targetIndex );
4548
4649 void addInventoryRecord (InventoryRecord inventoryRecord );
Original file line number Diff line number Diff line change 44import static nustorage .commons .util .CollectionUtil .requireAllNonNull ;
55
66import java .nio .file .Path ;
7+ import java .util .List ;
78import java .util .Optional ;
89import java .util .function .Predicate ;
910import java .util .logging .Logger ;
@@ -114,6 +115,11 @@ public void addFinanceRecord(FinanceRecord newRecord) {
114115 financeAccount .addRecord (newRecord );
115116 }
116117
118+ @ Override
119+ public List <FinanceRecord > viewFinanceRecords () {
120+ return financeAccount .getFinanceRecords ();
121+ }
122+
117123 @ Override
118124 public Optional <FinanceRecord > deleteFinanceRecord (Index targetIndex ) {
119125 return financeAccount .removeRecord (targetIndex );
Original file line number Diff line number Diff line change 99import java .nio .file .Path ;
1010import java .util .ArrayList ;
1111import java .util .Arrays ;
12+ import java .util .List ;
1213import java .util .Optional ;
1314import java .util .function .Predicate ;
1415
@@ -115,6 +116,11 @@ public void addFinanceRecord(FinanceRecord newRecord) {
115116
116117 }
117118
119+ @ Override
120+ public List <FinanceRecord > viewFinanceRecords () {
121+ return null ;
122+ }
123+
118124 @ Override
119125 public Optional <FinanceRecord > deleteFinanceRecord (Index targetIndex ) {
120126 return Optional .empty ();
You can’t perform that action at this time.
0 commit comments