From 1186c390fb9295a7190e37d76afe96c75543558d Mon Sep 17 00:00:00 2001 From: CodeSteak Date: Tue, 28 Apr 2020 21:02:33 +0200 Subject: [PATCH] Implement Entries // TODO: Move to packages, add Repos. --- .../org/hso/ecommerce/entities/Address.java | 10 +++++ .../org/hso/ecommerce/entities/Article.java | 38 ++++++++++++++++ .../hso/ecommerce/entities/ArticleOffer.java | 22 ++++++++++ .../hso/ecommerce/entities/BackgroundJob.java | 23 ++++++++++ .../org/hso/ecommerce/entities/Booking.java | 25 +++++++++++ .../entities/BookingAccountEntry.java | 25 +++++++++++ .../hso/ecommerce/entities/BookingReason.java | 27 ++++++++++++ .../org/hso/ecommerce/entities/Category.java | 23 ++++++++++ .../hso/ecommerce/entities/CustomerOrder.java | 44 +++++++++++++++++++ .../entities/CustomerOrderPosition.java | 22 ++++++++++ .../ecommerce/entities/CustomerPayment.java | 18 ++++++++ .../ecommerce/entities/DashboardSummary.java | 25 +++++++++++ .../org/hso/ecommerce/entities/Image.java | 17 +++++++ .../hso/ecommerce/entities/PaymentMethod.java | 10 +++++ .../org/hso/ecommerce/entities/Supplier.java | 23 ++++++++++ .../hso/ecommerce/entities/SupplierOrder.java | 37 ++++++++++++++++ .../java/org/hso/ecommerce/entities/User.java | 13 +++++- .../ecommerce/entities/WarehouseBooking.java | 27 ++++++++++++ .../entities/WarehouseBookingPosition.java | 30 +++++++++++++ .../WarehouseBookingPositionSlotEntry.java | 21 +++++++++ .../entities/WarehouseBookingReason.java | 23 ++++++++++ 21 files changed, 501 insertions(+), 2 deletions(-) create mode 100644 prototype/src/main/java/org/hso/ecommerce/entities/Address.java create mode 100644 prototype/src/main/java/org/hso/ecommerce/entities/Article.java create mode 100644 prototype/src/main/java/org/hso/ecommerce/entities/ArticleOffer.java create mode 100644 prototype/src/main/java/org/hso/ecommerce/entities/BackgroundJob.java create mode 100644 prototype/src/main/java/org/hso/ecommerce/entities/Booking.java create mode 100644 prototype/src/main/java/org/hso/ecommerce/entities/BookingAccountEntry.java create mode 100644 prototype/src/main/java/org/hso/ecommerce/entities/BookingReason.java create mode 100644 prototype/src/main/java/org/hso/ecommerce/entities/Category.java create mode 100644 prototype/src/main/java/org/hso/ecommerce/entities/CustomerOrder.java create mode 100644 prototype/src/main/java/org/hso/ecommerce/entities/CustomerOrderPosition.java create mode 100644 prototype/src/main/java/org/hso/ecommerce/entities/CustomerPayment.java create mode 100644 prototype/src/main/java/org/hso/ecommerce/entities/DashboardSummary.java create mode 100644 prototype/src/main/java/org/hso/ecommerce/entities/Image.java create mode 100644 prototype/src/main/java/org/hso/ecommerce/entities/PaymentMethod.java create mode 100644 prototype/src/main/java/org/hso/ecommerce/entities/Supplier.java create mode 100644 prototype/src/main/java/org/hso/ecommerce/entities/SupplierOrder.java create mode 100644 prototype/src/main/java/org/hso/ecommerce/entities/WarehouseBooking.java create mode 100644 prototype/src/main/java/org/hso/ecommerce/entities/WarehouseBookingPosition.java create mode 100644 prototype/src/main/java/org/hso/ecommerce/entities/WarehouseBookingPositionSlotEntry.java create mode 100644 prototype/src/main/java/org/hso/ecommerce/entities/WarehouseBookingReason.java diff --git a/prototype/src/main/java/org/hso/ecommerce/entities/Address.java b/prototype/src/main/java/org/hso/ecommerce/entities/Address.java new file mode 100644 index 0000000..ecd4b35 --- /dev/null +++ b/prototype/src/main/java/org/hso/ecommerce/entities/Address.java @@ -0,0 +1,10 @@ +package org.hso.ecommerce.entities; + +import javax.persistence.Embeddable; + +@Embeddable +public class Address { + public String name; + public String addressString; + public String country = "DE"; +} diff --git a/prototype/src/main/java/org/hso/ecommerce/entities/Article.java b/prototype/src/main/java/org/hso/ecommerce/entities/Article.java new file mode 100644 index 0000000..23c0209 --- /dev/null +++ b/prototype/src/main/java/org/hso/ecommerce/entities/Article.java @@ -0,0 +1,38 @@ +package org.hso.ecommerce.entities; + +import javax.persistence.*; +import javax.validation.constraints.NotNull; +import java.util.HashSet; +import java.util.Set; + +@Entity +@Table(name = "articles") +public class Article { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic + public long id; + + @ManyToOne(optional = false) + public ArticleOffer related; + + public int shopPricePerUnitNetCent; + public int warehouseUnitsPerSlot; + + public boolean shouldReorder; + public int reorderMaxPrice; + + @NotNull + public String title; + + @NotNull + public String description; + + @OneToOne(optional = true) + public Image image; + + @ManyToMany + @JoinTable(name = "article_categories_bindings") + public Set categories = new HashSet<>(); +} diff --git a/prototype/src/main/java/org/hso/ecommerce/entities/ArticleOffer.java b/prototype/src/main/java/org/hso/ecommerce/entities/ArticleOffer.java new file mode 100644 index 0000000..f880fe2 --- /dev/null +++ b/prototype/src/main/java/org/hso/ecommerce/entities/ArticleOffer.java @@ -0,0 +1,22 @@ +package org.hso.ecommerce.entities; + +import javax.persistence.*; +import javax.validation.constraints.NotNull; + +@Entity +@Table(name = "article_offers") +public class ArticleOffer { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic + public long id; + + @NotNull + public String manufacturer; + + @NotNull + public String articleNumber; + + public int vatPercent; +} diff --git a/prototype/src/main/java/org/hso/ecommerce/entities/BackgroundJob.java b/prototype/src/main/java/org/hso/ecommerce/entities/BackgroundJob.java new file mode 100644 index 0000000..6fe33d8 --- /dev/null +++ b/prototype/src/main/java/org/hso/ecommerce/entities/BackgroundJob.java @@ -0,0 +1,23 @@ +package org.hso.ecommerce.entities; + +import javax.persistence.*; +import javax.validation.constraints.NotNull; + +@Entity +@Table(name = "background_jobs") +public class BackgroundJob { + + public final String JOB_DASHBOARD = "Dashboard"; + public final String JOB_REORDER = "SupplierOrder"; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic + public long id; + + @NotNull + public String jobName; + + @NotNull + public java.sql.Timestamp lastExecution; +} diff --git a/prototype/src/main/java/org/hso/ecommerce/entities/Booking.java b/prototype/src/main/java/org/hso/ecommerce/entities/Booking.java new file mode 100644 index 0000000..ac53277 --- /dev/null +++ b/prototype/src/main/java/org/hso/ecommerce/entities/Booking.java @@ -0,0 +1,25 @@ +package org.hso.ecommerce.entities; + +import javax.persistence.*; + +@Entity +@Table(name = "bookings") +public class Booking { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic + public long id; + + // always >= 0 + public int amountCent; + + @ManyToOne(optional = true) + public BookingAccountEntry source; + + @ManyToOne(optional = true) + public BookingAccountEntry destination; + + @OneToOne(optional = false) + public BookingReason reason; +} diff --git a/prototype/src/main/java/org/hso/ecommerce/entities/BookingAccountEntry.java b/prototype/src/main/java/org/hso/ecommerce/entities/BookingAccountEntry.java new file mode 100644 index 0000000..da98894 --- /dev/null +++ b/prototype/src/main/java/org/hso/ecommerce/entities/BookingAccountEntry.java @@ -0,0 +1,25 @@ +package org.hso.ecommerce.entities; + +import javax.persistence.*; + +@Entity +@Table(name = "booking_account_entries") +public class BookingAccountEntry { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic + public long id; + + public int newSumCent; + + @ManyToOne(optional = true) + public User userAccount; + + @ManyToOne(optional = true) + public Supplier supplierAccount; + + public boolean isMainAccount; + public boolean isVATAccount; + +} diff --git a/prototype/src/main/java/org/hso/ecommerce/entities/BookingReason.java b/prototype/src/main/java/org/hso/ecommerce/entities/BookingReason.java new file mode 100644 index 0000000..561bf05 --- /dev/null +++ b/prototype/src/main/java/org/hso/ecommerce/entities/BookingReason.java @@ -0,0 +1,27 @@ +package org.hso.ecommerce.entities; + +import javax.persistence.*; + +@Entity +@Table(name = "booking_reasons") +public class BookingReason { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic + public long id; + + public boolean isManuel; + public boolean isStartBooking; + + public String comment; + + @ManyToOne(optional = true) + public CustomerOrder customerOrder; + + @ManyToOne(optional = true) + public CustomerPayment customerPayment; + + @ManyToOne(optional = true) + public SupplierOrder supplierOrder; +} diff --git a/prototype/src/main/java/org/hso/ecommerce/entities/Category.java b/prototype/src/main/java/org/hso/ecommerce/entities/Category.java new file mode 100644 index 0000000..9703b0a --- /dev/null +++ b/prototype/src/main/java/org/hso/ecommerce/entities/Category.java @@ -0,0 +1,23 @@ +package org.hso.ecommerce.entities; + +import javax.persistence.*; +import javax.validation.constraints.NotNull; +import java.util.HashSet; +import java.util.Set; + +@Entity +@Table(name = "categories") +public class Category { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic + public long id; + + @NotNull + @Column(unique = true) + public String name; + + @ManyToMany(mappedBy = "categories") + public Set
articles = new HashSet<>(); +} diff --git a/prototype/src/main/java/org/hso/ecommerce/entities/CustomerOrder.java b/prototype/src/main/java/org/hso/ecommerce/entities/CustomerOrder.java new file mode 100644 index 0000000..455aede --- /dev/null +++ b/prototype/src/main/java/org/hso/ecommerce/entities/CustomerOrder.java @@ -0,0 +1,44 @@ +package org.hso.ecommerce.entities; + +import javax.persistence.*; +import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.List; + +@Entity +@Table(name = "customer_orders") +public class CustomerOrder { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic + public long id; + + @ManyToOne(optional = false) + public User customer; + + @Embedded + public Address destination; + + @OneToMany( + targetEntity = CustomerOrderPosition.class, + mappedBy = "order" + ) + public List positions = new ArrayList<>(); + + @NotNull + public java.sql.Timestamp created; + + @NotNull + public String trackingId; + + @Column(nullable = true) + public java.sql.Timestamp inDeliverySince; + + @Column(nullable = true) + public java.sql.Timestamp deliveredAt; + + public int totalNetCent; + public int totalGrossCent; + public int totalVatCent; +} diff --git a/prototype/src/main/java/org/hso/ecommerce/entities/CustomerOrderPosition.java b/prototype/src/main/java/org/hso/ecommerce/entities/CustomerOrderPosition.java new file mode 100644 index 0000000..db1d486 --- /dev/null +++ b/prototype/src/main/java/org/hso/ecommerce/entities/CustomerOrderPosition.java @@ -0,0 +1,22 @@ +package org.hso.ecommerce.entities; + +import javax.persistence.*; + +@Entity +@Table(name = "customer_order_positions") +public class CustomerOrderPosition { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic + public long id; + + @ManyToOne(optional = false) + public CustomerOrder order; + + @ManyToOne(optional = false) + public Article article; + + public int pricePerUnit; + public int quantity; +} diff --git a/prototype/src/main/java/org/hso/ecommerce/entities/CustomerPayment.java b/prototype/src/main/java/org/hso/ecommerce/entities/CustomerPayment.java new file mode 100644 index 0000000..b52a2d9 --- /dev/null +++ b/prototype/src/main/java/org/hso/ecommerce/entities/CustomerPayment.java @@ -0,0 +1,18 @@ +package org.hso.ecommerce.entities; + +import javax.persistence.*; + +@Entity +@Table(name = "customer_payments") +public class CustomerPayment { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic + public long id; + + public int amountCent; + + @Embedded + public PaymentMethod payment; +} diff --git a/prototype/src/main/java/org/hso/ecommerce/entities/DashboardSummary.java b/prototype/src/main/java/org/hso/ecommerce/entities/DashboardSummary.java new file mode 100644 index 0000000..13f7965 --- /dev/null +++ b/prototype/src/main/java/org/hso/ecommerce/entities/DashboardSummary.java @@ -0,0 +1,25 @@ +package org.hso.ecommerce.entities; + +import javax.persistence.*; +import javax.validation.constraints.NotNull; + +@Entity +@Table(name = "dashboard_summaries") +public class DashboardSummary { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic + public long id; + + @NotNull + public java.sql.Date created; + + public int todaysCustomers; + public int todaysCustomersOrders; + public int todaysSuppliersOrders; + public int todaysItemsSold; + public int todaysSalesCent; + public int totalWarehouseCapacity; + public int currentWarehouseCapacity; +} diff --git a/prototype/src/main/java/org/hso/ecommerce/entities/Image.java b/prototype/src/main/java/org/hso/ecommerce/entities/Image.java new file mode 100644 index 0000000..62eac9e --- /dev/null +++ b/prototype/src/main/java/org/hso/ecommerce/entities/Image.java @@ -0,0 +1,17 @@ +package org.hso.ecommerce.entities; + +import javax.persistence.*; + +@Entity +@Table(name = "images") +public class Image { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic + public long id; + + @Lob + @Column(name = "data", columnDefinition = "BLOB", nullable = false) + private byte[] data; +} diff --git a/prototype/src/main/java/org/hso/ecommerce/entities/PaymentMethod.java b/prototype/src/main/java/org/hso/ecommerce/entities/PaymentMethod.java new file mode 100644 index 0000000..0723219 --- /dev/null +++ b/prototype/src/main/java/org/hso/ecommerce/entities/PaymentMethod.java @@ -0,0 +1,10 @@ +package org.hso.ecommerce.entities; + +import javax.persistence.Embeddable; +import javax.validation.constraints.NotNull; + +@Embeddable +public class PaymentMethod { + @NotNull + public String creditCardNumber; +} diff --git a/prototype/src/main/java/org/hso/ecommerce/entities/Supplier.java b/prototype/src/main/java/org/hso/ecommerce/entities/Supplier.java new file mode 100644 index 0000000..5ae9794 --- /dev/null +++ b/prototype/src/main/java/org/hso/ecommerce/entities/Supplier.java @@ -0,0 +1,23 @@ +package org.hso.ecommerce.entities; + +import javax.persistence.*; +import javax.validation.constraints.NotNull; + +@Entity +@Table(name = "suppliers") +public class Supplier { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic + public long id; + + @Column(unique = true) + public String uuid; + + @NotNull + public String name; + + @NotNull + public String apiUrl; +} diff --git a/prototype/src/main/java/org/hso/ecommerce/entities/SupplierOrder.java b/prototype/src/main/java/org/hso/ecommerce/entities/SupplierOrder.java new file mode 100644 index 0000000..80bb818 --- /dev/null +++ b/prototype/src/main/java/org/hso/ecommerce/entities/SupplierOrder.java @@ -0,0 +1,37 @@ +package org.hso.ecommerce.entities; + +import javax.persistence.*; +import javax.validation.constraints.NotNull; +import java.sql.Timestamp; + +@Entity +@Table(name = "supplier_orders") +public class SupplierOrder { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic + public long id; + + @NotNull + public java.sql.Timestamp created; + + @ManyToOne(optional = false) + public Supplier supplier; + + @ManyToOne(optional = false) + public ArticleOffer ordered; + + public int numberOfUnits; + public int pricePerUnitNetCent; + + // Includes discounts + public int totalPriceNet; + + @Column(nullable = true) + public Timestamp delivered; + + public boolean wasDelivered() { + return delivered != null; + } +} diff --git a/prototype/src/main/java/org/hso/ecommerce/entities/User.java b/prototype/src/main/java/org/hso/ecommerce/entities/User.java index 1c3c721..5d023cf 100644 --- a/prototype/src/main/java/org/hso/ecommerce/entities/User.java +++ b/prototype/src/main/java/org/hso/ecommerce/entities/User.java @@ -3,6 +3,7 @@ package org.hso.ecommerce.entities; import org.springframework.security.crypto.bcrypt.BCrypt; import javax.persistence.*; +import javax.validation.constraints.NotNull; @Entity @@ -13,16 +14,24 @@ public class User { @GeneratedValue(strategy = GenerationType.IDENTITY) @Basic public long id; + + @NotNull public java.sql.Timestamp created; + @NotNull @Column(unique = true) public String email; + public String passwordHash; public boolean isActive; public boolean isEmployee; - public boolean getsAds; - public boolean isB2B; + + @Embedded + private Address defaultDeliveryAddress; + + @Embedded + private PaymentMethod defaultPayment; public long getId() { return id; diff --git a/prototype/src/main/java/org/hso/ecommerce/entities/WarehouseBooking.java b/prototype/src/main/java/org/hso/ecommerce/entities/WarehouseBooking.java new file mode 100644 index 0000000..b6501ef --- /dev/null +++ b/prototype/src/main/java/org/hso/ecommerce/entities/WarehouseBooking.java @@ -0,0 +1,27 @@ +package org.hso.ecommerce.entities; + +import javax.persistence.*; +import javax.validation.constraints.NotNull; +import java.util.ArrayList; +import java.util.List; + +@Entity +@Table(name = "warehouse_bookings") +public class WarehouseBooking { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic + public long id; + + @NotNull + public java.sql.Timestamp created; + + public boolean isInProgress; + public boolean isDone; + + @OneToMany( + mappedBy = "booking" + ) + public List positions = new ArrayList<>(); +} diff --git a/prototype/src/main/java/org/hso/ecommerce/entities/WarehouseBookingPosition.java b/prototype/src/main/java/org/hso/ecommerce/entities/WarehouseBookingPosition.java new file mode 100644 index 0000000..9cf35f0 --- /dev/null +++ b/prototype/src/main/java/org/hso/ecommerce/entities/WarehouseBookingPosition.java @@ -0,0 +1,30 @@ +package org.hso.ecommerce.entities; + +import javax.persistence.*; + +// TODO Unify with $$$ Bookings + WarehouseBookingEntry. + +@Entity +@Table(name = "warehouse_booking_positions") +public class WarehouseBookingPosition { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic + public long id; + + @ManyToOne(optional = false) + public WarehouseBooking booking; + + @ManyToOne(optional = false) + public Article article; + + public int amount; // positive or negative + + @ManyToOne(optional = true) + public WarehouseBookingPositionSlotEntry source; + + @ManyToOne(optional = true) + public WarehouseBookingPositionSlotEntry destination; + +} diff --git a/prototype/src/main/java/org/hso/ecommerce/entities/WarehouseBookingPositionSlotEntry.java b/prototype/src/main/java/org/hso/ecommerce/entities/WarehouseBookingPositionSlotEntry.java new file mode 100644 index 0000000..3ea0d57 --- /dev/null +++ b/prototype/src/main/java/org/hso/ecommerce/entities/WarehouseBookingPositionSlotEntry.java @@ -0,0 +1,21 @@ +package org.hso.ecommerce.entities; + +import javax.persistence.*; + +@Entity +@Table(name = "warehouse_booking_position_entries") +public class WarehouseBookingPositionSlotEntry { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic + public long id; + + @ManyToOne + public Article article; + + public int newSumArticles; + public int newSumWarehousePosition; + + public int slot; +} diff --git a/prototype/src/main/java/org/hso/ecommerce/entities/WarehouseBookingReason.java b/prototype/src/main/java/org/hso/ecommerce/entities/WarehouseBookingReason.java new file mode 100644 index 0000000..0fd4834 --- /dev/null +++ b/prototype/src/main/java/org/hso/ecommerce/entities/WarehouseBookingReason.java @@ -0,0 +1,23 @@ +package org.hso.ecommerce.entities; + +import javax.persistence.*; + +@Entity +@Table(name = "warehouse_booking_reasons") +public class WarehouseBookingReason { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Basic + public long id; + + public String comment; + + @ManyToOne(optional = true) + public SupplierOrder causeSupplierOrder; + + @ManyToOne(optional = true) + public CustomerOrder customerOrder; + + public boolean isManuel; +}