Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/AY2324S1-CS2113-T18-2/tp
Browse files Browse the repository at this point in the history
…into help-command

# Conflicts:
#	src/main/java/seedu/financialplanner/utils/Parser.java
  • Loading branch information
YFshadaow committed Nov 1, 2023
2 parents 3f80f21 + 62ab3bf commit ac5f45a
Show file tree
Hide file tree
Showing 34 changed files with 502 additions and 153 deletions.
97 changes: 76 additions & 21 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
* [Visualization Feature](#visualization-feature-)
* [Class diagram](#class-diagram)
* [Sequence diagram](#sequence-diagram-)
* [Add income/expense feature](#add-incomeexpense-feature)
* [Step 1](#step-1)
* [Step 2](#step-2)
* [Step 3](#step-3)
* [Step 4](#step-4)
* [Diagrams](#diagrams)
* [Add Income/Expense Feature](#add-incomeexpense-feature)
* [Class Diagram](#add-incomeexpense-class-diagram)
* [Sequence Diagram](#add-incomeexpense-sequence-diagram)
* [Recurring Cashflow Feature](#recurring-cashflow-feature)
* [Class Diagram](#recurring-cashflow-class-diagram)
* [Sequence Diagrams](#recurring-cashflow-sequence-diagrams)
* [Budget Feature](#budget-feature)
* [Set and update budget](#set-and-update-budget)
* [Delete budget](#delete-budget)
Expand Down Expand Up @@ -99,8 +99,8 @@ the data one upon exiting the program with the `exit` command.

This feature is implemented with the help of [XChart](https://knowm.org/open-source/xchart/), a simple charting library for Java by Knowm.

By typing in the vis command with the appropriate arguments (/s and /t), users will be able to visualize their income or expense
using visualization tools (Piechart, Bar Chart)
By typing in the vis command with the appropriate arguments (`/s` and `/t`), users will be able to visualize their
income or expense using visualization tools (Piechart, Bar Chart or Radar Chart)

Demo:

Expand Down Expand Up @@ -132,7 +132,7 @@ specified cashflow entry according to type using a Hashmap which is returned and

Visualizer's Role:

According to the chart type (Pie/Bar) argument and the Hashmap obtained from the categorizer passed in,
According to the chart type (Pie/Bar/Radar) argument and the Hashmap obtained from the categorizer passed in,
the visualizer displays the specified visualization chart by calling the charting library Xchart.

### Class Diagram
Expand All @@ -153,7 +153,7 @@ Visualizer

![](images/vis/visualizerSequence.png)

### Add income/expense feature
### Add Income/Expense Feature

The add income/expense command has 2 compulsory arguments `/t` and `/a` and 1 optional argument `/r`.

Expand All @@ -162,12 +162,9 @@ Example:
add income /a 100 /t salary /r 30
```
Below are the steps that shows the implementation of add income/expense.
#### Step 1
An instantiated AddCashflowCommand class gets the instance of CashflowList.

This allows the AddCashflowCommand instance to access the methods of CashflowList.
#### Step 2
The AddCashflowCommand instance then calls addIncome() or addExpense(), depending on what `category` is initialised as.
#### Step 1
The AddCashflowCommand instance calls addIncome() or addExpense(), depending on what `category` is initialised as.

addIncome() or addExpense() instantiates an Income or Expense object respectively.

Expand All @@ -185,20 +182,78 @@ switch (category) {
break;
}
```
#### Step 3
#### Step 2
The instantiated income/expense then updates the overall balance through addIncomeValue() or addExpenseValue().

The income/expense object is also added to the list in Cashflowlist which contains all incomes/expenses.
#### Step 4
#### Step 3
The added income/expense is then displayed to the user through the Ui.

#### Diagrams
#### Add Income/Expense Class Diagram
Given below is the class diagram showing the class structure of the add income/expense mechanism:
![](images/CashflowClassDiagram.png)

![](images/cashflow/CashflowClassDiagram.png)
#### Add Income/Expense Sequence Diagram
Given below is the sequence diagram showing the add income/expense mechanism:
![](images/AddCashflowSequence.png)
![](images/cashflow/AddCashflowSequence.png)
### Recurring Cashflow Feature
Cashflow refers to an income or expense.

This feature is called from the user through the `/r` argument in add income/expense command.

If a cashflow is set to be recurring, the program would add another entry of the same cashflow to the Financial Planner after a set period of time.

Below are the steps that shows the implementation of the recurring cashflow feature.

#### Step 1
Once the cashflow is set to be recurring, its corresponding `Cashflow` object would store the date at which the cashflow was added to the Financial Planner.

The `recur` variable in the object would also be instantiated according to the user's input.

An additional `boolean` variable, `hasRecurred` is stored in the object and is set to `false` by default.

Example:
```
public abstract class Cashflow {
protected int recur;
protected LocalDate date;
protected boolean hasRecurred;
}
```
#### Step 2
When the Financial Planner is started again in the future, the date of startup would be obtained from the system.

After loading existing saved cashflows from data.txt, the program will check for cashflows that are set to be recurring and has not recurred.

Example:
```
if (recur > 0 && !hasRecurred) {
...
}
```

#### Step 3
Once a cashflow matches the above criteria, the date of its next addition to the Financial Planner, `dateOfAddition`, would be determined.

`dateOfAddition` would be compared to the current date, and if the current date is after or equal to `dateOfAddition`, an identical cashflow would be instantiated.

This identical cashflow would then have its `date` variable set to `dateOfAddition`, then this cashflow would be added to a temporary list, `tempCashflowList`.

The original cashflow would then have its `hasRecurred` variable be set to `true`.

#### Step 4
Each cashflow in `tempCashflowList` goes through **Step 3** again, so that multiple cashflows can be added if it has recurred more than once.

Once the process is done, all cashflows in `tempCashflowList` are then added to the Financial Planner.

The added cashflows are then displayed to the user.

#### Recurring Cashflow Class Diagram
Given below is the class diagram showing the class structure of the recurring cashflow mechanism:
![](images/cashflow/RecurClassDiagram.png)
#### Recurring Cashflow Sequence Diagrams
Given below is the sequence diagram showing the recurring cashflow mechanism:
![](images/cashflow/RecurSequence.png)
![](images/cashflow/AddRecurringSequence.png)

### Budget Feature

Expand Down
28 changes: 20 additions & 8 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ you a one-stop interface to access a plethora of features to manage your finance

e.g. `[/r DAYS]` can be used as `/r 30` or left empty.

### Notes about naming convention
- Cashflow refers to an income or expense.

### Add cashflow

#### Add income: `add income`
Expand Down Expand Up @@ -252,9 +255,9 @@ You have removed an Expense
Description: groceries
from the Financial Planner.
Balance: -830.00
- Note: Balance displayed above is just an example. Your actual balance may differ.
```

- Note: Balance displayed above is just an example. Your actual balance may differ.
### List

#### List all: `list`
Expand Down Expand Up @@ -538,7 +541,7 @@ Use watchlist command to view updated Watchlist

### Visualizing your cashflow: `vis`

Using this command to visualize your income or expenses in a pie chart or bar chart
Using this command to visualize your income or expenses in a pie chart, bar chart or radar chart

Format: `vis /t TYPE /c TOOL`

Expand All @@ -547,10 +550,11 @@ Format: `vis /t TYPE /c TOOL`
| Income Cashflows `Income` |
| Expense Cashflows `Expense` |

| Tool `/c` |
|----------------|
| PieChart `pie` |
| BarChart `bar` |
| Tool `/c` |
|--------------------|
| PieChart `pie` |
| BarChart `bar` |
| RadarChart `radar` |

Example of usage: `vis /t expense /c pie`

Expand All @@ -562,14 +566,22 @@ Displaying piechart for expense

![](images/vis/visOutput.png)

Example of usage: `vis /t expense /c bar`
Example of usage: `vis /t income /c bar`

```
Displaying barchart for income
```

![](images/vis/barOuput.png)

Example of usage: `vis /t income /c radar`

```
Displaying radarchart for income
```

![](images/vis/radarOutput.png)

### Exiting the program: `exit`

Exits the program.
Expand Down
31 changes: 0 additions & 31 deletions docs/diagrams/AddCashflowSequence.puml

This file was deleted.

28 changes: 0 additions & 28 deletions docs/diagrams/CashflowClassDiagram.puml

This file was deleted.

38 changes: 38 additions & 0 deletions docs/diagrams/cashflow/AddCashflowSequence.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@startuml

participant ":AddCashflowCommand" as AddCashflowCommand
participant ":CashflowList" as CashflowList
participant ":Income" as Income
participant ":Expense" as Expense
participant ":Ui" as Ui

-> AddCashflowCommand: execute()
activate AddCashflowCommand
alt income
AddCashflowCommand -> CashflowList: addIncome(amount, incomeType, recur, description)
activate CashflowList
create Income
CashflowList -> Income: Income(value, type, recur, description)
activate Income
Income -> Income: addIncomeValue()
return
CashflowList -> CashflowList: addToList(toAdd)
CashflowList -> Ui: printAddedCashflow(toAdd)
return

else expense
AddCashflowCommand -> CashflowList: addExpense(amount, incomeType, recur, description)
activate CashflowList
create Expense
CashflowList -> Expense: Expense(value, type, recur, description)
activate Expense
Expense -> Expense: addExpenseValue()
return
CashflowList -> CashflowList: addToList(toAdd)
CashflowList -> Ui: printAddedCashflow(toAdd)
return
end
return

hide footbox
@enduml
26 changes: 26 additions & 0 deletions docs/diagrams/cashflow/AddRecurringSequence.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@startuml
mainframe sd add recurring cashflows to templist

participant "<<class>>\nLoadData" as LoadData
participant ":Income" as Income
participant ":Expense" as Expense

loop current date is after or equals next recurring date
LoadData -> Cashflow: setHasRecurred(true)

alt income
create Income
LoadData -> Income: Income((Income) cashflow)
LoadData -> Income: setDate(dateOfAddition)
LoadData -> LoadData: addToTempList(tempCashflowList, toAdd)

else expense
create Expense
LoadData -> Expense: Expense((Expense) cashflow)
LoadData -> Expense: setDate(dateOfAddition)
LoadData -> LoadData: addToTempList(tempCashflowList, toAdd)
end

end
hide footbox
@enduml
Loading

0 comments on commit ac5f45a

Please sign in to comment.