feat: Add additional fields to OrderItem and update cost calculation in ViewOrderCard

This commit is contained in:
Achintha Isuru
2026-03-19 23:55:57 -04:00
parent 4cd83a9281
commit 1e4c8982a5
2 changed files with 73 additions and 1 deletions

View File

@@ -26,6 +26,16 @@ class OrderItem extends Equatable {
this.locationName,
required this.status,
this.workers = const <AssignedWorkerSummary>[],
this.eventName = '',
this.clientName = '',
this.hourlyRate = 0.0,
this.hours = 0.0,
this.totalValue = 0.0,
this.locationAddress,
this.startTime,
this.endTime,
this.hubManagerId,
this.hubManagerName,
});
/// Deserialises an [OrderItem] from a V2 API JSON map.
@@ -53,6 +63,16 @@ class OrderItem extends Equatable {
locationName: json['locationName'] as String?,
status: ShiftStatus.fromJson(json['status'] as String?),
workers: workersList,
eventName: json['eventName'] as String? ?? '',
clientName: json['clientName'] as String? ?? '',
hourlyRate: (json['hourlyRate'] as num?)?.toDouble() ?? 0.0,
hours: (json['hours'] as num?)?.toDouble() ?? 0.0,
totalValue: (json['totalValue'] as num?)?.toDouble() ?? 0.0,
locationAddress: json['locationAddress'] as String?,
startTime: json['startTime'] as String?,
endTime: json['endTime'] as String?,
hubManagerId: json['hubManagerId'] as String?,
hubManagerName: json['hubManagerName'] as String?,
);
}
@@ -98,6 +118,36 @@ class OrderItem extends Equatable {
/// Assigned workers for this line item.
final List<AssignedWorkerSummary> workers;
/// Event/order name.
final String eventName;
/// Client/business name.
final String clientName;
/// Billing rate in dollars per hour.
final double hourlyRate;
/// Duration of the shift in fractional hours.
final double hours;
/// Total cost in dollars (rate x workers x hours).
final double totalValue;
/// Full street address of the location.
final String? locationAddress;
/// Display start time string (HH:MM UTC).
final String? startTime;
/// Display end time string (HH:MM UTC).
final String? endTime;
/// Hub manager's business membership ID.
final String? hubManagerId;
/// Hub manager's display name.
final String? hubManagerName;
/// Serialises this [OrderItem] to a JSON map.
Map<String, dynamic> toJson() {
return <String, dynamic>{
@@ -115,6 +165,16 @@ class OrderItem extends Equatable {
'locationName': locationName,
'status': status.toJson(),
'workers': workers.map((AssignedWorkerSummary w) => w.toJson()).toList(),
'eventName': eventName,
'clientName': clientName,
'hourlyRate': hourlyRate,
'hours': hours,
'totalValue': totalValue,
'locationAddress': locationAddress,
'startTime': startTime,
'endTime': endTime,
'hubManagerId': hubManagerId,
'hubManagerName': hubManagerName,
};
}
@@ -134,5 +194,15 @@ class OrderItem extends Equatable {
locationName,
status,
workers,
eventName,
clientName,
hourlyRate,
hours,
totalValue,
locationAddress,
startTime,
endTime,
hubManagerId,
hubManagerName,
];
}

View File

@@ -123,7 +123,9 @@ class _ViewOrderCardState extends State<ViewOrderCard> {
: 0;
final double hours = _computeHours(order);
final double cost = order.totalCostCents / 100.0;
final double cost = order.totalValue > 0
? order.totalValue
: order.totalCostCents / 100.0;
return Container(
decoration: BoxDecoration(