Skip to content

Commit

Permalink
Merge pull request #119 from ryan1604/branch-UG
Browse files Browse the repository at this point in the history
Update UG and fix minor bugs
  • Loading branch information
ryan1604 authored Oct 29, 2023
2 parents 543ea73 + 715d104 commit f84cb8f
Show file tree
Hide file tree
Showing 9 changed files with 195 additions and 24 deletions.
13 changes: 12 additions & 1 deletion docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ API: `Storage.java`
* The `load` method in LoadData reads the `data.txt` file and loads any existing Income, Expense and Budget into the application.
* The `save` method in SaveData saves all Incomes, Expenses and existing Budget into the `data.txt` file.

#### Design considerations:

* There are 2 main ways to implement the storage, one is to save the data after every command, and the other is to save
the data one upon exiting the program with the `exit` command.
* Saving the data once upon exit (Currently implemented):
* Advantage: Better efficiency and performance of the program.
* Disadvantage: If the program crashes or exits incorrectly, data will not be saved.
* Saving the data after every command:
* Advantage: Changes are saved after every command.
* Disadvantage: Executing command might slow down the program when there is a large amount of data to be saved.

### Visualization Feature

This feature is implemented with the help of [XChart](https://knowm.org/open-source/xchart/), a simple charting library for Java by Knowm.
Expand Down Expand Up @@ -187,7 +198,7 @@ Example: `budget delete`

The budget will be reset by resetting the current budget to the initial budget through the `resetBudget()` method in `Budget.java`.

Example : `budget reset`
Example: `budget reset`

#### View budget:

Expand Down
171 changes: 160 additions & 11 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
# User Guide

## Table of contents

* [Introduction](#introduction)
* [Quick start](#quick-start)
* [Features](#features)
* [Budget](#budget)
* [Setting budget](#setting-a-budget-budget-set)
* [Updating budget](#updating-budget-budget-update)
* [Resetting budget](#resetting-budget-budget-reset)
* [Deleting budget](#deleting-budget-budget-delete)
* [Viewing budget](#viewing-budget-budget-view)
* [Displaying Overview](#displaying-overview-overview)
* [View Balance](#viewing-balance-balance)
* [Exiting the program](#exiting-the-program-exit)
* [Saving data](#saving-the-data)
* [Loading data](#loading-the-data)
* [FAQ](#faq)
* [Command Summary](#command-summary)

## Introduction

{Give a product intro}
Financial Planner is a Command Line Interface (CLI) application for managing your finances conveniently.
It is optimized for use via the CLI and leverages your expertise in CLI and your ability to type fast and gives
you a one-stop interface to access a plethora of features to manage your finances.

## Quick Start

Expand All @@ -11,23 +32,142 @@
1. Ensure that you have Java 11 or above installed.
1. Down the latest version of `Duke` from [here](http://link.to/duke).

## Features
## Features

{Give detailed description of each feature}

### Adding a todo: `todo`
Adds a new item to the list of todo items.
### Budget

#### Setting a budget: `budget set`

Sets a monthly budget.

Format: `budget set /b BUDGET`

* `BUDGET` has to be a positive number.

Example of usage: `budget set /b 500`

Example output:

```
A monthly budget of 500.00 has been set.
```

#### Updating budget: `budget update`

Updates budget to a new value.

Format: `budget update /b BUDGET`

* `Budget` has to be a positive number.
* There has to be an existing budget.

Example of usage: `budget update /b 1000`

Example output:

```
Budget has been updated:
Old initial budget: 500.00
Old current budget: 500.00
New initial budget: 1000.00
New current budget: 1000.00
```

#### Resetting budget: `budget reset`

Resets current budget to initial budget if they are different.

Format: `budget reset`

* Budget will be reset to initial budget or current balance, whichever is lower.

Example of usage: `budget reset`

Example output:

```
Budget has been reset to 1000.00.
```

#### Deleting budget: `budget delete`

Deletes existing budget.

Format: `budget delete`

Example of usage: `budget delete`

Example output:

```
Budget has been deleted.
```

#### Viewing budget: `budget view`

View existing budget.

Format: `budget view`

Example of usage: `budget view`

Example output:

```
You have a remaining budget of 1000.00.
```

### Displaying overview: `overview`

Displays an overview of user's financials.

Format: `overview`

Example of usage: `overview`

Example output:

```
Here is an overview of your financials:
Total balance: 3790.00
Highest income: 5000.00 Category: Salary
Highest expense: 500.00 Category: Others
Remaining budget for the month: 1000.00
Reminders:
No reminders added yet.
```

### Viewing balance: `balance`

View user's current balance.

Format: `balance`

Example of usage: `balance`

Example output:

```
Balance: 3790.00
```

### Exiting the program: `exit`

Exits the program.

Format: `todo n/TODO_NAME d/DEADLINE`
Format: `exit`

* The `DEADLINE` can be in a natural language format.
* The `TODO_NAME` cannot contain punctuation.
### Saving the data

Example of usage:
Data is automatically saved upon exiting the program using the `exit` command. Closing the program without exiting
will not save the data.

`todo n/Write the rest of the User Guide d/next week`
### Loading the data

`todo n/Refactor the User Guide to remove passive voice d/13/04/2020`
Existing data will be automatically loaded when the program starts up.

## FAQ

Expand All @@ -39,4 +179,13 @@ Example of usage:

{Give a 'cheat sheet' of commands here}

* Add todo `todo n/TODO_NAME d/DEADLINE`
| Action | Format |
|----------------------|---------------------------|
| **Set budget** | `budget set /b BUDGET` |
| **Update budget** | `budget update /b BUDGET` |
| **Reset budget** | `budget reset` |
| **Delete budget** | `budget delete` |
| **View budget** | `budget view` |
| **Display Overview** | `overview` |
| **View balance** | `balance` |
| **Exit program** | `exit` |
11 changes: 6 additions & 5 deletions docs/diagrams/Storage.puml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Class Storage
Class "{abstract}\nLoadData" as LoadData
Class "{abstract}\nSaveData" as SaveData
Class CashflowList
Class Budget
Class Cashflow
Class "{abstract}\nBudget" as Budget
Class "{abstract}\nCashflow" as Cashflow
Class "<<enumeration>>\nExpenseType" as ExpenseType
Class "<<enumeration>>\nIncomeType" as IncomeType
Class Ui
Expand All @@ -26,9 +26,10 @@ SaveData ..> Cashflow

LoadData --> CashflowList
LoadData ..> Budget
LoadData --> ExpenseType
LoadData --> IncomeType
LoadData --> Cashflow
LoadData ..> ExpenseType
LoadData ..> IncomeType
LoadData ..> Cashflow
LoadData -right-> Ui: prints message >


@enduml
2 changes: 2 additions & 0 deletions docs/diagrams/resetBudget.puml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ alt spentBudget
end
BudgetCommand -> Budget: resetBudget()
BudgetCommand -> Ui: printResetBudget()
else !hasBudget
BudgetCommand -> Ui: printBudgetError("delete")
else else
BudgetCommand -> Ui: printBudgetError("reset")
end
Expand Down
Binary file modified docs/images/Storage.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 modified docs/images/resetBudget.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import seedu.financialplanner.cashflow.Cashflow;
import seedu.financialplanner.utils.Ui;

import java.text.DecimalFormat;
import java.util.ArrayList;

public class BalanceCommand extends Command {
Expand All @@ -17,6 +18,11 @@ public BalanceCommand(RawCommand rawCommand) {

@Override
public void execute() throws Exception {
ui.showMessage("Balance: " + Cashflow.getBalance());
ui.showMessage("Balance: " + getBalanceString());
}

private String getBalanceString() {
DecimalFormat decimalFormat = new DecimalFormat("####0.00");
return decimalFormat.format(Cashflow.round(Cashflow.getBalance(), 2));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ private void resetBudget() {
}
Budget.resetBudget();
ui.printResetBudget();
} else if (!Budget.hasBudget()) {
ui.printBudgetError("delete");
} else {
ui.printBudgetError("reset");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ public void execute() throws Exception {
//todo: goal disparity
}

private static String getBudgetDesc() {
private String getBudgetDesc() {
return Budget.getCurrentBudgetString();
}

private static String getHighestIncome() {
private String getHighestIncome() {
double maxIncome = 0;
String incomeType = "";
for (Cashflow entry : cashflowList.list) {
Expand All @@ -57,7 +57,7 @@ private static String getHighestIncome() {
return formatDoubleToString(maxIncome) + " Category: " + incomeType;
}

private static String getHighestExpense() {
private String getHighestExpense() {
double maxExpense = 0;
String expenseType = "";
for (Cashflow entry : cashflowList.list) {
Expand All @@ -75,13 +75,13 @@ private static String getHighestExpense() {
return formatDoubleToString(maxExpense) + " Category: " + expenseType;
}

private static String formatDoubleToString(double amount) {
private String formatDoubleToString(double amount) {
DecimalFormat decimalFormat = new DecimalFormat("####0.00");

return decimalFormat.format(Cashflow.round(amount, 2));
}

private static String getReminders() {
private String getReminders() {
ReminderList reminderList = ReminderList.INSTANCE;
if (reminderList.list.isEmpty()) {
return "No reminders added yet.";
Expand All @@ -96,7 +96,7 @@ private static String getReminders() {
return reminders.toString();
}

private static String getBalance() {
private String getBalance() {
return formatDoubleToString(Cashflow.getBalance());
}
}

0 comments on commit f84cb8f

Please sign in to comment.