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

import jakarta.persistence.*;

import java.math.BigDecimal;
import java.time.Instant;
import java.time.LocalDate;

@Entity
@Table(name = "stock_batches")
public class StockBatchEntity {

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

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "stock_id", nullable = false)
    private StockEntity stock;

    @Column(name = "batch_id", nullable = false, length = 100)
    private String batchId;

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

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

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

    @Column(name = "expiry_date", nullable = false)
    private LocalDate expiryDate;

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

    @Column(name = "received_at", nullable = false)
    private Instant receivedAt;

    protected StockBatchEntity() {}

    public StockBatchEntity(String id, StockEntity stock, String batchId, String batchType,
                            BigDecimal quantityAmount, String quantityUnit, LocalDate expiryDate,
                            String status, Instant receivedAt) {
        this.id = id;
        this.stock = stock;
        this.batchId = batchId;
        this.batchType = batchType;
        this.quantityAmount = quantityAmount;
        this.quantityUnit = quantityUnit;
        this.expiryDate = expiryDate;
        this.status = status;
        this.receivedAt = receivedAt;
    }

    public String getId() { return id; }
    public StockEntity getStock() { return stock; }
    public String getBatchId() { return batchId; }
    public String getBatchType() { return batchType; }
    public BigDecimal getQuantityAmount() { return quantityAmount; }
    public String getQuantityUnit() { return quantityUnit; }
    public LocalDate getExpiryDate() { return expiryDate; }
    public String getStatus() { return status; }
    public Instant getReceivedAt() { return receivedAt; }

    public void setId(String id) { this.id = id; }
    public void setStock(StockEntity stock) { this.stock = stock; }
    public void setBatchId(String batchId) { this.batchId = batchId; }
    public void setBatchType(String batchType) { this.batchType = batchType; }
    public void setQuantityAmount(BigDecimal quantityAmount) { this.quantityAmount = quantityAmount; }
    public void setQuantityUnit(String quantityUnit) { this.quantityUnit = quantityUnit; }
    public void setExpiryDate(LocalDate expiryDate) { this.expiryDate = expiryDate; }
    public void setStatus(String status) { this.status = status; }
    public void setReceivedAt(Instant receivedAt) { this.receivedAt = receivedAt; }
}
