attendence records, extra hours , rewards and punishment funnctionality have been added

This commit is contained in:
Daniah Ayad Al-sultani
2026-02-10 16:27:08 +03:00
parent cd7ba8e9d5
commit 1002937045
25 changed files with 1048 additions and 181 deletions

View File

@@ -0,0 +1,45 @@
class AttendanceRecordDto {
final String id;
final String employeeId;
final DateTime? login;
final DateTime? logout;
final String? reason;
final DateTime? createdAt;
final bool isDeleted;
AttendanceRecordDto({
required this.id,
required this.employeeId,
this.login,
this.logout,
this.reason,
this.createdAt,
required this.isDeleted,
});
factory AttendanceRecordDto.fromJson(Map<String, dynamic> json) {
return AttendanceRecordDto(
id: json['id']?.toString() ?? '',
employeeId: json['employeeId']?.toString() ?? '',
login: _parseDateTime(json['login']),
logout: _parseDateTime(json['logout']),
reason: json['reason'],
createdAt: _parseDateTime(json['createdAt']),
isDeleted: json['isDeleted'] ?? false,
);
}
static DateTime? _parseDateTime(dynamic value) {
if (value == null) return null;
if (value is DateTime) return value;
if (value is String) {
if (value.isEmpty) return null;
try {
return DateTime.parse(value);
} catch (e) {
return null; // Handle parse error gracefully
}
}
return null;
}
}

View File

@@ -0,0 +1,49 @@
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(),
);
}
}

View File

@@ -0,0 +1,46 @@
class OvertimeDto {
final String id;
final DateTime date;
final double hours;
final double hourlyRateAtTheTime;
final String employeeId;
final bool isDeleted;
OvertimeDto({
required this.id,
required this.employeeId,
required this.date,
required this.hours,
required this.hourlyRateAtTheTime,
required this.isDeleted,
});
factory OvertimeDto.fromJson(Map<String, dynamic> json) {
return OvertimeDto(
id: json['id']?.toString() ?? '',
date: DateTime.parse(json['date']),
hours: (json['hours'] as num?)?.toDouble() ?? 0.0,
hourlyRateAtTheTime:
(json['hourlyRateAtTheTime'] as num?)?.toDouble() ?? 0.0,
employeeId: json['employeeId']?.toString() ?? '',
isDeleted: json['isDeleted'] ?? false,
);
}
}
class OvertimeListResponseDto {
final List<OvertimeDto> items;
OvertimeListResponseDto({required this.items});
factory OvertimeListResponseDto.fromJson(Map<String, dynamic> json) {
final data = json['data'];
if (data == null || data is! Map<String, dynamic>) {
return OvertimeListResponseDto(items: []);
}
final itemsJson = data['items'] as List? ?? [];
return OvertimeListResponseDto(
items: itemsJson.map((e) => OvertimeDto.fromJson(e)).toList(),
);
}
}

View 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(),
);
}
}

View File

@@ -0,0 +1,46 @@
class RewardDto {
final String id;
final DateTime date;
final double amount;
final String? reason;
final String? note;
final String employeeId;
RewardDto({
required this.id,
required this.date,
required this.amount,
this.reason,
this.note,
required this.employeeId,
});
factory RewardDto.fromJson(Map<String, dynamic> json) {
return RewardDto(
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 RewardListResponseDto {
final List<RewardDto> items;
RewardListResponseDto({required this.items});
factory RewardListResponseDto.fromJson(Map<String, dynamic> json) {
final data = json['data'];
if (data == null || data is! Map<String, dynamic>) {
return RewardListResponseDto(items: []);
}
final itemsJson = data['items'] as List? ?? [];
return RewardListResponseDto(
items: itemsJson.map((e) => RewardDto.fromJson(e)).toList(),
);
}
}