Add the Income and Asset classes.
This commit is contained in:
parent
0aa8fdf271
commit
fcf4fca33b
19
lib/models/asset.dart
Normal file
19
lib/models/asset.dart
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import '/models/tracked_type.dart';
|
||||||
|
|
||||||
|
class Asset extends TrackedType {
|
||||||
|
static String amountText = "Amount";
|
||||||
|
|
||||||
|
Asset({
|
||||||
|
super.id,
|
||||||
|
required super.name,
|
||||||
|
required super.amount,
|
||||||
|
required super.description,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Asset.fromMap(Map<String, dynamic> json) => Asset(
|
||||||
|
id: json['id'],
|
||||||
|
name: json['name'],
|
||||||
|
amount: json['amount'],
|
||||||
|
description: json['description'],
|
||||||
|
);
|
||||||
|
}
|
35
lib/models/income.dart
Normal file
35
lib/models/income.dart
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import '/models/recurring_tracked_type.dart';
|
||||||
|
import '/models/frequency.dart';
|
||||||
|
|
||||||
|
class Income extends RecurringTrackedType {
|
||||||
|
static String amountText = "Revenue";
|
||||||
|
|
||||||
|
Income({
|
||||||
|
super.id,
|
||||||
|
required super.name,
|
||||||
|
required super.amount,
|
||||||
|
required super.frequency,
|
||||||
|
required super.description,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Income.fromMap(Map<String, dynamic> json) => Income(
|
||||||
|
id: json['id'],
|
||||||
|
name: json['name'],
|
||||||
|
amount: json['revenue'],
|
||||||
|
frequency: Frequency.values
|
||||||
|
.where((freq) => freq.title == json['frequency'])
|
||||||
|
.first,
|
||||||
|
description: json['description'],
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toMap() {
|
||||||
|
return {
|
||||||
|
'id': id,
|
||||||
|
'name': name,
|
||||||
|
'revenue': amount,
|
||||||
|
'frequency': frequency.title,
|
||||||
|
'description': description,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user