41 lines
915 B
Dart
41 lines
915 B
Dart
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<String, dynamic> json) =>
|
|
_$TransactionFromJson(json);
|
|
|
|
Map<String, dynamic> toJson() => _$TransactionToJson(this);
|
|
}
|