Skip to content

Commit

Permalink
Merge branch 'master' into ug-delete-command
Browse files Browse the repository at this point in the history
# Conflicts:
#	docs/DeveloperGuide.md
  • Loading branch information
ElginL committed Oct 21, 2022
2 parents e5649c6 + 4edb35b commit 1fa7ecd
Show file tree
Hide file tree
Showing 13 changed files with 297 additions and 4 deletions.
80 changes: 76 additions & 4 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ Step 1. The user launches the application. The `UiManager` will call on the `Mai

![FilterTransState0](images/FilterTransState0.png)

Step 2. The user executes `filter buy` command to filter all the buy transactions from all the clients. This is done by calling the
Step 2. The user executes `filter buy` command to filter all the buy transactions from all the clients. This is done by calling the
`Client#getBuyTransactionList()` which returns an unmodifiable view of the buy transaction list.


Expand Down Expand Up @@ -287,6 +287,80 @@ The following activity diagram summarizes what happens when a user executes the
* Pros: Performs faster as the command only filters through one client. Also able to know which client the transactions are from.
* Cons: User would have to manually select each client and filter the transactions.

### \[Proposed\] Buy feature for transactions

The proposed sort mechanism is facilitated by `BuyCommand`. It extends `Command` and `BuyCommandParser` which extends from `Parser`.
To invoke the buy command, `BuyCommandParser` will parse the arguments from the user input via `BuyCommandParser#parse()` and returns the buy command
if the arguments are valid.

`BuyCommand` implements the `BuyCommandParser#execute()` operation which executes the command and returns the result message in a
`CommandResult` object.

The operation is exposed in the `logic` interface as `Logic#execute()`.

Given below is an example usage scenario and how the buy transaction mechanism behaves at each step.

Step 1. The user launches the application. The `UiManager` will call on the `MainWindow` to invoke the UI which displays the clients.

![BuyState0](images/BuyState0-initial_state.png)

Step 2. The user executes `buy 1 q/10 g/Apple p/0.5 d/17/05/2000` command to add a buy transaction of 10 apples at $0.50 each on the 17/05/2000 to the
client at index 1.

Step 3. The `Execute` of `BuyCommand` will call `Model#getFilteredClientList()` to get the list of clients. `List<Client>#get()` is called to
get the client at the index to copy. The `BuyTransaction` is then added to the copied client by calling `Client#addTransaction(Transaction)`.
The copied client is replaced with the client at the index by calling `Model#setClient(Client, Client)`.

The following sequence diagrams shows how the buy operation works:

![BuyCommandSequenceDiagram](images/BuyCommandSequenceDiagram.png)

<div markdown="span" class="alert alert-info">:information_source: **Note:** The lifeline for `BuyCommand` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram.

</div>

The following activity diagram summarizes what happens when a user executes the buy command:

<img src="images/BuyCommandActivityDiagram.png" width="250" />

#### Design considerations:

**Aspect: How buy transaction executes:**

* **Alternative 1 (current choice):** Add buy transaction by into each client.
* Pros: Easy to implement and allow the user to see all the buy transactions for each client via view command.
* Cons: Users cannot see all buy transaction of every client at one time.
* **Alternative 2:** Add buy transaction to JeeqTracker instead of per client.
* Pros: Easy to see every past buy transaction with all the clients.
* Cons: Users may be overwhelmed if there are too many transactions. Also cannot distintively see which buy transaction belongs to which client.

_{more aspects and alternatives to be added}_

--------------------------------------------------------------------------------------------------------------
### \[Proposed\] Editing feature for transactions
#### Implementation
The edit transaction mechanism is facilitated by EditTransactionCommand which extends from `EditCommand` (which extends from `Command`) and
`EditCommandParser` which extends from `Parser`. To invoke the edit command, `EditCommandParser` will parse the arguments from user input with
`EditCommandParser#parse()` and returns the edit command if the arguments are valid.

`EditTransactionCommand` implements the `EditTransactionCommand#execute()` operation which executes the command and returns the result
message in a `CommandResult` object.

The operation is exposed in the `Logic` interface as `Logic#execute()`.

Give below is the usage scenario and how the edit mechanism behaves at each step.

Step 1. The user launches the application. The `UiManager` will call on the `MainWindow` to invoke the UI which displays the clients.

