39 lines
1.1 KiB
Dart
39 lines
1.1 KiB
Dart
class FuelEntry {
|
|
final String id;
|
|
final String vehicleId;
|
|
final DateTime date;
|
|
final double gallons;
|
|
final double pricePerGallon;
|
|
final double totalCost;
|
|
final String? receiptImagePath;
|
|
|
|
FuelEntry({
|
|
required this.id,
|
|
required this.vehicleId,
|
|
required this.date,
|
|
required this.gallons,
|
|
required this.pricePerGallon,
|
|
required this.totalCost,
|
|
this.receiptImagePath,
|
|
});
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'vehicleId': vehicleId,
|
|
'date': date.toIso8601String(),
|
|
'gallons': gallons,
|
|
'pricePerGallon': pricePerGallon,
|
|
'totalCost': totalCost,
|
|
'receiptImagePath': receiptImagePath,
|
|
};
|
|
|
|
factory FuelEntry.fromJson(Map<String, dynamic> json) => FuelEntry(
|
|
id: json['id'] as String,
|
|
vehicleId: json['vehicleId'] as String,
|
|
date: DateTime.parse(json['date'] as String),
|
|
gallons: (json['gallons'] as num).toDouble(),
|
|
pricePerGallon: (json['pricePerGallon'] as num).toDouble(),
|
|
totalCost: (json['totalCost'] as num).toDouble(),
|
|
receiptImagePath: json['receiptImagePath'] as String?,
|
|
);
|
|
}
|