Skip to content

Commit

Permalink
Merge pull request #178 from Dandford/master
Browse files Browse the repository at this point in the history
Updating UserDocs
  • Loading branch information
jessicax941 authored Oct 30, 2019
2 parents 48b8b14 + ec5b7dd commit b4aa1b9
Show file tree
Hide file tree
Showing 7 changed files with 281 additions and 65 deletions.
228 changes: 165 additions & 63 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -52,38 +52,48 @@ e.g. typing *`help`* and pressing kbd:[Enter] will open the help window.

=== Expenses and Income

==== Adding a expense: `addExpense`
Adds a new expenditure to your total/daily/weekly/monthly spending with current timestamp. Inputs can be arranged in a different order. Description and tag may be omitted from the expenditure record.
==== Adding Expense: `add`
Adds a new expenditure to your total/daily/weekly/monthly spending with current timestamp. Inputs can be arranged in a different order.Tag may be omitted from the expenditure record. Category must already exist in the list of category.

Format: `addExpense [--desc <description>] [--tag <tag>] --amt <expenditure>`
Format: `add typ/Expense cat/<category> n/<description> amt/<expenditure> d/<date> [--tag <tag>]`

Examples:

* `addExpense --desc deck mala --tag food --amt 5.60`
* `addExpense --tag food --amt 5.60`
* `addExpense --amt 5.60 --cat food`
* `addExpense --amt 5.60`
* `add cat/Food typ/Expense n/Mala amt/5.50 d/2019 09 09 tg/food tg/indulgence`
* `add cat/Travel typ/Expense n/Travel To Alaska amt/550000 d/2019 09 09`

==== Editing a expense: `editExpense`
==== Adding Income : `add`
Adds a new Income to your total/daily/weekly/monthly spending with current timestamp. Inputs can be arranged in a different order. Tag may be omitted from the expenditure record. . Category must already exist in the list of category.

Edits a current expenditure with the given index number
Format: `add typ/Income cat/<category> n/<description> amt/<expenditure> d/<date> [--tag <tag>]`

Format: `editExpense <index> [--desc <description>] [--tag <tag>] [--amt <expenditure>]`
Examples:

* `add cat/Gifts typ/Income n/Durian amt/200.00 d/2019 09 09 tg/food`
* `add cat/Business typ/Income n/business Trip To Mars amt/20000.00 d/2019 09 09`

==== Editing a expense/income: `edit`

Edits a current entry with the given index number. Category must already exist in the list of category.

Format: `edit <index> [cat/<category>] [n/<description>] [d/<date>] [amt/ <expenditure>] [--tag <tag>]`

Examples:

* `editExpense 1 --desc deck mala with friends`
* `editExpense 1 --tag mala --amt 5.33`
* `edit 1 cat/Food n/deck mala with friends`
* `edit 3 cat/Business n/Selling Coding Services amt/0.01`
* `edit 5 tg/helpmykidneys`

==== Deleting a expense: `deleteExpense`
==== Deleting a expense/income: `delete`

Deletes the recorded expenditure with the given index number.

Format: `deleteExpense <index>`
Format: `delete <index>`

Examples:

* `deleteExpense 2`
* `delete 2`
* `delete 4`

==== Adding AutoExpenditure : `addAutoExpenditure`

Expand Down Expand Up @@ -112,38 +122,6 @@ Deletes a current automatically recurring expenditure at the given index.

Format: `deleteAutoExpenditure <index>`

==== Adding Income : `addIncome`

Adds the amount to your total income. Inputs can be arranged in a different order. Description may be omitted from the income record.

Format: `addIncome [n/<description>] amt/<income amount>`

Examples:

* `addIncome amt/6000`
* `addIncome amt/1000 n/year-end bonus!! :DD`

==== Editing Income : `editIncome`

Edits a current income record at the given index number.

Format: `editIncome <index> [n/<description>] [amt/<income amount>] [t/<tag>]`

Examples:

* `editIncome 1 n/salary for feb`
* `editIncome 1 n/february amt/650 t/salary`

==== Deleting Income : `deleteIncome`

Deletes the recorded income at the given index number.

Format: `deleteIncome <index>`

Examples:

* `deleteIncome 3`

==== Adding Budget : 'addBudget`

Adds a new budget for expenditure with a certain tag, if applicable. Period: day/week/month
Expand Down Expand Up @@ -187,19 +165,122 @@ Examples:

* `deleteBudget 2`

==== Adding Category : 'addCategory`

Adds a new Category for either Income or Expense. The category added must not exist in the application.

Format: `addCategory cat/<Category> n/<CategoryName>`

Examples:

* `addCategory cat/Expense n/Transport`
* `addCategory cat/Income n/Lottery`

==== Editing Category : 'editCategory`
Edits a current category's description.

Format: `editCategory typ/<CategoryType> cat/<OldNameOfCategory> n/<NewNameOfCategory>`

Examples:

* `editCategory typ/Income cat/Business n/HotelManagement`
* `editCategory typ/Expense cat/Family n/Baby Planning`

==== Listing Categories : 'listCategories`

