barcode_scanner/lib/backend/schema/stock_picking/stock_picking_model.dart
mandreshope 1d331acc54 feat: Streamlines product data and stock picking API
Refactors the product data model to primarily store `id`, `barcode`, and `displayName`. This simplifies the product structure, focusing on essential attributes for inventory and scanning operations.

Optimizes API calls for stock picking to fetch more relevant product details. Unnecessary fields are removed, and specific product attributes like `barcode` and `quantity` are now explicitly requested for stock moves.

Moves `StockPickingRecordModel` to its own dedicated file for improved code organization and maintainability. Updates all affected UI components and scanner logic to align with the revised product model.
2025-07-30 12:47:08 +03:00

72 lines
2.2 KiB
Dart

import 'package:e_scan/backend/schema/stock_picking/stock_picking_record_model.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'stock_picking_model.freezed.dart';
part 'stock_picking_model.g.dart';
@freezed
abstract class StockPickingResponseModel with _$StockPickingResponseModel {
const factory StockPickingResponseModel({
String? jsonrpc,
int? id,
StockPickingResultModel? result,
}) = _StockPickingResponseModel;
factory StockPickingResponseModel.fromJson(Map<String, dynamic> json) =>
_$StockPickingResponseModelFromJson(json);
}
@freezed
abstract class StockPickingResultModel with _$StockPickingResultModel {
const factory StockPickingResultModel({
int? length,
List<StockPickingRecordModel>? records,
}) = _StockPickingResultModel;
factory StockPickingResultModel.fromJson(Map<String, dynamic> json) =>
_$StockPickingResultModelFromJson(json);
}
@freezed
abstract class StockPickingCompanyModel with _$StockPickingCompanyModel {
const factory StockPickingCompanyModel({@JsonKey(name: 'id') int? id}) =
_StockPickingCompanyModel;
factory StockPickingCompanyModel.fromJson(Map<String, dynamic> json) =>
_$StockPickingCompanyModelFromJson(json);
}
@freezed
abstract class StockPickingPartnerModel with _$StockPickingPartnerModel {
const factory StockPickingPartnerModel({
int? id,
@JsonKey(name: 'display_name') String? displayName,
}) = _StockPickingPartnerModel;
factory StockPickingPartnerModel.fromJson(Map<String, dynamic> json) =>
_$StockPickingPartnerModelFromJson(json);
}
@freezed
abstract class StockPickingLocationModel with _$StockPickingLocationModel {
const factory StockPickingLocationModel({
int? id,
@JsonKey(name: 'complete_name') String? completeName,
}) = _StockPickingLocationModel;
factory StockPickingLocationModel.fromJson(Map<String, dynamic> json) =>
_$StockPickingLocationModelFromJson(json);
}
@freezed
abstract class StockPickingTypeModel with _$StockPickingTypeModel {
const factory StockPickingTypeModel({
int? id,
@JsonKey(name: 'display_name') String? displayName,
}) = _StockPickingTypeModel;
factory StockPickingTypeModel.fromJson(Map<String, dynamic> json) =>
_$StockPickingTypeModelFromJson(json);
}