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

import de.effigenix.domain.masterdata.customer.ContractLineItem;
import io.swagger.v3.oas.annotations.media.Schema;

import java.math.BigDecimal;

@Schema(requiredProperties = {"articleId", "agreedPrice", "agreedQuantity", "unit"})
public record ContractLineItemResponse(
        String articleId,
        BigDecimal agreedPrice,
        BigDecimal agreedQuantity,
        String unit
) {
    public static ContractLineItemResponse from(ContractLineItem item) {
        return new ContractLineItemResponse(
                item.articleId().value(),
                item.agreedPrice().amount(),
                item.agreedQuantity(),
                item.unit().name()
        );
    }
}
