package de.effigenix.infrastructure.production.web.dto;

import de.effigenix.domain.production.ProductionOrder;

import java.time.LocalDate;
import java.time.OffsetDateTime;

public record ProductionOrderResponse(
        String id,
        String recipeId,
        String status,
        String batchId,
        String batchNumber,
        String plannedQuantity,
        String plannedQuantityUnit,
        LocalDate plannedDate,
        String priority,
        String notes,
        String cancelledReason,
        OffsetDateTime createdAt,
        OffsetDateTime updatedAt
) {
    public static ProductionOrderResponse from(ProductionOrder order, String batchNumber) {
        return new ProductionOrderResponse(
                order.id().value(),
                order.recipeId().value(),
                order.status().name(),
                order.batchId() != null ? order.batchId().value() : null,
                batchNumber,
                order.plannedQuantity().amount().toPlainString(),
                order.plannedQuantity().uom().name(),
                order.plannedDate(),
                order.priority().name(),
                order.notes(),
                order.cancelledReason(),
                order.createdAt(),
                order.updatedAt()
        );
    }
}
