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

import jakarta.persistence.*;

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

@Entity
@Table(name = "stock_movements")
public class StockMovementEntity {

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

    @Column(name = "stock_id", nullable = false, length = 36)
    private String stockId;

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

    @Column(name = "stock_batch_id", nullable = false, length = 36)
    private String stockBatchId;

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

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

    @Column(name = "movement_type", nullable = false, length = 30)
    private String movementType;

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

    @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 = "reason", length = 500)
    private String reason;

    @Column(name = "reference_document_id", length = 100)
    private String referenceDocumentId;

    @Column(name = "performed_by", nullable = false, length = 36)
    private String performedBy;

    @Column(name = "performed_at", nullable = false)
    private Instant performedAt;

    public StockMovementEntity() {}

    public StockMovementEntity(String id, String stockId, String articleId, String stockBatchId,
                               String batchId, String batchType, String movementType, String direction,
                               BigDecimal quantityAmount, String quantityUnit, String reason,
                               String referenceDocumentId, String performedBy, Instant performedAt) {
        this.id = id;
        this.stockId = stockId;
        this.articleId = articleId;
        this.stockBatchId = stockBatchId;
        this.batchId = batchId;
        this.batchType = batchType;
        this.movementType = movementType;
        this.direction = direction;
        this.quantityAmount = quantityAmount;
        this.quantityUnit = quantityUnit;
        this.reason = reason;
        this.referenceDocumentId = referenceDocumentId;
        this.performedBy = performedBy;
        this.performedAt = performedAt;
    }

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

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

    public String getStockId() { return stockId; }
    public void setStockId(String stockId) { this.stockId = stockId; }

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

    public String getStockBatchId() { return stockBatchId; }
    public void setStockBatchId(String stockBatchId) { this.stockBatchId = stockBatchId; }

    public String getBatchId() { return batchId; }
    public void setBatchId(String batchId) { this.batchId = batchId; }

    public String getBatchType() { return batchType; }
    public void setBatchType(String batchType) { this.batchType = batchType; }

    public String getMovementType() { return movementType; }
    public void setMovementType(String movementType) { this.movementType = movementType; }

    public String getDirection() { return direction; }
    public void setDirection(String direction) { this.direction = direction; }

    public BigDecimal getQuantityAmount() { return quantityAmount; }
    public void setQuantityAmount(BigDecimal quantityAmount) { this.quantityAmount = quantityAmount; }

    public String getQuantityUnit() { return quantityUnit; }
    public void setQuantityUnit(String quantityUnit) { this.quantityUnit = quantityUnit; }

    public String getReason() { return reason; }
    public void setReason(String reason) { this.reason = reason; }

    public String getReferenceDocumentId() { return referenceDocumentId; }
    public void setReferenceDocumentId(String referenceDocumentId) { this.referenceDocumentId = referenceDocumentId; }

    public String getPerformedBy() { return performedBy; }
    public void setPerformedBy(String performedBy) { this.performedBy = performedBy; }

    public Instant getPerformedAt() { return performedAt; }
    public void setPerformedAt(Instant performedAt) { this.performedAt = performedAt; }
}
