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:
@@ -301,6 +301,10 @@ class ReceiptComponentBuilder {
|
||||
List<int> orderItem({
|
||||
required String productName,
|
||||
required int quantity,
|
||||
|
||||
/// Untuk baris berbobot, isi dengan "4,2 ons" — angka quantity-nya selalu
|
||||
/// 1 dan akan salah dibaca di struk.
|
||||
String? quantityLabel,
|
||||
required String unitPrice,
|
||||
required String totalPrice,
|
||||
String? variantName,
|
||||
@@ -314,7 +318,10 @@ class ReceiptComponentBuilder {
|
||||
? '$productName ($variantName)'
|
||||
: productName;
|
||||
bytes += textLeft(displayName, bold: true, fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth);
|
||||
bytes += row2Columns('${quantity}x $unitPrice', totalPrice, fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth,);
|
||||
final quantityText = quantityLabel != null && quantityLabel.isNotEmpty
|
||||
? '$quantityLabel x $unitPrice'
|
||||
: '${quantity}x $unitPrice';
|
||||
bytes += row2Columns(quantityText, totalPrice, fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth,);
|
||||
if (notes != null && notes.isNotEmpty) {
|
||||
bytes += row2Columns('Note', notes, fontType: fontType, height: height ?? _bodyHeight, width: width ?? _bodyWidth, leftWidth: 4, rightWidth: 8);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user