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

import jakarta.persistence.*;

import java.math.BigDecimal;
import java.time.OffsetDateTime;

@Entity
@Table(name = "batch_consumptions")
public class ConsumptionEntity {

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

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "batch_id", nullable = false)
    private BatchEntity batch;

    @Column(name = "input_batch_id", nullable = false, length = 36)
    private String inputBatchId;

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

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

    @Column(name = "quantity_used_unit", nullable = false, length = 10)
    private String quantityUsedUnit;

    @Column(name = "consumed_at", nullable = false)
    private OffsetDateTime consumedAt;

    protected ConsumptionEntity() {}

    public ConsumptionEntity(String id, BatchEntity batch, String inputBatchId, String articleId,
                             BigDecimal quantityUsedAmount, String quantityUsedUnit, OffsetDateTime consumedAt) {
        this.id = id;
        this.batch = batch;
        this.inputBatchId = inputBatchId;
        this.articleId = articleId;
        this.quantityUsedAmount = quantityUsedAmount;
        this.quantityUsedUnit = quantityUsedUnit;
        this.consumedAt = consumedAt;
    }

    public String getId() { return id; }
    public BatchEntity getBatch() { return batch; }
    public String getInputBatchId() { return inputBatchId; }
    public String getArticleId() { return articleId; }
    public BigDecimal getQuantityUsedAmount() { return quantityUsedAmount; }
    public String getQuantityUsedUnit() { return quantityUsedUnit; }
    public OffsetDateTime getConsumedAt() { return consumedAt; }
}
