barcode_scanner/lib/backend/schema/product/product_model.freezed.dart
mandreshope 6e49971883 enhance: Enhances data models and reception details
Improves JSON deserialization for product and stock picking models by
using custom `fromJson` methods and explicit `JsonKey` mappings.
This ensures robust parsing of fields like barcode, display name, and product IDs.

Adds a new `ecart` getter to calculate the difference between requested
and received quantities for stock moves.

Updates the reception details page to display a list of products
with their requested, received, and calculated difference quantities.

Removes redundant JSON-RPC fields from the `stock.picking/web_read` API call.
2025-07-30 14:16:27 +03:00

155 lines
5.6 KiB
Dart

// dart format width=80
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'product_model.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$ProductModel {
int? get id;@JsonKey(fromJson: stringFromJson) String? get barcode;@JsonKey(name: 'display_name', fromJson: stringFromJson) String? get displayName;
/// Create a copy of ProductModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$ProductModelCopyWith<ProductModel> get copyWith => _$ProductModelCopyWithImpl<ProductModel>(this as ProductModel, _$identity);
/// Serializes this ProductModel to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is ProductModel&&(identical(other.id, id) || other.id == id)&&(identical(other.barcode, barcode) || other.barcode == barcode)&&(identical(other.displayName, displayName) || other.displayName == displayName));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,id,barcode,displayName);
@override
String toString() {
return 'ProductModel(id: $id, barcode: $barcode, displayName: $displayName)';
}
}
/// @nodoc
abstract mixin class $ProductModelCopyWith<$Res> {
factory $ProductModelCopyWith(ProductModel value, $Res Function(ProductModel) _then) = _$ProductModelCopyWithImpl;
@useResult
$Res call({
int? id,@JsonKey(fromJson: stringFromJson) String? barcode,@JsonKey(name: 'display_name', fromJson: stringFromJson) String? displayName
});
}
/// @nodoc
class _$ProductModelCopyWithImpl<$Res>
implements $ProductModelCopyWith<$Res> {
_$ProductModelCopyWithImpl(this._self, this._then);
final ProductModel _self;
final $Res Function(ProductModel) _then;
/// Create a copy of ProductModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? id = freezed,Object? barcode = freezed,Object? displayName = freezed,}) {
return _then(_self.copyWith(
id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as int?,barcode: freezed == barcode ? _self.barcode : barcode // ignore: cast_nullable_to_non_nullable
as String?,displayName: freezed == displayName ? _self.displayName : displayName // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
/// @nodoc
@JsonSerializable()
class _ProductModel implements ProductModel {
_ProductModel({this.id, @JsonKey(fromJson: stringFromJson) this.barcode, @JsonKey(name: 'display_name', fromJson: stringFromJson) this.displayName});
factory _ProductModel.fromJson(Map<String, dynamic> json) => _$ProductModelFromJson(json);
@override final int? id;
@override@JsonKey(fromJson: stringFromJson) final String? barcode;
@override@JsonKey(name: 'display_name', fromJson: stringFromJson) final String? displayName;
/// Create a copy of ProductModel
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$ProductModelCopyWith<_ProductModel> get copyWith => __$ProductModelCopyWithImpl<_ProductModel>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$ProductModelToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ProductModel&&(identical(other.id, id) || other.id == id)&&(identical(other.barcode, barcode) || other.barcode == barcode)&&(identical(other.displayName, displayName) || other.displayName == displayName));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,id,barcode,displayName);
@override
String toString() {
return 'ProductModel(id: $id, barcode: $barcode, displayName: $displayName)';
}
}
/// @nodoc
abstract mixin class _$ProductModelCopyWith<$Res> implements $ProductModelCopyWith<$Res> {
factory _$ProductModelCopyWith(_ProductModel value, $Res Function(_ProductModel) _then) = __$ProductModelCopyWithImpl;
@override @useResult
$Res call({
int? id,@JsonKey(fromJson: stringFromJson) String? barcode,@JsonKey(name: 'display_name', fromJson: stringFromJson) String? displayName
});
}
/// @nodoc
class __$ProductModelCopyWithImpl<$Res>
implements _$ProductModelCopyWith<$Res> {
__$ProductModelCopyWithImpl(this._self, this._then);
final _ProductModel _self;
final $Res Function(_ProductModel) _then;
/// Create a copy of ProductModel
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? id = freezed,Object? barcode = freezed,Object? displayName = freezed,}) {
return _then(_ProductModel(
id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as int?,barcode: freezed == barcode ? _self.barcode : barcode // ignore: cast_nullable_to_non_nullable
as String?,displayName: freezed == displayName ? _self.displayName : displayName // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
// dart format on