Added working edit transaction
This commit is contained in:
@@ -14,18 +14,25 @@ class Transaction {
|
||||
const Transaction({
|
||||
this.id,
|
||||
required this.amount,
|
||||
required this.transactionType,
|
||||
required this.type,
|
||||
required this.budgetId,
|
||||
required this.budgetCategoryId,
|
||||
this.budgetCategoryId,
|
||||
required this.addedByUserId,
|
||||
required this.date,
|
||||
this.memo,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
this.hide = false,
|
||||
});
|
||||
|
||||
final int? id;
|
||||
final int budgetId, budgetCategoryId, addedByUserId;
|
||||
final int? id, budgetCategoryId;
|
||||
final int budgetId, addedByUserId;
|
||||
final double amount;
|
||||
final TransactionType transactionType;
|
||||
final String? memo;
|
||||
final TransactionType type;
|
||||
|
||||
@JsonKey(fromJson: boolFromJson, toJson: boolToJson)
|
||||
final bool hide;
|
||||
|
||||
@JsonKey(fromJson: dateFromJson, toJson: dateToJson)
|
||||
final DateTime date;
|
||||
@@ -33,8 +40,26 @@ class Transaction {
|
||||
@JsonKey(fromJson: dateFromJson, toJson: dateToJson)
|
||||
final DateTime? createdAt;
|
||||
|
||||
@JsonKey(fromJson: dateFromJson, toJson: dateToJson)
|
||||
final DateTime? updatedAt;
|
||||
|
||||
factory Transaction.fromJson(Map<String, dynamic> json) =>
|
||||
_$TransactionFromJson(json);
|
||||
|
||||
factory Transaction.copyWith(Transaction trans, Map<String, dynamic> data) =>
|
||||
Transaction(
|
||||
id: data['id'] ?? trans.id,
|
||||
amount: data['amount'] ?? trans.amount,
|
||||
type: data['type'] ?? trans.type,
|
||||
budgetId: data['budget_id'] ?? trans.budgetId,
|
||||
budgetCategoryId: data['budget_category_id'] ?? trans.budgetCategoryId,
|
||||
addedByUserId: data['added_by_user_id'] ?? trans.addedByUserId,
|
||||
date: data['date'] ?? trans.date,
|
||||
memo: data['memo'] ?? trans.memo,
|
||||
createdAt: data['created_at'] ?? trans.createdAt,
|
||||
updatedAt: data['updated_at'] ?? trans.updatedAt,
|
||||
hide: data['hide'] ?? trans.hide,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => _$TransactionToJson(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user