Refactoring - Version stable

This commit is contained in:
dahoud
2026-03-28 14:25:59 +00:00
parent 11f9135f90
commit d0e61ead97

View File

@@ -116,6 +116,46 @@ class FinancialAuditLog extends Equatable {
this.metadata, this.metadata,
}); });
factory FinancialAuditLog.fromJson(Map<String, dynamic> json) {
return FinancialAuditLog(
id: json['id']?.toString() ?? '',
operation: AuditOperation.values.firstWhere(
(e) => e.name == json['operation'],
orElse: () => AuditOperation.read,
),
entityType: AuditEntityType.values.firstWhere(
(e) => e.name == json['entityType'],
orElse: () => AuditEntityType.other,
),
entityId: json['entityId']?.toString() ?? '',
userId: json['userId']?.toString() ?? '',
userName: json['userName']?.toString() ?? '',
userRole: json['userRole']?.toString() ?? '',
organizationId: json['organizationId']?.toString(),
severity: AuditSeverity.values.firstWhere(
(e) => e.name == json['severity'],
orElse: () => AuditSeverity.info,
),
description: json['description']?.toString() ?? '',
dataBefore: json['dataBefore'] != null
? Map<String, dynamic>.from(json['dataBefore'] as Map)
: null,
dataAfter: json['dataAfter'] != null
? Map<String, dynamic>.from(json['dataAfter'] as Map)
: null,
amountBefore: (json['amountBefore'] as num?)?.toDouble(),
amountAfter: (json['amountAfter'] as num?)?.toDouble(),
ipAddress: json['ipAddress']?.toString(),
userAgent: json['userAgent']?.toString(),
timestamp: json['timestamp'] != null
? DateTime.parse(json['timestamp'].toString())
: DateTime.now(),
metadata: json['metadata'] != null
? Map<String, dynamic>.from(json['metadata'] as Map)
: null,
);
}
/// Vérifie si c'est une opération de modification de montant /// Vérifie si c'est une opération de modification de montant
bool get isAmountChanged => bool get isAmountChanged =>
amountBefore != null && amountBefore != null &&