package io.gmss.fiscad.repositories.rfu.metier;

import io.gmss.fiscad.entities.rfu.metier.EnqueteBatiment;
import io.gmss.fiscad.entities.rfu.metier.ImpositionsTfu;
import io.gmss.fiscad.paylaods.response.restoration.EnqueteBatimentPayLoad;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Optional;


public interface ImpositionsTfuRepository extends JpaRepository<ImpositionsTfu, Long> {

    Optional<ImpositionsTfu> findAllByCommune_IdAndExercice_Id(Long communeId,Long ExerciceId);
    @Query(value = "select i.* " +
            " from impositions_tfu i " +
            " inner join commune c on c.id=i.commune_id" +
            " inner join exercice e on e.id=i.exercice_id" +
            " where status_avis in ('VALIDE','CREE','GENERE') " +
            " and c.code= ?1 and e.annee = ?2 " +
            " and i.deleted is false ", nativeQuery = true)
    List<ImpositionsTfu> getImpositionsTfuByCommuneAndExercice(String codeCommnune,int annee);
}
