attendence records, extra hours , rewards and punishment funnctionality have been added
This commit is contained in:
46
lib/data/dto/punishment_dto.dart
Normal file
46
lib/data/dto/punishment_dto.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
class PunishmentDto {
|
||||
final String id;
|
||||
final DateTime date;
|
||||
final double amount;
|
||||
final String? reason;
|
||||
final String? note;
|
||||
final String employeeId;
|
||||
|
||||
PunishmentDto({
|
||||
required this.id,
|
||||
required this.date,
|
||||
required this.amount,
|
||||
this.reason,
|
||||
this.note,
|
||||
required this.employeeId,
|
||||
});
|
||||
|
||||
factory PunishmentDto.fromJson(Map<String, dynamic> json) {
|
||||
return PunishmentDto(
|
||||
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() ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class PunishmentListResponseDto {
|
||||
final List<PunishmentDto> items;
|
||||
|
||||
PunishmentListResponseDto({required this.items});
|
||||
|
||||
factory PunishmentListResponseDto.fromJson(Map<String, dynamic> json) {
|
||||
final data = json['data'];
|
||||
if (data == null || data is! Map<String, dynamic>) {
|
||||
return PunishmentListResponseDto(items: []);
|
||||
}
|
||||
final itemsJson = data['items'] as List? ?? [];
|
||||
return PunishmentListResponseDto(
|
||||
items: itemsJson.map((e) => PunishmentDto.fromJson(e)).toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user