
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.
25 lines
782 B
Dart
25 lines
782 B
Dart
import 'package:e_scan/backend/objectbox/entities/product/product_entity.dart';
|
|
import 'package:e_scan/utils/utils.dart';
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
|
|
part 'product_model.freezed.dart';
|
|
part 'product_model.g.dart';
|
|
|
|
@Freezed(toJson: true)
|
|
abstract class ProductModel with _$ProductModel {
|
|
factory ProductModel({
|
|
int? id,
|
|
@JsonKey(fromJson: stringFromJson) String? barcode,
|
|
@JsonKey(name: 'display_name', fromJson: stringFromJson)
|
|
String? displayName,
|
|
}) = _ProductModel;
|
|
|
|
factory ProductModel.fromJson(Map<String, dynamic> json) =>
|
|
_$ProductModelFromJson(json);
|
|
}
|
|
|
|
extension ProductModelExt on ProductModel {
|
|
ProductEntity get toEntity =>
|
|
ProductEntity(id: id ?? 0, displayName: displayName, barcode: barcode);
|
|
}
|