This repository has been archived on 2020-08-02. You can view files and clone it, but cannot push or open issues or pull requests.
e-commerce/web_backend/src/main/java/org/hso/ecommerce/entities/shop/Article.java

49 lines
1.1 KiB
Java
Raw Normal View History

2020-04-29 22:44:16 +02:00
package org.hso.ecommerce.entities.shop;
import org.hso.ecommerce.entities.supplier.ArticleOffer;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.HashSet;
import java.util.Set;
@Entity
@Table(name = "articles")
2020-05-15 18:13:12 +02:00
public class Article {
2020-05-15 18:13:12 +02:00
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic
public long id;
2020-06-12 19:22:36 +02:00
@OneToOne(optional = false)
2020-05-15 18:13:12 +02:00
public ArticleOffer related;
2020-05-15 18:13:12 +02:00
public int shopPricePerUnitNetCent;
public int warehouseUnitsPerSlot;
2020-05-15 18:13:12 +02:00
public boolean shouldReorder;
public int reorderMaxPrice;
2020-05-15 18:13:12 +02:00
@NotNull
public String title;
2020-05-15 18:13:12 +02:00
@NotNull
public String description;
2020-05-15 18:13:12 +02:00
@OneToOne(optional = true)
@Basic(fetch = FetchType.LAZY)
public Image image;
@ManyToMany(cascade = CascadeType.ALL)
2020-05-15 18:13:12 +02:00
@JoinTable(name = "article_categories_bindings")
public Set<Category> categories = new HashSet<>();
2020-05-15 18:13:12 +02:00
public int getVat() {
return (shopPricePerUnitNetCent * related.vatPercent) / 100;
}
2020-05-15 18:13:12 +02:00
public int getPriceGross() {
return shopPricePerUnitNetCent + getVat();
}
}