package de.effigenix.domain.inventory;

import de.effigenix.domain.masterdata.article.ArticleId;
import de.effigenix.shared.common.RepositoryError;
import de.effigenix.shared.common.Result;

import java.time.LocalDate;
import java.util.List;
import java.util.Optional;

public interface StockRepository {

    Result<RepositoryError, Optional<Stock>> findById(StockId id);

    Result<RepositoryError, Optional<Stock>> findByArticleIdAndStorageLocationId(ArticleId articleId, StorageLocationId storageLocationId);

    Result<RepositoryError, Boolean> existsByArticleIdAndStorageLocationId(ArticleId articleId, StorageLocationId storageLocationId);

    Result<RepositoryError, List<Stock>> findAll();

    Result<RepositoryError, List<Stock>> findAllByStorageLocationId(StorageLocationId storageLocationId);

    Result<RepositoryError, List<Stock>> findAllByArticleId(ArticleId articleId);

    Result<RepositoryError, List<Stock>> findAllWithExpiryRelevantBatches(LocalDate referenceDate);

    Result<RepositoryError, List<Stock>> findAllBelowMinimumLevel();

    Result<RepositoryError, Void> save(Stock stock);
}
