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:
efrilm
2026-09-06 23:03:31 +07:00
co-authored by Claude Opus 5
parent 9777f63426
commit 1505a83dd3
72 changed files with 5388 additions and 584 deletions
@@ -255,7 +255,7 @@ class RefundSuccessRightPanel extends StatelessWidget {
borderRadius: BorderRadius.circular(12),
),
child: Text(
'${item.quantity}x',
(item.isWeighted ? item.quantityLabel : "${item.quantity}x"),
style: AppStyle.md.copyWith(
fontWeight: FontWeight.bold,
color: Colors.white,
@@ -62,7 +62,9 @@ class RefundLeftPanel extends StatelessWidget {
),
),
Text(
'Qty: ${item.quantity} x Rp ${item.unitPrice.currencyFormatRpV2} ',
item.isWeighted
? item.quantityPriceLabel
: 'Qty: ${item.quantity} x ${item.unitPrice.currencyFormatRpV2}',
style: AppStyle.md.copyWith(
color: AppColor.textSecondary,
),