Implement Maestro E2E Tests for Mobile Happy Paths & Document #572
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// ignore_for_file: always_specify_types, depend_on_referenced_packages, dead_code, dead_null_aware_expression, unused_local_variable, unused_import, sort_constructors_first, prefer_final_fields, prefer_const_constructors, deprecated_member_use, implicit_call_tearoffs
|
||||
// ignore_for_file: always_specify_types, depend_on_referenced_packages, dead_code, dead_null_aware_expression, unused_local_variable, unused_import, sort_constructors_first, prefer_final_fields, prefer_const_constructors, deprecated_member_use, implicit_call_tearoffs
|
||||
import 'package:firebase_data_connect/src/core/ref.dart';
|
||||
import 'package:krow_data_connect/krow_data_connect.dart' as dc;
|
||||
import 'package:krow_domain/krow_domain.dart';
|
||||
@@ -247,51 +247,59 @@ class BillingConnectorRepositoryImpl implements BillingConnectorRepository {
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
// Fallback: If roles is empty, try to get workers from shift applications
|
||||
else if (invoice.shift != null &&
|
||||
invoice.shift.applications_on_shift != null) {
|
||||
final List<dynamic> apps = invoice.shift.applications_on_shift;
|
||||
workers = apps.map((dynamic app) {
|
||||
final String name = app.staff?.fullName ?? 'Unknown';
|
||||
final String roleTitle = app.shiftRole?.role?.name ?? 'Staff';
|
||||
final double amount =
|
||||
(app.shiftRole?.totalValue as num?)?.toDouble() ?? 0.0;
|
||||
final double hours = (app.shiftRole?.hours as num?)?.toDouble() ?? 0.0;
|
||||
// Fallback: If roles is empty, try to get workers from shift applications.
|
||||
// Only when the invoice type has a 'shift' field (e.g. getInvoiceById); listInvoicesByBusinessId
|
||||
// generated type has shiftId but no shift getter, so we guard with try/catch.
|
||||
else {
|
||||
try {
|
||||
final dynamic shift = (invoice as dynamic).shift;
|
||||
if (shift != null && shift.applications_on_shift != null) {
|
||||
final List<dynamic> apps = shift.applications_on_shift;
|
||||
workers = apps.map((dynamic app) {
|
||||
final String name = app.staff?.fullName ?? 'Unknown';
|
||||
final String roleTitle = app.shiftRole?.role?.name ?? 'Staff';
|
||||
final double amount =
|
||||
(app.shiftRole?.totalValue as num?)?.toDouble() ?? 0.0;
|
||||
final double hours = (app.shiftRole?.hours as num?)?.toDouble() ?? 0.0;
|
||||
|
||||
// Calculate rate if not explicitly provided
|
||||
double rate = 0.0;
|
||||
if (hours > 0) {
|
||||
rate = amount / hours;
|
||||
// Calculate rate if not explicitly provided
|
||||
double rate = 0.0;
|
||||
if (hours > 0) {
|
||||
rate = amount / hours;
|
||||
}
|
||||
|
||||
// Map break type to minutes
|
||||
int breakMin = 0;
|
||||
final String? breakType = app.shiftRole?.breakType?.toString();
|
||||
if (breakType != null) {
|
||||
if (breakType.contains('10'))
|
||||
breakMin = 10;
|
||||
else if (breakType.contains('15'))
|
||||
breakMin = 15;
|
||||
else if (breakType.contains('30'))
|
||||
breakMin = 30;
|
||||
else if (breakType.contains('45'))
|
||||
breakMin = 45;
|
||||
else if (breakType.contains('60'))
|
||||
breakMin = 60;
|
||||
}
|
||||
|
||||
return InvoiceWorker(
|
||||
name: name,
|
||||
role: roleTitle,
|
||||
amount: amount,
|
||||
hours: hours,
|
||||
rate: rate,
|
||||
checkIn: _service.toDateTime(app.checkInTime),
|
||||
checkOut: _service.toDateTime(app.checkOutTime),
|
||||
breakMinutes: breakMin,
|
||||
avatarUrl: app.staff?.photoUrl,
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
// Map break type to minutes
|
||||
int breakMin = 0;
|
||||
final String? breakType = app.shiftRole?.breakType?.toString();
|
||||
if (breakType != null) {
|
||||
if (breakType.contains('10'))
|
||||
breakMin = 10;
|
||||
else if (breakType.contains('15'))
|
||||
breakMin = 15;
|
||||
else if (breakType.contains('30'))
|
||||
breakMin = 30;
|
||||
else if (breakType.contains('45'))
|
||||
breakMin = 45;
|
||||
else if (breakType.contains('60'))
|
||||
breakMin = 60;
|
||||
}
|
||||
|
||||
return InvoiceWorker(
|
||||
name: name,
|
||||
role: roleTitle,
|
||||
amount: amount,
|
||||
hours: hours,
|
||||
rate: rate,
|
||||
checkIn: _service.toDateTime(app.checkInTime),
|
||||
checkOut: _service.toDateTime(app.checkOutTime),
|
||||
breakMinutes: breakMin,
|
||||
avatarUrl: app.staff?.photoUrl,
|
||||
);
|
||||
}).toList();
|
||||
} catch (_) {
|
||||
// Invoice type has no 'shift' getter (e.g. ListInvoicesByBusinessIdInvoices). Skip.
|
||||
}
|
||||
}
|
||||
|
||||
return Invoice(
|
||||
|
||||
Reference in New Issue
Block a user