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

import de.effigenix.domain.masterdata.article.SalesUnit;
import io.swagger.v3.oas.annotations.media.Schema;

import java.math.BigDecimal;

@Schema(requiredProperties = {"id", "unit", "priceModel", "price"})
public record SalesUnitResponse(
        String id,
        String unit,
        String priceModel,
        BigDecimal price
) {
    public static SalesUnitResponse from(SalesUnit su) {
        return new SalesUnitResponse(
                su.id().value(),
                su.unit().name(),
                su.priceModel().name(),
                su.price().amount()
        );
    }
}
