PROJECT: EYLAH


Overview

EYLAH is a desktop application programmed specifically for students staying in Temasek Hall at the National University of Singapore. It aims to ease their lives in hall by providing them with an application that split bills easily and help them keep track of their diet. The user interacts with the application using a CLI and it is programmed using Java 11.

Summary of contributions

  • Major Enhancements

    1. Added Entry and Receipt for Expense Splitter portion of EYLAH (Pull request #130)

      • What it does:
        Receipt is used to store multiple Entries, and these Entries are used to store the information about a particular Item and the Persons involved in splitting the cost of that Item.

      • Justification:
        These classes are required to keep track of Items and the Persons involved for each of that Item.

    2. Added AddItemCommand and enhanced the DeleteItemCommand for the Expense Splitter portion of EYLAH (Pull request #134, #163)

      • What it does:
        It simply adds a new Entry into the Receipt or deletes an existing Entry from the Receipt.

      • Justification:
        The AddItemCommand is required for users to input new Items and the Persons involved in splitting the cost of that Item. The DeleteItemCommand is for users to remove an Item in case he/she made a mistake or simply wants to remove the Item.

      • Highlights:
        These commands are only allowed to be used when the Receipt has not been marked as completed as this was accomplished using a boolean flag in the Receipt class. This is because of a bug that we discovered, which will be explained in the point below.

    3. Added a boolean flag in Receipt (Pull request #201)

      • What it does
        It checks if the Receipt is marked as complete (true) or incomplete (false).

      • Justification
        DeleteItemCommand actually removes the Amount owed by the person from the PersonAmountBook. So does the PaidCommand. As such, if a user uses the DeleteItemCommand after using the PaidCommand, and if the Amount owed goes to negative, an exception would be thrown due to the nature of BigDecimal (BigDecimal does not accept negative values). Hence, a flag was included to prevent this from happening.

    4. Added DoneReceiptCommand and ClearReceiptCommand for the Expense Splitter portion of EYLAH (Pull request #201, #204)

      • What it does:
        DoneReceiptCommand marks the Receipt as done and ClearReceiptCommand removes all existing Entries from the Receipt.

      • Justification:
        DoneReceiptCommand is required to toggle the boolean flag of Receipt to be done. ClearReceiptCommand does the opposite by toggling the Receipt back as undone.

      • Highlights:
        These commands are required to prevent an Exception being thrown with regards to negative BigDecimal values, as explained in the point above.

    5. Added CalculateUtil for EYLAH (Pull request #191)

      • What it does:
        CalculateUtil does all the handling of calculations required in EYLAH.

      • Justification:
        Abstraction, to make things easier and more streamlined in our application.

  • Minor Enhancements

    1. Removed case sensitivity when adding a new Person

      • What it does:
        All the names inputted by the user are now made into lowercase.

      • Justification
        This is to facilitate quicker use of the application as users would not be required to capitalize any names. Internally, this is also to prevent duplicate Person objects with the same name (but in different case sensitivity) from being created, i.e Bob vs bob or aLiCe vs alice.

    2. Fixed the rounding issue with regards to using BigDecimal as currency in our application

      • What it does:
        Decimals with regards to currency in EYLAH is made to be 2 decimal points (d.p).

      • Justification
        The Amount class only accepts decimals up till 2 d.p. Users are also made to only input decimals up till 2 d.p. However, the problem comes when dividing BigDecimals, e.g 10 / 3 = 3.333333…​ Since we create a new Amount object called amountPerPerson, i.e new Amount("3.33333"), this would throw an Exception. As such, I made it such that any all calculations with regards to BigDecimal and Amount would be kept at a maximum of 2 d.p to prevent this Exception from being thrown. In addition, I also did the formatting of the BigDecimal to be represented as a currency.

      • Credits

      • Added test cases for Entry and Receipt classes

      • Added test cases for AddItemCommand, DeleteItemCommand, DoneReceiptCommand and ClearReceiptCommand

      • Assisted in downscaling of AddressBook3 by removing Phone class

  • Code contributed:
    Functional and Test code

  • Other contributions:

    • Project management:

      • Lead for ExpenseSplitter portion of EYLAH.

      • Participated in planning the project timeline for EYLAH.

    • Enhancements to existing features:

      • Enhanced ParserUtil to be able to handle more inputted texts and output the required Objects.

      • Adapted the given Address Book 3 code into EYLAH.

    • Documentation:

      • Updated the Developer Guide to include AddItemCommand and DeleteItemCommand (Pull request #164, #171, #353, #409)

      • Updated the Developer Guide to include ClearReceiptCommand (Pull request #359, #409)

      • Updated the User Guide to include DoneReceiptCommand and ClearReceipt Command (Pull request #241)

      • Updated the User Guide to include Appendix H: Effort (Pull request #384)

      • Updated the User Guide with minor changes with regards to the use of English and to maintain consistency throughout the document (Pull request #411)

    • Community:

      • PRs reviewed (with non-trivial review comments): Pull requests #397

      • Reported bugs and suggestions for other teams in the class: ped

Code contributed

Please click the following link to see my code contributions dashboard. Code Report

Contributions to the User Guide

Given below are sections I contributed to the User Guide. They showcase my ability to write documentation targeting end-users.

Adding an item: additem

In this section, you will learn more about the additem command, how to use it and the expected outcome after using the additem command.

Summary of Add Item Command:
additem allows you to add an item, it’s price and the persons involved in sharing the cost of that item.

How to use the Add Item Command:

Format:
additem -i ITEMNAME -p PRICE -n NAME
additem -i ITEMNAME -p PRICE -n NAME [-n NAME]…​

Valid Example:
additem -i pizza -p 30 -n bob
additem -i pasta -p 19.90 -n alice -n bob -n charlie

Expected outcome:

expensesplitteradditemexpectedoutcome
Figure 1. Expense Splitter Add Item Command
  • Price can be up to 2 decimal places, i.e. 7.99. There is no need to add the dollar sign ($).

  • The maximum price of an item is 10,000.

  • All names inputted will automatically be converted to lowercase. (e.g: Bob → bob)


Deleting an item: deleteitem

In this section, you will learn more about the deleteitem command, how to use it and the expected outcome after using the deleteitem command.

Summary of Delete Item Command:
deleteitem allows you to delete an item from the receipt.

How to use the Delete Item Command:

Format:
deleteitem INDEX

Valid Example:
deleteitem 3

Expected outcome:

expensesplitterdeleteitemexpectedoutcome
Figure 2. Expense Splitter Delete Item Command
Use listreceipt to view your item indices before deletion.

Clears the receipt clearreceipt

In this section, you will learn more about the clearreceipt command, how to use it and the expected outcome after using the clearreceipt command.

Summary of Clear Receipt Command:
clearreceipt allows you to remove all items from the receipt and start with a clean receipt.

How to use the Clear Receipt Command:

Format:
clearreceipt

Valid Example:
clearreceipt

Expected outcome:

expensesplitterclearreceiptexpectedoutcome
Figure 3. Expense Splitter Clear Receipt Command
  • If you use this command before marking the receipt as done via the donereceipt command, you will be removing all the previously inputting items, as well as the amount owed by each person.

  • However, if you use this command after marking the receipt as done via the donereceipt command, the amount owed by each person will still be present and will be accessible via the listamount command.

  • After you use this command, you will be able to add new items using the additem command and delete items using the deleteitem command.

  • However, you will be unable to use the paid command.

Contributions to the Developer Guide

Given below are sections I contributed to the Developer Guide. They showcase my ability to write technical documentation and the technical depth of my contributions to the project.

Add Item Command

In this section, we will learn more about how the additem command is implemented.

What is the Add Item Command

The additem command allows the user to add an Item into the Receipt, along with the ItemPrice of the Item and the Persons involved in splitting the cost of that Item.

The additem command was implemented as AddItemCommand in the expensesplitter/logic/commands package.

The additem command has the following input format:

additem -i ITEMNAME -p ITEMPRICE -n NAME [-n NAME]…​

  • -i ITEMNAME and -p ITEMPRICE are compulsory fields.

  • There can be multiple -n NAME, however, a minimum of 1 is required.

  • ITEMPRICE can be up to 2 decimal places, i.e 7.99. There is no need to add the dollar sign ($).

The following activity diagram illustrates what happens when a user executes the additem command:

ExpenseSplitterAddItemCommandActivityDiagram
Figure 4. Add Item Command Activity Diagram

 

Structure of Add Item Command

In this section, you will learn more about the relationships between objects related to the AddItemCommand.

ExpenseSplitterAddItemCommandClassDiagram
Figure 5. Add Item Command Class Diagram

The above class diagram shows the structure of the AddItemCommand and it’s associated classes and interfaces. Some methods and fields have been left out because they are not of concern in the AddItemCommand.

Implementation of Add Item Command

The following is a detailed explanation of the operations AddItemCommand performs.

  1. The AddItemCommand#execute(SplitterModel splitterModel) method is executed and it checks if the specified Item and list of Persons to be added are valid. If valid, a new Entry would be created with the specified Item and list of Persons.

  2. The SplitterModel#addEntry(Entry entry) method would then be called to add the Entry into the Receipt.

  3. For each Person in the list of Persons, the Person is first checked through the PersonAmountBook#persons using the SplitterModel#hasPerson(Person person) method to check if the person already exists.

  4. If the person does not already exist, the method SplitterModel#addPerson(Person person) would be called to add the person, together with the amount, into the PersonAmountBook#persons.

  5. If the Person exists, the Person would be retrieved from the PersonAmountBook#persons using the SplitterModel#getPerson(Person person) method, and then the amount would be added to that person using the SplitterModel#addAmount(Person person, Amount amount) method.

Sequence diagram for Add Item Command

The following sequence diagram summarizes what happens during the execution of additem command.

ExpenseSplitterAddItemCommandSequenceDiagram
Figure 6. Add Item Command Sequence Diagram
ExpenseSplitterAddItemCommandSequenceDiagram2
Figure 7. Execution of Add Item Command

Delete Item Command

In this section, we will learn more about how the deleteitem command is implemented.

What is the Delete Item Command

The deleteitem command allows users to remove the Item from the Receipt via the Index.

The deleteitem command was implemented as DeleteItemCommand in the expensesplitter/logic/commands package.

The deleteitem command has the following input format:

deleteitem INDEX

  • INDEX is a compulsory field.

  • The Index of the Item can be retrieved by using the listreceipt command.

The following activity diagram illustrates what happens when a user executes the deleteitem command:

ExpenseSplitterDeleteItemCommandActivityDiagram
Figure 8. Delete Item Command Activity Diagram

 

Structure of Delete Item Command

In this section, you will learn more about the relationships between objects related to the DeleteItemCommand.

ExpenseSplitterDeleteItemCommandClassDiagram
Figure 9. Delete Item Command Class Diagram

The above class diagram shows the structure of the DeleteItemCommand and it’s associated classes and interfaces. Some methods and fields have been left out because they are not of concern in the DeleteItemCommand.

Implementation

The following is a detailed explanation of the operations DeleteItemCommand performs.

  1. The DeleteItemCommand#execute(SplitterModel splitterModel) method is executed and it validates that the specified Index to delete is within range. If valid, the Entry to be deleted will be retrieved from Receipt using its Index.

  2. The method SplitterModel#getEntry(Index index) is called to retrieve the current Entry, which subsequently retrieves the current Item using the Entry#getItem() method and the amountPerPerson associated with it via the Item#getAmountPerPerson() method. The list of Persons are also retrieved via the Entry#getPersonsList() method.

  3. For each Person in the list of Persons, the amount is subtracted from the current amount owed by the Person.

  4. The method SplitterModel#deleteEntry(int index) will then be called to remove the Item from the Receipt. Receipt#deleteEntry(int index) is invoked which makes a call to its internal list to remove the specified Item.

Sequence Diagram for Delete Item Command

The following sequence diagram summarizes what happens during the execution of deleteitem command.

ExpenseSplitterDeleteItemCommandSequenceDiagram
Figure 10. Delete Item Command Sequence Diagram
ExpenseSplitterDeleteItemCommandSequenceDiagram2
Figure 11. Execution of Delete Item Command

Clear Receipt Command

In this section, we will learn more about how the clearreceipt command is implemented.

What is the Clear Receipt Command

The clearreceipt command essentially deletes all the Entries in the Receipt and allows the user to input new Entries into a clean receipt.

The clearreceipt command was implemented as ClearReceiptCommand in the expensesplitter/logic/commands package.

The clearreceipt command has the following input format:

clearreceipt

  • Use this command only when you are very sure that you want to delete all entries and start a clean receipt.

  • When you use the clearreceipt command, you are concurrently marking the new receipt as undone. As such, you would only be able to use the additem and deleteitem commands.

The following activity diagram illustrates what happens when a user executes the clearreceipt command:

ExpenseSplitterClearReceiptCommandActivityDiagram
Figure 12. Clear Receipt Command Activity Diagram

 

Structure of Clear Receipt Command

In this section, you will learn more about the relationships between objects related to the ClearReceiptCommand.

ExpenseSplitterClearReceiptCommandClassDiagram
Figure 13. Clear Receipt Command Class Diagram

The above class diagram shows the structure of the ClearReceiptCommand and it’s associated classes and interfaces. Some methods and fields have been left out because they are not of concern in the ClearReceiptCommand.

Implementation of Clear Receipt Command

The following is a detailed explanation of the operations ClearReceiptCommand performs.

  1. The ClearReceiptCommand#execute(SplitterModel splitterModel) method is executed.

  2. If the Receipt is marked as undone via the SplitterModel#isReceiptDone() method, the SplitterModel#deleteAllEntires() method is called, which calls the PersonAmountBook#deleteAllEntries() method. What does method does is that it first retrieves the ArrayList<Entry> from the Receipt via the Receipt#getReceipt() method, then for each Entry, it gets the Item and the Amount owed my each person via the Entry#getItem() and Item#getAmountPerPerson() methods respectively. The Amount is then removed from each Person in the Entry via the Entry#getPersonsList() method. After which, the splitterModel#clearReceipt() method will then be called. This will invoke the Receipt#clearReceipt() method which creates a new ArrayList and assigns it to the Receipt. At the same time, the boolean Receipt#isDone is assigned to false.

  3. If the Receipt is marked as done, the splitterModel#clearReceipt() method will then be called. This will invoke the Receipt#clearReceipt() method which creates a new ArrayList and assigns it to the Receipt. At the same time, the boolean Receipt#isDone is assigned to false.

Sequence Diagram for Clear Receipt Command

The following sequence diagram summarizes what happens during the execution of the clearreceipt command.

ExpenseSplitterClearReceiptCommandSequenceDiagram
Figure 14. Clear Receipt Command Sequence Diagram
ExpenseSplitterClearReceiptCommandSequenceDiagram2
Figure 15. Execution of Clear Receipt Command

Use case: UC08 - Adding an Item

Actor: User
Guarantees:
Item will be added into the Receipt.

MSS

  1. User keys in the ItemName, it’s ItemPrice and Person(s) involved in the splitting of the Item.

  2. EYLAH adds the Item and Persons into a Entry.

  3. EYLAH adds the Entry into a Receipt.

  4. EYLAH displays the Item and Person(s) involved in the splitting of the item, as well as the Amount owed per Person.

    Use case ends.

Extensions

  • 1a. EYLAH detects empty ItemName, ItemPrice or Person(s)

    • 1a1. EYLAH displays an error message and displays an example of a correct additem function.

      Use case ends.

  • 1b. Eylah detects invalid syntax.

    • 1b1. EYLAH displays an error message and displays an example of a correct additem function.

      Use case ends.


Use case: UC09 - Deleting an Item

Actor: User
Preconditions: Item user wants to delete is present in the Receipt.
Guarantees:
Item will be deleted from Receipt.

MSS

  1. User keys in request to delete an Item in the current Receipt via it’s Index.

  2. EYLAH deletes that Item and deducts the appropriate amount associated with each Person(s) involved in splitting that Item.

  3. EYLAH displays a MESSAGE_SUCCESS informing the user that Item has been successfully deleted.

    Use case ends.

Extensions

  • 1a. User did not input the Index of the Item. (Inserting deleteitem instead of deleteitem 1)

    • 1a1. EYLAH displays an error message and displays an example of a correct deleteitem function.

      Use case ends.


Use case: UC13 - Clearing the Receipt when Receipt is done

Actor: User
Preconditions: Receipt is marked as done.
Guarantees:
Deletes all the Entries in the Receipt. It also marks the Receipt as undone.

MSS

  1. User requests to clear the receipt after he/she decides to start a clean Receipt.

  2. EYLAH removes all the Entries from the Receipt.

  3. EYLAH marks the Receipt as undone.

  4. EYLAH display a MESSAGE_SUCCESS informing the user that the Receipt has been successfully cleared.

    Use case ends.

Use case: UC14 - Clearing the Receipt when Receipt is undone

Actor: User
Preconditions: Receipt is marked as undone.
Guarantees:
Deletes all the Entries in the Receipt. It also marks the Receipt as undone.

MSS

  1. User requests to clear the receipt after he/she decides to start a clean Receipt.

  2. EYLAH removes Amount owed per Person from the PersonAmountBook.

  3. EYLAH removes all the Entries from the Receipt.

  4. EYLAH display a MESSAGE_SUCCESS informing the user that the Receipt has been successfully cleared.

    Use case ends.


Add Item In Expense Splitter

  1. Adding an Item into the current Receipt.

    1. Add Item Command format: additem -i ITEMNAME -p ITEMPRICE -n PERSON [-n PERSON]…​

    2. Test case: additem -i pasta -p 33.50 -n John -n Bob
      Expected: Adds an item with the above details to current receipt and increase the person amount equal to dividing the price with the number of person splitting that item.

    3. Test case: Invalid Syntax
      Expected: No item is added to the current receipt and no change to person amount. An error message will be displayed.


Delete Item In Expense Splitter

  1. Deleting an Item from the current Receipt.

    1. Delete Item Command format: deleteitem INDEX

    2. Test case: delete 1
      Expected: Removes the item of the specified index from the receipt.

    3. Test case: Invalid Syntax
      Expected: No item will be deleted from the current receipt. An error message will be displayed.


Done Receipt In Expense Splitter

  1. Marks the current receipt as done.

    1. Done Receipt Command format: donereceipt

    2. Test case: donereceipt
      Expected: The receipt is marked as done. A success message will be displayed.


Clear Receipt In Expense Splitter

  1. Clears the receipt and marks the receipt as undone.

    1. Clear Receipt Command format: clearreceipt

    2. Test case: clearreceipt
      Expected: The receipt is cleared and is marked as undone. A success message will be displayed.