Skip to content

Commit

Permalink
Merge pull request #110 from LDerpy/branch-LastMinuteStuffv2.1
Browse files Browse the repository at this point in the history
Checkstyle and bug fixes
  • Loading branch information
LDerpy authored Apr 11, 2022
2 parents 73713d7 + 85d4aba commit e107c45
Show file tree
Hide file tree
Showing 26 changed files with 123 additions and 188 deletions.
3 changes: 2 additions & 1 deletion docs/AboutUs.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
| ![](https://via.placeholder.com/100.png?text=Photo) | Shyun Yin | [Github](https://github.com/Shyunyin) | [Portfolio](team/Shyunyin.md) |
| ![](https://via.placeholder.com/100.png?text=Photo) | Tuan | [Github](https://github.com/tuan0369) | [Portfolio](team/tuan0369.md) |
| ![](https://via.placeholder.com/100.png?text=Photo) | Haziq Hakim | [Github](https://github.com/LDerpy) | [Portfolio](team/lderpy.md) |
| ![](https://via.placeholder.com/100.png?text=Photo) | Jun Leong | [Github](https://github.com/hjunleon) | [Portfolio](team/hjunleon.md) |
| ![](https://via.placeholder.com/100.png?text=Photo) | Jun Leong | [Github](https://github.com/hjunleon) | [Portfolio](team/hjunleon.md) |


75 changes: 51 additions & 24 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ setup and quick to use. Simplst will mainly be used to add, remove, list and vie
* [Explanation of Key Terms or Symbols](#explanation-of-key-terms-or-symbols)
* [Quick start](#quick-start)
* [Features](#features)
* [Help Command](#help-command-help)
* [Unit Good Commands](#unit-good-commands)
* [Adding a Unit Good](#adding-a-unit-good-add-ug)
* [Removing a Unit Good](#removing-a-unit-good-remove-ug)
Expand All @@ -38,18 +39,18 @@ setup and quick to use. Simplst will mainly be used to add, remove, list and vie

## Explanation of key terms or symbols

| Terms or Symbols used | Further Explanation |
|----------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit Good](#unit-good-commands) | A template containing details of a good. |
| SKU | Stands for Stock-Keeping Unit. It is the unique unit number for a specific warehouse item. It can contain characters and numbers (e.g WC01). |
| Capacity | Size of the object defined as Small, Medium and Large.<br/>SMALL <br/>Medium <br/>Large |
| [Good](#good-commands) | A Good is the actual good that is currently in the warehouse inventory. |
| [Order](#order-commands) | An order in Simplst is used to know who made the order and what goods to deliver to that shipping address. |
| [Orderline](#orderline-commands) | An orderline is the goods required by the order. |
| [Fulfill](#fulfill-order-fulfill) | Used to check and indicate if an order is completed. |
| `Words in MarkUp` | Used to highlight keywords used for commands and commands themselves. |
| <img src="img.png" alt="img" style="width:30px;"/> | Used to denote features for warehouse managers. |
| `*Optional*` | Fields in MarkUp bounded by asterisks (*) are optional to be filled in, but should be replaced with a space ' ' instead. |
| Terms or Symbols used | Further Explanation |
|----------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit Good](#unit-good-commands) | A template containing details of a good. |
| SKU | Stands for Stock-Keeping Unit. It is the unique unit number for a specific warehouse item. It can contain characters and numbers (e.g WC01). |
| Capacity | Size of the object defined as Small, Medium and Large.<br/>Small <br/>Medium <br/>Large |
| [Good](#good-commands) | A Good is the actual good that is currently in the warehouse inventory. |
| [Order](#order-commands) | An order in Simplst is used to know who made the order and what goods to deliver to that shipping address. |
| [Orderline](#orderline-commands) | An orderline is the goods required by the order. |
| [Fulfill](#fulfill-order-fulfill) | Used to check and indicate if an order is completed. |
| `Words in MarkUp` | Used to highlight keywords used for commands and commands themselves. |
| <img src="img.png" alt="img" style="width:30px;"/> | Used to denote features for warehouse managers. |
| `*Optional*` | Fields in MarkUp bounded by asterisks (*) are optional to be filled in, but should be replaced with a space ' ' instead. |


This User Guide is meant for both warehouse workers and managers to learn how to use Simplst and the features to
Expand All @@ -65,26 +66,37 @@ If you do not, you can download it from [here](https://www.oracle.com/java/techn
4. Open the terminal in the folder which contains Simplst.jar and run java -jar Simplst.jar. The Startup should look like below:
```
____________________________________________________________
New login.
Hello from
Simplst
What would you like to do?
New login. Please type the total number of goods your warehouse can hold
____________________________________________________________
```
5. Type the commands in the terminal and press `Enter` to execute them. For example: typing help and pressing `Enter` will show you the features
available in Simplst and how to type the command into the command line.

## Features

### Help Command `help`
All the features can be viewed on the Command-Line Interface using the help command if you want to view the commands
there instead. This is done by using the `help` command. You can also use flags to indicate which specific set of commands
to view.

Help Commands:
* `help` - View all commands
* `help ug` - View commands related to Unit Goods
* `help g` - View commands related to Goods
* `help o` - View commands related to Orders and Orderlines

### ***Unit Good Commands***
A Unit Good is a template of a good. A unit good should be added to the warehouse to allow Simplst to know what kind goods will be added to the warehouse later.
Unit Goods can help Simplst to estimate storage capacity in the future and other predicitive features for future versions.

A Unit Good contains:
* unique SKU
* name
* description of unit good
* capacity
* Unique SKU
* Name
* Description of unit good
* Capacity

### Adding a Unit Good `add ug/`
Add a new unit good to the warehouse, creating a Good with quantity 0 in the process.
Expand All @@ -104,7 +116,7 @@ Adding a Unit Good with SKU being WC1, with name Wooden Chair, description as Ch

Expected Output
```
Unit Good with SKU: WC1 added to warehouse
Unit Good of SKU: WC1 added to warehouse
Another command?
```

Expand All @@ -124,7 +136,7 @@ Removing a Unit Good of SKU WC1<br/>

Expected Output
```
Unit Good with SKU: WC1 has been removed from warehouse
Unit Good of SKU: WC1 has been removed from warehouse
Another command?
```

Expand Down Expand Up @@ -268,7 +280,10 @@ An Order contains:
* Receiver name
* Shipping address

### <img src="img.png" alt="img" style="width:30px;"/> Adding an Order `add o/`
### Adding an Order `add o/`

<img src="img.png" alt="img" style="width:30px;"/>

Adding a new order to be tracked in the warehouse.

Format: `add o/ oid/[ORDER_ID] r/[RECEIVER_NAME] addr/[SHIPPING_ADDRESS]`
Expand All @@ -286,7 +301,10 @@ Order 1 added to the warehouse
Another command?
```

### <img src="img.png" alt="img" style="width:30px;"/> Removing an Order `remove o/`
### Removing an Order `remove o/`

<img src="img.png" alt="img" style="width:30px;"/>

Removing the quantity of a Unit Good from its previous value.

Format: `remove o/ oid/[ORDER_ID]`
Expand All @@ -301,7 +319,10 @@ Order 1 has been removed
Another command?
```

### <img src="img.png" alt="img" style="width:30px;"/> Listing Current Orders `list o/`
### Listing Current Orders `list o/`

<img src="img.png" alt="img" style="width:30px;"/>

Listing all orders in the warehouse. This would show the order details such as:
* Order id
* Receiver Name
Expand All @@ -321,7 +342,10 @@ List of orders:
Another command?
```

### <img src="img.png" alt="img" style="width:30px;"/> View Order `view o/`
### View Order `view o/`

<img src="img.png" alt="img" style="width:30px;"/>

View a specific order in the warehouse. This would show the order details such as:
* Order id
* Receiver Name
Expand Down Expand Up @@ -352,7 +376,10 @@ Could not find order with given id!
Another command?
```

### <img src="img.png" alt="img" style="width:30px;"/> Fulfill Order `fulfill`
### Fulfill Order `fulfill`

<img src="img.png" alt="img" style="width:30px;"/>

Fulfill a currently unfulfilled order in the warehouse. To fulfill an order, Simplst will check if all the orderlines relating to the order have their required quantities met.<br/>
When all the orderlines quantities are fulfilled, the order will be considered as fulfilled.

Expand Down
27 changes: 6 additions & 21 deletions src/main/java/seedu/simplst/Display.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,18 @@ public static void hello() {
}

public static void bye() {
System.out.println("Thanks for using Simplst 1.0!");
System.out.println("Thanks for using Simplst 2.1!");
}

public static void stateRestored() {
System.out.println("State restored!");
}

public static void stateSaved() {
System.out.println("State saved!");
}

public static void stateNotSaved() {
System.out.println("State not saved!");
}

public static void newLogin() {
System.out.println("New login.");
}

// successful output
public static void inventoryGoodQtyRemoved(Float qty, String goodName) {
System.out.println(qty + " of " + goodName + " has been removed.");
}

public static void orderlineCheckedOff(String unitGoodName, String orderId) {
System.out.println(unitGoodName + "of order " + orderId + " has been removed.");
}

public static void unitGoodAdded(String sku) {
System.out.println("Unit Good of SKU: " + sku + " added to warehouse");
Expand Down Expand Up @@ -88,7 +73,7 @@ public static void warehouseStateNotSaved() {
System.out.println("Warehouse information can't save.");
}

public static void warehouseStateNotRestored(){
public static void warehouseStateNotRestored() {
System.out.println("Warehouse information can't restore.");
}

Expand Down Expand Up @@ -155,15 +140,15 @@ public static void helpOrder() {
System.out.println("\tExample: add o/ oid/1 r/Danny Phantom "
+ "addr/Amity Park\n");
System.out.println("Add good to order Command");
System.out.println("\tFormat: add og/ oid/[ORDER_ID] sku/[SKU] q/[QUANTITY_NEEDED_FOR_ORDER]");
System.out.println("\tExample: add og/ oid/1 sku/WC1 q/10");
System.out.println("\tFormat: add og/ oid/[ORDER_ID] sku/[SKU] qty/[QUANTITY_NEEDED_FOR_ORDER]");
System.out.println("\tExample: add og/ oid/1 sku/WC1 qty/10\n");
System.out.println("Remove order Command");
System.out.println("\tFormat: remove o/ oid/[ORDER_ID]");
System.out.println("\tExample: remove o/ oid/1\n");
System.out.println("Remove a specific quantity of orderline in an order");
System.out.println("\tFormat: remove og/ oid/[ORDER_ID] sku/[SKU]"
+ " q/[QUANTITY_TO_REMOVE]");
System.out.println("\tExample: remove og/ oid/1 sku/WC1 q/1\n");
+ " qty/[QUANTITY_TO_REMOVE]");
System.out.println("\tExample: remove og/ oid/1 sku/WC1 qty/1\n");
System.out.println("Listing all orders");
System.out.println("\tFormat: list o/\n");
System.out.println("Listing orderlines in an order");
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/simplst/LocalStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ public static String readSaveFile(String filePath) {
/**
* Opens and writes serialised string versino of tasklist to file at SAVE_PATH.
*/

public static Boolean writeSaveFile(String storeStr, String filePath) {
Path dir = Paths.get(filePath).toAbsolutePath().normalize().getParent();
if (!Files.exists(dir)) {
try {
Files.createDirectory(dir);
System.out.printf("Output Directory created at %s!\n", dir.toString());
System.out.println("Output Directory created at current directory!");
} catch (IOException e) {
System.err.println("Failed to create directory! " + e.getMessage());
return false;
Expand Down
23 changes: 11 additions & 12 deletions src/main/java/seedu/simplst/Order.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ public Orderline addOrderline(UnitGood unitGood, String qty)
Display.orderlineAlreadyExists(orderline.getName(), orderline.getQuantity());
return null;
}
orderline = new Orderline(unitGood,
orderlines.size() + 1, quantity);
orderline = new Orderline(unitGood, quantity);
orderlines.add(orderline);
Display.orderlineAdded(orderline.getName(), orderline.getQuantity());
} catch (NumberFormatException e) {
Expand Down Expand Up @@ -186,44 +185,44 @@ public JSONObject serialize() {

public static Order restoreOrder(JSONObject jo) {
Object idO = jo.get(OrderKeys.orderId);
Object rO = jo.get(OrderKeys.receiver);
Object ro = jo.get(OrderKeys.receiver);
Object saO = jo.get(OrderKeys.shippingAddress);
Object fO = jo.get(OrderKeys.isFulfilled);
Object fo = jo.get(OrderKeys.isFulfilled);
Object olO = jo.get(OrderKeys.orderlines);
if (idO == null || rO == null || saO == null || fO == null || olO == null){
if (idO == null || ro == null || saO == null || fo == null || olO == null) {
return null;
}
Integer orderId = Integer.parseInt(idO.toString());
String receiver = rO.toString();
String receiver = ro.toString();
String shippingAddress = saO.toString();
Order cur = new Order(
orderId,
receiver,
shippingAddress
);

cur.setFulfilled(Boolean.parseBoolean(fO.toString()));
cur.setFulfilled(Boolean.parseBoolean(fo.toString()));
JSONArray orderLinesJA = (JSONArray) olO;
for (Object item: orderLinesJA){
for (Object item: orderLinesJA) {
JSONObject jol = (JSONObject) item;
UnitGood ug = UnitGood.restoreUnitGood(jol);
if (ug == null){
if (ug == null) {
return null;
}
Object qtyO = jol.get(GoodKeys.quantity);
Object qfO = jol.get(OrderlinesKeys.quantityFulfilled);
Object ifO = jol.get(OrderlinesKeys.isCheckedOff);
if (qtyO == null || qfO == null || ifO == null){
if (qtyO == null || qfO == null || ifO == null) {
return null;
}
String qty = qtyO.toString();
try {
Orderline ol = cur.addOrderline(ug, qty);
if (ol == null){
if (ol == null) {
return null;
}
Boolean isCheckOff = Boolean.parseBoolean(ifO.toString());
if (isCheckOff){
if (isCheckOff) {
ol.checkOff();
}
Integer qtyF = Integer.parseInt(qfO.toString());
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/seedu/simplst/Orderline.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class Orderline extends Good {
private int quantityFulfilled = 0;
private Boolean isCheckedOff = false;

public Orderline(UnitGood unitGood, int id, int quantity) {
public Orderline(UnitGood unitGood, int quantity) {
super(unitGood, quantity);
}

Expand Down Expand Up @@ -52,10 +52,6 @@ public String toString() {
+ isDone();
}

public int getId() {
return 0;
}

public JSONObject serialize() {
JSONObject jo = super.serialize();
jo.put(OrderlinesKeys.isCheckedOff, this.isCheckedOff);
Expand Down
15 changes: 6 additions & 9 deletions src/main/java/seedu/simplst/Simplst.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package seedu.simplst;

import util.exceptions.NullException;

import java.io.IOException;

/**
* Main entry-point for the java.duke.Duke application.
*/
public class Simplst {
public static void main(String[] args) throws NullException, IOException, IOException {
public static void main(String[] args) {
UserInterface ui;
Warehouse w = new Warehouse(0);
Boolean status = w.restoreWarehouseState();
Expand All @@ -22,12 +20,11 @@ public static void main(String[] args) throws NullException, IOException, IOExce
Display.hello();
ui = new UserInterface(w);
ui.run();
status = w.saveWarehouseState();
// if (status) {
// Display.stateSaved();
// } else {
// Display.stateNotSaved();
// }
try {
w.saveWarehouseState();
} catch (IOException e) {
System.out.println("File not saved!");
}
Display.bye();
}
}
4 changes: 2 additions & 2 deletions src/main/java/seedu/simplst/UnitGood.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ public static UnitGood restoreUnitGood(JSONObject jo) {
Object description = jo.get(UnitGoodKeys.description);
Object capacity = jo.get(UnitGoodKeys.capacity);
String desc = "";
if (sku == null || name == null || capacity == null){
if (sku == null || name == null || capacity == null) {
return null;
}
if(description == null){
if (description == null) {
desc = "";
} else {
desc = description.toString();
Expand Down
Loading

0 comments on commit e107c45

Please sign in to comment.