Added components to article
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import 'component.dart';
|
||||
|
||||
part 'article.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
@ -15,6 +17,10 @@ class ArticleDTO {
|
||||
required this.scannedAmount,
|
||||
required this.removeNoteId,
|
||||
required this.taxRate,
|
||||
required this.isParent,
|
||||
this.components,
|
||||
this.warehouseNr,
|
||||
this.warehouseName,
|
||||
});
|
||||
|
||||
String name;
|
||||
@ -27,6 +33,10 @@ class ArticleDTO {
|
||||
String scannedRemovedAmount;
|
||||
String? removeNoteId;
|
||||
bool scannable;
|
||||
bool isParent;
|
||||
List<ComponentDTO>? components;
|
||||
String? warehouseNr;
|
||||
String? warehouseName;
|
||||
|
||||
factory ArticleDTO.fromJson(Map<String, dynamic> json) =>
|
||||
_$ArticleDTOFromJson(json);
|
||||
|
||||
@ -17,6 +17,13 @@ ArticleDTO _$ArticleDTOFromJson(Map<String, dynamic> json) => ArticleDTO(
|
||||
scannedAmount: json['scanned_amount'] as String,
|
||||
removeNoteId: json['remove_note_id'] as String?,
|
||||
taxRate: json['tax_rate'] as String,
|
||||
isParent: json['is_parent'] as bool,
|
||||
components:
|
||||
(json['components'] as List<dynamic>?)
|
||||
?.map((e) => ComponentDTO.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
warehouseNr: json['warehouse_nr'] as String?,
|
||||
warehouseName: json['warehouse_name'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ArticleDTOToJson(ArticleDTO instance) =>
|
||||
@ -31,4 +38,8 @@ Map<String, dynamic> _$ArticleDTOToJson(ArticleDTO instance) =>
|
||||
'scanned_removed_amount': instance.scannedRemovedAmount,
|
||||
'remove_note_id': instance.removeNoteId,
|
||||
'scannable': instance.scannable,
|
||||
'is_parent': instance.isParent,
|
||||
'components': instance.components,
|
||||
'warehouse_nr': instance.warehouseNr,
|
||||
'warehouse_name': instance.warehouseName,
|
||||
};
|
||||
|
||||
23
lib/dto/component.dart
Normal file
23
lib/dto/component.dart
Normal file
@ -0,0 +1,23 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'component.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class ComponentDTO {
|
||||
ComponentDTO({
|
||||
required this.articleNr,
|
||||
required this.name,
|
||||
required this.quantity,
|
||||
required this.pos,
|
||||
});
|
||||
|
||||
String articleNr;
|
||||
String name;
|
||||
String quantity;
|
||||
String pos;
|
||||
|
||||
factory ComponentDTO.fromJson(Map<String, dynamic> json) =>
|
||||
_$ComponentDTOFromJson(json);
|
||||
|
||||
Map<dynamic, dynamic> toJson() => _$ComponentDTOToJson(this);
|
||||
}
|
||||
22
lib/dto/component.g.dart
Normal file
22
lib/dto/component.g.dart
Normal file
@ -0,0 +1,22 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'component.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
ComponentDTO _$ComponentDTOFromJson(Map<String, dynamic> json) => ComponentDTO(
|
||||
articleNr: json['article_nr'] as String,
|
||||
name: json['name'] as String,
|
||||
quantity: json['quantity'] as String,
|
||||
pos: json['pos'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ComponentDTOToJson(ComponentDTO instance) =>
|
||||
<String, dynamic>{
|
||||
'article_nr': instance.articleNr,
|
||||
'name': instance.name,
|
||||
'quantity': instance.quantity,
|
||||
'pos': instance.pos,
|
||||
};
|
||||
Reference in New Issue
Block a user