package de.effigenix.domain.inventory;

public sealed interface StockMovementError {

    String code();
    String message();

    record InvalidStockId(String reason) implements StockMovementError {
        @Override public String code() { return "INVALID_STOCK_ID"; }
        @Override public String message() { return "Invalid stock ID: " + reason; }
    }

    record InvalidArticleId(String reason) implements StockMovementError {
        @Override public String code() { return "INVALID_ARTICLE_ID"; }
        @Override public String message() { return "Invalid article ID: " + reason; }
    }

    record InvalidStockBatchId(String reason) implements StockMovementError {
        @Override public String code() { return "INVALID_STOCK_BATCH_ID"; }
        @Override public String message() { return "Invalid stock batch ID: " + reason; }
    }

    record InvalidBatchReference(String reason) implements StockMovementError {
        @Override public String code() { return "INVALID_BATCH_REFERENCE"; }
        @Override public String message() { return "Invalid batch reference: " + reason; }
    }

    record InvalidMovementType(String reason) implements StockMovementError {
        @Override public String code() { return "INVALID_MOVEMENT_TYPE"; }
        @Override public String message() { return "Invalid movement type: " + reason; }
    }

    record InvalidDirection(String reason) implements StockMovementError {
        @Override public String code() { return "INVALID_DIRECTION"; }
        @Override public String message() { return "Invalid direction: " + reason; }
    }

    record InvalidQuantity(String reason) implements StockMovementError {
        @Override public String code() { return "INVALID_QUANTITY"; }
        @Override public String message() { return "Invalid quantity: " + reason; }
    }

    record ReasonRequired(String movementType) implements StockMovementError {
        @Override public String code() { return "REASON_REQUIRED"; }
        @Override public String message() { return "Reason is required for movement type: " + movementType; }
    }

    record ReferenceDocumentRequired(String movementType) implements StockMovementError {
        @Override public String code() { return "REFERENCE_DOCUMENT_REQUIRED"; }
        @Override public String message() { return "Reference document ID is required for movement type: " + movementType; }
    }

    record InvalidPerformedBy(String reason) implements StockMovementError {
        @Override public String code() { return "INVALID_PERFORMED_BY"; }
        @Override public String message() { return "Invalid performed by: " + reason; }
    }

    record StockMovementNotFound(String id) implements StockMovementError {
        @Override public String code() { return "STOCK_MOVEMENT_NOT_FOUND"; }
        @Override public String message() { return "Stock movement not found: " + id; }
    }

    record Unauthorized(String message) implements StockMovementError {
        @Override public String code() { return "UNAUTHORIZED"; }
    }

    record InvalidDateRange(String reason) implements StockMovementError {
        @Override public String code() { return "INVALID_DATE_RANGE"; }
        @Override public String message() { return "Invalid date range: " + reason; }
    }

    record RepositoryFailure(String message) implements StockMovementError {
        @Override public String code() { return "REPOSITORY_ERROR"; }
    }
}
