prasule/lib/api/debt_entry.dart

39 lines
1,010 B
Dart
Raw Normal View History

2024-07-17 16:44:02 +02:00
import 'package:json_annotation/json_annotation.dart';
import 'package:prasule/api/debt_person.dart';
part 'debt_entry.g.dart';
/// Single transaction
///
/// The debt will be split between people who are not in [whoPayed]
@JsonSerializable()
class DebtEntry {
/// Single transaction
///
/// The debt will be split between people who are not in [whoPayed]
DebtEntry({
required this.id,
required this.amount,
required this.name,
required this.whoPayed,
}) : assert(whoPayed.isNotEmpty, "There has to be at least one payer");
/// Generates a class instance from a Map
factory DebtEntry.fromJson(Map<String, dynamic> json) =>
_$DebtEntryFromJson(json);
/// Converts the data in this instance into a Map
Map<String, dynamic> toJson() => _$DebtEntryToJson(this);
/// Unique identifier
final int id;
/// The payed amount
int amount;
/// User-friendly identifier for the transaction
String name;
/// List of people who payed
List<DebtPerson> whoPayed;
}