import 'package:equatable/equatable.dart'; class Fine extends Equatable { final int id; final int orderId; // ← добавлено final String scooterNumber; // можно оставить для совместимости, но не использовать в UI final DateTime createdAtDateTime; // ← новое поле final String description; final double amount; final String amountPrint; final List photoUrls; final bool isPaid; const Fine({ required this.id, required this.orderId, required this.scooterNumber, required this.createdAtDateTime, required this.description, required this.amount, required this.amountPrint, required this.photoUrls, required this.isPaid, }); factory Fine.fromJson(Map json, {String? scooterNumber}) { final List filesJson = json['files'] ?? []; final List photos = filesJson .map((file) => file['path'] as String? ?? file['filename'] as String? ?? '') .where((path) => path.isNotEmpty) .toList(); // Парсим createdAt как DateTime final createdAtDateTime = DateTime.tryParse(json['createdAt'].toString()) ?? DateTime.now(); // fallback return Fine( id: json['id'] as int? ?? 0, orderId: json['orderId'] as int? ?? 0, scooterNumber: scooterNumber ?? '', createdAtDateTime: createdAtDateTime, description: json['description'] as String? ?? '', amount: (json['value'] as num?)?.toDouble() ?? 0.0, amountPrint: json['valuePrint'] as String? ?? '0,00 BYN', photoUrls: photos, isPaid: json['isPaid'] as bool? ?? false, ); } @override List get props => [ id, orderId, scooterNumber, createdAtDateTime, description, amount, amountPrint, photoUrls, isPaid, ]; }