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

import jakarta.persistence.*;

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

@Entity
@Table(name = "production_orders")
public class ProductionOrderEntity {

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

    @Version
    @Column(name = "version", nullable = false)
    private Long version;

    @Column(name = "recipe_id", nullable = false, length = 36)
    private String recipeId;

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

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

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

    @Column(name = "planned_date", nullable = false)
    private LocalDate plannedDate;

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

    @Column(name = "notes", length = 1000)
    private String notes;

    @Column(name = "created_at", nullable = false, updatable = false)
    private OffsetDateTime createdAt;

    @Column(name = "updated_at", nullable = false)
    private OffsetDateTime updatedAt;

    protected ProductionOrderEntity() {}

    public ProductionOrderEntity(
            String id,
            String recipeId,
            String status,
            BigDecimal plannedQuantityAmount,
            String plannedQuantityUnit,
            LocalDate plannedDate,
            String priority,
            String notes,
            OffsetDateTime createdAt,
            OffsetDateTime updatedAt
    ) {
        this.id = id;
        this.recipeId = recipeId;
        this.status = status;
        this.plannedQuantityAmount = plannedQuantityAmount;
        this.plannedQuantityUnit = plannedQuantityUnit;
        this.plannedDate = plannedDate;
        this.priority = priority;
        this.notes = notes;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
    }

    public String getId() { return id; }
    public Long getVersion() { return version; }
    public String getRecipeId() { return recipeId; }
    public String getStatus() { return status; }
    public BigDecimal getPlannedQuantityAmount() { return plannedQuantityAmount; }
    public String getPlannedQuantityUnit() { return plannedQuantityUnit; }
    public LocalDate getPlannedDate() { return plannedDate; }
    public String getPriority() { return priority; }
    public String getNotes() { return notes; }
    public OffsetDateTime getCreatedAt() { return createdAt; }
    public OffsetDateTime getUpdatedAt() { return updatedAt; }

    public void setStatus(String status) { this.status = status; }
    public void setUpdatedAt(OffsetDateTime updatedAt) { this.updatedAt = updatedAt; }
    public void setNotes(String notes) { this.notes = notes; }
    public void setPriority(String priority) { this.priority = priority; }
}
