Skip to content

Commit

Permalink
Merge bfabdc4 into 57e7348
Browse files Browse the repository at this point in the history
  • Loading branch information
ParasK26 committed Oct 31, 2018
2 parents 57e7348 + bfabdc4 commit bc4073c
Show file tree
Hide file tree
Showing 52 changed files with 1,220 additions and 691 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jacocoTestReport {
}

test {
useJUnitPlatform()
//useJUnitPlatform()
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ day, that is, the active `ShopDay` in the `SalesHistory` of `AddressBook`.

[NOTE]
It is important to note that the `ShopDay` class stores each `Transaction` on a `TreeMap`, where each `Transaction` has
its `transactionTime` as its key. This is to facilitate quick access to any transaction on a given day, and to maintain
its `reminderTime` as its key. This is to facilitate quick access to any transaction on a given day, and to maintain
the `Transaction` objects in order of their creation times within memory.

==== Alternative Implementations
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/seedu/address/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@
import seedu.address.storage.DistributorBookStorage;
import seedu.address.storage.JsonUserPrefsStorage;
import seedu.address.storage.ProductDatabaseStorage;
import seedu.address.storage.SalesHistoryStorage;
import seedu.address.storage.Storage;
import seedu.address.storage.StorageManager;
import seedu.address.storage.UserDatabaseStorage;
import seedu.address.storage.UserPrefsStorage;
import seedu.address.storage.XmlDistributorBookStorage;
import seedu.address.storage.XmlProductDatabaseStorage;
import seedu.address.storage.XmlSalesHistoryStorage;
import seedu.address.storage.XmlUserDatabaseStorage;
import seedu.address.ui.Ui;
import seedu.address.ui.UiManager;
Expand All @@ -64,7 +66,7 @@ public class MainApp extends Application {

@Override
public void init() throws Exception {
logger.info("=============================[ Initializing Inventori PRO ]===========================");
logger.info("=============================[ Initializing Inventarie PRO ]===========================");
super.init();

AppParameters appParameters = AppParameters.parse(getParameters());
Expand All @@ -77,10 +79,12 @@ public void init() throws Exception {
new XmlUserDatabaseStorage(userPrefs.getUsersFilePath());
ProductDatabaseStorage productDatabaseStorage =
new XmlProductDatabaseStorage(userPrefs.getAddressBookFilePath());
SalesHistoryStorage salesHistoryStorage =
new XmlSalesHistoryStorage(userPrefs.getSalesHistoryFilePath());
DistributorBookStorage distributorBookStorage =
new XmlDistributorBookStorage(userPrefs.getDistributorBookFilePath());
storage = new StorageManager(productDatabaseStorage, distributorBookStorage, userPrefsStorage, usersStorage);

storage = new StorageManager(productDatabaseStorage, distributorBookStorage,
userPrefsStorage, usersStorage, salesHistoryStorage);

initLogging(config);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package seedu.address.commons.events.model;

import seedu.address.commons.events.BaseEvent;
import seedu.address.model.saleshistory.ReadOnlySalesHistory;
import seedu.address.model.saleshistory.SalesHistory;

/**
* Indicates a change in the {@link SalesHistory}
*/
public class SalesHistoryChangedEvent extends BaseEvent {

public final ReadOnlySalesHistory data;

public SalesHistoryChangedEvent(ReadOnlySalesHistory data) {
this.data = data;
}

@Override
public String toString() {
return "number of transactions: " + data.getTransactionsAsObservableList().size()
+ " number of reminders: " + data.getRemindersAsObservableList().size();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import seedu.address.logic.CommandHistory;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.timeidentifiedclass.Reminder;
import seedu.address.model.timeidentifiedclass.exceptions.DuplicateReminderException;
import seedu.address.model.timeidentifiedclass.exceptions.InvalidTimeFormatException;
import seedu.address.model.timeidentifiedclass.shopday.Reminder;
import seedu.address.model.timeidentifiedclass.shopday.exceptions.DuplicateReminderException;

/**
* Adds a reminder to the Address Book.
Expand Down Expand Up @@ -43,7 +43,7 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
return new CommandResult(e.getExceptionMessage());
}
model.commitAddressBook();
return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd.getMessage(), toAdd.getTime()));
return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd.getReminderMessage(), toAdd.getReminderTime()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
import seedu.address.logic.CommandHistory;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.timeidentifiedclass.Transaction;
import seedu.address.model.timeidentifiedclass.exceptions.DuplicateTransactionException;
import seedu.address.model.timeidentifiedclass.exceptions.InvalidTimeFormatException;
import seedu.address.model.timeidentifiedclass.shopday.exceptions.ClosedShopDayException;
import seedu.address.model.timeidentifiedclass.shopday.exceptions.DuplicateTransactionException;
import seedu.address.model.timeidentifiedclass.transaction.Transaction;

/**
* Adds a transaction to the address book.
Expand Down Expand Up @@ -43,8 +42,6 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
model.addTransaction(toAdd);
} catch (InvalidTimeFormatException e) {
return new CommandResult(e.getExceptionMessage() + ". Upon adding this transaction");
} catch (ClosedShopDayException e) {
return new CommandResult(e.getExceptionMessage() + ". Upon adding this transaction");
} catch (DuplicateTransactionException e) {
return new CommandResult(e.getLocalizedMessage() + ". Upon adding this transaction");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.timeidentifiedclass.exceptions.InvalidTimeFormatException;
import seedu.address.model.timeidentifiedclass.shopday.Reminder;

/**
* This class removes a reminder whose task has been finished
Expand All @@ -25,22 +24,22 @@ public class FinishedReminderCommand extends Command {

private static final String MESSAGE_SUCCESS = "Reminder at time %s successfully removed";
private static final String FAILURE_NO_SUCH_REMINDER = "No such reminder has been set";
private final Reminder toRemove;
private final String toRemoveReminderTime;

public FinishedReminderCommand(Reminder toRemove) {
this.toRemove = toRemove;
public FinishedReminderCommand(String toRemoveReminderTime) {
this.toRemoveReminderTime = toRemoveReminderTime;
}

@Override
public CommandResult execute(Model model, CommandHistory history) throws CommandException {
try {
model.removeReminder(toRemove);
model.removeReminder(toRemoveReminderTime);
} catch (InvalidTimeFormatException e) {
return new CommandResult(e.getExceptionMessage() + "Upon trying to remove this reminder.");
} catch (NoSuchElementException e) {
return new CommandResult(FAILURE_NO_SUCH_REMINDER);
}
model.commitAddressBook();
return new CommandResult(String.format(MESSAGE_SUCCESS, toRemove.getTime()));
return new CommandResult(String.format(MESSAGE_SUCCESS, toRemoveReminderTime));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public LoginCommand(Username username, Password password) {
this.username = username;
this.password = password;
}

@Override
public CommandResult execute(Model model, CommandHistory history) throws CommandException {
requireNonNull(username);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import seedu.address.logic.CommandHistory;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.timeidentifiedclass.shopday.Reminder;
import seedu.address.model.timeidentifiedclass.Reminder;

/**
* This command allows us to view all reminders in the active shop day that are due.
Expand All @@ -19,7 +19,7 @@ public class ThreadDueRemindersCommand extends Command {

@Override
public CommandResult execute(Model model, CommandHistory history) throws CommandException {
ArrayList<Reminder> reminders = model.getDueRemindersInActiveBusinessDayForThread();
ArrayList<Reminder> reminders = model.getOverdueRemindersForThread();

if (reminders.size() == 0) {
return new CommandResult(NO_THREAD_REMINDERS);
Expand All @@ -30,7 +30,7 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
allReminders.append("Reminders due:\n");

for (Reminder reminder : reminders) {
allReminders.append(reminder.getTime() + "\t\t" + reminder.getMessage() + "\n");
allReminders.append(reminder.getReminderTime() + "\t\t" + reminder.getReminderMessage() + "\n");
}

return new CommandResult(allReminders.toString());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package seedu.address.logic.commands;

import seedu.address.model.saleshistory.SalesHistory;

/**
* This command displays all the reminders in the {@link SalesHistory}.
*/
public class ViewAllRemindersCommand {

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import seedu.address.logic.CommandHistory;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.timeidentifiedclass.shopday.Reminder;
import seedu.address.model.timeidentifiedclass.Reminder;

/**
* This command allows us to view all reminders in the active shop day that are due.
Expand All @@ -19,7 +19,7 @@ public class ViewDueRemindersCommand extends Command {

@Override
public CommandResult execute(Model model, CommandHistory history) throws CommandException {
ArrayList<Reminder> reminders = model.getDueRemindersInActiveBusinessDay();
ArrayList<Reminder> reminders = model.getOverdueReminders();

if (reminders.size() == 0) {
return new CommandResult(NO_REMINDERS_SET);
Expand All @@ -30,7 +30,7 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
allReminders.append("Reminders due as of now today:\n");

for (Reminder reminder : reminders) {
allReminders.append(reminder.getTime() + "\t\t" + reminder.getMessage() + "\n");
allReminders.append(reminder.getReminderTime() + "\t\t" + reminder.getReminderMessage() + "\n");
}

return new CommandResult(allReminders.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import seedu.address.logic.CommandHistory;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.timeidentifiedclass.transaction.Transaction;
import seedu.address.model.timeidentifiedclass.Transaction;

/**
* Javadoc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@

import seedu.address.logic.commands.AddReminderCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.timeidentifiedclass.Reminder;
import seedu.address.model.timeidentifiedclass.exceptions.InvalidTimeFormatException;
import seedu.address.model.timeidentifiedclass.shopday.Reminder;


/**
* Parses input arguments and creates new AddReminderCommand object.
*/

public class AddReminderCommandParser implements Parser<AddReminderCommand> {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import seedu.address.logic.commands.AddTransactionCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.timeidentifiedclass.transaction.Transaction;
import seedu.address.model.timeidentifiedclass.transaction.exceptions.ClosedTransactionException;
import seedu.address.model.timeidentifiedclass.Transaction;
import seedu.address.model.timeidentifiedclass.exceptions.ClosedTransactionException;

/**
* Parses input arguments and creates a new AddTransactionCommand object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,18 @@

import seedu.address.logic.commands.FinishedReminderCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.timeidentifiedclass.exceptions.InvalidTimeFormatException;
import seedu.address.model.timeidentifiedclass.shopday.Reminder;

/**
* Parses the arguments for finishing a reminder task.
*/
public class FinishedReminderCommandParser implements Parser<FinishedReminderCommand> {

private static final String REMINDER_TO_REMOVE = "To be remove";

/**
* Parses the given {@code String} of arguments in the context of AddReminderCommand
* and returns an AddReminderCommand object for execution.
* @throws ParseException if the user input does not conform the expected format
*/
public FinishedReminderCommand parse(String args) throws ParseException {

Reminder toRemoveReminder;
ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_TIME);

if (!arePrefixesPresent(argMultimap, PREFIX_TIME)
Expand All @@ -34,13 +28,13 @@ public FinishedReminderCommand parse(String args) throws ParseException {
FinishedReminderCommand.MESSAGE_USAGE));
}

String toRemoveReminderTime;
try {
toRemoveReminder = new Reminder(ParserUtil.parseReminderTime(argMultimap.getValue(PREFIX_TIME).get()),
REMINDER_TO_REMOVE);
} catch (InvalidTimeFormatException e) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, Reminder.REMINDER_TIME_CONSTRAINTS));
toRemoveReminderTime = ParserUtil.parseReminderTime(argMultimap.getValue(PREFIX_TIME).get());
} catch (ParseException e) {
throw e;
}
return new FinishedReminderCommand(toRemoveReminder);
return new FinishedReminderCommand(toRemoveReminderTime);
}

/**
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
import seedu.address.model.product.Name;
import seedu.address.model.product.SerialNumber;
import seedu.address.model.tag.Tag;
import seedu.address.model.timeidentifiedclass.shopday.Reminder;
import seedu.address.model.timeidentifiedclass.transaction.Transaction;
import seedu.address.model.timeidentifiedclass.Reminder;

/**
* Contains utility methods used for parsing strings in the various *Parser classes.
Expand Down Expand Up @@ -66,7 +65,7 @@ public static Name parseName(String name) throws ParseException {
public static String parseReminderTime(String reminderTime) throws ParseException {
requireNonNull(reminderTime);
String trimmedTime = reminderTime.trim();
if (!Transaction.isValidTransactionTime(reminderTime)) {
if (!Reminder.isValidReminderTime(reminderTime)) {
throw new ParseException(Reminder.REMINDER_TIME_CONSTRAINTS);
}
return trimmedTime;
Expand Down
27 changes: 10 additions & 17 deletions src/main/java/seedu/address/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
import seedu.address.model.login.exceptions.DuplicateUserException;
import seedu.address.model.login.exceptions.UserNotFoundException;
import seedu.address.model.product.Product;
import seedu.address.model.timeidentifiedclass.Reminder;
import seedu.address.model.timeidentifiedclass.Transaction;
import seedu.address.model.timeidentifiedclass.exceptions.DuplicateReminderException;
import seedu.address.model.timeidentifiedclass.exceptions.DuplicateTransactionException;
import seedu.address.model.timeidentifiedclass.exceptions.InvalidTimeFormatException;
import seedu.address.model.timeidentifiedclass.shopday.Reminder;
import seedu.address.model.timeidentifiedclass.shopday.exceptions.ClosedShopDayException;
import seedu.address.model.timeidentifiedclass.shopday.exceptions.DuplicateReminderException;
import seedu.address.model.timeidentifiedclass.shopday.exceptions.DuplicateTransactionException;
import seedu.address.model.timeidentifiedclass.transaction.Transaction;

/**
* The API of the Model component.
Expand Down Expand Up @@ -164,10 +163,9 @@ public interface Model {
* @param transaction
* @throws InvalidTimeFormatException
* @throws DuplicateTransactionException
* @throws ClosedShopDayException
*/
void addTransaction(Transaction transaction) throws InvalidTimeFormatException,
DuplicateTransactionException, ClosedShopDayException;
DuplicateTransactionException;

/**
* Adds a reminder to the active business day.
Expand All @@ -179,31 +177,26 @@ void addTransaction(Transaction transaction) throws InvalidTimeFormatException,

/**
* Removes a reminder from the active business day.
* @param reminder
* @param reminderTime
* @throws InvalidTimeFormatException
* @throws NoSuchElementException
*/
void removeReminder(Reminder reminder) throws InvalidTimeFormatException, NoSuchElementException;
void removeReminder(String reminderTime) throws InvalidTimeFormatException, NoSuchElementException;

/**
* Returns the reminders due on the current active day.
*/
ArrayList<Reminder> getDueRemindersInActiveBusinessDay();
ArrayList<Reminder> getOverdueReminders();

/**
* Returns the reminders that have not been shown by the thread.
*/
ArrayList<Reminder> getDueRemindersInActiveBusinessDayForThread();
ArrayList<Reminder> getOverdueRemindersForThread();

/**
* Returns a given day's transaction history
*/
String getDaysHistory(String day);

/**
* Returns the active day's transaction history
*/
String getActiveDayHistory();
String getDaysTransactions(String day) throws InvalidTimeFormatException;

/**
* Returns the latest transaction.
Expand Down

0 comments on commit bc4073c

Please sign in to comment.