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:
@@ -77,6 +77,7 @@ class PrintUi {
|
||||
bytes += builder.orderItem(
|
||||
productName: item.productName,
|
||||
quantity: item.quantity,
|
||||
quantityLabel: item.isWeighted ? item.quantityLabel : null,
|
||||
unitPrice: item.unitPrice.currencyFormatRpV2,
|
||||
totalPrice: item.totalPrice.currencyFormatRpV2,
|
||||
variantName: item.productVariantName,
|
||||
@@ -140,7 +141,7 @@ class PrintUi {
|
||||
// Items — qty NAMA (uppercase), variant indent
|
||||
for (final item in order.orderItems.where((e) => e.printToChecker)) {
|
||||
final name = item.productName.toUpperCase();
|
||||
bytes += builder.itemText('${item.quantity} $name');
|
||||
bytes += builder.itemText('${item.quantityLabel} $name');
|
||||
if (item.productVariantName.isNotEmpty) {
|
||||
bytes += builder.itemText(' ${item.productVariantName.toUpperCase()}', bold: false);
|
||||
}
|
||||
@@ -196,7 +197,7 @@ class PrintUi {
|
||||
|
||||
// Single item
|
||||
final name = item.productName.toUpperCase();
|
||||
bytes += builder.itemText('${item.quantity} $name');
|
||||
bytes += builder.itemText('${item.quantityLabel} $name');
|
||||
if (item.productVariantName.isNotEmpty) {
|
||||
bytes += builder.itemText(' ${item.productVariantName.toUpperCase()}', bold: false);
|
||||
}
|
||||
@@ -252,7 +253,7 @@ class PrintUi {
|
||||
|
||||
// Single item
|
||||
final name = item.productName.toUpperCase();
|
||||
bytes += builder.itemText('${item.quantity} $name');
|
||||
bytes += builder.itemText('${item.quantityLabel} $name');
|
||||
if (item.productVariantName.isNotEmpty) {
|
||||
bytes += builder.itemText(' ${item.productVariantName.toUpperCase()}', bold: false);
|
||||
}
|
||||
@@ -359,6 +360,7 @@ class PrintUi {
|
||||
bytes += builder.orderItem(
|
||||
productName: item.productName,
|
||||
quantity: item.quantity,
|
||||
quantityLabel: item.isWeighted ? item.quantityLabel : null,
|
||||
unitPrice: item.unitPrice.currencyFormatRpV2,
|
||||
totalPrice: item.totalPrice.currencyFormatRpV2,
|
||||
variantName: item.productVariantName,
|
||||
@@ -439,6 +441,7 @@ class PrintUi {
|
||||
bytes += builder.orderItem(
|
||||
productName: item.productName,
|
||||
quantity: item.quantity,
|
||||
quantityLabel: item.isWeighted ? item.quantityLabel : null,
|
||||
unitPrice: item.unitPrice.currencyFormatRpV2,
|
||||
totalPrice: item.totalPrice.currencyFormatRpV2,
|
||||
variantName: item.productVariantName,
|
||||
@@ -530,6 +533,7 @@ class PrintUi {
|
||||
bytes += builder.orderItem(
|
||||
productName: item.productName,
|
||||
quantity: item.quantity,
|
||||
quantityLabel: item.isWeighted ? item.quantityLabel : null,
|
||||
unitPrice: item.unitPrice.currencyFormatRpV2,
|
||||
totalPrice: item.totalPrice.currencyFormatRpV2,
|
||||
variantName: item.productVariantName,
|
||||
|
||||
Reference in New Issue
Block a user