2025-10-28 00:08:12 +07:00
|
|
|
part of '../order.dart';
|
|
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
|
class OrderRequest with _$OrderRequest {
|
|
|
|
|
const factory OrderRequest({
|
|
|
|
|
required String outletId,
|
|
|
|
|
required String customerId,
|
|
|
|
|
required String tableNumber,
|
|
|
|
|
required String tableId,
|
|
|
|
|
required String orderType,
|
|
|
|
|
required String notes,
|
|
|
|
|
required List<OrderItemRequest> orderItems,
|
|
|
|
|
required String customerName,
|
|
|
|
|
}) = _OrderRequest;
|
|
|
|
|
|
|
|
|
|
factory OrderRequest.empty() => const OrderRequest(
|
|
|
|
|
outletId: '',
|
|
|
|
|
customerId: '',
|
|
|
|
|
tableNumber: '',
|
|
|
|
|
tableId: '',
|
|
|
|
|
orderType: '',
|
|
|
|
|
notes: '',
|
|
|
|
|
orderItems: [],
|
|
|
|
|
customerName: '',
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
|
class OrderItemRequest with _$OrderItemRequest {
|
|
|
|
|
const factory OrderItemRequest({
|
|
|
|
|
required String productId,
|
|
|
|
|
required String productVariantId,
|
|
|
|
|
required int quantity,
|
|
|
|
|
required int unitPrice,
|
|
|
|
|
required String notes,
|
2026-09-06 23:03:31 +07:00
|
|
|
|
|
|
|
|
/// Hanya diisi untuk produk `sell_by: "weight"`; produk cacah tidak boleh
|
|
|
|
|
/// mengirim berat sama sekali.
|
|
|
|
|
double? weight,
|
2025-10-28 00:08:12 +07:00
|
|
|
}) = _OrderItemRequest;
|
|
|
|
|
|
|
|
|
|
factory OrderItemRequest.empty() => const OrderItemRequest(
|
|
|
|
|
productId: '',
|
|
|
|
|
productVariantId: '',
|
|
|
|
|
quantity: 0,
|
|
|
|
|
unitPrice: 0,
|
|
|
|
|
notes: '',
|
|
|
|
|
);
|
2026-09-06 23:03:31 +07:00
|
|
|
|
|
|
|
|
/// Bentuk baris dari isi keranjang: produk timbangan selalu `quantity: 1`
|
|
|
|
|
/// ditambah `weight`, produk cacah tetap seperti sebelumnya.
|
|
|
|
|
factory OrderItemRequest.fromProductQuantity(ProductQuantity item) =>
|
|
|
|
|
OrderItemRequest(
|
|
|
|
|
productId: item.product.id,
|
|
|
|
|
productVariantId: item.variant?.id ?? '',
|
|
|
|
|
quantity: item.isWeighted ? 1 : item.quantity,
|
|
|
|
|
unitPrice: item.product.price.toInt(),
|
|
|
|
|
notes: item.notes,
|
|
|
|
|
weight: item.weight,
|
|
|
|
|
);
|
2025-10-28 00:08:12 +07:00
|
|
|
}
|