Refactoring - Version stable
This commit is contained in:
@@ -116,6 +116,46 @@ class FinancialAuditLog extends Equatable {
|
||||
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
|
||||
bool get isAmountChanged =>
|
||||
amountBefore != null &&
|
||||
|
||||
Reference in New Issue
Block a user