import 'package:json_annotation/json_annotation.dart'; import '../global/utils.dart'; part 'transaction_model.g.dart'; enum TransactionType { income, expense, } @JsonSerializable() class Transaction { const Transaction({ this.id, required this.amount, required this.transactionType, required this.budgetId, required this.budgetCategoryId, required this.addedByUserId, required this.date, this.createdAt, }); final int? id; final int budgetId, budgetCategoryId, addedByUserId; final double amount; final TransactionType transactionType; @JsonKey(fromJson: dateFromJson, toJson: dateToJson) final DateTime date; @JsonKey(fromJson: dateFromJson, toJson: dateToJson) final DateTime? createdAt; factory Transaction.fromJson(Map json) => _$TransactionFromJson(json); Map toJson() => _$TransactionToJson(this); }