feat: Refactor code structure and optimize performance across multiple modules

This commit is contained in:
Achintha Isuru
2025-11-17 23:29:28 -05:00
parent 831570f2e0
commit a64cbd9edf
1508 changed files with 105319 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
class EarningDisputeInfo {
String reason = '';
String details = '';
}

View File

@@ -0,0 +1,64 @@
class EarningShiftEntity {
final String id;
final EarningStatus status;
final String businessImageUrl;
final String skillName;
final String businessName;
final int? totalBreakTime;
final int? paymentStatus;
final double? earned;
final DateTime? clockIn;
final DateTime? clockOut;
final String eventName;
final DateTime eventDate;
EarningShiftEntity({
required this.id,
required this.status,
required this.businessImageUrl,
required this.skillName,
required this.businessName,
required this.totalBreakTime,
required this.paymentStatus,
required this.earned,
required this.clockIn,
required this.clockOut,
required this.eventName,
required this.eventDate,
});
int get paymentProgressStep {
return switch (status) {
EarningStatus.pending => 0, // corresponds to Pending Sent
EarningStatus.processing => 1, // corresponds to Pending Payment
EarningStatus.paid => 2, // corresponds to Payment Received
_ => -1, // don't show active step
};
}
}
enum EarningStatus {
new_,
pending,
confirmedByAdmin,
confirmedByStaff,
declineByStaff,
processing,
paid,
failed,
canceled;
static EarningStatus fromString(value) {
return switch (value) {
'new' => new_,
'confirmed_by_admin' => confirmedByAdmin,
'confirmed_by_staff' => confirmedByStaff,
'decline_by_staff' => declineByStaff,
'pending' => pending,
'paid' => paid,
'failed' => failed,
'canceled' => canceled,
_ => canceled,
};
}
}

View File

@@ -0,0 +1,15 @@
import 'package:krow/features/earning/domain/entities/earning_shift_entity.dart';
class EarningsBatchEntity {
EarningsBatchEntity({
required this.batchStatus,
required this.hasNextBatch,
required this.earnings,
this.cursor,
});
final String batchStatus;
final bool hasNextBatch;
final List<EarningShiftEntity> earnings;
final String? cursor;
}

View File

@@ -0,0 +1,69 @@
import 'package:flutter/foundation.dart';
@immutable
class EarningsSummaryEntity {
const EarningsSummaryEntity({
required this.totalEarningsByWeek,
required this.totalEarningsByMonth,
required this.totalWorkedHoursByWeek,
required this.totalWorkedHoursByMonth,
required this.payoutByWeek,
required this.payoutByMonth,
required this.startDatePeriod,
required this.endDatePeriod,
required this.maxEarningInPeriod,
required this.minEarningInPeriod,
});
const EarningsSummaryEntity.empty({
this.totalEarningsByWeek = 0,
this.totalEarningsByMonth = 0,
this.totalWorkedHoursByWeek = 0,
this.totalWorkedHoursByMonth = 0,
this.payoutByWeek = 0,
this.payoutByMonth = 0,
this.startDatePeriod,
this.endDatePeriod,
this.maxEarningInPeriod = 0,
this.minEarningInPeriod = 0,
});
final double totalEarningsByWeek;
final double totalEarningsByMonth;
final double totalWorkedHoursByWeek;
final double totalWorkedHoursByMonth;
final double payoutByWeek;
final double payoutByMonth;
final DateTime? startDatePeriod;
final DateTime? endDatePeriod;
final int maxEarningInPeriod;
final int minEarningInPeriod;
EarningsSummaryEntity copyWith({
double? totalEarningsByWeek,
double? totalEarningsByMonth,
double? totalWorkedHoursByWeek,
double? totalWorkedHoursByMonth,
double? payoutByWeek,
double? payoutByMonth,
DateTime? startDatePeriod,
DateTime? endDatePeriod,
int? maxEarningInPeriod,
int? minEarningInPeriod,
}) {
return EarningsSummaryEntity(
totalEarningsByWeek: totalEarningsByWeek ?? this.totalEarningsByWeek,
totalEarningsByMonth: totalEarningsByMonth ?? this.totalEarningsByMonth,
totalWorkedHoursByWeek:
totalWorkedHoursByWeek ?? this.totalWorkedHoursByWeek,
totalWorkedHoursByMonth:
totalWorkedHoursByMonth ?? this.totalWorkedHoursByMonth,
payoutByWeek: payoutByWeek ?? this.payoutByWeek,
payoutByMonth: payoutByMonth ?? this.payoutByMonth,
startDatePeriod: startDatePeriod,
endDatePeriod: endDatePeriod,
maxEarningInPeriod: maxEarningInPeriod ?? this.maxEarningInPeriod,
minEarningInPeriod: minEarningInPeriod ?? this.minEarningInPeriod,
);
}
}