package de.effigenix.infrastructure.production.persistence.entity;

import jakarta.persistence.*;

import java.math.BigDecimal;

@Entity
@Table(name = "recipe_ingredients")
public class IngredientEntity {

    @Id
    @Column(name = "id", nullable = false, length = 36)
    private String id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "recipe_id", nullable = false)
    private RecipeEntity recipe;

    @Column(name = "position", nullable = false)
    private int position;

    @Column(name = "article_id", nullable = false, length = 36)
    private String articleId;

    @Column(name = "quantity", nullable = false, precision = 19, scale = 6)
    private BigDecimal quantity;

    @Column(name = "uom", nullable = false, length = 20)
    private String uom;

    @Column(name = "sub_recipe_id", length = 36)
    private String subRecipeId;

    @Column(name = "substitutable", nullable = false)
    private boolean substitutable;

    protected IngredientEntity() {}

    public IngredientEntity(String id, RecipeEntity recipe, int position, String articleId,
                            BigDecimal quantity, String uom, String subRecipeId, boolean substitutable) {
        this.id = id;
        this.recipe = recipe;
        this.position = position;
        this.articleId = articleId;
        this.quantity = quantity;
        this.uom = uom;
        this.subRecipeId = subRecipeId;
        this.substitutable = substitutable;
    }

    public String getId() { return id; }
    public RecipeEntity getRecipe() { return recipe; }
    public int getPosition() { return position; }
    public String getArticleId() { return articleId; }
    public BigDecimal getQuantity() { return quantity; }
    public String getUom() { return uom; }
    public String getSubRecipeId() { return subRecipeId; }
    public boolean isSubstitutable() { return substitutable; }

    public void setId(String id) { this.id = id; }
    public void setRecipe(RecipeEntity recipe) { this.recipe = recipe; }
    public void setPosition(int position) { this.position = position; }
    public void setArticleId(String articleId) { this.articleId = articleId; }
    public void setQuantity(BigDecimal quantity) { this.quantity = quantity; }
    public void setUom(String uom) { this.uom = uom; }
    public void setSubRecipeId(String subRecipeId) { this.subRecipeId = subRecipeId; }
    public void setSubstitutable(boolean substitutable) { this.substitutable = substitutable; }
}