Lists all the current categories the user has.

Format: `listCategories`

Examples:

* `listCategories`

==== Deleting Category : `deleteCategory`
Deletes a category from guiltTrip. The category that is deleted should not have any entries.

Format: `deleteCategory cat/<CategoryType> n/<CategoryName>`

Examples:

* `deleteCategory cat/Income n/Business`
* `deleteCategory cat/Expense n/Food`

==== Adding a Loan : `addLoan` [coming in v2.0]
Adds a new loan with the given description, amount and interest (in percentage) and calculates the total outstanding amount based on the interest.

Format: `addLoan n/<description> amt/<loan amount> i/<interest>`

Example:

* `addLoan n/student loan amt/30000 i/4.5`

==== Listing a loan : `listLoan` [coming in v2.0]
Lists all the loans that the user has.

Format: `listLoan`

Example: `listLoan`

==== Editing a loan : `editLoan` [coming in v2.0]
Edits a current loan's description, loan amount, or both.

Format: `editLoan <index> [n/<description>] [amt/<loan amount>] [i/<interest>]`

Example:

* `editLoan 1 n/nus tuition loan T.T`
* `editLoan 1 amt/25000 i/4.45%`

==== Deleting a loan : `deleteLoan` [coming in v2.0]

Deletes a current loan at the given index.

Format: `deleteLoan <index>`

Example:

* `deleteLoan 1`

==== Paying a loan : `payLoan` [coming in v2.0]

Reduces the loan amount for the loan at the given index after user pays for part of the loan.

Format: `payLoan <index> amt/<amountPaid>`

Example:

* `payLoan 1 amt/4000`

=== Statistics

==== Viewing History : `viewHistory`
View past expenditure/ income from startDate to endDate (if present). If startDate not present, lists from 1 month before endDate. If endDate not present, list to current time.
==== Switching to Statistics View : `switch`
Switches between the entry view and the statistics summary.

Format: `switch`

Example:

`switch`

==== Switching to Statistics View : `switchStats`
Switches between the statistics table view and the statistics graph view.

Format: `viewHistory -- cat <category> [--period <startDate>, <endDate>]`
Format: `switchStats`

Example:

* `viewHistory -- cat expenditure`
* `viewHistory -- cat expenditure --period 11/9/2019, 21/9/2019`
* `viewHistory -- cat income --period 11/9/2019`
* `viewHistory -- cat expenditure --period ,2 21/9/2019`
`switchStats`

==== Viewing Statistics : `viewStatistics`
View past expenditure/ income by Month. If not present, will only show current Month.

Format: `viewStatistics [p/<Date>]`

Example:

* `viewStatistics`
* `viewStatistics p/2019-09`

==== Sorting : `sort`

Expand All @@ -213,20 +294,41 @@ Example:
* `sort typ/amount s/ascending`
* `sort typ/category s/descending`

==== Search : `search`
==== Search : `find`

Search income/expenditure by Category,Description,Amount,Date or Tags. There must be at least one find parameter.

Format: `find [cat/<category>] [n/<description>] [amt/<expenditure>] [d/<date>] [--tag <tag>]`

Example:

* `find cat/food n/mala: lists each entry in expenditure and income with title containing keyword “mala” and category of Food.`
* `find cat/business d/2019-09-09: lists each entry in expenditure and income with date of "2019-09-09" and category of business.`
* `find d/2019-09-09 tg/a tg/b: lists each entry in expenditure and income with date of "2019-09-09" and tags of a and b.`

==== Search Wish: `findWish`

Search Wish by Category,Description,Amount,Date or Tags. There must be at least one find parameter.

Format: `findWish [cat/<category>] [n/<description>] [amt/<expenditure>] [d/<date>] [--tag <tag>]`

Example:

* `findWish cat/food n/mala: lists each entry in Wish with title containing keyword “mala” and category of Food.`
* `findWish cat/business d/2019-09-09: lists each entry in Wish with date of "2019-09-09" and category of business.`
* `findWish d/2019-09-09 tg/a tg/b: lists each entry in Wish with date of "2019-09-09" and tags of a and b.`

==== Search Budget: `findBudget`

Search income/expenditure list/ wishlist for keyword/ tag.
Search Budget by Category,Description,Amount,Date or Tags. There must be at least one find parameter.

Format: `Search [--cat <category>] --key <keyword> || --amt <(== || < || > || <= || >=) amount> || --tag <tag>`
Format: `findBudget [cat/<category>] [n/<description>] [amt/<expenditure>] [d/<date>] [--tag <tag>]`

Example:

* `search --cat expenditure --key book: lists each entry in expenditure with title containing keyword “book”.`
* `search --cat wishlist --key monitor: lists each entry in expenditure with title containing keyword “monitor”`
* `search --key book: search everything in database with keyword “book”.`
* `search --cat expenditure --tag _CLOTHING: lists each entry in expenditure with tag _CLOTHING.`
* `search --cat wishlist --tag _BOOK: lists each entry in wishlist with tag _BOOK.`
* `search --cat expenditure --amt >100: list each entry in expenditure over $100.`
* `findBudget cat/food n/mala: lists each entry in Budget with title containing keyword “mala” and category of Food.`
* `findBudget cat/business d/2019-09-09: lists each entry in Budget with date of "2019-09-09" and category of business.`
* `findBudget d/2019-09-09 tg/a tg/b: lists each entry in Budget with date of "2019-09-09" and tags of a and b.`

