toDTO static method
Implementation
static OrderFirestoreDTO toDTO(Order order) {
return OrderFirestoreDTO(
id: order.orderId,
customerId: order.customerId,
items: order.items
.map(
(item) => OrderItemDTO(
productId: item.productId,
quantity: item.quantity.toInt(),
unit: item.unit.name,
type: item.productType.name,
unitPrice: item.unitPrice.amount,
currency: item.unitPrice.currency,
),
)
.toList(),
totalAmount: order.totalAmount.asDouble, // Storing for query purposes
status: order.status.name,
placedAt: order.createdAt,
timeSlot: {
'startHour': order.timeSlot.startHour,
'endHour': order.timeSlot.endHour,
'startMinute': order.timeSlot.startMinute,
'endMinute': order.timeSlot.endMinute,
},
);
}