Skip to content

Commit

Permalink
Merge pull request #212 from Dheekshitha2/shree-DG-3
Browse files Browse the repository at this point in the history
Add changes to developer guide for budget functions, added CommandCreator for list budget
  • Loading branch information
Dheekshitha2 authored Apr 13, 2024
2 parents 7539393 + 5e47b91 commit 041758b
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 60 deletions.
98 changes: 40 additions & 58 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,6 @@

## Design & implementation

### Budget Management

#### Implementation
The Budget Management feature allows users to set financial limits for the various categories and monitor their spending.
This feature's objective is to give users the ability to stay within their financial goals and avoid overspending.

This feature is orchestrated by `ListBudgetCommand` and `SetBudgetCommand`, which are initialised by the `Parser`
class. Below is a description of the key class attributes and methods involved in the budget setting and listing
process:

##### Class Attributes for `SetBudgetCommand`:
| Class Attribute | Variable Type | Relevance |
|-----------------|---------------|---------------------------------------------------------------------|
| expenseList | ExpenseList | Object containing the list of expenses to check against set budgets |
| category | String | The category for which the budget is being set |
| budget | double | The budget amount to be set for the category |

##### Class Attributes for `ListBudgetCommand`:
| Class Attribute | Variable Type | Relevance |
|-----------------|---------------|---------------------------------------------------------------------|
| expenseList | ExpenseList | Object containing the list of expenses to check against set budgets |


Upon the call of the `execute()` method in `BudgetBuddy` using `command.execute()`, `SetBudgetCommand` will update the
budget in `ExpenseList` using `setBudget`. Similarly, `ListBudgetCommand` will fetch and display all categories with
their budgets using `getBudgets`, and highlight those that are above the set budget.

##### Key Methods used from `ExpenseList`
| Method | Return Type | Relevance |
|-----------------------------|---------------|--------------------------------------------------------------------|
| setBudget(category, budget) | void | Sets or updates the budget for a given category in the ExpenseList |
| getBudgets() | List<Budget> | Retrieves the list of all budgets set |

The `ListBudgetCommand`'s updated execution function now features an improved display that not only shows the budget,
spent amount, and remaining balance but also clearly indicates when the budget has been exceeded. If the expenses
surpass the budget, instead of showing a negative remaining balance, it displays "Exceeded", providing a straightforward
and immediate visual cue that the budget limits have been surpassed.

The "Categories above budget" section offers a concise table summarizing which categories have gone over the budget and
by what amount, making it easy for users to identify areas of concern.


#### Sequence diagrams

