diff --git a/docs/AboutUs.adoc b/docs/AboutUs.adoc index 630b1385c0c..6b30ce7623e 100644 --- a/docs/AboutUs.adoc +++ b/docs/AboutUs.adoc @@ -39,7 +39,7 @@ Responsibilities: Testing, Data organisation === Tay Yu Hong image::yuhongtay.png[width="150", align="left"] -{empty}[https://github.com/yuhongtay[github]] [http://localhost:63342/Group%20Project/Group_Project/build/docs/html5/team/yuhongtay.html?_ijt=8knnqjm52asvlcuj89bdqjpqd9[portfolio]] +{empty}[https://github.com/yuhongtay[github]] [<>] Role: Developer + Responsibilities: Code quality, Reminders diff --git a/docs/team/swampertx.adoc b/docs/team/swampertx.adoc index 3a0e4dfd33c..b6385b09cb1 100644 --- a/docs/team/swampertx.adoc +++ b/docs/team/swampertx.adoc @@ -11,7 +11,7 @@ Craving for a nice bowl of Mala but can’t seem to save up enough for it? guiltTrip() is the perfect platform for those *aspiring to be able to afford their Mala*, finally! - +nk == Summary of contributions * *Major enhancement 1*: added *AutoSuggestion for any command input* @@ -49,7 +49,7 @@ Craving for a nice bowl of Mala but can’t seem to save up enough for it? guilt * *Minor enhancement*: added a history command that allows the user to navigate to previous commands using up/down keys. -* *Code contributed*: [https://github.com[Functional code]] [https://github.com[Test code]] _{give links to collated code files}_ +* *Code contributed*: https://nus-cs2103-ay1920s1.github.io/tp-dashboard/#search=swampertx&sort=groupTitle&sortWithin=title&since=2019-09-06&timeframe=commit&mergegroup=false&groupSelect=groupByRepos&breakdown=false[Functional code] * *Other contributions*: diff --git a/src/main/java/seedu/guilttrip/model/GuiltTrip.java b/src/main/java/seedu/guilttrip/model/GuiltTrip.java index c26586b51d5..73f1feaa611 100644 --- a/src/main/java/seedu/guilttrip/model/GuiltTrip.java +++ b/src/main/java/seedu/guilttrip/model/GuiltTrip.java @@ -481,7 +481,6 @@ public void setReminder(Reminder target, Reminder editedEntry) { public void setBudget(Budget target, Budget editedEntry) { requireNonNull(editedEntry); budgets.setBudget(target, editedEntry); - reminders.setEntryUpdate(target, editedEntry); conditions.setEntryUpdate(target, editedEntry); indicateModified(); } diff --git a/src/main/java/seedu/guilttrip/model/reminders/EntryReminder.java b/src/main/java/seedu/guilttrip/model/reminders/EntryReminder.java index dab1d617c0b..769e0e9d95a 100644 --- a/src/main/java/seedu/guilttrip/model/reminders/EntryReminder.java +++ b/src/main/java/seedu/guilttrip/model/reminders/EntryReminder.java @@ -160,7 +160,7 @@ public void update() { if (!currDate.isBefore(nextActive)) { newStatus = Status.met; } - if (currDate.isAfter(entry.getDate())) { + if (currDate.isEqual(entry.getDate()) || currDate.isAfter(entry.getDate())) { newStatus = Status.exceeded; entry.setHasReminder(false); entry.setUniqueId(null); @@ -184,6 +184,9 @@ public void reset() { public Status getStatus() { return this.status; } + public void setStatus(Status status) { + this.status = status; + } public boolean willDisplayPopUp() { return displayPopUp; }; diff --git a/src/main/java/seedu/guilttrip/model/reminders/ReminderList.java b/src/main/java/seedu/guilttrip/model/reminders/ReminderList.java index f8a3e2b1ee8..811880aac51 100644 --- a/src/main/java/seedu/guilttrip/model/reminders/ReminderList.java +++ b/src/main/java/seedu/guilttrip/model/reminders/ReminderList.java @@ -153,10 +153,8 @@ public ObservableList asUnmodifiableNotificationList() { * Transfers entry reminder from beingRemove to beingAdded. */ public void setEntryUpdate(Entry beingRemove, Entry beingAdded) { - TimeUtil.startTimer(); - TimeUtil.forceSetDate(new Date("11/11/2019")); if (beingAdded.getDate().isAfter(new Date(TimeUtil.getLastRecordedDate())) && beingRemove.hasReminder()) { - Optional optReminder = findReminderFOrEntry(beingRemove); + Optional optReminder = findReminderForEntry(beingRemove); if (optReminder.isPresent()) { Reminder reminder = optReminder.get(); logger.info("transferring reminder to new entry"); @@ -170,22 +168,20 @@ public void setEntryUpdate(Entry beingRemove, Entry beingAdded) { */ public void deleteEntryUpdate(Entry beingRemoved) { if (beingRemoved.hasReminder()) { - for (Reminder reminder : internalList.filtered(isEntryReminder)) { - if (reminder.getUniqueId().equals(beingRemoved.getUniqueId())) { - internalList.remove(reminder); - } - } + Optional reminder = findReminderForEntry(beingRemoved); + EntryReminder entryReminder = (EntryReminder) reminder.get(); + entryReminder.setStatus(Reminder.Status.exceeded); } } /** * Finds the entry reminder in the list. - * @param beingAdded entry being added. + * @param beingRemoved entry being removed. * @return */ - private Optional findReminderFOrEntry(Entry beingAdded) { + private Optional findReminderForEntry(Entry beingRemoved) { for (Reminder reminder : internalList.filtered(isEntryReminder)) { - if (reminder.getUniqueId().equals(beingAdded.getUniqueId())) { + if (reminder.getUniqueId().equals(beingRemoved.getUniqueId())) { return Optional.of(reminder); } } @@ -197,31 +193,27 @@ private Optional findReminderFOrEntry(Entry beingAdded) { */ private void transferReminder(Reminder reminder, Entry beingAdded) { if (reminder instanceof EntryReminder) { - transferIewReminder((EntryReminder) reminder, beingAdded); + transferEntryReminder((EntryReminder) reminder, beingAdded).setStatus(Reminder.Status.exceeded); } } /** - * transferIewReminder from beingRemoved to beingAdded. + * transferEntryReminder from beingRemoved to beingAdded. */ - private void transferIewReminder(EntryReminder reminder, Entry beingAdded) { + private EntryReminder transferEntryReminder(EntryReminder reminder, Entry beingAdded) { Description header = reminder.getHeader(); Period period = reminder.getPeriod(); Frequency freq = reminder.getFrequency(); - internalList.remove(reminder); EntryReminder newReminder = new EntryReminder(header, beingAdded, period, freq); newReminder.setMessage(reminder.getMessage()); newReminder.togglePopUpDisplay(reminder.willDisplayPopUp()); add(newReminder); newReminder.update(); - if (!newReminder.getStatus().equals(Reminder.Status.unmet)) { + if (!reminder.getStatus().equals(Reminder.Status.unmet)) { notificationList.add(reminder.genNotification()); - if (newReminder.getStatus().equals(Reminder.Status.met)) { - reminder.reset(); - reminder.setNextActive(); - } } + return reminder; } diff --git a/src/main/java/seedu/guilttrip/ui/reminder/ExpenseReminderCard.java b/src/main/java/seedu/guilttrip/ui/reminder/ExpenseReminderCard.java index 46242b2dc0d..3629c7838d3 100644 --- a/src/main/java/seedu/guilttrip/ui/reminder/ExpenseReminderCard.java +++ b/src/main/java/seedu/guilttrip/ui/reminder/ExpenseReminderCard.java @@ -59,7 +59,7 @@ public ExpenseReminderCard(EntryReminder entryReminder, int displayedIndex) { String descWithType = entryReminder.getHeader().toString() + " ~ " + expense.getDesc().fullDesc; desc.setText(descWithType); - date.setText(expense.getDate().toString() + "period: " + period + " freq: " + freq.toString()); + date.setText(expense.getDate().toString() + " period: " + period + " freq: " + freq.toString()); amt.setText("$" + expense.getAmount().value); category.setText(expense.getCategory().getCategoryName()); diff --git a/src/main/java/seedu/guilttrip/ui/reminder/IncomeReminderCard.java b/src/main/java/seedu/guilttrip/ui/reminder/IncomeReminderCard.java index 0a28ed89e4f..d8f5a17f127 100644 --- a/src/main/java/seedu/guilttrip/ui/reminder/IncomeReminderCard.java +++ b/src/main/java/seedu/guilttrip/ui/reminder/IncomeReminderCard.java @@ -57,7 +57,7 @@ public IncomeReminderCard(EntryReminder entryReminder, int displayedIndex) { String descWithType = entryReminder.getHeader().toString() + " ~ " + income.getDesc().fullDesc; desc.setText(descWithType); - date.setText(income.getDate().toString() + "period: " + period + " freq: " + freq.toString()); + date.setText(income.getDate().toString() + " period: " + period + " freq: " + freq.toString()); amt.setText("$" + income.getAmount().value); category.setText(income.getCategory().getCategoryName()); diff --git a/src/main/java/seedu/guilttrip/ui/reminder/WishReminderCard.java b/src/main/java/seedu/guilttrip/ui/reminder/WishReminderCard.java index ae8525cb256..cb923e534a0 100644 --- a/src/main/java/seedu/guilttrip/ui/reminder/WishReminderCard.java +++ b/src/main/java/seedu/guilttrip/ui/reminder/WishReminderCard.java @@ -59,7 +59,7 @@ public WishReminderCard(EntryReminder entryReminder, int displayedIndex) { String descWithType = entryReminder.getHeader().toString() + " ~ " + wish.getDesc().fullDesc; desc.setText(descWithType); - date.setText(wish.getDate().toString() + "period: " + period + " freq: " + freq.toString()); + date.setText(wish.getDate().toString() + " period: " + period + " freq: " + freq.toString()); amt.setText("$" + wish.getAmount().value); category.setText(wish.getCategory().toString()); diff --git a/src/test/java/seedu/guilttrip/logic/commands/EditCategoryCommandTest.java b/src/test/java/seedu/guilttrip/logic/commands/EditCategoryCommandTest.java index e2c1a5d1479..667b2d16bb3 100644 --- a/src/test/java/seedu/guilttrip/logic/commands/EditCategoryCommandTest.java +++ b/src/test/java/seedu/guilttrip/logic/commands/EditCategoryCommandTest.java @@ -11,6 +11,7 @@ import org.junit.jupiter.api.Test; +import seedu.guilttrip.commons.util.TimeUtil; import seedu.guilttrip.logic.CommandHistory; import seedu.guilttrip.logic.CommandHistoryStub; import seedu.guilttrip.logic.commands.editcommands.EditCategoryCommand; @@ -29,6 +30,7 @@ public class EditCategoryCommandTest { @Test public void execute_allFieldsSpecifiedAndNotInList_success() { + TimeUtil.startTimer(); //non existent-category leisure Category editedCategory = new CategoryBuilder().withCatName("Leisure").build(); EditCategoryCommand.EditCategoryDescriptor descriptor = diff --git a/src/test/java/seedu/guilttrip/logic/commands/EditExpenseCommandTest.java b/src/test/java/seedu/guilttrip/logic/commands/EditExpenseCommandTest.java index fa16ab68ea4..f850d4912fd 100644 --- a/src/test/java/seedu/guilttrip/logic/commands/EditExpenseCommandTest.java +++ b/src/test/java/seedu/guilttrip/logic/commands/EditExpenseCommandTest.java @@ -21,6 +21,7 @@ import seedu.guilttrip.commons.core.Messages; import seedu.guilttrip.commons.core.index.Index; +import seedu.guilttrip.commons.util.TimeUtil; import seedu.guilttrip.logic.CommandHistory; import seedu.guilttrip.logic.CommandHistoryStub; import seedu.guilttrip.logic.commands.editcommands.EditExpenseCommand; @@ -49,7 +50,7 @@ public void execute_allFieldsSpecifiedUnfilteredList_success() { EditExpenseCommand editCommand = new EditExpenseCommand(INDEX_FIRST_ENTRY, descriptor); String expectedMessage = String.format(EditExpenseCommand.MESSAGE_EDIT_ENTRY_SUCCESS, editedExpense); - + TimeUtil.startTimer(); Model expectedModel = new ModelManager(new GuiltTrip(model.getGuiltTrip()), new UserPrefs()); expectedModel.setExpense(model.getFilteredExpenses().get(0), editedExpense); expectedModel.commitGuiltTrip(); @@ -74,7 +75,7 @@ public void execute_someFieldsSpecifiedUnfilteredList_success() { EditExpenseCommand editCommand = new EditExpenseCommand(indexLastExpense, descriptor); String expectedMessage = String.format(EditExpenseCommand.MESSAGE_EDIT_ENTRY_SUCCESS, editedExpense); - + TimeUtil.startTimer(); Model expectedModel = new ModelManager(new GuiltTrip(model.getGuiltTrip()), new UserPrefs()); expectedModel.setExpense(lastExpense, editedExpense); expectedModel.commitGuiltTrip(); @@ -106,7 +107,7 @@ public void execute_filteredList_success() { new EditExpenseDescriptorBuilder().withDescription(VALID_DESC_FOOD_EXPENSE).build()); String expectedMessage = String.format(EditExpenseCommand.MESSAGE_EDIT_ENTRY_SUCCESS, editedExpense); - + TimeUtil.startTimer(); Model expectedModel = new ModelManager(new GuiltTrip(model.getGuiltTrip()), new UserPrefs()); expectedModel.setExpense(model.getFilteredExpenses().get(INDEX_FIRST_ENTRY.getZeroBased()), editedExpense); expectedModel.commitGuiltTrip(); @@ -121,6 +122,7 @@ public void execute_duplicateExpenseList_success() { EditExpenseDescriptor descriptor = new EditExpenseDescriptorBuilder(firstExpense).build(); //set the second expense as a duplicate EditExpenseCommand editCommand = new EditExpenseCommand(INDEX_SECOND_ENTRY, descriptor); + TimeUtil.startTimer(); Model expectedModel = new ModelManager(new GuiltTrip(model.getGuiltTrip()), new UserPrefs()); expectedModel.setExpense(model.getFilteredExpenses().get(INDEX_SECOND_ENTRY.getZeroBased()), firstExpense); expectedModel.commitGuiltTrip();