feat: Add additional fields to OrderItem and update cost calculation in ViewOrderCard
This commit is contained in:
@@ -26,6 +26,16 @@ class OrderItem extends Equatable {
|
|||||||
this.locationName,
|
this.locationName,
|
||||||
required this.status,
|
required this.status,
|
||||||
this.workers = const <AssignedWorkerSummary>[],
|
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.
|
/// Deserialises an [OrderItem] from a V2 API JSON map.
|
||||||
@@ -53,6 +63,16 @@ class OrderItem extends Equatable {
|
|||||||
locationName: json['locationName'] as String?,
|
locationName: json['locationName'] as String?,
|
||||||
status: ShiftStatus.fromJson(json['status'] as String?),
|
status: ShiftStatus.fromJson(json['status'] as String?),
|
||||||
workers: workersList,
|
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.
|
/// Assigned workers for this line item.
|
||||||
final List<AssignedWorkerSummary> workers;
|
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.
|
/// Serialises this [OrderItem] to a JSON map.
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
return <String, dynamic>{
|
return <String, dynamic>{
|
||||||
@@ -115,6 +165,16 @@ class OrderItem extends Equatable {
|
|||||||
'locationName': locationName,
|
'locationName': locationName,
|
||||||
'status': status.toJson(),
|
'status': status.toJson(),
|
||||||
'workers': workers.map((AssignedWorkerSummary w) => w.toJson()).toList(),
|
'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,
|
locationName,
|
||||||
status,
|
status,
|
||||||
workers,
|
workers,
|
||||||
|
eventName,
|
||||||
|
clientName,
|
||||||
|
hourlyRate,
|
||||||
|
hours,
|
||||||
|
totalValue,
|
||||||
|
locationAddress,
|
||||||
|
startTime,
|
||||||
|
endTime,
|
||||||
|
hubManagerId,
|
||||||
|
hubManagerName,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,7 +123,9 @@ class _ViewOrderCardState extends State<ViewOrderCard> {
|
|||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
final double hours = _computeHours(order);
|
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(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
|||||||
Reference in New Issue
Block a user