Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

final fix #313

Open
wants to merge 5 commits into
base: Later-Fixes
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/AboutUs.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]] [<<yuhongtay#, portfolio>>]

Role: Developer +
Responsibilities: Code quality, Reminders
Expand Down
4 changes: 2 additions & 2 deletions docs/team/swampertx.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down Expand Up @@ -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*:

Expand Down
1 change: 0 additions & 1 deletion src/main/java/seedu/guilttrip/model/GuiltTrip.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
};
Expand Down
32 changes: 12 additions & 20 deletions src/main/java/seedu/guilttrip/model/reminders/ReminderList.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,8 @@ public ObservableList<Notification> 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<Reminder> optReminder = findReminderFOrEntry(beingRemove);
Optional<Reminder> optReminder = findReminderForEntry(beingRemove);
if (optReminder.isPresent()) {
Reminder reminder = optReminder.get();
logger.info("transferring reminder to new entry");
Expand All @@ -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> 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<Reminder> findReminderFOrEntry(Entry beingAdded) {
private Optional<Reminder> 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);
}
}
Expand All @@ -197,31 +193,27 @@ private Optional<Reminder> 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;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down