package dev.lions.unionflow.server.repository;

import dev.lions.unionflow.server.entity.RapportTrimestrielControleurInterne;
import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase;
import jakarta.enterprise.context.ApplicationScoped;
import java.util.List;
import java.util.Optional;
import java.util.UUID;

/** Repository des rapports trimestriels Contrôleur Interne. */
@ApplicationScoped
public class RapportTrimestrielControleurInterneRepository
    implements PanacheRepositoryBase<RapportTrimestrielControleurInterne, UUID> {

  public Optional<RapportTrimestrielControleurInterne> trouverParOrgAnneeTrimestre(
      UUID orgId, int annee, int trimestre) {
    return find("organisationId = ?1 AND annee = ?2 AND trimestre = ?3",
        orgId, annee, trimestre).firstResultOptional();
  }

  public List<RapportTrimestrielControleurInterne> listerParOrgAnnee(UUID orgId, int annee) {
    return list("organisationId = ?1 AND annee = ?2 ORDER BY trimestre", orgId, annee);
  }

  public List<RapportTrimestrielControleurInterne> listerNonSignes() {
    return list("statut = 'DRAFT' ORDER BY dateGeneration");
  }
}
