feat(backend): ajout 8 endpoints manquants workflow financier
Endpoints ajoutés :
- POST /api/finance/approvals - requestApproval (avec organizationId)
- GET /api/finance/approvals/history - historique filtrable
- PUT /api/finance/budgets/{id} - updateBudget (name, description, status)
- DELETE /api/finance/budgets/{id} - deleteBudget (soft delete)
- GET /api/finance/stats - statistiques workflow global
- GET /api/finance/audit-logs - logs d'audit filtrables
- GET /api/finance/audit-logs/anomalies - détection anomalies
- POST /api/finance/audit-logs/export - export CSV/PDF
Services :
- ApprovalService.requestApproval() : logique niveaux LEVEL1/2/3 selon montant
- ApprovalService.getApprovalsHistory() : filtres date + statut
- BudgetService.updateBudget() : validation statut + approbation
- BudgetService.deleteBudget() : soft delete (actif=false)
Notes :
- Niveau approbation : <100K=NONE, 100K-1M=LEVEL1, 1M-5M=LEVEL2, >5M=LEVEL3
- organizationId optionnel dans requestApproval (pas de récup auto depuis Membre)
- FinanceWorkflowResource créé pour stats/audit (implémentation stub)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,7 @@ import org.jboss.logging.Logger;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@@ -36,6 +37,42 @@ public class ApprovalResource {
|
||||
@Inject
|
||||
ApprovalService approvalService;
|
||||
|
||||
@POST
|
||||
@RolesAllowed({"ORG_ADMIN", "SUPER_ADMIN", "MEMBRE"})
|
||||
@Operation(summary = "Demande une approbation de transaction",
|
||||
description = "Crée une demande d'approbation pour une transaction financière")
|
||||
public Response requestApproval(Map<String, Object> request) {
|
||||
LOG.infof("POST /api/finance/approvals - Request approval");
|
||||
|
||||
try {
|
||||
String transactionId = (String) request.get("transactionId");
|
||||
String transactionType = (String) request.get("transactionType");
|
||||
Double amount = ((Number) request.get("amount")).doubleValue();
|
||||
String organizationIdStr = (String) request.get("organizationId");
|
||||
|
||||
if (transactionId == null || transactionType == null || amount == null) {
|
||||
return Response.status(Response.Status.BAD_REQUEST)
|
||||
.entity(new ErrorResponse("transactionId, transactionType et amount sont requis"))
|
||||
.build();
|
||||
}
|
||||
|
||||
UUID organizationId = organizationIdStr != null ? UUID.fromString(organizationIdStr) : null;
|
||||
|
||||
TransactionApprovalResponse approval = approvalService.requestApproval(
|
||||
UUID.fromString(transactionId), transactionType, amount, organizationId);
|
||||
return Response.status(Response.Status.CREATED).entity(approval).build();
|
||||
} catch (IllegalArgumentException e) {
|
||||
return Response.status(Response.Status.BAD_REQUEST)
|
||||
.entity(new ErrorResponse(e.getMessage()))
|
||||
.build();
|
||||
} catch (Exception e) {
|
||||
LOG.error("Erreur lors de la création de la demande d'approbation", e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
|
||||
.entity(new ErrorResponse(e.getMessage()))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/pending")
|
||||
@RolesAllowed({"ORG_ADMIN", "SUPER_ADMIN"})
|
||||
|
||||
Reference in New Issue
Block a user