=== Organization

Expand Down
24 changes: 23 additions & 1 deletion src/main/java/seedu/address/logic/parser/FindCommandParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,22 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_DESC;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.function.Predicate;

import seedu.address.logic.commands.FindCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.person.Entry;
import seedu.address.model.person.predicates.AmountContainsValuePredicate;
import seedu.address.model.person.predicates.DescriptionContainsKeywordsPredicate;
import seedu.address.model.person.predicates.EntryContainsDatePredicate;
import seedu.address.model.person.predicates.EntryContainsTagsPredicate;
import seedu.address.model.person.predicates.entries.CategoryContainsKeywordsPredicate;
import seedu.address.model.tag.Tag;

/**
* Parses input arguments and creates a new FindCommand object
Expand All @@ -31,6 +37,7 @@ public class FindCommandParser implements Parser<FindCommand> {
public FindCommand parse(String args) throws ParseException {
ArgumentMultimap argMultimap =
ArgumentTokenizer.tokenize(args, PREFIX_CATEGORY, PREFIX_DESC, PREFIX_DATE, PREFIX_AMOUNT, PREFIX_TAG);

List<Predicate<Entry>> predicateList = new ArrayList<Predicate<Entry>>();
if (argMultimap.getValue(PREFIX_DESC).isPresent()) {
String trimmedArgs = ParserUtil.parseDescription(argMultimap.getValue(PREFIX_DESC).get()).fullDesc.trim();
Expand All @@ -44,10 +51,25 @@ public FindCommand parse(String args) throws ParseException {
}

if (argMultimap.getValue(PREFIX_AMOUNT).isPresent()) {
double trimmedDouble = ParserUtil.parseAmount(argMultimap.getValue(PREFIX_AMOUNT).get()).value;
double trimmedDouble = ParserUtil.parseAmount(argMultimap.getValue(PREFIX_AMOUNT).get().trim()).value;
predicateList.add(new AmountContainsValuePredicate(trimmedDouble));
}

if (argMultimap.getValue(PREFIX_CATEGORY).isPresent()) {
String name = argMultimap.getValue(PREFIX_CATEGORY).get().trim();
predicateList.add(new CategoryContainsKeywordsPredicate(name));
}

if (argMultimap.getValue(PREFIX_DATE).isPresent()) {
LocalDate dateToCompare = ParserUtil.parseDate(argMultimap.getValue(PREFIX_DATE).get().trim()).getDate();
predicateList.add(new EntryContainsDatePredicate(dateToCompare));
}

if (argMultimap.getValue(PREFIX_TAG).isPresent()) {
Set<Tag> tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG));
predicateList.add(new EntryContainsTagsPredicate(tagList));
}

if (predicateList.size() == 0) {
throw new ParseException(FindCommand.INSUFFICENT_ARGUMENTS);
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/seedu/address/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ public void setEntry(Entry target, Entry editedEntry) {
Income incomeToEdit = versionedAddressBook.getIncomeList().filtered(t -> t == target).get(0);
Income toEditEntry = new Income(editedEntry.getCategory(), editedEntry.getDesc(), editedEntry.getDate(),
editedEntry.getAmount(), editedEntry.getTags());
versionedAddressBook.setEntry(incomeToEdit, toEditEntry);
versionedAddressBook.setIncome(incomeToEdit, toEditEntry);
}
filteredReminders.filtered(PREDICATE_SHOW_ACTIVE_REMINDERS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import seedu.address.model.person.Entry;

/**
* Tests that a {@code Person}'s {@code Name} matches any of the keywords given.
* Tests that a {@code Entry's}'s {@code Description} matches any of the keywords given.
*/
public class DescriptionContainsKeywordsPredicate implements Predicate<Entry> {
private final List<String> keywords;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package seedu.address.model.person.predicates;

import java.time.LocalDate;
import java.util.function.Predicate;

import seedu.address.model.person.Entry;

/**
* Tests that a {@code Entry's}'s {@code LocalDate} matches any of the keywords given.
*/
public class EntryContainsDatePredicate implements Predicate<Entry> {
private final LocalDate dateToFilter;

public EntryContainsDatePredicate(LocalDate dateToFilter) {
this.dateToFilter = dateToFilter;
}

@Override
public boolean test(Entry entry) {
return dateToFilter.equals(entry.getDate().getDate());
}

@Override
public boolean equals(Object other) {
return other == this // short circuit if same object
|| (other instanceof EntryContainsDatePredicate // instanceof handles nulls
&& dateToFilter == (((EntryContainsDatePredicate) other).dateToFilter)); // state check
}
}
Loading

0 comments on commit b4aa1b9

Please sign in to comment.