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

import jakarta.persistence.*;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

@Entity
@Table(name = "stocks")
public class StockEntity {

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

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

    @Column(name = "storage_location_id", nullable = false, length = 36)
    private String storageLocationId;

    @Column(name = "minimum_level_amount", precision = 12, scale = 3)
    private BigDecimal minimumLevelAmount;

    @Column(name = "minimum_level_unit", length = 20)
    private String minimumLevelUnit;

    @Column(name = "minimum_shelf_life_days")
    private Integer minimumShelfLifeDays;

    @OneToMany(mappedBy = "stock", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
    private List<StockBatchEntity> batches = new ArrayList<>();

    @OneToMany(mappedBy = "stock", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
    private List<ReservationEntity> reservations = new ArrayList<>();

    public StockEntity() {}

    // ==================== Getters & Setters ====================

    public String getId() { return id; }
    public void setId(String id) { this.id = id; }

    public String getArticleId() { return articleId; }
    public void setArticleId(String articleId) { this.articleId = articleId; }

    public String getStorageLocationId() { return storageLocationId; }
    public void setStorageLocationId(String storageLocationId) { this.storageLocationId = storageLocationId; }

    public BigDecimal getMinimumLevelAmount() { return minimumLevelAmount; }
    public void setMinimumLevelAmount(BigDecimal minimumLevelAmount) { this.minimumLevelAmount = minimumLevelAmount; }

    public String getMinimumLevelUnit() { return minimumLevelUnit; }
    public void setMinimumLevelUnit(String minimumLevelUnit) { this.minimumLevelUnit = minimumLevelUnit; }

    public Integer getMinimumShelfLifeDays() { return minimumShelfLifeDays; }
    public void setMinimumShelfLifeDays(Integer minimumShelfLifeDays) { this.minimumShelfLifeDays = minimumShelfLifeDays; }

    public List<StockBatchEntity> getBatches() { return batches; }
    public void setBatches(List<StockBatchEntity> batches) { this.batches = batches; }

    public List<ReservationEntity> getReservations() { return reservations; }
    public void setReservations(List<ReservationEntity> reservations) { this.reservations = reservations; }
}
