Skip to content

Commit

Permalink
Merge pull request #198 from mukund1403/master
Browse files Browse the repository at this point in the history
Update dg for expense
  • Loading branch information
MonkeScripts committed Apr 15, 2024
2 parents 6e675ad + e57cf79 commit d2b5be8
Show file tree
Hide file tree
Showing 3 changed files with 190 additions and 3 deletions.
35 changes: 32 additions & 3 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ The Group Storage feature:
The implementation of the Group Storage feature is covered in the next section.


### Expenses
The Expenses feature allows users to add and delete expenses. It does this through an intermediate
ExpenseCommand class which handles Parser input and calls the Expense constructor to create a new expense.

Below is the class diagram for Expense feature:

![ExpenseClassDiagram.png](images/ExpenseClassDiagram.png)

The Expense feature:
- `Expense` class: Represents a new expense with total Amount, payer, payee list with amount owed by each payee and description of expense
- `ExpenseCommand` class: Responsible for taking in the user input and creating a new object of the Expense class. Also handles deletion of expense objects.
- It contains the `addEqualExpense` and `addUnequalExpense` methods to handle both kinds of expenses.
- It also uses the `Money` class to add the correct currency to totalAmount and payee Amounts.

The implementation of Expense is covered in the next section.

## Implementation

### Help menu feature
Expand Down Expand Up @@ -97,17 +113,30 @@ The following sequence diagram illustrates the flow of the "Add Member to Group"

#### Implementation

The Expenses feature is facilitated through the Expense class. It allows users to add a new Expense through creation of
The Expenses feature is facilitated through the Expense class and ExpenseCommand class. It allows users to add a new Expense through creation of
a new Expense object. Users can specify amount paid, the payee, and the members of the group involved in the
transaction.
Additionally, it implements the following operations:

It implements the following operations:


+ `Expense#addExpense` - Creates a new expense and adds it to the expense list
+ `Expense#deleteExpense` - Deletes an existing expense
These operations are exposed in the ExpenseCommand class through the `addExpense` and `deleteExpense` functions respectively.


Additionally, it implements the following:
+ `Expenses#payer()` - Gives the name of the member who paid for the expense
+ `Expenses#totalAmount()` - Returns the total amount of the expense
+ `Expenses#payees()` - Returns all the members involved in the transaction
+ `Expenses#currency()` - Returns the currency of the expense

These operations are exposed in the Expense class through the `getPayerName()`, `getTotalAmount()`, and `getPayees()`
These operations are exposed in the Expense class through the `getPayerName()`, `getTotalAmount()`, `getPayees()`, and `getCurrency()`
functions respectively.


The following sequence diagrams show the process of adding an equal split and unequal split expense:

![Sequence Diagram](images/equal.png)
![Sequence Diagram](images/unequal.png)

Expand Down
158 changes: 158 additions & 0 deletions docs/diagrams/ExpenseCommandClassDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
@startuml

/' diagram meta data start
config=StructureConfiguration;
{
"projectClassification": {
"searchMode": "OpenProject", // OpenProject, AllProjects
"includedProjects": "",
"pathEndKeywords": "*.impl",
"isClientPath": "",
"isClientName": "",
"isTestPath": "",
"isTestName": "",
"isMappingPath": "",
"isMappingName": "",
"isDataAccessPath": "",
"isDataAccessName": "",
"isDataStructurePath": "",
"isDataStructureName": "",
"isInterfaceStructuresPath": "",
"isInterfaceStructuresName": "",
"isEntryPointPath": "",
"isEntryPointName": "",
"treatFinalFieldsAsMandatory": false
},
"graphRestriction": {
"classPackageExcludeFilter": "",
"classPackageIncludeFilter": "",
"classNameExcludeFilter": "",
"classNameIncludeFilter": "",
"methodNameExcludeFilter": "",
"methodNameIncludeFilter": "",
"removeByInheritance": "", // inheritance/annotation based filtering is done in a second step
"removeByAnnotation": "",
"removeByClassPackage": "", // cleanup the graph after inheritance/annotation based filtering is done
"removeByClassName": "",
"cutMappings": false,
"cutEnum": true,
"cutTests": true,
"cutClient": true,
"cutDataAccess": false,
"cutInterfaceStructures": false,
"cutDataStructures": false,
"cutGetterAndSetter": true,
"cutConstructors": true
},
"graphTraversal": {
"forwardDepth": 6,
"backwardDepth": 6,
"classPackageExcludeFilter": "",
"classPackageIncludeFilter": "",
"classNameExcludeFilter": "",
"classNameIncludeFilter": "",
"methodNameExcludeFilter": "",
"methodNameIncludeFilter": "",
"hideMappings": false,
"hideDataStructures": false,
"hidePrivateMethods": true,
"hideInterfaceCalls": true, // indirection: implementation -> interface (is hidden) -> implementation
"onlyShowApplicationEntryPoints": false, // root node is included
"useMethodCallsForStructureDiagram": "ForwardOnly" // ForwardOnly, BothDirections, No
},
"details": {
"aggregation": "GroupByClass", // ByClass, GroupByClass, None
"showClassGenericTypes": true,
"showMethods": true,
"showMethodParameterNames": true,
"showMethodParameterTypes": true,
"showMethodReturnType": true,
"showPackageLevels": 2,
"showDetailedClassStructure": true
},
"rootClass": "seedu.duke.commands.ExpenseCommand",
"extensionCallbackMethod": "" // qualified.class.name#methodName - signature: public static String method(String)
}
diagram meta data end '/



