swt23w23/src/main/java/catering/order/CustomOrder.java

87 lines
2 KiB
Java
Raw Normal View History

package catering.order;
import com.querydsl.core.Tuple;
import org.aspectj.weaver.ast.Or;
import org.salespointframework.quantity.Quantity;
2023-11-05 11:36:39 +01:00
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
/**
* This class is only used for the prototype to avoid using the bloated Salespoint API
*/
public class CustomOrder {
2023-11-05 16:41:22 +01:00
private int id;
private OrderType orderType;
2023-11-05 11:36:39 +01:00
private LocalDateTime start;
private LocalDateTime finish;
private Map<String, Quantity> products;
private boolean invoiceAvailable;
private double totalCost; // this is in €
private DateTimeFormatter formatter;
2023-11-05 11:36:39 +01:00
public CustomOrder(OrderType orderType, LocalDateTime start, LocalDateTime finish, Map<String, Quantity> products, boolean invoiceAvailable, double totalCost) {
2023-11-05 16:41:22 +01:00
this.id = (int) (Math.random() * Integer.MAX_VALUE);
this.orderType = orderType;
2023-11-05 11:36:39 +01:00
this.start = start;
this.finish = finish;
this.products = products;
this.invoiceAvailable = invoiceAvailable;
this.totalCost = totalCost;
this.formatter = DateTimeFormatter.ofPattern("dd.MM.yyy, HH:mm 'Uhr'");
}
2023-11-05 16:41:22 +01:00
public int getId() {
return id;
}
public OrderType getOrderType() {
return orderType;
}
2023-11-05 11:36:39 +01:00
public LocalDateTime getStart() {
return start;
}
public String getFormattedStart() {
return start.format(formatter);
}
2023-11-05 11:36:39 +01:00
public LocalDateTime getFinish() {
return finish;
}
public String getFormattedFinish() {
return finish.format(formatter);
}
public Map<String, Quantity> getProducts() {
return products;
}
public Collection<String> getFormattedProducts() {
ArrayList<String> formattedProducts = new ArrayList<>();
getProducts().forEach((k, v) -> formattedProducts.add(k + ": " + v));
return formattedProducts;
}
public boolean invoiceAvailable() {
return invoiceAvailable;
}
public double getTotalCost() {
return totalCost;
}
enum OrderType {
RENT_A_COOK,
EVENT_CATERING,
SUSHI_NIGHT,
SOMETHING_ELSE
}
}