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:
@@ -55,7 +55,10 @@ class VoidFormBloc extends Bloc<VoidFormEvent, VoidFormState> {
|
||||
(item) => item.id == entry.key,
|
||||
);
|
||||
if (item == null) continue;
|
||||
newTotal += item.unitPrice.toInt() * entry.value;
|
||||
// Baris berbobot di-void utuh; rupiahnya sudah weight x harga.
|
||||
newTotal += item.isWeighted
|
||||
? item.totalPrice
|
||||
: item.unitPrice.toInt() * entry.value;
|
||||
}
|
||||
|
||||
emit(
|
||||
@@ -92,7 +95,13 @@ class VoidFormBloc extends Bloc<VoidFormEvent, VoidFormState> {
|
||||
productVariantName: originalItem.productVariantName,
|
||||
quantity: voidQty,
|
||||
unitPrice: originalItem.unitPrice,
|
||||
totalPrice: (originalItem.unitPrice) * voidQty,
|
||||
totalPrice: originalItem.isWeighted
|
||||
? originalItem.totalPrice
|
||||
: (originalItem.unitPrice) * voidQty,
|
||||
weight: originalItem.weight,
|
||||
unitId: originalItem.unitId,
|
||||
unitName: originalItem.unitName,
|
||||
unitAbbreviation: originalItem.unitAbbreviation,
|
||||
modifiers: originalItem.modifiers,
|
||||
notes: originalItem.notes,
|
||||
status: originalItem.status,
|
||||
|
||||
Reference in New Issue
Block a user