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

import de.effigenix.domain.inventory.CountItem;

import java.math.BigDecimal;

public record CountItemResponse(
        String id,
        String articleId,
        BigDecimal expectedQuantityAmount,
        String expectedQuantityUnit,
        BigDecimal actualQuantityAmount,
        String actualQuantityUnit,
        BigDecimal deviation
) {
    public static CountItemResponse from(CountItem item) {
        return new CountItemResponse(
                item.id().value(),
                item.articleId().value(),
                item.expectedQuantity().amount(),
                item.expectedQuantity().uom().name(),
                item.actualQuantity() != null ? item.actualQuantity().amount() : null,
                item.actualQuantity() != null ? item.actualQuantity().uom().name() : null,
                item.deviation()
        );
    }
}
