2024-07-17 16:44:02 +02:00
|
|
|
import 'package:json_annotation/json_annotation.dart';
|
|
|
|
import 'package:prasule/api/debt_entry.dart';
|
|
|
|
import 'package:prasule/api/debt_person.dart';
|
|
|
|
part 'debt_scenario.g.dart';
|
|
|
|
|
|
|
|
/// A folder for different entries and people
|
|
|
|
@JsonSerializable()
|
|
|
|
class DebtScenario {
|
|
|
|
/// A folder for different entries and people
|
|
|
|
DebtScenario({
|
|
|
|
required this.id,
|
|
|
|
required this.name,
|
|
|
|
required this.isArchived,
|
|
|
|
this.entries = const [],
|
|
|
|
this.people = const [],
|
|
|
|
});
|
|
|
|
|
|
|
|
/// Generates a class instance from a Map
|
|
|
|
factory DebtScenario.fromJson(Map<String, dynamic> json) =>
|
|
|
|
_$DebtScenarioFromJson(json);
|
|
|
|
|
|
|
|
/// Converts the data in this instance into a Map
|
|
|
|
Map<String, dynamic> toJson() => _$DebtScenarioToJson(this);
|
|
|
|
|
|
|
|
/// Unique identified
|
2024-07-17 17:37:41 +02:00
|
|
|
@JsonKey(disallowNullValue: true)
|
2024-07-17 16:44:02 +02:00
|
|
|
final int id;
|
|
|
|
|
|
|
|
/// User-friendly identifier
|
2024-07-17 17:37:41 +02:00
|
|
|
@JsonKey(defaultValue: "Unknown")
|
2024-07-17 16:44:02 +02:00
|
|
|
String name;
|
|
|
|
|
|
|
|
/// Whether this scenario should be shown under archived ones
|
2024-07-17 17:37:41 +02:00
|
|
|
@JsonKey(defaultValue: false)
|
2024-07-17 16:44:02 +02:00
|
|
|
bool isArchived;
|
|
|
|
|
|
|
|
/// All entries
|
2024-07-17 17:37:41 +02:00
|
|
|
@JsonKey(defaultValue: [])
|
2024-07-17 16:44:02 +02:00
|
|
|
List<DebtEntry> entries;
|
|
|
|
|
|
|
|
/// All people
|
2024-07-17 17:37:41 +02:00
|
|
|
@JsonKey(defaultValue: _defaultPeopleList)
|
2024-07-17 16:44:02 +02:00
|
|
|
List<DebtPerson> people;
|
|
|
|
}
|
2024-07-17 17:37:41 +02:00
|
|
|
|
|
|
|
List<DebtPerson> _defaultPeopleList() => [DebtPerson.unknownPerson()];
|