50 lines
1.3 KiB
Dart
50 lines
1.3 KiB
Dart
class ExtraPaymentDto {
|
|
final String id;
|
|
final DateTime date;
|
|
final double amount;
|
|
final String? reason;
|
|
final String? note;
|
|
final String employeeId;
|
|
final bool isDeleted;
|
|
|
|
ExtraPaymentDto({
|
|
required this.id,
|
|
required this.date,
|
|
required this.amount,
|
|
this.reason,
|
|
this.note,
|
|
required this.employeeId,
|
|
required this.isDeleted,
|
|
});
|
|
|
|
factory ExtraPaymentDto.fromJson(Map<String, dynamic> json) {
|
|
return ExtraPaymentDto(
|
|
id: json['id']?.toString() ?? '',
|
|
date:
|
|
json['date'] != null ? DateTime.parse(json['date']) : DateTime.now(),
|
|
amount: (json['amount'] as num?)?.toDouble() ?? 0.0,
|
|
reason: json['reason'],
|
|
note: json['note'],
|
|
employeeId: json['employeeId']?.toString() ?? '',
|
|
isDeleted: json['isDeleted'] ?? false,
|
|
);
|
|
}
|
|
}
|
|
|
|
class ExtraPaymentListResponseDto {
|
|
final List<ExtraPaymentDto> items;
|
|
|
|
ExtraPaymentListResponseDto({required this.items});
|
|
|
|
factory ExtraPaymentListResponseDto.fromJson(Map<String, dynamic> json) {
|
|
final data = json['data'];
|
|
if (data == null || data is! Map<String, dynamic>) {
|
|
return ExtraPaymentListResponseDto(items: []);
|
|
}
|
|
final itemsJson = data['items'] as List? ?? [];
|
|
return ExtraPaymentListResponseDto(
|
|
items: itemsJson.map((e) => ExtraPaymentDto.fromJson(e)).toList(),
|
|
);
|
|
}
|
|
}
|