fix(disaster-recovery): restaurer 134 fichiers accidentellement supprimés par a72ab54
Some checks failed
CI/CD Pipeline / pipeline (push) Failing after 3m46s
Some checks failed
CI/CD Pipeline / pipeline (push) Failing after 3m46s
Le commita72ab54(chore docker Dockerfile racine) a involontairement balayé des fichiers du commit31330d9(PI-SPI, KYC, RLS, mutuelle parts, comptabilité PDF) lors d'un git add -A trop large. Restauration de l'intégralité des fichiers depuis a72ab54^ : - 11 migrations Flyway V32-V42 (parts sociales, SYSCOHADA, Keycloak Org Id, KYC, RLS, Provider défaut, FCM, App DB Roles) - Package payment/pispi/ complet (PispiAuth, PispiClient, PispiIso20022Mapper, PispiSignatureVerifier, PispiWebhookResource, dto/Pacs008Request, dto/Pacs002Response, PispiPaymentProvider) - Package payment/{wave,orangemoney,mtnmomo}/* (PaymentProvider impls) - Package payment/orchestration/ (PaymentOrchestrator, PaymentProviderRegistry) - Entités KycDossier, mutuelle/parts/* (ComptePartsSociales, TransactionPartsSociales) - Mappers, repositories, resources associés - Services KycAmlService, ComptabilitePdfService, ReleveComptePdfService, InteretsEpargneService - AdminKeycloakOrganisationResource, KycResource, PaiementUnifieResource - Tests unitaires PI-SPI, KYC, mutuelle parts
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package dev.lions.unionflow.server.resource;
|
||||
|
||||
import dev.lions.unionflow.server.service.MigrerOrganisationsVersKeycloakService;
|
||||
import dev.lions.unionflow.server.service.MigrerOrganisationsVersKeycloakService.MigrationReport;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Endpoints d'administration Keycloak 26 Organizations.
|
||||
*
|
||||
* <p>Réservés aux SUPER_ADMIN. Opérations à déclencher manuellement lors de la
|
||||
* migration Keycloak 23 → 26.
|
||||
*/
|
||||
@Slf4j
|
||||
@Path("/api/admin/keycloak")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@RolesAllowed("SUPER_ADMIN")
|
||||
public class AdminKeycloakOrganisationResource {
|
||||
|
||||
@Inject
|
||||
MigrerOrganisationsVersKeycloakService migrationService;
|
||||
|
||||
/**
|
||||
* Lance la migration one-shot des organisations UnionFlow vers Keycloak 26 Organizations.
|
||||
*
|
||||
* <p>Idempotent : les organisations déjà migrées (keycloak_org_id non null) sont ignorées.
|
||||
*
|
||||
* @return rapport de migration (total, créés, ignorés, erreurs)
|
||||
*/
|
||||
@POST
|
||||
@Path("/migrer-organisations")
|
||||
public Response migrerOrganisations() {
|
||||
log.info("Déclenchement migration organisations → Keycloak 26 Organizations");
|
||||
try {
|
||||
MigrationReport report = migrationService.migrerToutesLesOrganisations();
|
||||
log.info("Migration terminée : {}", report);
|
||||
|
||||
return Response
|
||||
.status(report.success() ? Response.Status.OK.getStatusCode() : 207)
|
||||
.entity(Map.of(
|
||||
"total", report.total(),
|
||||
"crees", report.crees(),
|
||||
"ignores", report.ignores(),
|
||||
"erreurs", report.erreurs(),
|
||||
"succes", report.success()
|
||||
))
|
||||
.build();
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("Erreur critique lors de la migration : {}", e.getMessage(), e);
|
||||
return Response.serverError()
|
||||
.entity(Map.of("error", e.getMessage()))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package dev.lions.unionflow.server.resource;
|
||||
|
||||
import dev.lions.unionflow.server.service.ComptabilitePdfService;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.*;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
import org.eclipse.microprofile.openapi.annotations.Operation;
|
||||
import org.eclipse.microprofile.openapi.annotations.tags.Tag;
|
||||
|
||||
/**
|
||||
* Endpoints de téléchargement des rapports comptables PDF SYSCOHADA révisé.
|
||||
*/
|
||||
@Path("/api/comptabilite/pdf")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@RolesAllowed({"ADMIN_ORGANISATION", "TRESORIER", "COMMISSAIRE_COMPTES", "SUPER_ADMIN"})
|
||||
@Tag(name = "Comptabilité PDF", description = "Rapports comptables SYSCOHADA : balance, compte de résultat, grand livre")
|
||||
public class ComptabilitePdfResource {
|
||||
|
||||
@Inject
|
||||
ComptabilitePdfService comptabilitePdfService;
|
||||
|
||||
@GET
|
||||
@Path("/organisations/{organisationId}/balance")
|
||||
@Produces("application/pdf")
|
||||
@Operation(summary = "Balance générale SYSCOHADA",
|
||||
description = "Génère la balance générale (cumul débit/crédit/solde) pour la période.")
|
||||
public Response balance(
|
||||
@PathParam("organisationId") UUID organisationId,
|
||||
@QueryParam("dateDebut") @DefaultValue("") String dateDebutStr,
|
||||
@QueryParam("dateFin") @DefaultValue("") String dateFinStr) {
|
||||
|
||||
LocalDate dateDebut = parseDateOrStartOfYear(dateDebutStr);
|
||||
LocalDate dateFin = parseDateOrToday(dateFinStr);
|
||||
|
||||
byte[] pdf = comptabilitePdfService.genererBalance(organisationId, dateDebut, dateFin);
|
||||
return buildPdfResponse(pdf, "balance_" + organisationId + ".pdf");
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/organisations/{organisationId}/compte-de-resultat")
|
||||
@Produces("application/pdf")
|
||||
@Operation(summary = "Compte de résultat SYSCOHADA",
|
||||
description = "Génère le compte de résultat (produits classes 7/8 − charges classes 6/8).")
|
||||
public Response compteDeResultat(
|
||||
@PathParam("organisationId") UUID organisationId,
|
||||
@QueryParam("dateDebut") @DefaultValue("") String dateDebutStr,
|
||||
@QueryParam("dateFin") @DefaultValue("") String dateFinStr) {
|
||||
|
||||
LocalDate dateDebut = parseDateOrStartOfYear(dateDebutStr);
|
||||
LocalDate dateFin = parseDateOrToday(dateFinStr);
|
||||
|
||||
byte[] pdf = comptabilitePdfService.genererCompteResultat(organisationId, dateDebut, dateFin);
|
||||
return buildPdfResponse(pdf, "compte_resultat_" + organisationId + ".pdf");
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/organisations/{organisationId}/grand-livre/{numeroCompte}")
|
||||
@Produces("application/pdf")
|
||||
@Operation(summary = "Grand livre d'un compte SYSCOHADA",
|
||||
description = "Génère le grand livre (détail chronologique) pour un compte comptable donné.")
|
||||
public Response grandLivre(
|
||||
@PathParam("organisationId") UUID organisationId,
|
||||
@PathParam("numeroCompte") String numeroCompte,
|
||||
@QueryParam("dateDebut") @DefaultValue("") String dateDebutStr,
|
||||
@QueryParam("dateFin") @DefaultValue("") String dateFinStr) {
|
||||
|
||||
LocalDate dateDebut = parseDateOrStartOfYear(dateDebutStr);
|
||||
LocalDate dateFin = parseDateOrToday(dateFinStr);
|
||||
|
||||
byte[] pdf = comptabilitePdfService.genererGrandLivre(organisationId, numeroCompte, dateDebut, dateFin);
|
||||
return buildPdfResponse(pdf, "grand_livre_" + numeroCompte + ".pdf");
|
||||
}
|
||||
|
||||
private static Response buildPdfResponse(byte[] pdf, String filename) {
|
||||
return Response.ok(pdf)
|
||||
.header("Content-Disposition", "attachment; filename=\"" + filename + "\"")
|
||||
.header("Content-Length", pdf.length)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static LocalDate parseDateOrStartOfYear(String s) {
|
||||
if (s == null || s.isBlank()) return LocalDate.of(LocalDate.now().getYear(), 1, 1);
|
||||
try { return LocalDate.parse(s); } catch (Exception e) {
|
||||
throw new BadRequestException("Format de date invalide (attendu : YYYY-MM-DD) : " + s);
|
||||
}
|
||||
}
|
||||
|
||||
private static LocalDate parseDateOrToday(String s) {
|
||||
if (s == null || s.isBlank()) return LocalDate.now();
|
||||
try { return LocalDate.parse(s); } catch (Exception e) {
|
||||
throw new BadRequestException("Format de date invalide (attendu : YYYY-MM-DD) : " + s);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package dev.lions.unionflow.server.resource;
|
||||
|
||||
import dev.lions.unionflow.server.api.dto.kyc.KycDossierRequest;
|
||||
import dev.lions.unionflow.server.api.dto.kyc.KycDossierResponse;
|
||||
import dev.lions.unionflow.server.service.KycAmlService;
|
||||
import io.quarkus.security.identity.SecurityIdentity;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.ws.rs.*;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Endpoints KYC/AML — gestion des dossiers d'identification et évaluation risque LCB-FT.
|
||||
*/
|
||||
@Path("/api/kyc")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public class KycResource {
|
||||
|
||||
@Inject
|
||||
KycAmlService kycAmlService;
|
||||
|
||||
@Inject
|
||||
SecurityIdentity identity;
|
||||
|
||||
/** Soumet ou met à jour un dossier KYC pour un membre. */
|
||||
@POST
|
||||
@Path("/dossiers")
|
||||
@RolesAllowed({"ADMIN_ORGANISATION", "TRESORIER", "SUPER_ADMIN"})
|
||||
public Response soumettre(@Valid KycDossierRequest request) {
|
||||
KycDossierResponse response = kycAmlService.soumettreOuMettreAJour(request, identity.getPrincipal().getName());
|
||||
return Response.status(Response.Status.CREATED).entity(response).build();
|
||||
}
|
||||
|
||||
/** Récupère le dossier KYC actif d'un membre. */
|
||||
@GET
|
||||
@Path("/membres/{membreId}")
|
||||
@RolesAllowed({"ADMIN_ORGANISATION", "TRESORIER", "SUPER_ADMIN"})
|
||||
public Response getDossierActif(@PathParam("membreId") UUID membreId) {
|
||||
return kycAmlService.getDossierActif(membreId)
|
||||
.map(d -> Response.ok(d).build())
|
||||
.orElse(Response.status(Response.Status.NOT_FOUND)
|
||||
.entity(Map.of("error", "Aucun dossier KYC actif pour ce membre."))
|
||||
.build());
|
||||
}
|
||||
|
||||
/** Évalue le score de risque LCB-FT du membre. */
|
||||
@POST
|
||||
@Path("/membres/{membreId}/evaluer-risque")
|
||||
@RolesAllowed({"ADMIN_ORGANISATION", "TRESORIER", "SUPER_ADMIN"})
|
||||
public Response evaluerRisque(@PathParam("membreId") UUID membreId) {
|
||||
KycDossierResponse response = kycAmlService.evaluerRisque(membreId);
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
/** Valide manuellement un dossier KYC (agent habilité). */
|
||||
@POST
|
||||
@Path("/dossiers/{dossierId}/valider")
|
||||
@RolesAllowed({"SUPER_ADMIN", "ADMIN_ORGANISATION"})
|
||||
public Response valider(
|
||||
@PathParam("dossierId") UUID dossierId,
|
||||
@QueryParam("validateurId") UUID validateurId,
|
||||
@QueryParam("notes") String notes) {
|
||||
KycDossierResponse response = kycAmlService.valider(
|
||||
dossierId, validateurId, notes, identity.getPrincipal().getName());
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
/** Refuse un dossier KYC avec motif. */
|
||||
@POST
|
||||
@Path("/dossiers/{dossierId}/refuser")
|
||||
@RolesAllowed({"SUPER_ADMIN", "ADMIN_ORGANISATION"})
|
||||
public Response refuser(
|
||||
@PathParam("dossierId") UUID dossierId,
|
||||
@QueryParam("validateurId") UUID validateurId,
|
||||
@QueryParam("motif") String motif) {
|
||||
KycDossierResponse response = kycAmlService.refuser(
|
||||
dossierId, validateurId, motif, identity.getPrincipal().getName());
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
/** Liste les dossiers KYC en attente de validation. */
|
||||
@GET
|
||||
@Path("/dossiers/en-attente")
|
||||
@RolesAllowed({"SUPER_ADMIN", "ADMIN_ORGANISATION"})
|
||||
public List<KycDossierResponse> getDossiersEnAttente() {
|
||||
return kycAmlService.getDossiersEnAttente();
|
||||
}
|
||||
|
||||
/** Liste les membres PEP (Personnes Exposées Politiquement). */
|
||||
@GET
|
||||
@Path("/pep")
|
||||
@RolesAllowed({"SUPER_ADMIN"})
|
||||
public List<KycDossierResponse> getPep() {
|
||||
return kycAmlService.getDossiersPep();
|
||||
}
|
||||
|
||||
/** Pièces d'identité expirant dans les 30 jours. */
|
||||
@GET
|
||||
@Path("/pieces-expirant-bientot")
|
||||
@RolesAllowed({"SUPER_ADMIN", "ADMIN_ORGANISATION", "TRESORIER"})
|
||||
public List<KycDossierResponse> getPiecesExpirant() {
|
||||
return kycAmlService.getPiecesExpirantDansLes30Jours();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package dev.lions.unionflow.server.resource;
|
||||
|
||||
import dev.lions.unionflow.server.api.payment.*;
|
||||
import dev.lions.unionflow.server.entity.SouscriptionOrganisation;
|
||||
import dev.lions.unionflow.server.payment.orchestration.PaymentOrchestrator;
|
||||
import dev.lions.unionflow.server.payment.orchestration.PaymentProviderRegistry;
|
||||
import dev.lions.unionflow.server.repository.SouscriptionOrganisationRepository;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.*;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.HttpHeaders;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Endpoints de paiement unifiés — abstraction multi-provider.
|
||||
* Remplace à terme les endpoints Wave-spécifiques.
|
||||
*/
|
||||
@Slf4j
|
||||
@Path("/api/paiements")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public class PaiementUnifieResource {
|
||||
|
||||
@Inject
|
||||
PaymentOrchestrator orchestrator;
|
||||
|
||||
@Inject
|
||||
PaymentProviderRegistry registry;
|
||||
|
||||
@Inject
|
||||
SouscriptionOrganisationRepository souscriptionRepository;
|
||||
|
||||
/**
|
||||
* Initie un paiement via le provider demandé (ou le provider par défaut).
|
||||
*
|
||||
* <p>Exemple : {@code POST /api/paiements/initier?provider=WAVE}
|
||||
*/
|
||||
@POST
|
||||
@Path("/initier")
|
||||
@RolesAllowed({"MEMBRE_ACTIF", "ADMIN_ORGANISATION", "TRESORIER", "SUPER_ADMIN"})
|
||||
public Response initier(
|
||||
@QueryParam("provider") String provider,
|
||||
PaiementInitierRequest req) {
|
||||
try {
|
||||
// Si une souscription est fournie, utiliser le providerDefaut de sa formule
|
||||
String resolvedProvider = provider;
|
||||
if (req.souscriptionId() != null) {
|
||||
resolvedProvider = souscriptionRepository.findByIdOptional(req.souscriptionId())
|
||||
.map(SouscriptionOrganisation::getFormule)
|
||||
.map(f -> f.getProviderDefaut())
|
||||
.filter(p -> p != null && !p.isBlank())
|
||||
.orElse(provider);
|
||||
}
|
||||
|
||||
CheckoutRequest checkoutRequest = new CheckoutRequest(
|
||||
req.montant(),
|
||||
req.devise() != null ? req.devise() : "XOF",
|
||||
req.telephone(),
|
||||
req.email(),
|
||||
req.reference(),
|
||||
req.successUrl(),
|
||||
req.cancelUrl(),
|
||||
Map.of()
|
||||
);
|
||||
CheckoutSession session = orchestrator.initierPaiement(checkoutRequest, resolvedProvider);
|
||||
return Response.ok(session).build();
|
||||
} catch (PaymentException e) {
|
||||
return Response.status(e.getHttpStatus())
|
||||
.entity(Map.of("error", e.getMessage(), "provider", e.getProviderCode()))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Webhook entrant d'un provider. Vérifie la signature et met à jour le statut.
|
||||
* Route : {@code POST /api/paiements/webhook/{provider}}
|
||||
*/
|
||||
@POST
|
||||
@Path("/webhook/{provider}")
|
||||
@PermitAll
|
||||
@Consumes(MediaType.WILDCARD)
|
||||
public Response webhook(
|
||||
@PathParam("provider") String providerCode,
|
||||
String rawBody,
|
||||
@Context HttpHeaders httpHeaders) {
|
||||
try {
|
||||
PaymentProvider provider = registry.get(providerCode.toUpperCase());
|
||||
Map<String, String> headers = httpHeaders.getRequestHeaders().entrySet().stream()
|
||||
.collect(Collectors.toMap(
|
||||
Map.Entry::getKey,
|
||||
e -> e.getValue().isEmpty() ? "" : e.getValue().get(0)
|
||||
));
|
||||
|
||||
PaymentEvent event = provider.processWebhook(rawBody, headers);
|
||||
orchestrator.handleEvent(event);
|
||||
return Response.ok().build();
|
||||
|
||||
} catch (UnsupportedOperationException e) {
|
||||
return Response.status(Response.Status.NOT_FOUND)
|
||||
.entity(Map.of("error", "Provider inconnu : " + providerCode))
|
||||
.build();
|
||||
} catch (PaymentException e) {
|
||||
log.error("Webhook {} rejeté : {}", providerCode, e.getMessage());
|
||||
return Response.status(e.getHttpStatus())
|
||||
.entity(Map.of("error", e.getMessage()))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
/** Retourne les providers de paiement disponibles. */
|
||||
@GET
|
||||
@Path("/providers")
|
||||
@RolesAllowed({"ADMIN_ORGANISATION", "SUPER_ADMIN"})
|
||||
public List<String> getProviders() {
|
||||
return registry.getAvailableCodes();
|
||||
}
|
||||
|
||||
public record PaiementInitierRequest(
|
||||
BigDecimal montant,
|
||||
String devise,
|
||||
String telephone,
|
||||
String email,
|
||||
String reference,
|
||||
String successUrl,
|
||||
String cancelUrl,
|
||||
/** Optionnel — si fourni, le providerDefaut de la formule prend le dessus sur le query param. */
|
||||
UUID souscriptionId
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package dev.lions.unionflow.server.resource.mutuelle;
|
||||
|
||||
import dev.lions.unionflow.server.api.dto.mutuelle.financier.ParametresFinanciersMutuellRequest;
|
||||
import dev.lions.unionflow.server.api.dto.mutuelle.financier.ParametresFinanciersMutuellResponse;
|
||||
import dev.lions.unionflow.server.security.RequiresModule;
|
||||
import dev.lions.unionflow.server.service.mutuelle.InteretsEpargneService;
|
||||
import dev.lions.unionflow.server.service.mutuelle.ParametresFinanciersService;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.ws.rs.*;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@Path("/api/v1/mutuelle/parametres-financiers")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@RequiresModule("EPARGNE")
|
||||
public class ParametresFinanciersResource {
|
||||
|
||||
@Inject ParametresFinanciersService parametresService;
|
||||
@Inject InteretsEpargneService interetsService;
|
||||
|
||||
@GET
|
||||
@Path("/{orgId}")
|
||||
@RolesAllowed({"ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MUTUELLE_RESP"})
|
||||
public Response getByOrganisation(@PathParam("orgId") UUID orgId) {
|
||||
return Response.ok(parametresService.getByOrganisation(orgId)).build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@RolesAllowed({"ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION"})
|
||||
public Response creerOuMettrAJour(@Valid ParametresFinanciersMutuellRequest request) {
|
||||
ParametresFinanciersMutuellResponse resp = parametresService.creerOuMettrAJour(request);
|
||||
return Response.ok(resp).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Déclenche manuellement le calcul des intérêts / dividendes pour une organisation.
|
||||
* Utile pour régularisation ou test.
|
||||
*/
|
||||
@POST
|
||||
@Path("/{orgId}/calculer-interets")
|
||||
@RolesAllowed({"ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION"})
|
||||
public Response calculerInterets(@PathParam("orgId") UUID orgId) {
|
||||
Map<String, Object> result = interetsService.calculerManuellement(orgId);
|
||||
return Response.ok(result).build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package dev.lions.unionflow.server.resource.mutuelle;
|
||||
|
||||
import dev.lions.unionflow.server.security.RequiresModule;
|
||||
import dev.lions.unionflow.server.service.mutuelle.ReleveComptePdfService;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.*;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import jakarta.ws.rs.core.Response.ResponseBuilder;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Relevés de compte en PDF.
|
||||
* - GET /api/v1/releves/epargne/{compteId} → relevé épargne
|
||||
* - GET /api/v1/releves/parts-sociales/{compteId} → relevé parts sociales
|
||||
*/
|
||||
@Path("/api/v1/releves")
|
||||
@RequiresModule("EPARGNE")
|
||||
public class ReleveCompteResource {
|
||||
|
||||
@Inject ReleveComptePdfService releveService;
|
||||
|
||||
@GET
|
||||
@Path("/epargne/{compteId}")
|
||||
@Produces("application/pdf")
|
||||
@RolesAllowed({"ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MUTUELLE_RESP", "MEMBRE", "USER"})
|
||||
public Response releveEpargne(
|
||||
@PathParam("compteId") UUID compteId,
|
||||
@QueryParam("dateDebut") String dateDebutStr,
|
||||
@QueryParam("dateFin") String dateFinStr) {
|
||||
|
||||
LocalDate dateDebut = parseDate(dateDebutStr);
|
||||
LocalDate dateFin = parseDate(dateFinStr);
|
||||
byte[] pdf = releveService.genererReleveEpargne(compteId, dateDebut, dateFin);
|
||||
|
||||
ResponseBuilder rb = Response.ok(pdf);
|
||||
rb.header("Content-Disposition",
|
||||
"attachment; filename=\"releve-epargne-" + compteId + ".pdf\"");
|
||||
rb.header("Content-Type", MediaType.valueOf("application/pdf"));
|
||||
return rb.build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/parts-sociales/{compteId}")
|
||||
@Produces("application/pdf")
|
||||
@RolesAllowed({"ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MUTUELLE_RESP", "MEMBRE", "USER"})
|
||||
public Response releveParts(
|
||||
@PathParam("compteId") UUID compteId,
|
||||
@QueryParam("dateDebut") String dateDebutStr,
|
||||
@QueryParam("dateFin") String dateFinStr) {
|
||||
|
||||
LocalDate dateDebut = parseDate(dateDebutStr);
|
||||
LocalDate dateFin = parseDate(dateFinStr);
|
||||
byte[] pdf = releveService.genererReleveParts(compteId, dateDebut, dateFin);
|
||||
|
||||
ResponseBuilder rb = Response.ok(pdf);
|
||||
rb.header("Content-Disposition",
|
||||
"attachment; filename=\"releve-parts-" + compteId + ".pdf\"");
|
||||
rb.header("Content-Type", MediaType.valueOf("application/pdf"));
|
||||
return rb.build();
|
||||
}
|
||||
|
||||
private LocalDate parseDate(String s) {
|
||||
if (s == null || s.isBlank()) return null;
|
||||
try {
|
||||
return LocalDate.parse(s);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("Format de date invalide. Utilisez YYYY-MM-DD. Valeur reçue: " + s);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package dev.lions.unionflow.server.resource.mutuelle.parts;
|
||||
|
||||
import dev.lions.unionflow.server.api.dto.mutuelle.parts.ComptePartsSocialesRequest;
|
||||
import dev.lions.unionflow.server.api.dto.mutuelle.parts.ComptePartsSocialesResponse;
|
||||
import dev.lions.unionflow.server.api.dto.mutuelle.parts.TransactionPartsSocialesRequest;
|
||||
import dev.lions.unionflow.server.api.dto.mutuelle.parts.TransactionPartsSocialesResponse;
|
||||
import dev.lions.unionflow.server.security.RequiresModule;
|
||||
import dev.lions.unionflow.server.service.mutuelle.parts.ComptePartsSocialesService;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.ws.rs.*;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Path("/api/v1/parts-sociales/comptes")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@RequiresModule("EPARGNE")
|
||||
public class ComptePartsSocialesResource {
|
||||
|
||||
@Inject
|
||||
ComptePartsSocialesService service;
|
||||
|
||||
@POST
|
||||
@RolesAllowed({"ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MUTUELLE_RESP"})
|
||||
public Response ouvrirCompte(@Valid ComptePartsSocialesRequest request) {
|
||||
ComptePartsSocialesResponse resp = service.ouvrirCompte(request);
|
||||
return Response.status(Response.Status.CREATED).entity(resp).build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/transactions")
|
||||
@RolesAllowed({"ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MUTUELLE_RESP"})
|
||||
public Response enregistrerTransaction(@Valid TransactionPartsSocialesRequest request) {
|
||||
TransactionPartsSocialesResponse resp = service.enregistrerSouscription(request);
|
||||
return Response.status(Response.Status.CREATED).entity(resp).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/{id}")
|
||||
@RolesAllowed({"ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MUTUELLE_RESP", "MEMBRE", "USER"})
|
||||
public Response getById(@PathParam("id") UUID id) {
|
||||
return Response.ok(service.getById(id)).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/membre/{membreId}")
|
||||
@RolesAllowed({"ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MUTUELLE_RESP", "MEMBRE", "USER"})
|
||||
public Response getByMembre(@PathParam("membreId") UUID membreId) {
|
||||
List<ComptePartsSocialesResponse> list = service.getByMembre(membreId);
|
||||
return Response.ok(list).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/organisation/{orgId}")
|
||||
@RolesAllowed({"ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MUTUELLE_RESP"})
|
||||
public Response getByOrganisation(@PathParam("orgId") UUID orgId) {
|
||||
List<ComptePartsSocialesResponse> list = service.getByOrganisation(orgId);
|
||||
return Response.ok(list).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/{id}/transactions")
|
||||
@RolesAllowed({"ADMIN", "SUPER_ADMIN", "ADMIN_ORGANISATION", "MUTUELLE_RESP", "MEMBRE", "USER"})
|
||||
public Response getTransactions(@PathParam("id") UUID id) {
|
||||
List<TransactionPartsSocialesResponse> list = service.getTransactions(id);
|
||||
return Response.ok(list).build();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user