Step 2. The user executes `view 1` command to focus on the client at index 1 and see the client's list of transactions.

Step 3. The user executes `edit 2 m/transaction q/10` command to edit the information of transaction at index 2 in the focused client's transaction list.
This is done by accessing the `TransactionLog` of the focused client, and executing `TransactionLog#setTransaction(index, editedTransaction)`

The following sequence diagram shows how the edit operation works in Logic Manager:

![EditTransactionSequenceDiagram](images/EditTransactionSequenceDiagram.png)

_{more aspects and alternatives to be added}_

### Delete Client/Transaction/Remark feature
Expand All @@ -299,7 +373,7 @@ The following class diagram shows the parent-child relation of `DeleteClientComm

![DeleteCommandClassDiagram](images/DeleteCommandClassDiagram.png)

The `DeleteCommandParser` will take in the `userInput`, parse it, and return the correct concrete command type that is either `DeleteClientCommand`, `DeleteTransactionCommand`, or `DeleteRemarkCommand` which will be executed to achieve the deletion functionality.
The `DeleteCommandParser` will take in the `userInput`, parse it, and return the correct concrete command type that is either `DeleteClientCommand`, `DeleteTransactionCommand`, or `DeleteRemarkCommand` which will be executed to achieve the deletion functionality.

This process of deleting the first client in the list is depicted by the following sequence diagram (for user input `delete 1 m/client`):

Expand Down Expand Up @@ -330,8 +404,6 @@ The process for deleting `transaction` and `remark` is almost the same as the pr
* Pros: More intuitive to use, shorter command to type.
* Cons: Adds more valid commands that the user can use, which may not be very user-friendly since they have to remember more commands. Also, there will be much more classes and code.

_{more aspects and alternatives to be added}_

--------------------------------------------------------------------------------------------------------------------

## **Documentation, logging, testing, configuration, dev-ops**
Expand Down
14 changes: 14 additions & 0 deletions docs/diagrams/BuyCommandActivityDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@startuml
start
:User inputs buy command;

'Since the beta syntax does not support placing the condition outside the
'diamond we place it as the true branch instead.

if () then ([command is valid argument])
:Executes buy command;

else ([else])
endif
stop
@enduml
78 changes: 78 additions & 0 deletions docs/diagrams/BuyCommandSequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
@startuml
!include style.puml

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":JeeqTrackerParser" as JeeqTrackerParser LOGIC_COLOR
participant ":BuyCommandParser" as BuyCommandParser LOGIC_COLOR
participant "d:BuyCommand" as BuyCommand LOGIC_COLOR
participant ":CommandResult" as CommandResult LOGIC_COLOR
end box

[-> LogicManager : execute("buy 1 q/10 g/Apple p/0.5 d/17/05/2000")
activate LogicManager

LogicManager -> JeeqTrackerParser : parseCommand("buy 1 q/10 g/Apple p/0.5 d/17/05/2000")
activate JeeqTrackerParser

create BuyCommandParser
JeeqTrackerParser -> BuyCommandParser
activate BuyCommandParser

BuyCommandParser --> JeeqTrackerParser
deactivate BuyCommandParser

JeeqTrackerParser -> BuyCommandParser : parse("buy 1 q/10 g/Apple p/0.5 d/17/05/2000")
activate BuyCommandParser

create BuyCommand
BuyCommandParser -> BuyCommand
activate BuyCommand

BuyCommand -> Model :getFilteredClientList()
activate Model

Model --> BuyCommand
deactivate Model

BuyCommand -> Client :addTransaction()
activate Client

Client --> BuyCommand
deactivate Client

BuyCommand -> Model :setClient()
activate Model

Model --> BuyCommand
deactivate Model

BuyCommand --> BuyCommandParser : d
deactivate BuyCommand

BuyCommandParser --> JeeqTrackerParser : d
deactivate BuyCommandParser
'Hidden arrow to position the destroy marker below the end of the activation bar.
BuyCommandParser -[hidden]-> JeeqTrackerParser
destroy BuyCommandParser


JeeqTrackerParser --> LogicManager : d
deactivate JeeqTrackerParser

LogicManager -> BuyCommand : execute()
activate BuyCommand

create CommandResult
BuyCommand -> CommandResult
activate CommandResult

CommandResult --> BuyCommand
deactivate CommandResult

BuyCommand --> LogicManager : result
deactivate BuyCommand

[<--LogicManager
deactivate LogicManager
@enduml
38 changes: 38 additions & 0 deletions docs/diagrams/BuyParserClasses.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@startuml
!include style.puml
skinparam arrowThickness 1.1
skinparam arrowColor LOGIC_COLOR_T4
skinparam classBackgroundColor LOGIC_COLOR

Class "{abstract}\nCommand" as Command
Class BuyCommand

package "Parser classes"{
Class "<<interface>>\nParser" as Parser
Class JeeqTrackerParser
Class BuyCommandParser
Class CliSyntax
Class ParserUtil
Class ArgumentMultimap
Class ArgumentTokenizer
Class Prefix
}

Class HiddenOutside #FFFFFF
HiddenOutside ..> JeeqTrackerParser

JeeqTrackerParser .down.> BuyCommandParser: creates >

BuyCommandParser ..> BuyCommand : creates >
JeeqTrackerParser ..> Command : returns >
BuyCommandParser .up.|> Parser
BuyCommandParser ..> ArgumentMultimap
BuyCommandParser ..> ArgumentTokenizer
ArgumentTokenizer .left.> ArgumentMultimap
BuyCommandParser ..> CliSyntax
CliSyntax ..> Prefix
BuyCommandParser ..> ParserUtil
ParserUtil .down.> Prefix
ArgumentTokenizer .down.> Prefix
BuyCommand -up-|> Command
@enduml
16 changes: 16 additions & 0 deletions docs/diagrams/BuyState0.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@startuml
!include style.puml
skinparam ClassFontColor #000000
skinparam ClassBorderColor #000000

title Initial state

package MainWindow {
class State1 as "clients:ClientListPanel"
class State2 as "companies:CompanyListPanel"
class State3 as "transactions:TransactionListPanel"
}
State1 -[hidden]right-> State2
State2 -[hidden]right-> State3
@end

16 changes: 16 additions & 0 deletions docs/diagrams/EditTransactionActitvityDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@startuml
start
:User inputs edit command;

'Since the beta syntax does not support placing the condition outside the
'diamond we place it as the true branch instead.

if () then ([command is valid argument])
:Executes edit command;

:Display edited transaction
with updated details;
else ([else])
endif
stop
@enduml
59 changes: 59 additions & 0 deletions docs/diagrams/tracing/EditTransactionSequence.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
@startuml
!include ../style.puml

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":JeeqTrackerParser" as JeeqTrackerParser LOGIC_COLOR
participant ":EditCommandParser" as EditCommandParser LOGIC_COLOR
participant "d:EditTransactionCommand" as EditTransactionCommand LOGIC_COLOR
participant ":CommandResult" as CommandResult LOGIC_COLOR
end box

[-> LogicManager : execute("edit")
activate LogicManager

LogicManager -> JeeqTrackerParser : parseCommand("edit")
activate JeeqTrackerParser

create EditCommandParser
JeeqTrackerParser -> EditCommandParser
activate EditCommandParser

EditCommandParser --> JeeqTrackerParser
deactivate EditCommandParser

JeeqTrackerParser -> EditCommandParser : parse("edit")
activate EditCommandParser

create EditTransactionCommand
EditCommandParser -> EditTransactionCommand
activate EditTransactionCommand

EditTransactionCommand --> EditCommandParser : d
deactivate EditTransactionCommand

EditCommandParser --> JeeqTrackerParser : d
deactivate EditCommandParser
'Hidden arrow to position the destroy marker below the end of the activation bar.
EditCommandParser -[hidden]-> JeeqTrackerParser
destroy EditCommandParser

JeeqTrackerParser --> LogicManager : d
deactivate JeeqTrackerParser

LogicManager -> EditTransactionCommand : execute()
activate EditTransactionCommand

create CommandResult
EditTransactionCommand -> CommandResult
activate CommandResult

CommandResult --> EditTransactionCommand
deactivate CommandResult

EditTransactionCommand --> LogicManager : result
deactivate EditTransactionCommand

[<--LogicManager
deactivate LogicManager
@enduml
Binary file added docs/images/BuyCommandActivityDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/BuyCommandSequenceDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/BuyParserClasses.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/BuyState0-Initial_state.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/EditTransactionActitvityDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/EditTransactionSequenceDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1fa7ecd

Please sign in to comment.