package catering.order; import com.querydsl.core.Tuple; import org.aspectj.weaver.ast.Or; import org.salespointframework.quantity.Quantity; 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 { private int id; private OrderType orderType; private LocalDateTime start; private LocalDateTime finish; private Map products; private boolean invoiceAvailable; private double totalCost; // this is in € private DateTimeFormatter formatter; public CustomOrder(OrderType orderType, LocalDateTime start, LocalDateTime finish, Map products, boolean invoiceAvailable, double totalCost) { this.id = (int) (Math.random() * Integer.MAX_VALUE); this.orderType = orderType; 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'"); } public int getId() { return id; } public OrderType getOrderType() { return orderType; } public LocalDateTime getStart() { return start; } public String getFormattedStart() { return start.format(formatter); } public LocalDateTime getFinish() { return finish; } public String getFormattedFinish() { return finish.format(formatter); } public Map getProducts() { return products; } public Collection getFormattedProducts() { ArrayList 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 } }