Skip to content

Commit

Permalink
Merge pull request #84 from ShyamKrishna33/developer-guide
Browse files Browse the repository at this point in the history
Update processTransaction in Developer Guide
  • Loading branch information
ShyamKrishna33 committed Apr 4, 2024
2 parents d9b01e6 + 0fdcd11 commit 3519839
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 16 deletions.
107 changes: 91 additions & 16 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,27 @@

## Acknowledgements

{list here sources of all reused/adapted ideas, code, documentation, and third-party libraries -- include links to the original source as well}
{list here sources of all reused/adapted ideas, code, documentation, and third-party libraries -- include links to the
original source as well}

## Design & implementation

{Describe the design and implementation of the product. Use UML diagrams and short code snippets where applicable.}

### [Implemented] Account feature

#### Implementation
The Account feature in the BudgetBuddy application serves as a core component for tracking the user's current financial

The Account feature in the BudgetBuddy application serves as a core component for tracking the user's current financial
balance. This feature is primarily facilitated through the `Account` class, which encapsulates the balance attribute and
provides mechanisms to get and set the balance. The Account object interacts closely with transactions, being updated
provides mechanisms to get and set the balance. The Account object interacts closely with transactions, being updated
whenever transactions are added or deleted.

Looking ahead, users will have the flexibility to manage multiple accounts—such as Wallet, Savings, Checking, and
Investment accounts—each encapsulated within the application's framework for seamless financial oversight. This
expansion will provide a comprehensive view of diverse financial sources and enhance personal financial management
Looking ahead, users will have the flexibility to manage multiple accounts—such as Wallet, Savings, Checking, and
Investment accounts—each encapsulated within the application's framework for seamless financial oversight. This
expansion will provide a comprehensive view of diverse financial sources and enhance personal financial management
within BudgetBuddy.


### [Implemented] Category feature

#### Description
Expand All @@ -38,19 +40,78 @@ Upon invoking the `Add` command, users are presented with a selection prompt fea
input, typically in the form of a numerical identifier corresponding to a category within the enum class, facilitates
the assignment of the appropriate enum object to the transaction's category attribute.

### [Implemented] Process transaction

#### Description

This method adds a transaction to the list of transactions based on the necessary input details given by the user.

#### Parameters

1. String input: A string containing the user input, which should include the `NAME`, `AMOUNT`, `DATE` and `TYPE` of the
transaction.
2. Account account: The account object associated with the transaction list.

#### Design and Implementation

1. ##### Syntax Validation:

The method first checks whether the input string contains all necessary arguments ("/a/", "/t/", "/n/", "/$/", "/d/")
required for adding a transaction. If any argument is missing, it throws an InvalidAddTransactionSyntax exception.

2. #### Transaction Parsing:

It utilizes a parser object to parse the user input string into a Transaction object using the
parseUserInputToTransaction method.

3. #### Assertion Checks:

Assertions are used for debugging purposes to ensure that the parsed transaction and added transaction are not null.
If they are null, assertion errors are thrown.

4. #### Category Assignment:

If the category of the transaction is null, it prompts the user to choose a category from a list and assigns the
chosen category to the transaction.

5. #### Transaction Addition:

After parsing and category assignment, the transaction is added to the account using the addTransaction method.

6. #### Feedback to User:

Upon successful addition of the transaction, a message is printed to the user indicating the details of the added
transaction and the updated account balance.

#### Exceptions:

1. `InvalidTransactionTypeException`: This exception is thrown when the transaction type is not one of `income`
and `expense`.

2. `InvalidAddTransactionSyntax`: This exception is thrown when the syntax of the add transaction is invalid.

3. `EmptyArgumentException`: This exception is thrown when an empty argument is encountered.

The following sequence diagram shows how a remove transaction goes works:

![](./uml/uml-images/addTransactionDiagram.png)

### [Implemented] Remove transaction

#### Description

This method is used to remove a transaction from the list of transactions based on the transaction ID provided
by the user. After the transaction is removed, the account balance is updated accordingly and a message is
displayed to the user indicating the success of the operation. This helps user to remove the transaction
from the list they added by mistake or those transactions they no longer need to keep track off.

#### Parameters

1. String input: A string containing the user input, which should include the transaction ID to be removed.
2. Account account: The account object associated with the transaction list.

#### Design and Implementation

The method first validates the user input to ensure it's not empty or null. If the input is invalid, it throws
an EmptyArgumentException. Next, it extracts the transaction ID from the input and verifies its integrity as a
valid integer. If the ID is invalid, a NumberFormatException is thrown.
Expand All @@ -68,34 +129,44 @@ The following sequence diagram shows how a remove transaction goes works:

![](./uml/uml-images/removeTransactionDiagram.png)


### [Implemented] Edit Transaction

#### Description

This method facilitates the editing of a transaction within the list of transactions associated with a
specific account. Users can edit transactions by providing the index of the transaction they wish to modify
along with the updated transaction details. After the edit operation is completed, the system updates the
transaction accordingly and notifies the user of the successful operation. This feature enhances user
flexibility by allowing them to correct erroneous transactions or update transaction details as needed.

