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:
@@ -286,6 +286,12 @@ mixin _$Product {
|
||||
String get updatedAt => throw _privateConstructorUsedError;
|
||||
List<ProductVariant> get variants => throw _privateConstructorUsedError;
|
||||
|
||||
/// `unit` (default) atau `weight`. Lihat [SellBy].
|
||||
String get sellBy => throw _privateConstructorUsedError;
|
||||
String get unitId => throw _privateConstructorUsedError;
|
||||
String get unitName => throw _privateConstructorUsedError;
|
||||
String get unitAbbreviation => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of Product
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -315,6 +321,10 @@ abstract class $ProductCopyWith<$Res> {
|
||||
String createdAt,
|
||||
String updatedAt,
|
||||
List<ProductVariant> variants,
|
||||
String sellBy,
|
||||
String unitId,
|
||||
String unitName,
|
||||
String unitAbbreviation,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -350,6 +360,10 @@ class _$ProductCopyWithImpl<$Res, $Val extends Product>
|
||||
Object? createdAt = null,
|
||||
Object? updatedAt = null,
|
||||
Object? variants = null,
|
||||
Object? sellBy = null,
|
||||
Object? unitId = null,
|
||||
Object? unitName = null,
|
||||
Object? unitAbbreviation = null,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
@@ -421,6 +435,22 @@ class _$ProductCopyWithImpl<$Res, $Val extends Product>
|
||||
? _value.variants
|
||||
: variants // ignore: cast_nullable_to_non_nullable
|
||||
as List<ProductVariant>,
|
||||
sellBy: null == sellBy
|
||||
? _value.sellBy
|
||||
: sellBy // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
unitId: null == unitId
|
||||
? _value.unitId
|
||||
: unitId // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
unitName: null == unitName
|
||||
? _value.unitName
|
||||
: unitName // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
unitAbbreviation: null == unitAbbreviation
|
||||
? _value.unitAbbreviation
|
||||
: unitAbbreviation // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
@@ -453,6 +483,10 @@ abstract class _$$ProductImplCopyWith<$Res> implements $ProductCopyWith<$Res> {
|
||||
String createdAt,
|
||||
String updatedAt,
|
||||
List<ProductVariant> variants,
|
||||
String sellBy,
|
||||
String unitId,
|
||||
String unitName,
|
||||
String unitAbbreviation,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -487,6 +521,10 @@ class __$$ProductImplCopyWithImpl<$Res>
|
||||
Object? createdAt = null,
|
||||
Object? updatedAt = null,
|
||||
Object? variants = null,
|
||||
Object? sellBy = null,
|
||||
Object? unitId = null,
|
||||
Object? unitName = null,
|
||||
Object? unitAbbreviation = null,
|
||||
}) {
|
||||
return _then(
|
||||
_$ProductImpl(
|
||||
@@ -558,6 +596,22 @@ class __$$ProductImplCopyWithImpl<$Res>
|
||||
? _value._variants
|
||||
: variants // ignore: cast_nullable_to_non_nullable
|
||||
as List<ProductVariant>,
|
||||
sellBy: null == sellBy
|
||||
? _value.sellBy
|
||||
: sellBy // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
unitId: null == unitId
|
||||
? _value.unitId
|
||||
: unitId // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
unitName: null == unitName
|
||||
? _value.unitName
|
||||
: unitName // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
unitAbbreviation: null == unitAbbreviation
|
||||
? _value.unitAbbreviation
|
||||
: unitAbbreviation // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -565,7 +619,7 @@ class __$$ProductImplCopyWithImpl<$Res>
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$ProductImpl with DiagnosticableTreeMixin implements _Product {
|
||||
class _$ProductImpl extends _Product with DiagnosticableTreeMixin {
|
||||
const _$ProductImpl({
|
||||
required this.id,
|
||||
required this.organizationId,
|
||||
@@ -584,8 +638,13 @@ class _$ProductImpl with DiagnosticableTreeMixin implements _Product {
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
required final List<ProductVariant> variants,
|
||||
this.sellBy = SellBy.unit,
|
||||
this.unitId = '',
|
||||
this.unitName = '',
|
||||
this.unitAbbreviation = '',
|
||||
}) : _metadata = metadata,
|
||||
_variants = variants;
|
||||
_variants = variants,
|
||||
super._();
|
||||
|
||||
@override
|
||||
final String id;
|
||||
@@ -633,9 +692,23 @@ class _$ProductImpl with DiagnosticableTreeMixin implements _Product {
|
||||
return EqualUnmodifiableListView(_variants);
|
||||
}
|
||||
|
||||
/// `unit` (default) atau `weight`. Lihat [SellBy].
|
||||
@override
|
||||
@JsonKey()
|
||||
final String sellBy;
|
||||
@override
|
||||
@JsonKey()
|
||||
final String unitId;
|
||||
@override
|
||||
@JsonKey()
|
||||
final String unitName;
|
||||
@override
|
||||
@JsonKey()
|
||||
final String unitAbbreviation;
|
||||
|
||||
@override
|
||||
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
|
||||
return 'Product(id: $id, organizationId: $organizationId, categoryId: $categoryId, sku: $sku, name: $name, description: $description, price: $price, cost: $cost, businessType: $businessType, imageUrl: $imageUrl, printerType: $printerType, printToChecker: $printToChecker, metadata: $metadata, isActive: $isActive, createdAt: $createdAt, updatedAt: $updatedAt, variants: $variants)';
|
||||
return 'Product(id: $id, organizationId: $organizationId, categoryId: $categoryId, sku: $sku, name: $name, description: $description, price: $price, cost: $cost, businessType: $businessType, imageUrl: $imageUrl, printerType: $printerType, printToChecker: $printToChecker, metadata: $metadata, isActive: $isActive, createdAt: $createdAt, updatedAt: $updatedAt, variants: $variants, sellBy: $sellBy, unitId: $unitId, unitName: $unitName, unitAbbreviation: $unitAbbreviation)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -659,7 +732,11 @@ class _$ProductImpl with DiagnosticableTreeMixin implements _Product {
|
||||
..add(DiagnosticsProperty('isActive', isActive))
|
||||
..add(DiagnosticsProperty('createdAt', createdAt))
|
||||
..add(DiagnosticsProperty('updatedAt', updatedAt))
|
||||
..add(DiagnosticsProperty('variants', variants));
|
||||
..add(DiagnosticsProperty('variants', variants))
|
||||
..add(DiagnosticsProperty('sellBy', sellBy))
|
||||
..add(DiagnosticsProperty('unitId', unitId))
|
||||
..add(DiagnosticsProperty('unitName', unitName))
|
||||
..add(DiagnosticsProperty('unitAbbreviation', unitAbbreviation));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -693,11 +770,17 @@ class _$ProductImpl with DiagnosticableTreeMixin implements _Product {
|
||||
other.createdAt == createdAt) &&
|
||||
(identical(other.updatedAt, updatedAt) ||
|
||||
other.updatedAt == updatedAt) &&
|
||||
const DeepCollectionEquality().equals(other._variants, _variants));
|
||||
const DeepCollectionEquality().equals(other._variants, _variants) &&
|
||||
(identical(other.sellBy, sellBy) || other.sellBy == sellBy) &&
|
||||
(identical(other.unitId, unitId) || other.unitId == unitId) &&
|
||||
(identical(other.unitName, unitName) ||
|
||||
other.unitName == unitName) &&
|
||||
(identical(other.unitAbbreviation, unitAbbreviation) ||
|
||||
other.unitAbbreviation == unitAbbreviation));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
int get hashCode => Object.hashAll([
|
||||
runtimeType,
|
||||
id,
|
||||
organizationId,
|
||||
@@ -716,7 +799,11 @@ class _$ProductImpl with DiagnosticableTreeMixin implements _Product {
|
||||
createdAt,
|
||||
updatedAt,
|
||||
const DeepCollectionEquality().hash(_variants),
|
||||
);
|
||||
sellBy,
|
||||
unitId,
|
||||
unitName,
|
||||
unitAbbreviation,
|
||||
]);
|
||||
|
||||
/// Create a copy of Product
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -727,7 +814,7 @@ class _$ProductImpl with DiagnosticableTreeMixin implements _Product {
|
||||
__$$ProductImplCopyWithImpl<_$ProductImpl>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _Product implements Product {
|
||||
abstract class _Product extends Product {
|
||||
const factory _Product({
|
||||
required final String id,
|
||||
required final String organizationId,
|
||||
@@ -746,7 +833,12 @@ abstract class _Product implements Product {
|
||||
required final String createdAt,
|
||||
required final String updatedAt,
|
||||
required final List<ProductVariant> variants,
|
||||
final String sellBy,
|
||||
final String unitId,
|
||||
final String unitName,
|
||||
final String unitAbbreviation,
|
||||
}) = _$ProductImpl;
|
||||
const _Product._() : super._();
|
||||
|
||||
@override
|
||||
String get id;
|
||||
@@ -783,6 +875,16 @@ abstract class _Product implements Product {
|
||||
@override
|
||||
List<ProductVariant> get variants;
|
||||
|
||||
/// `unit` (default) atau `weight`. Lihat [SellBy].
|
||||
@override
|
||||
String get sellBy;
|
||||
@override
|
||||
String get unitId;
|
||||
@override
|
||||
String get unitName;
|
||||
@override
|
||||
String get unitAbbreviation;
|
||||
|
||||
/// Create a copy of Product
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@@ -1121,6 +1223,10 @@ mixin _$ProductQuantity {
|
||||
ProductVariant? get variant => throw _privateConstructorUsedError;
|
||||
int get quantity => throw _privateConstructorUsedError;
|
||||
String get notes => throw _privateConstructorUsedError;
|
||||
String get lineId => throw _privateConstructorUsedError;
|
||||
|
||||
/// Angka timbangan dalam satuan produk. `null` untuk produk cacah.
|
||||
double? get weight => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of ProductQuantity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -1141,6 +1247,8 @@ abstract class $ProductQuantityCopyWith<$Res> {
|
||||
ProductVariant? variant,
|
||||
int quantity,
|
||||
String notes,
|
||||
String lineId,
|
||||
double? weight,
|
||||
});
|
||||
|
||||
$ProductCopyWith<$Res> get product;
|
||||
@@ -1166,6 +1274,8 @@ class _$ProductQuantityCopyWithImpl<$Res, $Val extends ProductQuantity>
|
||||
Object? variant = freezed,
|
||||
Object? quantity = null,
|
||||
Object? notes = null,
|
||||
Object? lineId = null,
|
||||
Object? weight = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
@@ -1185,6 +1295,14 @@ class _$ProductQuantityCopyWithImpl<$Res, $Val extends ProductQuantity>
|
||||
? _value.notes
|
||||
: notes // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
lineId: null == lineId
|
||||
? _value.lineId
|
||||
: lineId // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
weight: freezed == weight
|
||||
? _value.weight
|
||||
: weight // ignore: cast_nullable_to_non_nullable
|
||||
as double?,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
@@ -1229,6 +1347,8 @@ abstract class _$$ProductQuantityImplCopyWith<$Res>
|
||||
ProductVariant? variant,
|
||||
int quantity,
|
||||
String notes,
|
||||
String lineId,
|
||||
double? weight,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -1255,6 +1375,8 @@ class __$$ProductQuantityImplCopyWithImpl<$Res>
|
||||
Object? variant = freezed,
|
||||
Object? quantity = null,
|
||||
Object? notes = null,
|
||||
Object? lineId = null,
|
||||
Object? weight = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_$ProductQuantityImpl(
|
||||
@@ -1274,6 +1396,14 @@ class __$$ProductQuantityImplCopyWithImpl<$Res>
|
||||
? _value.notes
|
||||
: notes // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
lineId: null == lineId
|
||||
? _value.lineId
|
||||
: lineId // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
weight: freezed == weight
|
||||
? _value.weight
|
||||
: weight // ignore: cast_nullable_to_non_nullable
|
||||
as double?,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -1281,15 +1411,16 @@ class __$$ProductQuantityImplCopyWithImpl<$Res>
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$ProductQuantityImpl
|
||||
with DiagnosticableTreeMixin
|
||||
implements _ProductQuantity {
|
||||
class _$ProductQuantityImpl extends _ProductQuantity
|
||||
with DiagnosticableTreeMixin {
|
||||
const _$ProductQuantityImpl({
|
||||
required this.product,
|
||||
this.variant,
|
||||
required this.quantity,
|
||||
required this.notes,
|
||||
});
|
||||
this.lineId = '',
|
||||
this.weight,
|
||||
}) : super._();
|
||||
|
||||
@override
|
||||
final Product product;
|
||||
@@ -1299,10 +1430,17 @@ class _$ProductQuantityImpl
|
||||
final int quantity;
|
||||
@override
|
||||
final String notes;
|
||||
@override
|
||||
@JsonKey()
|
||||
final String lineId;
|
||||
|
||||
/// Angka timbangan dalam satuan produk. `null` untuk produk cacah.
|
||||
@override
|
||||
final double? weight;
|
||||
|
||||
@override
|
||||
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
|
||||
return 'ProductQuantity(product: $product, variant: $variant, quantity: $quantity, notes: $notes)';
|
||||
return 'ProductQuantity(product: $product, variant: $variant, quantity: $quantity, notes: $notes, lineId: $lineId, weight: $weight)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1313,7 +1451,9 @@ class _$ProductQuantityImpl
|
||||
..add(DiagnosticsProperty('product', product))
|
||||
..add(DiagnosticsProperty('variant', variant))
|
||||
..add(DiagnosticsProperty('quantity', quantity))
|
||||
..add(DiagnosticsProperty('notes', notes));
|
||||
..add(DiagnosticsProperty('notes', notes))
|
||||
..add(DiagnosticsProperty('lineId', lineId))
|
||||
..add(DiagnosticsProperty('weight', weight));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1325,12 +1465,21 @@ class _$ProductQuantityImpl
|
||||
(identical(other.variant, variant) || other.variant == variant) &&
|
||||
(identical(other.quantity, quantity) ||
|
||||
other.quantity == quantity) &&
|
||||
(identical(other.notes, notes) || other.notes == notes));
|
||||
(identical(other.notes, notes) || other.notes == notes) &&
|
||||
(identical(other.lineId, lineId) || other.lineId == lineId) &&
|
||||
(identical(other.weight, weight) || other.weight == weight));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, product, variant, quantity, notes);
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
product,
|
||||
variant,
|
||||
quantity,
|
||||
notes,
|
||||
lineId,
|
||||
weight,
|
||||
);
|
||||
|
||||
/// Create a copy of ProductQuantity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -1344,13 +1493,16 @@ class _$ProductQuantityImpl
|
||||
);
|
||||
}
|
||||
|
||||
abstract class _ProductQuantity implements ProductQuantity {
|
||||
abstract class _ProductQuantity extends ProductQuantity {
|
||||
const factory _ProductQuantity({
|
||||
required final Product product,
|
||||
final ProductVariant? variant,
|
||||
required final int quantity,
|
||||
required final String notes,
|
||||
final String lineId,
|
||||
final double? weight,
|
||||
}) = _$ProductQuantityImpl;
|
||||
const _ProductQuantity._() : super._();
|
||||
|
||||
@override
|
||||
Product get product;
|
||||
@@ -1360,6 +1512,12 @@ abstract class _ProductQuantity implements ProductQuantity {
|
||||
int get quantity;
|
||||
@override
|
||||
String get notes;
|
||||
@override
|
||||
String get lineId;
|
||||
|
||||
/// Angka timbangan dalam satuan produk. `null` untuk produk cacah.
|
||||
@override
|
||||
double? get weight;
|
||||
|
||||
/// Create a copy of ProductQuantity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
|
||||
Reference in New Issue
Block a user