2024-06-30 20:25:36 +02:00
|
|
|
// SPDX-FileCopyrightText: (C) 2024 Matyáš Caras
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2023-10-09 17:28:05 +02:00
|
|
|
import 'package:json_annotation/json_annotation.dart';
|
|
|
|
part 'entry_data.g.dart';
|
|
|
|
|
2023-12-29 21:39:54 +01:00
|
|
|
/// Contains raw data
|
2023-10-09 17:28:05 +02:00
|
|
|
@JsonSerializable()
|
|
|
|
class EntryData {
|
2023-12-29 21:39:54 +01:00
|
|
|
/// Contains raw data
|
2023-11-01 17:58:05 +01:00
|
|
|
EntryData({required this.name, required this.amount, this.description = ""});
|
2023-10-09 17:28:05 +02:00
|
|
|
|
2024-07-17 16:44:02 +02:00
|
|
|
/// Generates a class instance from a Map
|
2023-10-09 17:28:05 +02:00
|
|
|
factory EntryData.fromJson(Map<String, dynamic> json) =>
|
|
|
|
_$EntryDataFromJson(json);
|
|
|
|
|
2024-07-17 17:37:41 +02:00
|
|
|
/// [EntryData] instance used as a default value for json_serializable
|
|
|
|
factory EntryData.unknown() => EntryData(name: "Unknown", amount: 0);
|
|
|
|
|
2023-12-29 21:39:54 +01:00
|
|
|
/// Name of entry
|
2024-07-17 17:37:41 +02:00
|
|
|
@JsonKey(defaultValue: "Unknown")
|
2023-12-29 21:39:54 +01:00
|
|
|
String name;
|
|
|
|
|
|
|
|
/// Optional description, default is empty
|
2024-07-17 17:37:41 +02:00
|
|
|
@JsonKey(defaultValue: "")
|
2023-12-29 21:39:54 +01:00
|
|
|
String description;
|
|
|
|
|
|
|
|
/// Amount for entry
|
2024-07-17 17:37:41 +02:00
|
|
|
@JsonKey(defaultValue: 0)
|
2023-12-29 21:39:54 +01:00
|
|
|
double amount;
|
|
|
|
|
2024-07-17 16:44:02 +02:00
|
|
|
/// Converts the data in this instance into a Map
|
2023-10-09 17:28:05 +02:00
|
|
|
Map<String, dynamic> toJson() => _$EntryDataToJson(this);
|
|
|
|
}
|