digraph g {
rankdir="TB"
splines=polyline


'nodes
subgraph cluster_3094955 {
label=duke
labeljust=l
fillcolor="#ececec"
style=filled

Expense1407063755[
label=<<TABLE BORDER="1" CELLBORDER="0" CELLPADDING="4" CELLSPACING="0">
<TR><TD ALIGN="CENTRE" >Expense</TD></TR>
<HR/>
<TR><TD ALIGN="LEFT" >- description: String </TD></TR>
<TR><TD ALIGN="LEFT" >- payees: ArrayList&lt;Pair&lt;String, Money&gt;&gt; </TD></TR>
<TR><TD ALIGN="LEFT" >- payerName: String</TD></TR>
<TR><TD ALIGN="LEFT" >- totalAmount: Money </TD></TR>
<HR/>
<TR><TD ALIGN="LEFT" >+ clear()</TD></TR>
<TR><TD ALIGN="LEFT" >+ clearPayeeValue(payeeName: String)</TD></TR>
<TR><TD ALIGN="LEFT" >+ successMessageString(): String</TD></TR>
</TABLE>>
style=filled
margin=0
shape=plaintext
fillcolor="#FFFFFF"
];


subgraph cluster_507334344 {
label=storage
labeljust=l
fillcolor="#d8d8d8"
style=filled

}

subgraph cluster_867077269 {
label=commands
labeljust=l
fillcolor="#d8d8d8"
style=filled

ExpenseCommand1418370849[
label=<<TABLE BORDER="1" CELLBORDER="0" CELLPADDING="4" CELLSPACING="0">
<TR><TD ALIGN="CENTRE" >ExpenseCommand</TD></TR>
<HR/>
<TR><TD ALIGN="LEFT" >+ addExpense(params: HashMap&lt;String, ArrayList&lt;String&gt;&gt;, argument: String, userInput: String)</TD></TR>
<TR><TD ALIGN="LEFT" >+ addEqualExpense(payeeList: ArrayList&lt;String&gt;, payees: ArrayList&lt;Pair&lt;String, Money&gt;&gt;, totalAmountAndCurrency: Money, payerName: String, argument: String): Expense</TD></TR>
<TR><TD ALIGN="LEFT" >+ addUnequalExpense(payeeList: ArrayList&lt;String&gt;, payees: ArrayList&lt;Pair&lt;String, Money&gt;&gt;, totalAmountAndCurrency: Money, payerName: String, argument: String): Expense</TD></TR>
<TR><TD ALIGN="LEFT" >- checkDescription(argument: String)</TD></TR>
<TR><TD ALIGN="LEFT" >- checkPayeeInGroup(payee: String)</TD></TR>
<TR><TD ALIGN="LEFT" >+ deleteExpense(listIndex: String)</TD></TR>
<TR><TD ALIGN="LEFT" >+ getCurrency(currencyString: String): CurrencyConversions</TD></TR>
<TR><TD ALIGN="LEFT" >+ getListIndex(listIndex: String, listSize: int): int</TD></TR>
<TR><TD ALIGN="LEFT" >+ getTotal(params: HashMap&lt;String, ArrayList&lt;String&gt;&gt;): Float</TD></TR>
<TR><TD ALIGN="LEFT" >- mergeBack(splitArray: String[]): String</TD></TR>
</TABLE>>
style=filled
margin=0
shape=plaintext
fillcolor="#FFFFFF"
];
}
}

'edges



ExpenseCommand1418370849 -> Expense1407063755[label="addExpense() -> successMessageString()"];



}
@enduml
Binary file added docs/images/ExpenseClassDiagram.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 d2b5be8

Please sign in to comment.