feat(paiements): ajout d'un système d'audit log pour les paiements avec filtres et correction d'accès agent
AS Talange CI/CD Pipeline / Build & Run Unit Tests (push) Successful in 2m46s
AS Talange CI/CD Pipeline / Build & Run in Docker Container (push) Successful in 2m48s

This commit is contained in:
2026-06-22 22:44:14 +02:00
parent 08dc39f61a
commit 14c83be77a
8 changed files with 308 additions and 4 deletions
@@ -0,0 +1,104 @@
package com.astalange.core.entity;
import jakarta.persistence.*;
import java.time.LocalDateTime;
import java.math.BigDecimal;
@Entity
@Table(name = "audit_log_paiement")
public class AuditLogPaiement {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String action; // CREATE, UPDATE, DELETE
@Column(nullable = false)
private LocalDateTime dateAction;
@Column(nullable = false)
private String utilisateur; // Username or 'Système'
@Column(nullable = true)
private Long paiementId; // Can be null if the payment is completely deleted or we just want to keep track
@Column(nullable = false, length = 1000)
private String details;
@Column(nullable = true)
private BigDecimal montant;
@Column(nullable = true)
private String adherentNomComplet;
@PrePersist
protected void onCreate() {
this.dateAction = LocalDateTime.now();
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public LocalDateTime getDateAction() {
return dateAction;
}
public void setDateAction(LocalDateTime dateAction) {
this.dateAction = dateAction;
}
public String getUtilisateur() {
return utilisateur;
}
public void setUtilisateur(String utilisateur) {
this.utilisateur = utilisateur;
}
public Long getPaiementId() {
return paiementId;
}
public void setPaiementId(Long paiementId) {
this.paiementId = paiementId;
}
public String getDetails() {
return details;
}
public void setDetails(String details) {
this.details = details;
}
public BigDecimal getMontant() {
return montant;
}
public void setMontant(BigDecimal montant) {
this.montant = montant;
}
public String getAdherentNomComplet() {
return adherentNomComplet;
}
public void setAdherentNomComplet(String adherentNomComplet) {
this.adherentNomComplet = adherentNomComplet;
}
}
@@ -0,0 +1,26 @@
package com.astalange.core.repository;
import com.astalange.core.entity.AuditLogPaiement;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
@Repository
public interface AuditLogPaiementRepository extends JpaRepository<AuditLogPaiement, Long> {
List<AuditLogPaiement> findAllByOrderByDateActionDesc();
@Query("SELECT a FROM AuditLogPaiement a WHERE " +
"(:action IS NULL OR :action = '' OR a.action = :action) AND " +
"(:utilisateur IS NULL OR :utilisateur = '' OR LOWER(a.utilisateur) LIKE LOWER(CONCAT('%', :utilisateur, '%'))) AND " +
"(:adherent IS NULL OR :adherent = '' OR LOWER(a.adherentNomComplet) LIKE LOWER(CONCAT('%', :adherent, '%'))) " +
"ORDER BY a.dateAction DESC")
List<AuditLogPaiement> findByFilters(
@Param("action") String action,
@Param("utilisateur") String utilisateur,
@Param("adherent") String adherent
);
}
@@ -0,0 +1,10 @@
CREATE TABLE audit_log_paiement (
id BIGSERIAL PRIMARY KEY,
action VARCHAR(50) NOT NULL,
date_action TIMESTAMP NOT NULL,
utilisateur VARCHAR(255) NOT NULL,
paiement_id BIGINT,
details VARCHAR(1000) NOT NULL,
montant DECIMAL(10, 2),
adherent_nom_complet VARCHAR(255)
);