package de.effigenix.shared.common;

/**
 * Value Object representing payment terms.
 * Immutable and self-validating.
 */
public record PaymentTerms(int paymentDueDays, String description) {

    public PaymentTerms {
        if (paymentDueDays < 0) {
            throw new IllegalArgumentException("Payment due days must not be negative");
        }
    }

    public static Result<String, PaymentTerms> create(int dueDays, String description) {
        try {
            return Result.success(new PaymentTerms(dueDays, description));
        } catch (IllegalArgumentException e) {
            return Result.failure(e.getMessage());
        }
    }
}
