Skip to content

Commit

Permalink
Merge a316c53 into d0f6011
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeo Su Yia, Denise committed Nov 11, 2018
2 parents d0f6011 + a316c53 commit f5d66e5
Show file tree
Hide file tree
Showing 51 changed files with 688 additions and 410 deletions.
2 changes: 1 addition & 1 deletion docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ image::UiClassDiagram.png[width="800"]

*API* : link:{repoURL}/src/main/java/seedu/productInfo/ui/Ui.java[`Ui.java`]

The UI consists of a `MainWindow` that is made up of parts e.g.`CommandBox`, `ResultDisplay`, `ProductListPanel`, `StatusBarFooter`, `BrowserPanel` etc. All these, including the `MainWindow`, inherit from the abstract `UiPart` class.
The UI consists of a `MainWindow` that is made up of parts e.g.`CommandBox`, `ResultDisplay`, `ProductListPanel`, `StatusBarFooter` etc. All these, including the `MainWindow`, inherit from the abstract `UiPart` class.

The `UI` component uses JavaFx UI framework. The layout of these UI parts are defined in matching `.fxml` files that are in the `src/main/resources/view` folder. For example, the layout of the link:{repoURL}/src/main/java/seedu/productInfo/ui/MainWindow.java[`MainWindow`] is specified in link:{repoURL}/src/main/resources/view/MainWindow.fxml[`MainWindow.fxml`]

Expand Down
Binary file modified docs/images/UiClassDiagram.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 72 additions & 0 deletions docs/team/dyeosy98.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
= Yeo Su Yia, Denise - Project Portfolio
:site-section: AboutUs
:imagesDir: ../images
:stylesDir: ../stylesheets

== PROJECT: Inventarie PRO

---

== Overview

Inventarie PRO is a desktop inventory application intended for use by self-employed provision shop owners who wish to digitise their inventory records. The user interacts with it using a CLI, and it has a GUI created with JavaFX. It is written in Java, and has about 10 kLoC.

== Summary of contributions

* *Major enhancement*: Added *the ability to manage distributors engaged with a provision shop*
** What it does: Allows the user to add, edit, delete and find distributors that the user would like a record of. It also allows the user to see which distributor provides what products for the shop.
** Justification: This feature is an essential part of a digitised inventory management system, given that a self-employed provision shop owner would want
** Highlights: This enhancement affects existing commands and commands to be added in future. It required an in-depth analysis of design alternatives. The implementation too was challenging as it required changes to existing commands.
** Credits: _{mention here if you reused any code/ideas from elsewhere or if a third-party library is heavily used in the feature so that a reader can make a more accurate judgement of how much effort went into the feature}_

* *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}_

* *Other contributions*:

