diff --git a/docs/UserGuide.md b/docs/UserGuide.md index 8fd05e65e2f..939930e6d65 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -145,8 +145,8 @@ Format: `delete c/CUSTOMER_ID` Examples: * `list` followed by `delete c/2` deletes the person with customer_id of `2` in the address book. * `find Betsy` followed by `delete c/1` deletes the person with customer_id of `1` in the results of the `find` command. - ![Deleting customer 2](images/DeleteCommand.png) - ![Result for deleting customer 2](images/DeleteCommandResult.png) + ![Deleting customer 2](images/DeleteCommand.png) + ![Result for deleting customer 2](images/DeleteCommandResult.png) ### Creating of orders: `order` @@ -158,7 +158,7 @@ Format: `order p/PHONE_NUMBER [by/DEADLINE]` * `DEADLINE` is an optional fields that is used to keep track of an order's deadline * * The format for deadline dates are dd/MM/yyyy * For single digit days or months, please precede them with a zero. -* Leaving Deadline blank will make the order's deadline marked as `Not Specified` +* Leaving `DEADLINE` blank will make the order's deadline marked as `Not Specified` * Strack will prompt users to input products using the product command * Follow up with products to be added to the order using the following format. Format: `product m/PRODUCT_ID pq/PRODUCT_QUANTITY`. * You can refer to the Menu list for the product index, i.e. `1. Cupcake` product index is `1`. diff --git a/src/main/java/seedu/address/logic/Messages.java b/src/main/java/seedu/address/logic/Messages.java index d6501daf98b..250a795357d 100644 --- a/src/main/java/seedu/address/logic/Messages.java +++ b/src/main/java/seedu/address/logic/Messages.java @@ -31,9 +31,11 @@ public class Messages { "Multiple values specified for the following single-valued field(s): "; public static final String MESSAGE_INVALID_PHONE_NUMBER = "Phone number provided not found"; + public static final String MESSAGE_INVALID_DATE = "Please specify a valid date."; public static final String MESSAGE_PHONE_NUMBER_NOT_FOUND = "Phone number provided not found"; public static final String MESSAGE_ORDER_NOT_CREATED = "Please create an order before adding products."; + public static final String MESSAGE_LARGE_QUANTITY = "Quantity specified is too large, please try again."; public static final String MESSAGE_ONLY_ONE_FIELD = "Only one field can be provided"; diff --git a/src/main/java/seedu/address/logic/commands/AddOrderCommand.java b/src/main/java/seedu/address/logic/commands/AddOrderCommand.java index 8e6d3c88fb9..f23f8683dd8 100644 --- a/src/main/java/seedu/address/logic/commands/AddOrderCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddOrderCommand.java @@ -23,7 +23,7 @@ public class AddOrderCommand extends Command { public static final String MESSAGE_ADD_PRODUCTS = "Add products using this command:" + "product m/[PRODUCT_ID] pq/[QUANTITY]"; public static final String MESSAGE_USAGE = COMMAND_WORD - + ": Edits the order of the person identified " + + ": Creates an order for the person identified " + "by the phone number of person. " + "\n" + "Parameters: phone number (must be a positive integer) " diff --git a/src/main/java/seedu/address/logic/commands/AddProductCommand.java b/src/main/java/seedu/address/logic/commands/AddProductCommand.java index aa04b6f1fef..6d8338dee1e 100644 --- a/src/main/java/seedu/address/logic/commands/AddProductCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddProductCommand.java @@ -80,6 +80,7 @@ public CommandResult execute(Model model) throws CommandException { if (lastOrder == null) { throw new CommandException(Messages.MESSAGE_ORDER_NOT_CREATED); } + Product product = model.findProductByIndex(productId.getZeroBased()); //Add ability to add product to order if (lastOrder.getProductMap().containsKey(product)) { diff --git a/src/main/java/seedu/address/logic/commands/EditOrderCommand.java b/src/main/java/seedu/address/logic/commands/EditOrderCommand.java index 7d0e394ec53..7ec8a34395b 100644 --- a/src/main/java/seedu/address/logic/commands/EditOrderCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditOrderCommand.java @@ -45,8 +45,8 @@ public class EditOrderCommand extends EditCommand { public static final String MESSAGE_NOT_EDITED = "Both product and quantity must be provided."; - public static final String MESSAGE_NOT_EDITED_EXTRA = "You can edit either product and quantity " - + "or the order's deadline"; + public static final String MESSAGE_NOT_EDITED_EXTRA = "Please provide either both product and quantity, " + + "or the order's deadline to be edited"; private final Index orderIndex; private final Index productIndex; diff --git a/src/main/java/seedu/address/logic/parser/AddProductCommandParser.java b/src/main/java/seedu/address/logic/parser/AddProductCommandParser.java index 0af4ff19b51..19c0a9803b8 100644 --- a/src/main/java/seedu/address/logic/parser/AddProductCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddProductCommandParser.java @@ -2,6 +2,7 @@ import static java.util.Objects.requireNonNull; import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; +import static seedu.address.logic.Messages.MESSAGE_LARGE_QUANTITY; import static seedu.address.logic.parser.CliSyntax.PREFIX_MENU; import static seedu.address.logic.parser.CliSyntax.PREFIX_PRODUCT_QUANTITY; @@ -39,6 +40,8 @@ public AddProductCommand parse(String args) throws ParseException { try { productId = ParserUtil.parseIndex(argMultimap.getValue(PREFIX_MENU).get()); quantity = ParserUtil.parseQuantity(argMultimap.getValue(PREFIX_PRODUCT_QUANTITY).get()); + } catch (NumberFormatException e) { + throw new ParseException(String.format(MESSAGE_LARGE_QUANTITY), e); } catch (IllegalValueException ive) { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddProductCommand.MESSAGE_USAGE), ive); diff --git a/src/main/java/seedu/address/logic/parser/EditOrderCommandParser.java b/src/main/java/seedu/address/logic/parser/EditOrderCommandParser.java index 3d3c9c28135..b9b495854f4 100644 --- a/src/main/java/seedu/address/logic/parser/EditOrderCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/EditOrderCommandParser.java @@ -71,7 +71,7 @@ public EditOrderCommand parse(String args) throws ParseException { if (!argMultimap.getValue(PREFIX_MENU).isPresent() && !argMultimap.getValue(PREFIX_PRODUCT_QUANTITY).isPresent() && !argMultimap.getValue(PREFIX_DEADLINE).isPresent()) { - throw new ParseException(EditOrderCommand.MESSAGE_NOT_EDITED); + throw new ParseException(EditOrderCommand.MESSAGE_NOT_EDITED_EXTRA); } diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index b4ea3c2f756..43c8dadca6d 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -12,6 +12,7 @@ import seedu.address.commons.util.StringUtil; import seedu.address.logic.Messages; import seedu.address.logic.parser.exceptions.ParseException; +import seedu.address.model.exceptions.InvalidDateException; import seedu.address.model.order.Deadline; import seedu.address.model.order.Product; import seedu.address.model.order.Quantity; @@ -155,7 +156,8 @@ public static Quantity parseQuantity(String quantity) throws ParseException { if (!Quantity.isValidQuantity(trimmedQuantity)) { throw new ParseException(Quantity.MESSAGE_CONSTRAINTS); } - return new Quantity(Integer.parseInt(trimmedQuantity)); + int result = Integer.parseInt(trimmedQuantity); + return new Quantity(result); } /** @@ -211,6 +213,12 @@ public static Deadline parseDeadline(String deadline) throws ParseException { if (!Deadline.isValidDeadline(trimmedDeadline)) { throw new ParseException(Deadline.MESSAGE_CONSTRAINTS); } - return new Deadline(trimmedDeadline); + Deadline result; + try { + result = new Deadline(trimmedDeadline); + } catch (InvalidDateException e) { + throw new ParseException(String.format(Messages.MESSAGE_INVALID_DATE)); + } + return result; } } diff --git a/src/main/java/seedu/address/model/order/Quantity.java b/src/main/java/seedu/address/model/order/Quantity.java index 80ef05ddaad..5cc36786ba2 100644 --- a/src/main/java/seedu/address/model/order/Quantity.java +++ b/src/main/java/seedu/address/model/order/Quantity.java @@ -74,4 +74,5 @@ public void setQuantity(int newQuantity) { public static boolean isValidQuantity(String test) { return test.matches(VALIDATION_REGEX); } + } diff --git a/src/main/resources/view/OrderListCard.fxml b/src/main/resources/view/OrderListCard.fxml index 94fe9ce746e..16019215af0 100644 --- a/src/main/resources/view/OrderListCard.fxml +++ b/src/main/resources/view/OrderListCard.fxml @@ -5,8 +5,7 @@ - + diff --git a/src/main/resources/view/Styles.css b/src/main/resources/view/Styles.css deleted file mode 100644 index b8025fd7b34..00000000000 --- a/src/main/resources/view/Styles.css +++ /dev/null @@ -1,15 +0,0 @@ -.order-card { - -fx-background-color: #FFFFFF; /* Default background color */ -} - -.order-card-near-deadline { - -fx-background-color: #FF6347; /* Background color for deadlines within 3 days */ -} - -.deadline-text { - -fx-text-fill: #555555; /* Default text color */ -} - -.deadline-text-urgent { - -fx-text-fill: red; /* Urgent deadline text color */ -} diff --git a/src/test/java/seedu/address/logic/parser/EditOrderCommandParserTest.java b/src/test/java/seedu/address/logic/parser/EditOrderCommandParserTest.java index 65d943bf5c9..f1838ff902d 100644 --- a/src/test/java/seedu/address/logic/parser/EditOrderCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/EditOrderCommandParserTest.java @@ -30,7 +30,7 @@ public class EditOrderCommandParserTest { @Test public void parse_missingParts_failure() { // no field specified - assertParseFailure(parser, " " + PREFIX_ORDER + "1", EditOrderCommand.MESSAGE_NOT_EDITED); + assertParseFailure(parser, " " + PREFIX_ORDER + "1", EditOrderCommand.MESSAGE_NOT_EDITED_EXTRA); // no index and no field specified assertParseFailure(parser, "", MESSAGE_INVALID_FORMAT);