59 lines
1.9 KiB
Dart
59 lines
1.9 KiB
Dart
import '../utils/app_time.dart';
|
|
|
|
class AttendanceLog {
|
|
AttendanceLog({
|
|
required this.id,
|
|
required this.userId,
|
|
required this.dutyScheduleId,
|
|
required this.shiftType,
|
|
required this.checkInAt,
|
|
required this.checkInLat,
|
|
required this.checkInLng,
|
|
this.checkOutAt,
|
|
this.checkOutLat,
|
|
this.checkOutLng,
|
|
this.justification,
|
|
this.verificationStatus = 'pending',
|
|
this.verificationPhotoUrl,
|
|
});
|
|
|
|
final String id;
|
|
final String userId;
|
|
final String dutyScheduleId;
|
|
final String shiftType;
|
|
final DateTime checkInAt;
|
|
final double checkInLat;
|
|
final double checkInLng;
|
|
final DateTime? checkOutAt;
|
|
final double? checkOutLat;
|
|
final double? checkOutLng;
|
|
final String? justification;
|
|
final String verificationStatus; // pending, verified, unverified, skipped
|
|
final String? verificationPhotoUrl;
|
|
|
|
bool get isCheckedOut => checkOutAt != null;
|
|
bool get isVerified => verificationStatus == 'verified';
|
|
bool get isUnverified =>
|
|
verificationStatus == 'unverified' || verificationStatus == 'skipped';
|
|
|
|
factory AttendanceLog.fromMap(Map<String, dynamic> map) {
|
|
return AttendanceLog(
|
|
id: map['id'] as String,
|
|
userId: map['user_id'] as String,
|
|
dutyScheduleId: map['duty_schedule_id'] as String,
|
|
shiftType: map['shift_type'] as String? ?? 'normal',
|
|
checkInAt: AppTime.parse(map['check_in_at'] as String),
|
|
checkInLat: (map['check_in_lat'] as num).toDouble(),
|
|
checkInLng: (map['check_in_lng'] as num).toDouble(),
|
|
checkOutAt: map['check_out_at'] == null
|
|
? null
|
|
: AppTime.parse(map['check_out_at'] as String),
|
|
checkOutLat: (map['check_out_lat'] as num?)?.toDouble(),
|
|
checkOutLng: (map['check_out_lng'] as num?)?.toDouble(),
|
|
justification: map['justification'] as String?,
|
|
verificationStatus: map['verification_status'] as String? ?? 'pending',
|
|
verificationPhotoUrl: map['verification_photo_url'] as String?,
|
|
);
|
|
}
|
|
}
|