feat: integrate TimeCard feature with Firebase support and restructure related components
This commit is contained in:
@@ -45,6 +45,7 @@ export 'src/entities/skills/skill_kit.dart';
|
||||
|
||||
// Financial & Payroll
|
||||
export 'src/entities/financial/invoice.dart';
|
||||
export 'src/entities/financial/time_card.dart';
|
||||
export 'src/entities/financial/invoice_item.dart';
|
||||
export 'src/entities/financial/invoice_decline.dart';
|
||||
export 'src/entities/financial/staff_payment.dart';
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import '../../entities/financial/time_card.dart';
|
||||
|
||||
/// Adapter for [TimeCard] to map data layer values to domain entity.
|
||||
class TimeCardAdapter {
|
||||
/// Maps primitive values to [TimeCard].
|
||||
static TimeCard fromPrimitives({
|
||||
required String id,
|
||||
required String shiftTitle,
|
||||
required String clientName,
|
||||
required DateTime date,
|
||||
required String startTime,
|
||||
required String endTime,
|
||||
required double totalHours,
|
||||
required double hourlyRate,
|
||||
required double totalPay,
|
||||
required String status,
|
||||
String? location,
|
||||
}) {
|
||||
return TimeCard(
|
||||
id: id,
|
||||
shiftTitle: shiftTitle,
|
||||
clientName: clientName,
|
||||
date: date,
|
||||
startTime: startTime,
|
||||
endTime: endTime,
|
||||
totalHours: totalHours,
|
||||
hourlyRate: hourlyRate,
|
||||
totalPay: totalPay,
|
||||
status: _stringToStatus(status),
|
||||
location: location,
|
||||
);
|
||||
}
|
||||
|
||||
static TimeCardStatus _stringToStatus(String status) {
|
||||
switch (status.toUpperCase()) {
|
||||
case 'CHECKED_OUT':
|
||||
case 'COMPLETED':
|
||||
return TimeCardStatus.approved; // Assuming completed = approved for now
|
||||
case 'PAID':
|
||||
return TimeCardStatus.paid; // If this status exists
|
||||
case 'DISPUTED':
|
||||
return TimeCardStatus.disputed;
|
||||
case 'CHECKED_IN':
|
||||
case 'ACCEPTED':
|
||||
case 'CONFIRMED':
|
||||
default:
|
||||
return TimeCardStatus.pending;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Status of a time card.
|
||||
enum TimeCardStatus {
|
||||
/// Waiting for approval or payment.
|
||||
pending,
|
||||
/// Approved by manager.
|
||||
approved,
|
||||
/// Payment has been issued.
|
||||
paid,
|
||||
/// Disputed by staff or client.
|
||||
disputed;
|
||||
|
||||
/// Whether the card is approved.
|
||||
bool get isApproved => this == TimeCardStatus.approved;
|
||||
/// Whether the card is paid.
|
||||
bool get isPaid => this == TimeCardStatus.paid;
|
||||
/// Whether the card is disputed.
|
||||
bool get isDisputed => this == TimeCardStatus.disputed;
|
||||
/// Whether the card is pending.
|
||||
bool get isPending => this == TimeCardStatus.pending;
|
||||
}
|
||||
|
||||
/// Represents a time card for a staff member.
|
||||
class TimeCard extends Equatable {
|
||||
/// Unique identifier of the time card (often matches Application ID).
|
||||
final String id;
|
||||
/// Title of the shift.
|
||||
final String shiftTitle;
|
||||
/// Name of the client business.
|
||||
final String clientName;
|
||||
/// Date of the shift.
|
||||
final DateTime date;
|
||||
/// Actual or scheduled start time.
|
||||
final String startTime;
|
||||
/// Actual or scheduled end time.
|
||||
final String endTime;
|
||||
/// Total hours worked.
|
||||
final double totalHours;
|
||||
/// Hourly pay rate.
|
||||
final double hourlyRate;
|
||||
/// Total pay amount.
|
||||
final double totalPay;
|
||||
/// Current status of the time card.
|
||||
final TimeCardStatus status;
|
||||
/// Location name.
|
||||
final String? location;
|
||||
|
||||
/// Creates a [TimeCard].
|
||||
const TimeCard({
|
||||
required this.id,
|
||||
required this.shiftTitle,
|
||||
required this.clientName,
|
||||
required this.date,
|
||||
required this.startTime,
|
||||
required this.endTime,
|
||||
required this.totalHours,
|
||||
required this.hourlyRate,
|
||||
required this.totalPay,
|
||||
required this.status,
|
||||
this.location,
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
shiftTitle,
|
||||
clientName,
|
||||
date,
|
||||
startTime,
|
||||
endTime,
|
||||
totalHours,
|
||||
hourlyRate,
|
||||
totalPay,
|
||||
status,
|
||||
location,
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user