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

import de.effigenix.domain.production.Batch;

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

public record BatchSummaryResponse(
        String id,
        String batchNumber,
        String recipeId,
        String status,
        String plannedQuantity,
        String plannedQuantityUnit,
        LocalDate productionDate,
        LocalDate bestBeforeDate,
        OffsetDateTime createdAt,
        OffsetDateTime updatedAt
) {
    public static BatchSummaryResponse from(Batch batch) {
        return new BatchSummaryResponse(
                batch.id().value(),
                batch.batchNumber().value(),
                batch.recipeId().value(),
                batch.status().name(),
                batch.plannedQuantity().amount().toPlainString(),
                batch.plannedQuantity().uom().name(),
                batch.productionDate(),
                batch.bestBeforeDate(),
                batch.createdAt(),
                batch.updatedAt()
        );
    }
}
