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:
+8
-23
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import '../../../../../../application/checkout/checkout_form/checkout_form_bloc.dart';
|
||||
import '../../../../../../common/extension/extension.dart';
|
||||
import '../../../../../../common/theme/theme.dart';
|
||||
import '../../../../../../domain/product/product.dart';
|
||||
import '../../../../../components/spaces/space.dart';
|
||||
|
||||
class SuccessAddItemOrderRightPanel extends StatelessWidget {
|
||||
@@ -86,14 +87,7 @@ class SuccessAddItemOrderRightPanel extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
Text(
|
||||
(checkoutState.items.fold(
|
||||
0,
|
||||
(previousValue, element) =>
|
||||
previousValue +
|
||||
(element.product.price.toInt() +
|
||||
(element.variant?.priceModifier.toInt() ?? 0)) *
|
||||
element.quantity,
|
||||
)).toString().currencyFormatRpV2,
|
||||
checkoutState.items.cartTotal.toInt().toString().currencyFormatRpV2,
|
||||
style: AppStyle.md.copyWith(fontWeight: FontWeight.w600),
|
||||
),
|
||||
],
|
||||
@@ -165,15 +159,10 @@ class SuccessAddItemOrderRightPanel extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
child: Text(
|
||||
(checkoutState.items.fold(
|
||||
0,
|
||||
(previousValue, element) =>
|
||||
previousValue +
|
||||
(element.product.price.toInt() +
|
||||
(element.variant?.priceModifier.toInt() ??
|
||||
0)) *
|
||||
element.quantity,
|
||||
)).toString().currencyFormatRpV2,
|
||||
checkoutState.items.cartTotal
|
||||
.toInt()
|
||||
.toString()
|
||||
.currencyFormatRpV2,
|
||||
style: AppStyle.xl.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
@@ -270,7 +259,7 @@ class SuccessAddItemOrderRightPanel 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,
|
||||
@@ -279,11 +268,7 @@ class SuccessAddItemOrderRightPanel extends StatelessWidget {
|
||||
),
|
||||
const SpaceHeight(8),
|
||||
Text(
|
||||
((item.product.price.toInt() +
|
||||
(item.variant?.priceModifier.toInt() ?? 0)) *
|
||||
item.quantity)
|
||||
.toString()
|
||||
.currencyFormatRpV2,
|
||||
item.lineTotal.toInt().toString().currencyFormatRpV2,
|
||||
style: AppStyle.lg.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColor.primary,
|
||||
|
||||
+1
-1
@@ -255,7 +255,7 @@ class SuccessOrderRightPanel 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,
|
||||
|
||||
@@ -211,7 +211,9 @@ class OrderList extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
'x${product.quantity}',
|
||||
(product.isWeighted
|
||||
? product.quantityLabel
|
||||
: "x${product.quantity}"),
|
||||
style: AppStyle.md.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColor.primary,
|
||||
|
||||
Reference in New Issue
Block a user