package de.effigenix.shared.common;

/**
 * Domain errors for Quantity-related Value Objects.
 */
public sealed interface QuantityError {

    String code();
    String message();

    record AmountMustBePositive(String amount) implements QuantityError {
        @Override public String code() { return "QUANTITY_AMOUNT_NOT_POSITIVE"; }
        @Override public String message() { return "Quantity amount must be positive, was: " + amount; }
    }

    record UnitOfMeasureMismatch(UnitOfMeasure expected, UnitOfMeasure actual) implements QuantityError {
        @Override public String code() { return "QUANTITY_UOM_MISMATCH"; }
        @Override public String message() { return "Unit of measure mismatch: expected " + expected.symbol() + ", got " + actual.symbol(); }
    }

    record SecondaryAmountMustBePositive(String amount) implements QuantityError {
        @Override public String code() { return "QUANTITY_SECONDARY_AMOUNT_NOT_POSITIVE"; }
        @Override public String message() { return "Secondary quantity amount must be positive, was: " + amount; }
    }

    record SecondaryUomRequired() implements QuantityError {
        @Override public String code() { return "QUANTITY_SECONDARY_UOM_REQUIRED"; }
        @Override public String message() { return "Secondary unit of measure is required when secondary amount is provided"; }
    }

    record InvalidYieldPercentage(int value) implements QuantityError {
        @Override public String code() { return "INVALID_YIELD_PERCENTAGE"; }
        @Override public String message() { return "Yield percentage must be between 1 and 200, was: " + value; }
    }

    record InvalidBatchNumber(String value) implements QuantityError {
        @Override public String code() { return "INVALID_BATCH_NUMBER"; }
        @Override public String message() { return "Batch number must match format P-YYYY-MM-DD-XXX, was: " + value; }
    }
}