** Project management:
*** Managed releases `v1.3` - `v1.5rc` (3 releases) on GitHub
** Enhancements to existing features:
*** Updated the GUI color scheme (Pull requests https://github.com[#33], https://github.com[#34])
*** Wrote additional tests for existing features to increase coverage from 88% to 92% (Pull requests https://github.com[#36], https://github.com[#38])
** Documentation:
*** Did cosmetic tweaks to existing contents of the User Guide: https://github.com[#14]
** Community:
*** PRs reviewed (with non-trivial review comments): https://github.com[#12], https://github.com[#32], https://github.com[#19], https://github.com[#42]
*** Contributed to forum discussions (examples: https://github.com[1], https://github.com[2], https://github.com[3], https://github.com[4])
*** Reported bugs and suggestions for other teams in the class (examples: https://github.com[1], https://github.com[2], https://github.com[3])
*** Some parts of the history feature I added was adopted by several other class mates (https://github.com[1], https://github.com[2])
** Tools:
*** Integrated a third party library (Natty) to the project (https://github.com[#42])
*** Integrated a new Github plugin (CircleCI) to the team repo

_{you can add/remove categories in the list above}_

== Contributions to the User Guide


|===
|_Given below are sections I contributed to the User Guide. They showcase my ability to write documentation targeting end-users._
|===

include::../UserGuide.adoc[tag=undoredo]

include::../UserGuide.adoc[tag=dataencryption]

== Contributions to the Developer Guide

|===
|_Given below are sections I contributed to the Developer Guide. They showcase my ability to write technical documentation and the technical depth of my contributions to the project._
|===

include::../DeveloperGuide.adoc[tag=undoredo]

include::../DeveloperGuide.adoc[tag=dataencryption]


== PROJECT: PowerPointLabs

---

_{Optionally, you may include other projects in your portfolio.}_
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
*/
public class MainApp extends Application {

public static final Version VERSION = new Version(1, 3, 0, true);
public static final Version VERSION = new Version(1, 3, 2, true);

private static final Logger logger = LogsCenter.getLogger(MainApp.class);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/commons/core/GuiSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class GuiSettings implements Serializable {

private static final double DEFAULT_HEIGHT = 600;
private static final double DEFAULT_WIDTH = 750;
private static final double DEFAULT_WIDTH = 400;

private Double windowWidth;
private Double windowHeight;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package seedu.address.commons.events.ui;

import seedu.address.commons.events.BaseEvent;
import seedu.address.model.distributor.DistributorProduct;

/**
* Represents a selection change in the Distributor List Panel
*/
public class DistributorProductPanelSelectionChangedEvent extends BaseEvent {


private final DistributorProduct newSelection;

public DistributorProductPanelSelectionChangedEvent(DistributorProduct newSelection) {
this.newSelection = newSelection;
}

@Override
public String toString() {
return getClass().getSimpleName();
}

public DistributorProduct getNewSelection() {
return newSelection;
}
}
21 changes: 16 additions & 5 deletions src/main/java/seedu/address/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_SERIAL_NR;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;

import java.util.List;

import seedu.address.logic.CommandHistory;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
Expand Down Expand Up @@ -39,7 +41,7 @@ public class AddCommand extends Command {
+ PREFIX_REMAINING_ITEMS + "12";

public static final String MESSAGE_SUCCESS = "New product added: %1$s \n\nRemember to edit the added distributor's"
+ "phone number instead of leaving it as the default 00000000!";
+ " phone number instead of leaving it as the default 00000000!";
public static final String MESSAGE_DUPLICATE_PRODUCT = "This product already exists in the product database";
public static final String MESSAGE_EDIT_DIST_PHONE = "The product was successfully added!\n\n"
+ "The distributor has not been added because"
Expand Down Expand Up @@ -70,11 +72,20 @@ public CommandResult execute(Model model, CommandHistory history) throws Command

model.addProduct(toAdd);

if (model.hasDistributor(distToAdd)) {
throw new CommandException(MESSAGE_EDIT_DIST_PHONE);
}
if (model.hasDistributorName(distToAdd)) {

List<Distributor> distList = model.getFilteredDistributorList();
Integer index = distList.indexOf(distToAdd);

model.addDistributor(distToAdd);
Distributor originalDist = distList.get(index + 1);

Distributor prodEditedDist = new Distributor(originalDist.getDistName(), originalDist.getDistPhone(),
distToAdd.getDistProds(), distToAdd.getTags());

model.updateDistributor(distToAdd, prodEditedDist);
} else {
model.addDistributor(distToAdd);
}

model.commitProductDatabase();
model.commitDistributorBook();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DIST_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DIST_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DIST_PROD;

import seedu.address.logic.CommandHistory;
import seedu.address.logic.commands.exceptions.CommandException;
Expand All @@ -20,13 +21,20 @@ public class AddDistributorCommand extends Command {
+ "Parameters: "
+ PREFIX_DIST_NAME + "DISTRIBUTOR NAME "
+ PREFIX_DIST_PHONE + "DISTRIBUTOR PHONE "
+ PREFIX_DIST_PROD + "DISTRIBUTOR PRODUCTS"
+ "Example: " + COMMAND_WORD + " "
+ PREFIX_DIST_NAME + "Ah Bee Distributors"
+ PREFIX_DIST_PHONE + "60123456 ";
+ PREFIX_DIST_PHONE + "60123456 "
+ PREFIX_DIST_PROD + "Apple"
+ PREFIX_DIST_PROD + "Banana";

public static final String MESSAGE_SUCCESS = "New distributor added: %1$s";
public static final String MESSAGE_DUPLICATE_DISTRIBUTOR =
"This distributor already exists in the distributor book";
public static final String MESSAGE_DUPLICATE_DISTRIBUTOR_NAME =
"A distirbutor with this name already exists in the distributor book.";
public static final String MESSAGE_DUPLICATE_DISTRIBUTOR_PHONE =
"A distirbutor with this phone already exists in the distributor book.";

private final Distributor toAdd;

Expand All @@ -41,8 +49,12 @@ public AddDistributorCommand(Distributor distributor) {
@Override
public CommandResult execute(Model model, CommandHistory history) throws CommandException {
requireNonNull(model);
if (model.hasDistributor(toAdd)) {
throw new CommandException(MESSAGE_DUPLICATE_DISTRIBUTOR);
if (model.hasDistributorName(toAdd)) {
throw new CommandException(MESSAGE_DUPLICATE_DISTRIBUTOR_NAME);
}

if (model.hasDistributorPhone(toAdd)) {
throw new CommandException(MESSAGE_DUPLICATE_DISTRIBUTOR_PHONE);
}

model.addDistributor(toAdd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import seedu.address.model.distributor.Distributor;
import seedu.address.model.distributor.DistributorName;
import seedu.address.model.distributor.DistributorPhone;
import seedu.address.model.distributor.DistributorProduct;
import seedu.address.model.tag.Tag;

/**
Expand All @@ -42,9 +43,15 @@ public class EditDistributorCommand extends Command {

public static final String MESSAGE_EDIT_DISTRIBUTOR_SUCCESS = "Edited Distributor: %1$s";
public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided.";
public static final String MESSAGE_DUPLICATE_DISTRIBUTOR = "This distributor already exists in the address book.";
public static final String MESSAGE_DUPLICATE_DISTRIBUTOR =
"This distirbutor already exists in the distributor book.";
public static final String MESSAGE_DUPLICATE_DISTRIBUTOR_NAME =
"A distirbutor with this name already exists in the distributor book.";
public static final String MESSAGE_DUPLICATE_DISTRIBUTOR_PHONE =
"A distirbutor with this phone already exists in the distributor book.";
private final Index index;
private final EditDistributorDescriptor editDistributorDescriptor;

/**
* @param index of the product in the filtered distributor list to edit
* @param editDistributorDescriptor details to edit the distributor with
Expand All @@ -69,7 +76,7 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
Distributor distributorToEdit = lastShownList.get(index.getZeroBased());
Distributor editedDistributor = createEditedDistributor(distributorToEdit, editDistributorDescriptor);

if (!distributorToEdit.isSameDistributor(editedDistributor) && model.hasDistributor(editedDistributor)) {
if (model.hasDistributorName(editedDistributor) && model.hasDistributorPhone(editedDistributor)) {
throw new CommandException(MESSAGE_DUPLICATE_DISTRIBUTOR);
}

Expand All @@ -91,8 +98,10 @@ private static Distributor createEditedDistributor(Distributor distributorToEdit
DistributorPhone updatedPhone =
editDistributorDescriptor.getDistPhone().orElse(distributorToEdit.getDistPhone());
Set<Tag> updatedTags = editDistributorDescriptor.getTags().orElse(distributorToEdit.getTags());
Set<DistributorProduct> updatedProds = editDistributorDescriptor.getProds()
.orElse(distributorToEdit.getDistProds());

return new Distributor(updatedName, updatedPhone, updatedTags);
return new Distributor(updatedName, updatedPhone, updatedProds, updatedTags);
}

@Override
Expand Down Expand Up @@ -121,6 +130,7 @@ public static class EditDistributorDescriptor {
private DistributorName name;
private DistributorPhone phone;
private Set<Tag> tags;
private Set<DistributorProduct> prods;

public EditDistributorDescriptor() {}

Expand All @@ -132,6 +142,7 @@ public EditDistributorDescriptor(EditDistributorDescriptor toCopy) {
setDistName(toCopy.name);
setDistPhone(toCopy.phone);
setTags(toCopy.tags);
setProds(toCopy.prods);
}

/**
Expand All @@ -157,6 +168,23 @@ public Optional<DistributorPhone> getDistPhone() {
return Optional.ofNullable(phone);
}

/**
* Sets {@code prods} to this object's {@code prods}.
* A defensive copy of {@code prods} is used internally.
*/
public void setProds(Set<DistributorProduct> prods) {
this.prods = (prods != null) ? new HashSet<>(prods) : null;
}

/**
* Returns an unmodifiable distributorproduct set, which throws {@code UnsupportedOperationException}
* if modification is attempted.
* Returns {@code Optional#empty()} if {@code tags} is null.
*/
public Optional<Set<DistributorProduct>> getProds() {
return (prods != null) ? Optional.of(Collections.unmodifiableSet(prods)) : Optional.empty();
}

/**
* Sets {@code tags} to this object's {@code tags}.
* A defensive copy of {@code tags} is used internally.
Expand Down Expand Up @@ -191,6 +219,7 @@ public boolean equals(Object other) {

return getDistName().equals(e.getDistName())
&& getDistPhone().equals(e.getDistPhone())
&& getProds().equals(e.getProds())
&& getTags().equals(e.getTags());
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package seedu.address.logic.commands;

import static java.util.Objects.requireNonNull;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
import seedu.address.logic.CommandHistory;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.distributor.Distributor;
import seedu.address.model.distributor.DistributorProduct;
import seedu.address.model.saleshistory.SalesHistory;

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

public static final String COMMAND_WORD = "listdistributorproducts";
public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Lists all products that the given distributor is recorded to carry.\n"
+ "Parameters: INDEX (must be a positive integer)\n"
+ "Example: " + COMMAND_WORD + " 1 ";
public static final String NO_DIST_PRODS_MESSAGE = "No products have been recorded for this distributor yet";

private final Index index;

/**
* @param index of the product in the filtered distributor list to list products of
**/
public ListDistributorProductsCommand(Index index) {
requireNonNull(index);

this.index = index;
}

@Override
public CommandResult execute(Model model, CommandHistory history) throws CommandException {
requireNonNull(model);

List<Distributor> lastShownList = model.getFilteredDistributorList();

if (index.getZeroBased() >= lastShownList.size()) {
throw new CommandException(Messages.MESSAGE_INVALID_DIST_DISPLAYED_INDEX);
}

Distributor distributorToShow = lastShownList.get(index.getZeroBased());

Set<DistributorProduct> distProdsSet = distributorToShow.getDistProds();

ArrayList<DistributorProduct> distprodsList = new ArrayList<>(distProdsSet);

if (distprodsList.size() == 0) {
return new CommandResult(NO_DIST_PRODS_MESSAGE);
}

StringBuilder allDistProds = new StringBuilder();

allDistProds.append("Products that " + distributorToShow.getDistName().toString() + " carries:");

for (DistributorProduct distributorProduct : distprodsList) {
allDistProds.append(distributorProduct.toString() + "\n");
}

return new CommandResult(allDistProds.toString());
}
}

0 comments on commit f5d66e5

Please sign in to comment.