#### Parameters

1. String input: A string representing user input, including the index of the transaction to be edited and
the updated transaction details.
2. Account account: The account object associated with the transaction list.

#### Design and Implementation

The processEditTransaction method follows a structured approach to ensure the successful editing of
transactions while maintaining data integrity:

1. Input Validation: The method begins by validating the user input to ensure it is not empty or null. If
the input is invalid, an EmptyArgumentException is thrown to prompt the user to provide valid input.
2. Transaction Index Extraction: After validating the input, the method extracts the index of the
transaction to be edited from the input string. It ensures the extracted data is a valid integer; otherwise, a NumberFormatException is thrown to indicate invalid input.
transaction to be edited from the input string. It ensures the extracted data is a valid integer; otherwise, a
NumberFormatException is thrown to indicate invalid input.
3. Index Calculation: Once a valid transaction index is obtained, the method calculates the corresponding
index in the transactions ArrayList. As ArrayList indices start from 0, the provided index is decremented
by 1 to align with the ArrayList index.
4. Index Bounds Verification: The method verifies whether the calculated index falls within the bounds of
the transactions ArrayList. If the index is out of bounds, an InvalidIndexException is thrown to notify the user of the invalid index provided.
the transactions ArrayList. If the index is out of bounds, an InvalidIndexException is thrown to notify the user of
the invalid index provided.
5. Transaction Editing: Upon successful validation, the method retrieves the transaction object at the
calculated index from the transactions ArrayList. It prompts the user to input the updated transaction details through the UserInterface.getEditInformation() method. The edited transaction is then parsed using the parser.parseTransactionType() method to ensure its validity and association with the provided account. Finally, the edited transaction replaces the original transaction at the specified index in the transactions ArrayList using the transactions.set() method.
calculated index from the transactions ArrayList. It prompts the user to input the updated transaction details
through the UserInterface.getEditInformation() method. The edited transaction is then parsed using the
parser.parseTransactionType() method to ensure its validity and association with the provided account. Finally, the
edited transaction replaces the original transaction at the specified index in the transactions ArrayList using the
transactions.set() method.
6. User Notification: After editing the transaction, the method notifies the user of the successful
operation by displaying a message through the UserInterface.printUpdatedTransaction() method.

Expand All @@ -104,11 +175,14 @@ The following sequence diagram illustrates the sequence of interactions involved
![](./uml/uml-images/processEditTransactionDiagram.png)

### [Implemented] List feature

### Description
The list feature allows users to view their existing transactions. This feature includes viewing all the transactions,

The list feature allows users to view their existing transactions. This feature includes viewing all the transactions,
past week's transactions, past month's transactions and transactions from a specified date range.

#### Implementation

This feature is facilitated through the `TransactionList#processList`, where it prompts the user for their choice of
list they wish to see. After the user inputs the choice, the get functions will store the transactions in a new
ArrayList and `UserInterface#printPastTransactions` will handle the output of the list.
Expand All @@ -118,6 +192,7 @@ The following sequence diagram illustrates the sequence of interactions involved
![](./uml/uml-images/processList.png)

## Product scope

### Target user profile

{Describe the target user profile}
Expand All @@ -128,10 +203,10 @@ The following sequence diagram illustrates the sequence of interactions involved

## User Stories

|Version| As a ... | I want to ... | So that I can ...|
|--------|----------|---------------|------------------|
|v1.0|new user|see usage instructions|refer to them when I forget how to use the application|
|v2.0|user|find a to-do item by name|locate a to-do without having to go through the entire list|
| Version | As a ... | I want to ... | So that I can ... |
|---------|----------|---------------------------|-------------------------------------------------------------|
| v1.0 | new user | see usage instructions | refer to them when I forget how to use the application |
| v2.0 | user | find a to-do item by name | locate a to-do without having to go through the entire list |

## Non-Functional Requirements

Expand Down
31 changes: 31 additions & 0 deletions docs/uml/addTransaction.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@startuml
'https://plantuml.com/sequence-diagram

autonumber

actor User
participant "TransactionManager" as TM
participant "Parser" as P
participant "UserInterface" as UI

User -> TM: processTransaction(input, account)
TM -> TM: validateSyntax(input)
TM -> P: parseUserInputToTransaction(input, account)
activate P
P --> TM: transaction
deactivate P
TM -> TM: checkCategory(transaction)
alt Category is null
TM -> UI: listCategories()
activate UI
UI --> User: Display category options
deactivate UI
User -> TM: selectCategory(categoryNum)
TM -> TM: setCategory(transaction, categoryNum)
end
TM -> TM: addTransaction(transaction)
TM -> UI: printAddMessage(transaction, account.balance)
activate UI
UI --> User: Display added transaction message
deactivate UI
@enduml
Binary file added docs/uml/uml-images/addTransactionDiagram.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 3519839

Please sign in to comment.