##### Setting a Budget
Expand Down Expand Up @@ -679,26 +637,23 @@ this `AddExpenseCommand`, do refer to the `Implementation` section for `AddExpen


### Setting Budget Feature
The Set Budget feature allows users to allocate a specific budget to various categories. This feature is managed by the
SetBudgetCommand class, which is instantiated by the SetBudgetCommandCreator as a result of the Parser class
interpretation. Within the SetBudgetCommand object, the following variables are initialized:

| Variable | Variable Type | Relevance |
|-------------|---------------|-------------------------------------------------------------------------|
| expenseList | ExpenseList | The ExpenseList object containing all the categories to set budgets for |
| category | String | The category for which the budget is to be set |
| budget | double | The financial limit allocated to the specified category |
The Budget Management feature allows users to set financial limits for the various categories and monitor their spending.
This feature's objective is to give users the ability to stay within their financial goals and avoid overspending.

When the execute() method is called via command.execute(), the SetBudgetCommand utilizes methods from the ExpenseList
class to apply the budget:
This feature is orchestrated by `ListBudgetCommand` and `SetBudgetCommand`, which are initialised by the `Parser`
class. Below is a description of the key class attributes and methods involved in the budget setting and listing
process:

| Method | Return Type | Relevance |
|-------------|-------------|----------------------------------------------------------|
| expenseList | ExpenseList | Sets the budget for a specific category within the list |
##### Class Attributes for `SetBudgetCommand`:
| Class Attribute | Variable Type | Relevance |
|-----------------|---------------|---------------------------------------------------------------------|
| expenseList | ExpenseList | Object containing the list of expenses to check against set budgets |
| category | String | The category for which the budget is being set |
| budget | double | The budget amount to be set for the category |

The UML Sequence diagram below illustrates the execution flow of the Set Budget Feature when a user inputs a valid
The UML Sequence diagram below illustrates the execution flow of the Set Budget Feature when a user inputs a valid
command to set a budget:
![SeqDiagramBudget.png](SeqDiagramBudget.png)
![sequenceDiagram_setBudget.jpg](diagrams%2FsequenceDiagram_setBudget.jpg)

The sequence of operations for an example input, `set budget c/Transport b/500`, is as follows:
1. BudgetBuddy receives the user input and utilizes the Parser to decipher it.
Expand All @@ -709,6 +664,33 @@ The sequence of operations for an example input, `set budget c/Transport b/500`,
6. The ExpenseList updates or creates a budget allocation for the specified category with the provided amount.
7. A confirmation message is displayed in the console indicating the budget has been successfully set or updated.

##### Class Attributes for `ListBudgetCommand`:
| Class Attribute | Variable Type | Relevance |
|-----------------|---------------|---------------------------------------------------------------------|
| expenseList | ExpenseList | Object containing the list of expenses to check against set budgets |

The UML Sequence diagram below illustrates the execution flow of the Set Budget Feature when a user inputs a valid
command to set a budget:
![sequenceDiagram_listBudget.png](diagrams%2FsequenceDiagram_listBudget.png)

Upon the call of the `execute()` method in `BudgetBuddy` using `command.execute()`, `SetBudgetCommand` will update the
budget in `ExpenseList` using `setBudget`. Similarly, `ListBudgetCommand` will fetch and display all categories with
their budgets using `getBudgets`, and highlight those that are above the set budget.

##### Key Methods used from `ExpenseList`
| Method | Return Type | Relevance |
|-----------------------------|---------------|--------------------------------------------------------------------|
| setBudget(category, budget) | void | Sets or updates the budget for a given category in the ExpenseList |
| getBudgets() | List<Budget> | Retrieves the list of all budgets set |

The `ListBudgetCommand`'s updated execution function now features an improved display that not only shows the budget,
spent amount, and remaining balance but also clearly indicates when the budget has been exceeded. If the expenses
surpass the budget, instead of showing a negative remaining balance, it displays "Exceeded", providing a straightforward
and immediate visual cue that the budget limits have been surpassed.

The "Categories above budget" section offers a concise table summarizing which categories have gone over the budget and
by what amount, making it easy for users to identify areas of concern.


## 5. Product scope

Expand Down
Binary file added docs/diagrams/sequenceDiagram_listBudget.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/diagrams/sequenceDiagram_setBudget.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions src/main/java/seedu/budgetbuddy/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import seedu.budgetbuddy.commandcreator.SettleSplitExpenseCommandCreator;
import seedu.budgetbuddy.commandcreator.SplitExpenseCommandCreator;
import seedu.budgetbuddy.commandcreator.GetBudgetCommandCreator;
import seedu.budgetbuddy.commandcreator.ListBudgetCommandCreator;
import seedu.budgetbuddy.commons.SavingList;
import seedu.budgetbuddy.commons.ExpenseList;
import seedu.budgetbuddy.commons.RecurringExpenseLists;
Expand Down Expand Up @@ -258,9 +259,9 @@ public Command parseCommand(ExpenseList expenses, SavingList savings, SplitExpen
return commandCreator.createCommand();
}
if (isListBudgetCommand(input)){
return handleListBudgetCommand(expenses);
CommandCreator commandCreator = new ListBudgetCommandCreator(expenses);
return commandCreator.createCommand();
}

if (isGetExpensesInsightsCommand(input)) {
CommandCreator commandCreator = new GetExpenseInsightsCommandCreator(expenses);
return commandCreator.createCommand();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package seedu.budgetbuddy.commandcreator;

import seedu.budgetbuddy.commons.ExpenseList;
import seedu.budgetbuddy.command.Command;
import seedu.budgetbuddy.command.ListBudgetCommand;

import java.util.logging.Level;
import java.util.logging.Logger;

public class ListBudgetCommandCreator extends CommandCreator {
private static final Logger LOGGER = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
private ExpenseList expenses;

public ListBudgetCommandCreator(ExpenseList expenses){
this.expenses = expenses;
}

@Override
public Command createCommand() {
LOGGER.log(Level.INFO, "Creating ListBudgetCommand");
return new ListBudgetCommand(expenses);
}
}

0 comments on commit 041758b

Please sign in to comment.