71 lines
1.7 KiB
Dart
71 lines
1.7 KiB
Dart
class DashboardMonthlyExpenseResponse {
|
|
final bool success;
|
|
final String message;
|
|
final List<MonthlyExpenseData> data;
|
|
final dynamic errors;
|
|
final int statusCode;
|
|
final String timestamp;
|
|
|
|
DashboardMonthlyExpenseResponse({
|
|
required this.success,
|
|
required this.message,
|
|
required this.data,
|
|
this.errors,
|
|
required this.statusCode,
|
|
required this.timestamp,
|
|
});
|
|
|
|
factory DashboardMonthlyExpenseResponse.fromJson(Map<String, dynamic> json) {
|
|
return DashboardMonthlyExpenseResponse(
|
|
success: json['success'] ?? false,
|
|
message: json['message'] ?? '',
|
|
data: (json['data'] as List<dynamic>?)
|
|
?.map((e) => MonthlyExpenseData.fromJson(e))
|
|
.toList() ??
|
|
[],
|
|
errors: json['errors'],
|
|
statusCode: json['statusCode'] ?? 0,
|
|
timestamp: json['timestamp'] ?? '',
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'success': success,
|
|
'message': message,
|
|
'data': data.map((e) => e.toJson()).toList(),
|
|
'errors': errors,
|
|
'statusCode': statusCode,
|
|
'timestamp': timestamp,
|
|
};
|
|
}
|
|
|
|
class MonthlyExpenseData {
|
|
final String monthName;
|
|
final int year;
|
|
final double total;
|
|
final int count;
|
|
|
|
MonthlyExpenseData({
|
|
required this.monthName,
|
|
required this.year,
|
|
required this.total,
|
|
required this.count,
|
|
});
|
|
|
|
factory MonthlyExpenseData.fromJson(Map<String, dynamic> json) {
|
|
return MonthlyExpenseData(
|
|
monthName: json['monthName'] ?? '',
|
|
year: json['year'] ?? 0,
|
|
total: (json['total'] ?? 0).toDouble(),
|
|
count: json['count'] ?? 0,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'monthName': monthName,
|
|
'year': year,
|
|
'total': total,
|
|
'count': count,
|
|
};
|
|
}
|