class TransactionModel { final String id; final double amount; final String type; // 'income' or 'expense' final int categoryId; final DateTime date; final String? note; final DateTime createdAt; final DateTime updatedAt; TransactionModel({ required this.id, required this.amount, required this.type, required this.categoryId, required this.date, this.note, required this.createdAt, required this.updatedAt, }); Map toMap() { return { 'id': id, 'amount': amount, 'type': type, 'categoryId': categoryId, 'date': date.millisecondsSinceEpoch, 'note': note, 'createdAt': createdAt.millisecondsSinceEpoch, 'updatedAt': updatedAt.millisecondsSinceEpoch, }; } factory TransactionModel.fromMap(Map map) { return TransactionModel( id: map['id'], amount: map['amount'], type: map['type'], categoryId: map['categoryId'], date: DateTime.fromMillisecondsSinceEpoch(map['date']), note: map['note'], createdAt: DateTime.fromMillisecondsSinceEpoch(map['createdAt']), updatedAt: DateTime.fromMillisecondsSinceEpoch(map['updatedAt']), ); } }