develop #275

Merged
judaur2005 merged 2 commits from develop into main 2026-07-28 13:30:28 +00:00
17 changed files with 420 additions and 645 deletions

View File

@@ -0,0 +1,63 @@
package io.gmss.fiscad.controllers.audit;
import io.gmss.fiscad.exceptions.*;
import io.gmss.fiscad.interfaces.audit.HistoriqueConnexionService;
import io.gmss.fiscad.paylaods.ApiResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException;
@RestController
@RequestMapping(value = "api/historique-connexion", produces = MediaType.APPLICATION_JSON_VALUE)
@SecurityRequirement(name = "bearer")
@Tag(name = "Historique des connexion")
@CrossOrigin(origins = "*")
public class HistoriqueConnexionController {
private final HistoriqueConnexionService historiqueConnexionService;
private static final Logger logger = LoggerFactory.getLogger(HistoriqueConnexionController.class);
public HistoriqueConnexionController(HistoriqueConnexionService historiqueConnexionService) {
this.historiqueConnexionService = historiqueConnexionService;
}
@GetMapping("/user/{userId}")
@PreAuthorize("hasAuthority('READ_HISTORIQUECONNEXION')")
public ResponseEntity<?> getHistoriqueConnexionByUserId(@PathVariable Long userId) {
try {
return new ResponseEntity<>(
new ApiResponse<>(true, historiqueConnexionService.gethistoriqueConnexionListByUserIdPage(userId), "Liste des historiqueConnexions par commune chargée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
}

View File

@@ -72,7 +72,7 @@ public class UserController {
@PostMapping("/change-password") @PostMapping("/change-password")
@PreAuthorize("hasAuthority('UPDATE_USER')") @PreAuthorize("hasAuthority('UPDATE_USER')")
public ResponseEntity<?> changeUserPassword(@RequestBody @Valid @Validated Login login) { public ResponseEntity<?> changeUserPassword(@RequestBody Login login) {
try { try {
userService.updatePassword(login.getUsername(), login.getPassword()); userService.updatePassword(login.getUsername(), login.getPassword());
return new ResponseEntity<>( return new ResponseEntity<>(
@@ -95,6 +95,40 @@ public class UserController {
} }
} }
@PostMapping("/change-my-password")
@PreAuthorize("hasAuthority('UPDATE_USER')")
public ResponseEntity<?> changeMyPassword(@CurrentUser UserPrincipal currentUser, @RequestBody Login login) {
try {
User user = currentUser.getUser() ;
if(!user.getUsername().equals(login.getUsername())){
return new ResponseEntity<>(
new ApiResponse<>(false, "Echec de changement de mot de passe : Utilisateur non identifié"),
HttpStatus.OK
);
}
userService.updatePassword(login.getUsername(), login.getPassword());
return new ResponseEntity<>(
new ApiResponse<>(true, "Votre mot de passe à été modifiée avec succès."),
HttpStatus.OK
);
} catch (HttpClientErrorException.MethodNotAllowed e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Method POST/GET is required."), HttpStatus.OK);
} catch (NotFoundException | BadRequestException | MyFileNotFoundException | ResourceNotFoundException |
FileStorageException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, e.getMessage()), HttpStatus.OK);
} catch (NullPointerException e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "Null value has been detected {" + e.getMessage() + "}."), HttpStatus.OK);
} catch (Exception e) {
logger.error(e.getLocalizedMessage());
return new ResponseEntity<>(new ApiResponse(false, null, "An error has been occur and the content is {" + e.getMessage() + "}."), HttpStatus.OK);
}
}
@GetMapping("/request-reset-password") @GetMapping("/request-reset-password")
//@PreAuthorize("hasAuthority('UPDATE_USER')") //@PreAuthorize("hasAuthority('UPDATE_USER')")
public ResponseEntity<?> resetUserPassword(@RequestParam String login) { public ResponseEntity<?> resetUserPassword(@RequestParam String login) {

View File

@@ -0,0 +1,35 @@
package io.gmss.fiscad.entities.audit;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.gmss.fiscad.deserializer.LocalDateDeserializer;
import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.user.User;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Where;
import java.io.Serializable;
import java.time.LocalDateTime;
@EqualsAndHashCode(callSuper = true)
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Where(clause = " deleted = false")
public class HistoriqueConnexion extends BaseEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@JsonFormat(pattern = "dd-MM-yyyy HH:mm:ss")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDateTime dateConnexion;
@JsonIgnore
@ManyToOne
private User user;
}

View File

@@ -278,6 +278,10 @@ public enum UserRole {
CREATE_PROFILEMODULEFONCTIONNALITE, CREATE_PROFILEMODULEFONCTIONNALITE,
READ_PROFILEMODULEFONCTIONNALITE, READ_PROFILEMODULEFONCTIONNALITE,
UPDATE_PROFILEMODULEFONCTIONNALITE, UPDATE_PROFILEMODULEFONCTIONNALITE,
DELETE_PROFILEMODULEFONCTIONNALITE DELETE_PROFILEMODULEFONCTIONNALITE,
CREATE_HISTORIQUECONNEXION,
READ_HISTORIQUECONNEXION,
UPDATE_HISTORIQUECONNEXION,
DELETE_HISTORIQUECONNEXION
} }

View File

@@ -0,0 +1,23 @@
package io.gmss.fiscad.implementations.audit;
import io.gmss.fiscad.interfaces.audit.HistoriqueConnexionService;
import io.gmss.fiscad.paylaods.request.crudweb.HistoriqueConnexionPaylaodWeb;
import io.gmss.fiscad.persistence.repositories.audit.HistoriqueConnexionRepository;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import java.util.List;
@AllArgsConstructor
@Service
public class HistoriqueConnexionServiceImpl implements HistoriqueConnexionService {
private final HistoriqueConnexionRepository historiqueConnexionRepository ;
@Override
public List<HistoriqueConnexionPaylaodWeb> gethistoriqueConnexionListByUserIdPage(Long userId) {
return historiqueConnexionRepository.findTop5HistoriqueConnexionByUserId(userId, PageRequest.of(0, 5));
}
}

View File

@@ -1,6 +1,7 @@
package io.gmss.fiscad.implementations.rfu.metier; package io.gmss.fiscad.implementations.rfu.metier;
import io.gmss.fiscad.entities.decoupage.Arrondissement; import io.gmss.fiscad.entities.decoupage.Arrondissement;
import io.gmss.fiscad.entities.infocad.metier.Parcelle;
import io.gmss.fiscad.entities.rfu.metier.DonneesImpositionTfu; import io.gmss.fiscad.entities.rfu.metier.DonneesImpositionTfu;
import io.gmss.fiscad.entities.rfu.metier.ImpositionsTfu; import io.gmss.fiscad.entities.rfu.metier.ImpositionsTfu;
import io.gmss.fiscad.entities.rfu.parametre.BaremRfuNonBati; import io.gmss.fiscad.entities.rfu.parametre.BaremRfuNonBati;
@@ -8,6 +9,7 @@ import io.gmss.fiscad.enums.StatusAvis;
import io.gmss.fiscad.exceptions.BadRequestException; import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException; import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.interfaces.rfu.metier.DonneesImpositionTfuService; import io.gmss.fiscad.interfaces.rfu.metier.DonneesImpositionTfuService;
import io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb;
import io.gmss.fiscad.paylaods.request.crudweb.DonneesImpositionPaylaodWeb; import io.gmss.fiscad.paylaods.request.crudweb.DonneesImpositionPaylaodWeb;
import io.gmss.fiscad.paylaods.request.crudweb.ImpositionsTfuPaylaodWeb; import io.gmss.fiscad.paylaods.request.crudweb.ImpositionsTfuPaylaodWeb;
import io.gmss.fiscad.paylaods.response.DonneesImpositionTfuResponse; import io.gmss.fiscad.paylaods.response.DonneesImpositionTfuResponse;
@@ -17,6 +19,7 @@ import io.gmss.fiscad.persistence.repositories.infocad.metier.ParcelleRepository
import io.gmss.fiscad.persistence.repositories.rfu.metier.DonneesImpositionTfuRepository; import io.gmss.fiscad.persistence.repositories.rfu.metier.DonneesImpositionTfuRepository;
import io.gmss.fiscad.persistence.repositories.rfu.metier.ImpositionsTfuRepository; import io.gmss.fiscad.persistence.repositories.rfu.metier.ImpositionsTfuRepository;
import io.gmss.fiscad.persistence.repositories.rfu.parametre.BaremRfuNonBatiRepository; import io.gmss.fiscad.persistence.repositories.rfu.parametre.BaremRfuNonBatiRepository;
import io.gmss.fiscad.persistence.repositories.rfu.parametre.BaremRfuRepository;
import io.gmss.fiscad.persistence.repositories.rfu.parametre.ExerciceRepository; import io.gmss.fiscad.persistence.repositories.rfu.parametre.ExerciceRepository;
import io.gmss.fiscad.service.EntityFromPayLoadService; import io.gmss.fiscad.service.EntityFromPayLoadService;
import jakarta.transaction.Transactional; import jakarta.transaction.Transactional;
@@ -40,6 +43,7 @@ public class DonneesImpositionTfuServiceImpl implements DonneesImpositionTfuServ
private final BaremRfuNonBatiRepository baremRfuNonBatiRepository; private final BaremRfuNonBatiRepository baremRfuNonBatiRepository;
private final ExerciceRepository exerciceRepository; private final ExerciceRepository exerciceRepository;
private final ArrondissementRepository arrondissementRepository; private final ArrondissementRepository arrondissementRepository;
private final BaremRfuRepository baremRfuRepository;
private final EntityFromPayLoadService entityFromPayLoadService; private final EntityFromPayLoadService entityFromPayLoadService;
@@ -112,18 +116,24 @@ public class DonneesImpositionTfuServiceImpl implements DonneesImpositionTfuServ
@Override @Override
@Transactional @Transactional
public ImpositionsTfuPaylaodWeb genererDonneesFiscalesParcelleNonBatieUneParcelle(ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb, Long userId,Long parcelleId) { public ImpositionsTfuPaylaodWeb genererDonneesFiscalesParcelleNonBatieUneParcelle(ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb, Long userId,Long parcelleId) {
// System.out.println("User : " +userId); boolean existsBareme = baremRfuNonBatiRepository.existsBaremForParcelleNonBati(parcelleId);
// System.out.println("Parcelle : " +parcelleId); Optional<Parcelle> optionalParcelle= parcelleRepository.findById(parcelleId);
// System.out.println("Imposition : " +impositionsTfuPaylaodWeb.getId()); String nomQuartier="";
String nomArrondissement="";
String nomCommune="";
if(optionalParcelle.isPresent()){
nomQuartier= optionalParcelle.get().getQuartier().getNom();
nomArrondissement= optionalParcelle.get().getQuartier().getArrondissement().getNom();
nomCommune= optionalParcelle.get().getQuartier().getArrondissement().getCommune().getNom();
}
if(!existsBareme){
throw new BadRequestException("Impossible de continuer la liquidation : Il n'existe pas de barème configuré pour la zone de cette parcelle : "+nomCommune+" : "+nomArrondissement+" : "+nomQuartier);
}
Integer nb= donneesImpositionTfuRepository.genererDonneesTfuNonBatie(impositionsTfuPaylaodWeb.getId(),userId,parcelleId); Integer nb= donneesImpositionTfuRepository.genererDonneesTfuNonBatie(impositionsTfuPaylaodWeb.getId(),userId,parcelleId);
// System.out.println(nb);
ImpositionsTfu impositionsTfu = entityFromPayLoadService.getImpositionsTfuFromPayLoadWeb(impositionsTfuPaylaodWeb); ImpositionsTfu impositionsTfu = entityFromPayLoadService.getImpositionsTfuFromPayLoadWeb(impositionsTfuPaylaodWeb);
impositionsTfu.setStatusAvis(StatusAvis.TFU_FNB_GENERE); impositionsTfu.setStatusAvis(StatusAvis.TFU_FNB_GENERE);
impositionsTfu.setNombreAvisFnb(nb); impositionsTfu.setNombreAvisFnb(nb);
impositionsTfuRepository.save(impositionsTfu); impositionsTfuRepository.save(impositionsTfu);
return impositionsTfuRepository.findByIdToDto(impositionsTfu.getId()).orElse(null); return impositionsTfuRepository.findByIdToDto(impositionsTfu.getId()).orElse(null);
} }
@@ -162,6 +172,29 @@ public class DonneesImpositionTfuServiceImpl implements DonneesImpositionTfuServ
@Transactional @Transactional
public ImpositionsTfuPaylaodWeb genererDonneesFiscalesParcelleBatieUneParcelle(ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb, Long userId, Long parcelleId) { public ImpositionsTfuPaylaodWeb genererDonneesFiscalesParcelleBatieUneParcelle(ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb, Long userId, Long parcelleId) {
Optional<ImpositionsTfuPaylaodWeb> imp=impositionsTfuRepository.findByIdToDto(impositionsTfuPaylaodWeb.getId());
if(imp.isPresent()){
boolean dejaLiquide = donneesImpositionTfuRepository.existsByImpositionAnneeAndParcelle(Long.valueOf(imp.get().getExerciceAnnee()),parcelleId);
if(dejaLiquide){
return imp.orElse(null);
}
}
boolean existsBareme = baremRfuRepository.existsBaremForParcelle(parcelleId);
Optional<Parcelle> optionalParcelle= parcelleRepository.findById(parcelleId);
String nomQuartier="";
String nomArrondissement="";
String nomCommune="";
if(optionalParcelle.isPresent()){
nomQuartier= optionalParcelle.get().getQuartier().getNom();
nomArrondissement= optionalParcelle.get().getQuartier().getArrondissement().getNom();
nomCommune= optionalParcelle.get().getQuartier().getArrondissement().getCommune().getNom();
}
if(!existsBareme){
throw new BadRequestException("Impossible de continuer la liquidation : Il n'existe pas de barème configuré pour la zone de cette parcelle : "+nomCommune+" : "+nomArrondissement+" : "+nomQuartier);
}
Integer nbb= donneesImpositionTfuRepository.genererDonneesTfuBatie(impositionsTfuPaylaodWeb.getId(),userId,parcelleId); Integer nbb= donneesImpositionTfuRepository.genererDonneesTfuBatie(impositionsTfuPaylaodWeb.getId(),userId,parcelleId);
Integer nbirfbtPlusieursBati = donneesImpositionTfuRepository.majDonneesTfuBatiePlusieursBatiment(impositionsTfuPaylaodWeb.getId(),parcelleId); Integer nbirfbtPlusieursBati = donneesImpositionTfuRepository.majDonneesTfuBatiePlusieursBatiment(impositionsTfuPaylaodWeb.getId(),parcelleId);
@@ -181,9 +214,9 @@ public class DonneesImpositionTfuServiceImpl implements DonneesImpositionTfuServ
impositionsTfu.setStatusAvis(StatusAvis.GENERE); impositionsTfu.setStatusAvis(StatusAvis.GENERE);
impositionsTfu.setNombreAvis(nbb+nbulo+ (impositionsTfu.getNombreAvisFnb()==null?0:impositionsTfu.getNombreAvisFnb())); impositionsTfu.setNombreAvis(impositionsTfu.getNombreAvis()+1);
impositionsTfu.setNombreAvisBatiment(nbb); impositionsTfu.setNombreAvisBatiment(impositionsTfu.getNombreAvisFnb()+1);
impositionsTfu.setNombreAvisUniteLog(nbulo); impositionsTfu.setNombreAvisUniteLog(impositionsTfu.getNombreAvisUniteLog()+1);
impositionsTfuRepository.save(impositionsTfu); impositionsTfuRepository.save(impositionsTfu);

View File

@@ -1,5 +1,6 @@
package io.gmss.fiscad.implementations.user; package io.gmss.fiscad.implementations.user;
import io.gmss.fiscad.entities.audit.HistoriqueConnexion;
import io.gmss.fiscad.entities.infocad.parametre.Structure; import io.gmss.fiscad.entities.infocad.parametre.Structure;
import io.gmss.fiscad.entities.user.User; import io.gmss.fiscad.entities.user.User;
import io.gmss.fiscad.enums.UserRole; import io.gmss.fiscad.enums.UserRole;
@@ -14,6 +15,7 @@ import io.gmss.fiscad.paylaods.Login;
import io.gmss.fiscad.paylaods.UserListByStructureResponse; import io.gmss.fiscad.paylaods.UserListByStructureResponse;
import io.gmss.fiscad.paylaods.UserResponse; import io.gmss.fiscad.paylaods.UserResponse;
import io.gmss.fiscad.paylaods.request.crudweb.UserPaylaodWeb; import io.gmss.fiscad.paylaods.request.crudweb.UserPaylaodWeb;
import io.gmss.fiscad.persistence.repositories.audit.HistoriqueConnexionRepository;
import io.gmss.fiscad.persistence.repositories.user.UserRepository; import io.gmss.fiscad.persistence.repositories.user.UserRepository;
import io.gmss.fiscad.security.TokenAuthentificationProvider; import io.gmss.fiscad.security.TokenAuthentificationProvider;
import io.gmss.fiscad.service.EntityFromPayLoadService; import io.gmss.fiscad.service.EntityFromPayLoadService;
@@ -49,6 +51,7 @@ public class UserServiceImpl implements UserService {
private final EntityFromPayLoadService entityFromPayLoadService; private final EntityFromPayLoadService entityFromPayLoadService;
private final StringService stringService ; private final StringService stringService ;
private final MailService mailService ; private final MailService mailService ;
private final HistoriqueConnexionRepository historiqueConnexionRepository ;
@Value("${dgi.sigibe-foncier.reset-pw.url}") @Value("${dgi.sigibe-foncier.reset-pw.url}")
private String reseturl ; private String reseturl ;
@@ -56,9 +59,7 @@ public class UserServiceImpl implements UserService {
@Value("${dgi.sigibe-foncier.reset-pw.token-delay}") @Value("${dgi.sigibe-foncier.reset-pw.token-delay}")
private String tokenDelay ; private String tokenDelay ;
public UserServiceImpl(UserRepository userRepository, PasswordEncoder passwordEncoder, RoleService roleService, AuthenticationManager authenticationManager, TokenAuthentificationProvider tokenAuthentificationProvider, StructureService structureService, EntityFromPayLoadService entityFromPayLoadService, StringService stringService, MailService mailService, HistoriqueConnexionRepository historiqueConnexionRepository) {
public UserServiceImpl(UserRepository userRepository, PasswordEncoder passwordEncoder, RoleService roleService, AuthenticationManager authenticationManager, TokenAuthentificationProvider tokenAuthentificationProvider, StructureService structureService, EntityFromPayLoadService entityFromPayLoadService, StringService stringService, MailService mailService) {
this.userRepository = userRepository; this.userRepository = userRepository;
this.passwordEncoder = passwordEncoder; this.passwordEncoder = passwordEncoder;
this.roleService = roleService; this.roleService = roleService;
@@ -68,6 +69,7 @@ public class UserServiceImpl implements UserService {
this.entityFromPayLoadService = entityFromPayLoadService; this.entityFromPayLoadService = entityFromPayLoadService;
this.stringService = stringService; this.stringService = stringService;
this.mailService = mailService; this.mailService = mailService;
this.historiqueConnexionRepository = historiqueConnexionRepository;
} }
@@ -121,6 +123,13 @@ public class UserServiceImpl implements UserService {
); );
SecurityContextHolder.getContext().setAuthentication(authentication); SecurityContextHolder.getContext().setAuthentication(authentication);
HistoriqueConnexion historiqueConnexion = new HistoriqueConnexion();
historiqueConnexion.setDateConnexion(LocalDateTime.now());
historiqueConnexion.setUser(user);
historiqueConnexionRepository.save(historiqueConnexion);
return tokenAuthentificationProvider.generateToken(authentication); return tokenAuthentificationProvider.generateToken(authentication);
} }

View File

@@ -0,0 +1,16 @@
package io.gmss.fiscad.interfaces.audit;
import io.gmss.fiscad.entities.decoupage.Arrondissement;
import io.gmss.fiscad.exceptions.BadRequestException;
import io.gmss.fiscad.exceptions.NotFoundException;
import io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb;
import io.gmss.fiscad.paylaods.request.crudweb.HistoriqueConnexionPaylaodWeb;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Optional;
public interface HistoriqueConnexionService {
List<HistoriqueConnexionPaylaodWeb> gethistoriqueConnexionListByUserIdPage(Long UserId);
}

View File

@@ -51,4 +51,6 @@ public interface DonneesImpositionTfuService {
public ImpositionsTfuPaylaodWeb genererDonneesFiscalesParcelleBatieUneParcelle(ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb, Long userId, Long parcelleId); public ImpositionsTfuPaylaodWeb genererDonneesFiscalesParcelleBatieUneParcelle(ImpositionsTfuPaylaodWeb impositionsTfuPaylaodWeb, Long userId, Long parcelleId);
//List<DonneesImpositionPaylaodWeb> getDonneesFiscalesByParcelleIdAndExercice(Long parcelleId, Long exerciceId);
} }

View File

@@ -0,0 +1,37 @@
package io.gmss.fiscad.paylaods.request.crudweb;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.gmss.fiscad.deserializer.LocalDateDeserializer;
import io.gmss.fiscad.entities.user.User;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
@NoArgsConstructor
@Data
public class HistoriqueConnexionPaylaodWeb {
private Long id;
@JsonFormat(pattern = "dd-MM-yyyy HH:mm:ss")
@JsonDeserialize(using = LocalDateDeserializer.class)
private LocalDateTime dateConnexion;
private Long userId;
private String userLogin;
private String userNom;
private String userPrenom;
public HistoriqueConnexionPaylaodWeb(Long id, LocalDateTime dateConnexion, Long userId, String userLogin, String userNom, String userPrenom) {
this.id = id;
this.dateConnexion = dateConnexion;
this.userId = userId;
this.userLogin = userLogin;
this.userNom = userNom;
this.userPrenom = userPrenom;
}
}

View File

@@ -1,289 +1,3 @@
/*CREATE OR REPLACE FUNCTION public.generer_donnees_imposition_irf_batie(
p_impositions_tfu_id BIGINT,
p_user_id BIGINT
)
RETURNS INTEGER
LANGUAGE plpgsql
AS
$$
DECLARE
v_rows_inserted INTEGER;
v_annee BIGINT;
v_structure_id BIGINT;
v_taux_defaut_sup_sol NUMERIC;
v_taux_valeur_locat_prof NUMERIC;
v_tfu_piscine_unitaire NUMERIC;
v_taux_irf NUMERIC;
BEGIN
-- récupération de l'année
SELECT ex.annee, it.structure_id
INTO STRICT v_annee, v_structure_id
FROM impositions_tfu it
join exercice ex on ex.id =it.exercice_id
WHERE it.id = p_impositions_tfu_id;
select value
into strict v_taux_defaut_sup_sol
from parameters
where name ='TAUX_DEFAUT_SUPERFICIE_AU_SOL';
select value
into STRICT v_taux_irf
from parameters
where name ='TAUX_IRF';
select value
into STRICT v_taux_valeur_locat_prof
from parameters
where name ='TAUX_VALEUR_LOCATIVE_PROFESSIONNELLE';
select value
into STRICT v_tfu_piscine_unitaire
from parameters
where name ='TFU_PAR_PISCINE';
INSERT INTO donnees_imposition_tfu(
annee,
code_departement,
nom_departement,
code_commune,
nom_commune,
code_arrondissement,
nom_arrondissement,
code_quartier_village,
nom_quartier_village,
q,
ilot,
parcelle,
nup,
titre_foncier,
num_batiment,
ifu,
npi,
tel_prop,
email_prop,
nom_prop,
prenom_prop,
raison_sociale,
adresse_prop,
tel_sc,
nom_sc,
prenom_sc,
longitude,
latitude,
batie,
exonere,
batiment_exonere,
standing_bat,
categorie_bat,
nombre_piscine,
date_enquete,
structure_id,
zone_rfu_id,
nature_impot,
superficie_parc,
superficie_au_sol_bat,
valeur_batiment,
valeur_locative_adm_metre_carre,
montant_loyer_annuel,
tfu_metre_carre,
tfu_minimum,
impositions_tfu_id,
deleted,
created_at ,
created_by ,
"source",
updated_at ,
updated_by,
categorie_usage,
superficie_au_sol_taux_prop_parc, ---70% de la surperficie au sol de la parcelle
valeur_locative_adm_taux_prop_parc,
tfu_calcule_taux_prop_parc, ----tfu correspondant au 70%
valeur_locative_adm_sup_reel,
valeur_locative_adm, ----------valeur locative administrative
tfu_superficie_au_sol_reel, ----tfu correspondant à la superficie au sol reelle
tfu_piscine,
montant_taxe, ----tfu finale
taux_tfu, ----taux tfu batie
parcelle_id,
batiment_id,
unite_logement_id,
superficie_au_sol_loue
)
SELECT
v_annee,
d.code,
d.nom,
c.code,
c.nom,
a.code,
a.nom,
q.code,
q.nom,
p.q,
p.i,
p.p,
p.nup,
ep.numero_titre_foncier,
b.nub,
pers.ifu,
pers.npi,
pers.tel1,
pers.email,
pers.nom,
pers.prenom,
pers.raison_sociale,
pers.adresse,
ep.representant_tel,
ep.representant_nom,
ep.representant_prenom,
p.longitude,
p.latitude,
TRUE,
(
CURRENT_DATE >= ep.date_debut_exemption
AND CURRENT_DATE <= COALESCE(ep.date_fin_exemption, CURRENT_DATE)
),
(
CURRENT_DATE >= eb.date_debut_excemption
AND CURRENT_DATE <= COALESCE(eb.date_fin_excemption, CURRENT_DATE)
),
cb.standing,
cb.nom,
eb.nombre_piscine,
eb.date_enquete,
st.id,
ep.zone_rfu_id,
'IRF',
p.superficie,
eb.superficie_au_sol,
case -------valeur_batiment
WHEN eb.valeur_batiment_reel IS NOT NULL AND eb.valeur_batiment_reel <> 0 THEN eb.valeur_batiment_reel
WHEN eb.valeur_batiment_calcule IS NOT NULL AND eb.valeur_batiment_calcule <> 0 THEN eb.valeur_batiment_calcule
WHEN eb.valeur_batiment_estime IS NOT NULL AND eb.valeur_batiment_estime <> 0 THEN eb.valeur_batiment_estime
ELSE 0
END,
brb.valeur_locative,
case ----- montant_loyer_annuel
WHEN eb.montant_locatif_annuel_declare IS NOT NULL AND eb.montant_locatif_annuel_declare <> 0 THEN eb.montant_locatif_annuel_declare
WHEN eb.montant_locatif_annuel_calcule IS NOT NULL AND eb.montant_locatif_annuel_calcule <> 0 THEN eb.montant_locatif_annuel_calcule
WHEN eb.montant_locatif_annuel_estime IS NOT NULL AND eb.montant_locatif_annuel_estime <> 0 THEN eb.montant_locatif_annuel_estime
ELSE 0
END,
brb.tfu_metre_carre,
brb.tfu_minimum,
p_impositions_tfu_id,
false,
current_date ,
p_user_id ,
'FISCAD',
current_date ,
p_user_id,
eb.categorie_usage,
p.superficie*v_taux_defaut_sup_sol/100,---superficie_au_sol_70pour100
(p.superficie * v_taux_defaut_sup_sol/100) * brb.valeur_locative,
0,
eb.superficie_au_sol * brb.valeur_locative,
0, ------ valeur_locative_adm : en attente de update
0,
0,
0,
v_taux_irf,
p.id,
b.id,
null,
eb.superficie_louee
FROM parcelle p
LEFT JOIN (
SELECT DISTINCT ON (parcelle_id)
parcelle_id,
superficie,
personne_id,
numero_titre_foncier,
date_enquete,
representant_tel,
representant_nom,
representant_prenom,
representant_npi,
date_debut_exemption,
date_fin_exemption,
zone_rfu_id
FROM enquete
ORDER BY parcelle_id, date_enquete DESC, id DESC
) ep ON ep.parcelle_id = p.id
LEFT JOIN personne pers
ON pers.id = ep.personne_id
JOIN quartier q ON q.id = p.quartier_id
JOIN arrondissement a ON a.id = q.arrondissement_id
JOIN commune c ON c.id = a.commune_id
JOIN departement d ON d.id = c.departement_id
JOIN secteur_decoupage sd ON sd.quartier_id = q.id
JOIN secteur sect ON sect.id = sd.secteur_id
JOIN section ses ON ses.id = sect.section_id
JOIN "structure" st ON st.id = ses.structure_id
JOIN batiment b ON b.parcelle_id = p.id
JOIN (
SELECT DISTINCT ON (batiment_id)
batiment_id,
superficie_au_sol,
nombre_piscine,
categorie_batiment_id,
date_enquete,
montant_locatif_annuel_declare,
montant_locatif_annuel_calcule,
montant_locatif_annuel_estime,
date_debut_excemption,
date_fin_excemption,
valeur_batiment_reel,
valeur_batiment_calcule,
valeur_batiment_estime,
u.categorie_usage,
superficie_louee
FROM enquete_batiment eb
join usage u on u.id=eb.usage_id
where superficie_louee*montant_locatif_annuel_declare>0
ORDER BY batiment_id, date_enquete DESC, eb.id DESC
) eb ON eb.batiment_id = b.id
JOIN categorie_batiment cb
ON cb.id = eb.categorie_batiment_id
JOIN LATERAL (
SELECT *
FROM barem_rfu_bati br
WHERE br.categorie_batiment_id = cb.id
AND br.arrondissement_id = a.id
AND (br.quartier_id = q.id OR br.quartier_id IS NULL)
ORDER BY br.quartier_id DESC NULLS LAST
LIMIT 1
) brb ON TRUE
WHERE p.batie = TRUE
AND NOT EXISTS (
SELECT 1
FROM unite_logement ul
WHERE ul.batiment_id = b.id
)
AND st.id = v_structure_id
ON CONFLICT DO NOTHING;
GET DIAGNOSTICS v_rows_inserted = ROW_COUNT;
UPDATE donnees_imposition_tfu dtfu
SET
valeur_locative_adm=montant_loyer_annuel,
montant_taxe = montant_loyer_annuel * v_taux_irf/100
WHERE impositions_tfu_id = p_impositions_tfu_id
AND batie = TRUE
AND NOT EXISTS (
SELECT 1
FROM unite_logement ul
WHERE ul.batiment_id = dtfu.batiment_id
);
RETURN v_rows_inserted;
END;
$$;*/
CREATE OR REPLACE FUNCTION public.generer_donnees_imposition_irf_batie( CREATE OR REPLACE FUNCTION public.generer_donnees_imposition_irf_batie(
p_impositions_tfu_id BIGINT, p_impositions_tfu_id BIGINT,
p_user_id BIGINT p_user_id BIGINT

View File

@@ -1,347 +1,3 @@
/*CREATE OR REPLACE FUNCTION public.generer_donnees_imposition_irf_batie_unite_logement(
p_impositions_tfu_id BIGINT,
p_user_id BIGINT
)
RETURNS INTEGER
LANGUAGE plpgsql
AS
$$
DECLARE
v_rows_inserted INTEGER;
v_annee BIGINT;
v_structure_id BIGINT;
v_taux_defaut_sup_sol NUMERIC;
v_taux_irf NUMERIC;
v_taux_valeur_locat_prof NUMERIC;
v_tfu_piscine_unitaire NUMERIC;
BEGIN
-- récupération de l'année
SELECT ex.annee, it.structure_id
INTO STRICT v_annee, v_structure_id
FROM impositions_tfu it
join exercice ex on ex.id =it.exercice_id
WHERE it.id = p_impositions_tfu_id;
select value
into strict v_taux_defaut_sup_sol
from parameters
where name ='TAUX_DEFAUT_SUPERFICIE_AU_SOL';
select value
into STRICT v_taux_irf
from parameters
where name ='TAUX_IRF';
select value
into STRICT v_taux_valeur_locat_prof
from parameters
where name ='TAUX_VALEUR_LOCATIVE_PROFESSIONNELLE';
select value
into STRICT v_tfu_piscine_unitaire
from parameters
where name ='TFU_PAR_PISCINE';
INSERT INTO donnees_imposition_tfu(
annee,
code_departement,
nom_departement,
code_commune,
nom_commune,
code_arrondissement,
nom_arrondissement,
code_quartier_village,
nom_quartier_village,
q,
ilot,
parcelle,
nup,
titre_foncier,
num_batiment,
num_unite_logement,
ifu,
npi,
tel_prop,
email_prop,
nom_prop,
prenom_prop,
raison_sociale,
adresse_prop,
tel_sc,
nom_sc,
prenom_sc,
longitude,
latitude,
batie,
exonere,
batiment_exonere,
unite_logement_exonere,
standing_bat,
categorie_bat,
nombre_piscine,
date_enquete,
structure_id,
zone_rfu_id,
nature_impot,
superficie_parc,
superficie_au_sol_bat,
superficie_au_sol_ulog,
valeur_batiment,
valeur_locative_adm_metre_carre,
montant_loyer_annuel,
tfu_metre_carre,
tfu_minimum,
impositions_tfu_id,
deleted,
created_at ,
created_by ,
"source",
updated_at ,
updated_by,
categorie_usage,
superficie_au_sol_taux_prop_parc, ---70% de la surperficie au sol de la parcelle
valeur_locative_adm_taux_prop_parc,
tfu_calcule_taux_prop_parc, ----tfu correspondant au 70%
valeur_locative_adm_sup_reel,
valeur_locative_adm, ----------valeur locative administrative
tfu_superficie_au_sol_reel, ----tfu correspondant à la superficie au sol reelle
tfu_piscine,
montant_taxe, ----tfu finale
taux_tfu, ----taux tfu batie
parcelle_id,
batiment_id,
unite_logement_id,
superficie_au_sol_loue
)
SELECT
v_annee,
d.code,
d.nom,
c.code,
c.nom,
a.code,
a.nom,
q.code,
q.nom,
p.q,
p.i,
p.p,
p.nup,
ep.numero_titre_foncier,
b.nub,
ul.nul,
eul.ifu,
eul.npi,
eul.tel1,
eul.email,
eul.nom,
eul.prenom,
eul.raison_sociale,
eul.adresse,
eul.representant_tel,
eul.representant_nom,
eul.representant_prenom,
p.longitude,
p.latitude,
TRUE,
(
CURRENT_DATE >= ep.date_debut_exemption
AND CURRENT_DATE <= COALESCE(ep.date_fin_exemption, CURRENT_DATE)
),
(
CURRENT_DATE >= eb.date_debut_excemption
AND CURRENT_DATE <= COALESCE(eb.date_fin_excemption, CURRENT_DATE)
),
(
CURRENT_DATE >= eul.date_debut_exemption
AND CURRENT_DATE <= COALESCE(eul.date_fin_exemption, CURRENT_DATE)
),
cb.standing,
cb.nom,
CASE
WHEN eul.nombre_piscine is null then 0
else eul.nombre_piscine
END,
eul.date_enquete,
st.id,
ep.zone_rfu_id,
'IRF',
p.superficie,
eb.superficie_au_sol,
eul.superficie_au_sol,
CASE -------valeur_batiment
WHEN eul.valeur_unite_logement_reel IS NOT NULL AND eul.valeur_unite_logement_reel <> 0 THEN eul.valeur_unite_logement_reel
WHEN eul.valeur_unite_logement_calcule IS NOT NULL AND eul.valeur_unite_logement_calcule <> 0 THEN eul.valeur_unite_logement_calcule
WHEN eul.valeur_unite_logement_estime IS NOT NULL AND eul.valeur_unite_logement_estime <> 0 THEN eul.valeur_unite_logement_estime
ELSE 0
END,
brb.valeur_locative,
CASE ----- montant_loyer_annuel
WHEN eul.montant_locatif_annuel_declare IS NOT NULL AND eul.montant_locatif_annuel_declare <> 0 THEN eul.montant_locatif_annuel_declare
WHEN eul.montant_locatif_annuel_calcule IS NOT NULL AND eul.montant_locatif_annuel_calcule <> 0 THEN eul.montant_locatif_annuel_calcule
WHEN eul.montant_locatif_annuel_estime IS NOT NULL AND eul.montant_locatif_annuel_estime <> 0 THEN eul.montant_locatif_annuel_estime
ELSE 0
END,
brb.tfu_metre_carre,
brb.tfu_minimum,
p_impositions_tfu_id,
false,
current_date,
p_user_id,
'FISCAD',
current_date,
p_user_id,
eul.categorie_usage,
p.superficie * v_taux_defaut_sup_sol/100,---superficie_au_sol_70pour100
case ----valeur_locative_adm70pour100
when eul.categorie_usage = 'HABITATION' then (p.superficie * v_taux_defaut_sup_sol/100) * brb.valeur_locative
else 0
end,
0,
eul.superficie_au_sol * brb.valeur_locative,
0, ------ valeur_locative_adm : en attente de update
0,
0,
0,
v_taux_irf,
p.id,
b.id,
ul.id,
eul.superficie_louee
FROM parcelle p
LEFT JOIN (
SELECT DISTINCT ON (parcelle_id)
parcelle_id,
superficie,
personne_id,
numero_titre_foncier,
date_enquete,
representant_tel,
representant_nom,
representant_prenom,
representant_npi,
date_debut_exemption,
date_fin_exemption,
zone_rfu_id
FROM enquete
ORDER BY parcelle_id, date_enquete DESC, id DESC
) ep ON ep.parcelle_id = p.id
LEFT JOIN personne pers
ON pers.id = ep.personne_id
JOIN quartier q ON q.id = p.quartier_id
JOIN arrondissement a ON a.id = q.arrondissement_id
JOIN commune c ON c.id = a.commune_id
JOIN departement d ON d.id = c.departement_id
--JOIN secteur_decoupage sd ON sd.quartier_id = q.id
JOIN (
SELECT DISTINCT ON (quartier_id)
quartier_id,
secteur_id
FROM secteur_decoupage
ORDER BY quartier_id
) sd ON sd.quartier_id = q.id
JOIN secteur sect ON sect.id = sd.secteur_id
JOIN section ses ON ses.id = sect.section_id
JOIN "structure" st ON st.id = ses.structure_id
JOIN batiment b ON b.parcelle_id = p.id
JOIN (
SELECT DISTINCT ON (batiment_id)
batiment_id,
superficie_au_sol,
nombre_piscine,
categorie_batiment_id,
date_enquete,
montant_locatif_annuel_declare,
montant_locatif_annuel_calcule,
montant_locatif_annuel_estime,
date_debut_excemption,
date_fin_excemption,
valeur_batiment_reel,
valeur_batiment_calcule,
valeur_batiment_estime,
u.categorie_usage
FROM enquete_batiment eb
join usage u on u.id=eb.usage_id
ORDER BY batiment_id, date_enquete DESC, eb.id DESC
) eb ON eb.batiment_id = b.id
JOIN unite_logement ul on ul.batiment_id = b.id
JOIN (
SELECT DISTINCT ON (eult.unite_logement_id)
eult.unite_logement_id,
pers1.id,
pers1.ifu,
pers1.npi,
pers1.tel1,
pers1.email,
pers1.nom,
pers1.prenom,
pers1.raison_sociale,
pers1.adresse,
eult.nombre_piscine,
eult.categorie_batiment_id,
eult.superficie_au_sol,
eult.superficie_louee,
eult.nbre_piece,
eult.date_enquete,
eult.montant_locatif_annuel_calcule,
eult.montant_locatif_annuel_declare,
eult.montant_locatif_annuel_estime,
eult.date_debut_exemption,
eult.date_fin_exemption,
eult.representant_nom,
eult.representant_prenom,
eult.representant_tel,
eult.valeur_unite_logement_reel,
eult.valeur_unite_logement_calcule,
eult.valeur_unite_logement_estime,
u.categorie_usage
FROM enquete_unite_logement eult
join usage u on u.id=eult.usage_id
left join personne pers1 on pers1.id = eult.personne_id
where superficie_louee*montant_locatif_annuel_declare>0
ORDER BY unite_logement_id, date_enquete DESC, eult.id DESC
) eul ON eul.unite_logement_id = ul.id
JOIN categorie_batiment cb
ON cb.id = eul.categorie_batiment_id
JOIN LATERAL (
SELECT *
FROM barem_rfu_bati br
WHERE br.categorie_batiment_id = cb.id
AND br.arrondissement_id = a.id
AND (br.quartier_id = q.id OR br.quartier_id IS NULL)
ORDER BY br.quartier_id DESC NULLS LAST
LIMIT 1
) brb ON TRUE
WHERE p.batie = TRUE
AND EXISTS (
SELECT 1
FROM unite_logement ul
WHERE ul.batiment_id = b.id
)
AND st.id = v_structure_id
ON CONFLICT DO NOTHING;
GET DIAGNOSTICS v_rows_inserted = ROW_COUNT;
UPDATE donnees_imposition_tfu dtfu
SET
valeur_locative_adm=montant_loyer_annuel,
montant_taxe = montant_loyer_annuel * v_taux_irf/100
WHERE impositions_tfu_id = p_impositions_tfu_id
AND batie = TRUE
AND EXISTS (
SELECT 1
FROM unite_logement ul
WHERE ul.batiment_id = dtfu.batiment_id
);
RETURN v_rows_inserted;
END;
$$;
*/
CREATE OR REPLACE FUNCTION public.generer_donnees_imposition_irf_batie_unite_logement( CREATE OR REPLACE FUNCTION public.generer_donnees_imposition_irf_batie_unite_logement(
p_impositions_tfu_id BIGINT, p_impositions_tfu_id BIGINT,
p_user_id BIGINT p_user_id BIGINT

View File

@@ -0,0 +1,71 @@
package io.gmss.fiscad.persistence.repositories.audit;
import io.gmss.fiscad.entities.audit.HistoriqueConnexion;
import io.gmss.fiscad.entities.decoupage.Arrondissement;
import io.gmss.fiscad.entities.decoupage.Commune;
import io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb;
import io.gmss.fiscad.paylaods.request.crudweb.HistoriqueConnexionPaylaodWeb;
import io.gmss.fiscad.paylaods.response.ArrondissementEnqResponse;
import io.gmss.fiscad.paylaods.response.synchronisation.ArrondissementSyncResponse;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;
import java.util.Optional;
public interface HistoriqueConnexionRepository extends JpaRepository<HistoriqueConnexion, Long> {
@Query("""
SELECT new io.gmss.fiscad.paylaods.request.crudweb.HistoriqueConnexionPaylaodWeb(
h.id,
h.dateConnexion,
h.user.id,
h.user.username,
h.user.nom,
h.user.prenom
)
FROM HistoriqueConnexion h
ORDER BY h.dateConnexion DESC
""")
List<HistoriqueConnexionPaylaodWeb> findHistoriqueConnexion();
@Query("""
SELECT new io.gmss.fiscad.paylaods.request.crudweb.HistoriqueConnexionPaylaodWeb(
h.id,
h.dateConnexion,
h.user.id,
h.user.username,
h.user.nom,
h.user.prenom
)
FROM HistoriqueConnexion h
WHERE h.user.id = :userId
ORDER BY h.dateConnexion DESC
""")
List<HistoriqueConnexionPaylaodWeb> findHistoriqueConnexionByUserId(
@Param("userId") Long userId
);
@Query("""
SELECT new io.gmss.fiscad.paylaods.request.crudweb.HistoriqueConnexionPaylaodWeb(
h.id,
h.dateConnexion,
h.user.id,
h.user.username,
h.user.nom,
h.user.prenom
)
FROM HistoriqueConnexion h
WHERE h.user.id = :userId
ORDER BY h.dateConnexion DESC
""")
List<HistoriqueConnexionPaylaodWeb> findTop5HistoriqueConnexionByUserId(
@Param("userId") Long userId,
Pageable pageable
);
}

View File

@@ -70,6 +70,25 @@ public interface ArrondissementRepository extends JpaRepository<Arrondissement,
""") """)
Optional<ArrondissementPaylaodWeb> findArrondissementToDtoById(@Param("arrondissementId") Long arrondissementId); Optional<ArrondissementPaylaodWeb> findArrondissementToDtoById(@Param("arrondissementId") Long arrondissementId);
// @Query("""
// SELECT new io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb(
// arr.id,
// arr.code,
// arr.nom,
// com.id,
// com.code,
// com.nom
// )
// FROM Parcelle p
// INNER JOIN p.quartier q
// INNER JOIN q.arrondissement arr
// INNER JOIN arr.commune com
// WHERE p.id = :parcelleId
// """)
// Optional<ArrondissementPaylaodWeb> findArrondissementToDtoByQuartierId(@Param("quartierId") Long quartierId);
@Query( @Query(
value = """ value = """
SELECT new io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb( SELECT new io.gmss.fiscad.paylaods.request.crudweb.ArrondissementPaylaodWeb(

View File

@@ -201,6 +201,9 @@ SELECT new io.gmss.fiscad.paylaods.request.crudweb.DonneesImpositionPaylaodWeb(
); );
@Query(""" @Query("""
SELECT new io.gmss.fiscad.paylaods.request.crudweb.DonneesImpositionPaylaodWeb( SELECT new io.gmss.fiscad.paylaods.request.crudweb.DonneesImpositionPaylaodWeb(
d.id, d.id,
@@ -876,4 +879,16 @@ SELECT new io.gmss.fiscad.paylaods.request.crudweb.DonneesImpositionPaylaodWeb(
List<DonneesImpositionPaylaodWeb> findAllByPersonneId( List<DonneesImpositionPaylaodWeb> findAllByPersonneId(
@Param("personneId") Long personneId @Param("personneId") Long personneId
); );
@Query("""
SELECT COUNT(d) > 0
FROM DonneesImpositionTfu d
WHERE d.annee = :annee
AND d.parcelleImposee.id = :parcelleId
""")
boolean existsByImpositionAnneeAndParcelle(
@Param("annee") Long annee,
@Param("parcelleId") Long parcelleId
);
} }

View File

@@ -143,5 +143,25 @@ Optional<BaremRfuNonBati> findAllByCommune_IdAndZoneRfu_Id(Long communeId,Long z
@Param("communeId") Long communeId, @Param("communeId") Long communeId,
@Param("zoneId") Long zoneId @Param("zoneId") Long zoneId
); );
@Query("""
SELECT COUNT(barem) > 0
FROM Parcelle p
JOIN p.quartier q
JOIN q.arrondissement a
JOIN Enquete ep
ON ep.parcelle=p
JOIN BaremRfuNonBati barem
ON (barem.commune = a.commune)
WHERE p.id = :parcelleId
AND ep.dateEnquete = (
SELECT MAX(ep2.dateEnquete)
FROM Enquete ep2
WHERE ep2.parcelle = p
)
AND barem.zoneRfu = ep.zoneRfu
""")
boolean existsBaremForParcelleNonBati(@Param("parcelleId") Long parcelleId);
} }

View File

@@ -252,5 +252,29 @@ public interface BaremRfuRepository extends JpaRepository<BaremRfuBati, Long> {
@Param("quartierId") Long quartierId, @Param("quartierId") Long quartierId,
@Param("categorieBatimentId") Long categorieBatimentId @Param("categorieBatimentId") Long categorieBatimentId
); );
@Query("""
SELECT COUNT(barem) > 0
FROM Parcelle p
JOIN p.quartier q
JOIN q.arrondissement a
JOIN Batiment b
ON b.parcelle = p
JOIN EnqueteBatiment eb
ON eb.batiment=b
JOIN BaremRfuBati barem
ON (barem.quartier = q OR barem.arrondissement = a)
WHERE p.id = :parcelleId
AND eb.dateEnquete = (
SELECT MAX(eb2.dateEnquete)
FROM EnqueteBatiment eb2
WHERE eb2.batiment = b
)
AND barem.categorieBatiment = eb.categorieBatiment
""")
boolean existsBaremForParcelle(@Param("parcelleId") Long parcelleId);
} }