73 lines
2.1 KiB
Dart
73 lines
2.1 KiB
Dart
import 'package:sk_base_mobile/models/product.model.dart';
|
|
import 'package:sk_base_mobile/models/project.model.dart';
|
|
|
|
class InventoryModel {
|
|
InventoryModel({
|
|
required this.id,
|
|
required this.createdAt,
|
|
required this.updatedAt,
|
|
required this.projectId,
|
|
required this.productId,
|
|
this.position,
|
|
required this.quantity,
|
|
required this.unitPrice,
|
|
this.remark,
|
|
required this.isDelete,
|
|
required this.inventoryNumber,
|
|
required this.project,
|
|
required this.product,
|
|
});
|
|
|
|
final int? id;
|
|
final DateTime? createdAt;
|
|
final DateTime? updatedAt;
|
|
final int? projectId;
|
|
final int? productId;
|
|
final String? position;
|
|
final int? quantity;
|
|
final String? unitPrice;
|
|
final dynamic remark;
|
|
final int? isDelete;
|
|
final String? inventoryNumber;
|
|
final ProjectModel? project;
|
|
final ProductModel? product;
|
|
|
|
factory InventoryModel.fromJson(Map<String, dynamic> json) {
|
|
return InventoryModel(
|
|
id: json["id"],
|
|
createdAt: DateTime.tryParse(json["createdAt"] ?? ""),
|
|
updatedAt: DateTime.tryParse(json["updatedAt"] ?? ""),
|
|
projectId: json["projectId"],
|
|
productId: json["productId"],
|
|
position: json["position"],
|
|
quantity: json["quantity"],
|
|
unitPrice: json["unitPrice"],
|
|
remark: json["remark"],
|
|
isDelete: json["isDelete"],
|
|
inventoryNumber: json["inventoryNumber"],
|
|
project: json["project"] == null
|
|
? null
|
|
: ProjectModel.fromJson(json["project"]),
|
|
product: json["product"] == null
|
|
? null
|
|
: ProductModel.fromJson(json["product"]),
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"id": id,
|
|
"createdAt": createdAt?.toIso8601String(),
|
|
"updatedAt": updatedAt?.toIso8601String(),
|
|
"projectId": projectId,
|
|
"productId": productId,
|
|
"position": position,
|
|
"quantity": quantity,
|
|
"unitPrice": unitPrice,
|
|
"remark": remark,
|
|
"isDelete": isDelete,
|
|
"inventoryNumber": inventoryNumber,
|
|
"project": project?.toJson(),
|
|
"product": product?.toJson(),
|
|
};
|
|
}
|