fix to prod
This commit is contained in:
@@ -2,8 +2,9 @@ import 'package:equatable/equatable.dart';
|
||||
|
||||
class Fine extends Equatable {
|
||||
final int id;
|
||||
final String scooterNumber;
|
||||
final String date;
|
||||
final int orderId; // ← добавлено
|
||||
final String scooterNumber; // можно оставить для совместимости, но не использовать в UI
|
||||
final DateTime createdAtDateTime; // ← новое поле
|
||||
final String description;
|
||||
final double amount;
|
||||
final String amountPrint;
|
||||
@@ -12,8 +13,9 @@ class Fine extends Equatable {
|
||||
|
||||
const Fine({
|
||||
required this.id,
|
||||
required this.orderId,
|
||||
required this.scooterNumber,
|
||||
required this.date,
|
||||
required this.createdAtDateTime,
|
||||
required this.description,
|
||||
required this.amount,
|
||||
required this.amountPrint,
|
||||
@@ -28,22 +30,15 @@ class Fine extends Equatable {
|
||||
.where((path) => path.isNotEmpty)
|
||||
.toList();
|
||||
|
||||
// Форматирование даты из createdAt (2026-08-07T09:15:26.565Z -> 07-08-2026)
|
||||
String formattedDate = '';
|
||||
if (json['createdAt'] != null) {
|
||||
final parsedDate = DateTime.tryParse(json['createdAt'].toString());
|
||||
if (parsedDate != null) {
|
||||
final day = parsedDate.day.toString().padLeft(2, '0');
|
||||
final month = parsedDate.month.toString().padLeft(2, '0');
|
||||
final year = parsedDate.year;
|
||||
formattedDate = '$day-$month-$year';
|
||||
}
|
||||
}
|
||||
// Парсим 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 ?? '',
|
||||
date: formattedDate,
|
||||
createdAtDateTime: createdAtDateTime,
|
||||
description: json['description'] as String? ?? '',
|
||||
amount: (json['value'] as num?)?.toDouble() ?? 0.0,
|
||||
amountPrint: json['valuePrint'] as String? ?? '0,00 BYN',
|
||||
@@ -52,21 +47,12 @@ class Fine extends Equatable {
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'description': description,
|
||||
'value': amount,
|
||||
'valuePrint': amountPrint,
|
||||
'isPaid': isPaid,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
orderId,
|
||||
scooterNumber,
|
||||
date,
|
||||
createdAtDateTime,
|
||||
description,
|
||||
amount,
|
||||
amountPrint,
|
||||
|
||||
Reference in New Issue
Block a user