2023-11-05 10:39:39 +01:00
|
|
|
package catering.order;
|
|
|
|
|
2023-11-05 17:05:56 +01:00
|
|
|
import com.querydsl.core.Tuple;
|
2023-11-05 10:39:39 +01:00
|
|
|
import org.aspectj.weaver.ast.Or;
|
|
|
|
import org.salespointframework.quantity.Quantity;
|
|
|
|
|
2023-11-05 11:36:39 +01:00
|
|
|
import java.time.LocalDateTime;
|
2023-11-05 15:36:46 +01:00
|
|
|
import java.time.format.DateTimeFormatter;
|
2023-11-05 17:05:56 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collection;
|
2023-11-05 10:39:39 +01:00
|
|
|
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;
|
2023-11-05 10:39:39 +01:00
|
|
|
private OrderType orderType;
|
2023-11-05 11:36:39 +01:00
|
|
|
private LocalDateTime start;
|
|
|
|
private LocalDateTime finish;
|
2023-11-05 10:39:39 +01:00
|
|
|
private Map<String, Quantity> products;
|
|
|
|
private boolean invoiceAvailable;
|
|
|
|
private double totalCost; // this is in €
|
2023-11-05 15:36:46 +01:00
|
|
|
private DateTimeFormatter formatter;
|
2023-11-05 10:39:39 +01:00
|
|
|
|
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);
|
2023-11-05 10:39:39 +01:00
|
|
|
this.orderType = orderType;
|
2023-11-05 11:36:39 +01:00
|
|
|
this.start = start;
|
|
|
|
this.finish = finish;
|
2023-11-05 10:39:39 +01:00
|
|
|
this.products = products;
|
|
|
|
this.invoiceAvailable = invoiceAvailable;
|
|
|
|
this.totalCost = totalCost;
|
2023-11-07 20:53:31 +01:00
|
|
|
this.formatter = DateTimeFormatter.ofPattern("dd.MM.yyy, HH:mm 'Uhr'");
|
2023-11-05 10:39:39 +01:00
|
|
|
}
|
|
|
|
|
2023-11-05 16:41:22 +01:00
|
|
|
public int getId() {
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2023-11-05 10:39:39 +01:00
|
|
|
public OrderType getOrderType() {
|
|
|
|
return orderType;
|
|
|
|
}
|
|
|
|
|
2023-11-05 11:36:39 +01:00
|
|
|
public LocalDateTime getStart() {
|
|
|
|
return start;
|
|
|
|
}
|
|
|
|
|
2023-11-05 15:36:46 +01:00
|
|
|
public String getFormattedStart() {
|
|
|
|
return start.format(formatter);
|
|
|
|
}
|
|
|
|
|
2023-11-05 11:36:39 +01:00
|
|
|
public LocalDateTime getFinish() {
|
|
|
|
return finish;
|
|
|
|
}
|
|
|
|
|
2023-11-05 15:36:46 +01:00
|
|
|
public String getFormattedFinish() {
|
|
|
|
return finish.format(formatter);
|
|
|
|
}
|
|
|
|
|
2023-11-05 10:39:39 +01:00
|
|
|
public Map<String, Quantity> getProducts() {
|
|
|
|
return products;
|
|
|
|
}
|
|
|
|
|
2023-11-05 17:05:56 +01:00
|
|
|
public Collection<String> getFormattedProducts() {
|
|
|
|
ArrayList<String> formattedProducts = new ArrayList<>();
|
|
|
|
getProducts().forEach((k, v) -> formattedProducts.add(k + ": " + v));
|
|
|
|
return formattedProducts;
|
|
|
|
}
|
|
|
|
|
2023-11-05 15:36:46 +01:00
|
|
|
public boolean invoiceAvailable() {
|
2023-11-05 10:39:39 +01:00
|
|
|
return invoiceAvailable;
|
|
|
|
}
|
|
|
|
|
|
|
|
public double getTotalCost() {
|
|
|
|
return totalCost;
|
|
|
|
}
|
|
|
|
|
2023-11-05 12:33:43 +01:00
|
|
|
enum OrderType {
|
2023-11-05 10:39:39 +01:00
|
|
|
RENT_A_COOK,
|
|
|
|
EVENT_CATERING,
|
|
|
|
SUSHI_NIGHT,
|
|
|
|
SOMETHING_ELSE
|
|
|
|
}
|
|
|
|
}
|