package com.astalange.core.repository;

import com.astalange.core.entity.Licence;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

@Repository
public interface LicenceRepository extends JpaRepository<Licence, Long>, JpaSpecificationExecutor<Licence> {
    List<Licence> findByAdherentId(Long adherentId);
    
    List<Licence> findBySaisonAndCategorie(com.astalange.core.entity.Saison saison, com.astalange.core.entity.Categorie categorie);

    long countByEtat(String etat);

    @Query("SELECT SUM(c.tarifBase) FROM Licence l JOIN l.categorie c")
    BigDecimal sumTarifBase();
}
