diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index 3301c430ac..6df0a4e3ed 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -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. @@ -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: diff --git a/docs/UserGuide.md b/docs/UserGuide.md index abd9fbe891..4863be0e36 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -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 @@ -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 @@ -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` | diff --git a/docs/diagrams/Storage.puml b/docs/diagrams/Storage.puml index 6b2a3ef31b..9b856c158d 100644 --- a/docs/diagrams/Storage.puml +++ b/docs/diagrams/Storage.puml @@ -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 "<>\nExpenseType" as ExpenseType Class "<>\nIncomeType" as IncomeType Class Ui @@ -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 \ No newline at end of file diff --git a/docs/diagrams/resetBudget.puml b/docs/diagrams/resetBudget.puml index 9e8de55185..8efef02d34 100644 --- a/docs/diagrams/resetBudget.puml +++ b/docs/diagrams/resetBudget.puml @@ -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 diff --git a/docs/images/Storage.png b/docs/images/Storage.png index 347b2cdb98..d0e6ec236b 100644 Binary files a/docs/images/Storage.png and b/docs/images/Storage.png differ diff --git a/docs/images/resetBudget.png b/docs/images/resetBudget.png index 50972a0bfc..e9f8f5e578 100644 Binary files a/docs/images/resetBudget.png and b/docs/images/resetBudget.png differ diff --git a/src/main/java/seedu/financialplanner/commands/BalanceCommand.java b/src/main/java/seedu/financialplanner/commands/BalanceCommand.java index 75eaf0944f..152b4da378 100644 --- a/src/main/java/seedu/financialplanner/commands/BalanceCommand.java +++ b/src/main/java/seedu/financialplanner/commands/BalanceCommand.java @@ -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 { @@ -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)); } } diff --git a/src/main/java/seedu/financialplanner/commands/BudgetCommand.java b/src/main/java/seedu/financialplanner/commands/BudgetCommand.java index d6f89788df..9dc8d19547 100644 --- a/src/main/java/seedu/financialplanner/commands/BudgetCommand.java +++ b/src/main/java/seedu/financialplanner/commands/BudgetCommand.java @@ -116,6 +116,8 @@ private void resetBudget() { } Budget.resetBudget(); ui.printResetBudget(); + } else if (!Budget.hasBudget()) { + ui.printBudgetError("delete"); } else { ui.printBudgetError("reset"); } diff --git a/src/main/java/seedu/financialplanner/commands/OverviewCommand.java b/src/main/java/seedu/financialplanner/commands/OverviewCommand.java index 4f21c1f28f..9aa2107a08 100644 --- a/src/main/java/seedu/financialplanner/commands/OverviewCommand.java +++ b/src/main/java/seedu/financialplanner/commands/OverviewCommand.java @@ -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) { @@ -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) { @@ -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."; @@ -96,7 +96,7 @@ private static String getReminders() { return reminders.toString(); } - private static String getBalance() { + private String getBalance() { return formatDoubleToString(Cashflow.getBalance()); } }