feat: dukung penjualan produk per timbangan
Produk kini punya cara jual `unit` (cacah) atau `weight` (timbangan), mengikuti kontrak backend di docs/integration-weight-based-products.md. - tipe SellBy, domain/infrastructure unit baru, dan endpoint /api/v1/units - dialog input berat saat produk timbangan ditambahkan ke keranjang - tiap penimbangan jadi baris keranjang sendiri; total baris dihitung berat x harga satuan, sedangkan produk cacah tetap digabung - request ke backend mengirim quantity 1 dan membawa berat - migrasi DB v3: kolom sell_by, unit_id, unit_name, unit_abbreviation di tabel products supaya satuan tetap tampil saat offline - tampilan keranjang, struk, split bill, void, dan refund memakai berat - test/weight_based_products_test.dart menutup perilaku di atas (9 test) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -33,6 +33,10 @@ class OrderItemRequest with _$OrderItemRequest {
|
||||
required int quantity,
|
||||
required int unitPrice,
|
||||
required String notes,
|
||||
|
||||
/// Hanya diisi untuk produk `sell_by: "weight"`; produk cacah tidak boleh
|
||||
/// mengirim berat sama sekali.
|
||||
double? weight,
|
||||
}) = _OrderItemRequest;
|
||||
|
||||
factory OrderItemRequest.empty() => const OrderItemRequest(
|
||||
@@ -42,4 +46,16 @@ class OrderItemRequest with _$OrderItemRequest {
|
||||
unitPrice: 0,
|
||||
notes: '',
|
||||
);
|
||||
|
||||
/// 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,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user