import 'package:sk_base_mobile/models/file.model.dart'; import 'package:sk_base_mobile/models/index.dart'; import 'package:sk_base_mobile/models/inventory.model.dart'; class InventoryInOutModel { InventoryInOutModel({ required this.id, required this.createdAt, required this.updatedAt, required this.inventoryInOutNumber, required this.productId, required this.inOrOut, required this.time, required this.quantity, required this.unitPrice, required this.amount, required this.agent, required this.issuanceNumber, required this.remark, required this.projectId, required this.isDelete, required this.files, required this.project, required this.product, this.inventory, }); final int? id; final DateTime? createdAt; final DateTime? updatedAt; final String? inventoryInOutNumber; final int? productId; final int? inOrOut; final DateTime? time; final int? quantity; final String? unitPrice; final String? amount; final String? agent; final dynamic issuanceNumber; final String? remark; final int? projectId; final int? isDelete; final List files; final ProjectModel? project; final ProductModel? product; final InventoryModel? inventory; factory InventoryInOutModel.fromJson(Map json) { return InventoryInOutModel( id: json["id"], createdAt: DateTime.tryParse(json["createdAt"] ?? "")?.toLocal(), updatedAt: DateTime.tryParse(json["updatedAt"] ?? "")?.toLocal(), inventoryInOutNumber: json["inventoryInOutNumber"], productId: json["productId"], inOrOut: json["inOrOut"], time: DateTime.tryParse(json["time"] ?? "")?.toLocal(), quantity: json["quantity"], unitPrice: json["unitPrice"], amount: json["amount"], agent: json["agent"], issuanceNumber: json["issuanceNumber"], remark: json["remark"], projectId: json["projectId"], isDelete: json["isDelete"], files: json["files"] == null ? [] : List.from( json["files"]!.map((x) => FileModel.fromJson(x))), project: json["project"] == null ? null : ProjectModel.fromJson(json["project"]), product: json["product"] == null ? null : ProductModel.fromJson(json["product"]), inventory: json['inventory'] == null ? null : InventoryModel.fromJson(json["inventory"]), ); } Map toJson() => { "id": id, "createdAt": createdAt?.toIso8601String(), "updatedAt": updatedAt?.toIso8601String(), "inventoryInOutNumber": inventoryInOutNumber, "productId": productId, "inOrOut": inOrOut, "time": time, "quantity": quantity, "unitPrice": unitPrice, "amount": amount, "agent": agent, "issuanceNumber": issuanceNumber, "remark": remark, "projectId": projectId, "isDelete": isDelete, "files": files.map((x) => x).toList(), "project": project?.toJson(), "product": product?.toJson(), "inventory": inventory?.toJson(), }; }