Files
Kifi/kifi-app/lib/features/projects/domain/project.dart

48 lines
1.1 KiB
Dart

class Project {
final int id;
final String name;
final String? description;
final int? customerId;
final int? userId;
final double budget;
final String status;
final DateTime? createdAt;
Project({
required this.id,
required this.name,
this.description,
this.customerId,
this.userId,
this.budget = 0.0,
this.status = 'ACTIVE',
this.createdAt,
});
factory Project.fromJson(Map<String, dynamic> json) {
return Project(
id: json['id'] as int,
name: json['name'] as String,
description: json['description'] as String?,
customerId: json['customerId'] as int?,
userId: json['userId'] as int?,
budget: (json['budget'] as num?)?.toDouble() ?? 0.0,
status: json['status'] as String? ?? 'ACTIVE',
createdAt: json['createdAt'] != null ? DateTime.parse(json['createdAt']) : null,
);
}
Map<String, dynamic> toJson() {
return {
'id': id,
'name': name,
'description': description,
'customerId': customerId,
'userId': userId,
'budget': budget,
'status': status,
'createdAt': createdAt?.toIso8601String(),
};
}
}