mobile_skt/lib/models/inventory_inout.model.dart

102 lines
3.1 KiB
Dart
Raw Normal View History

2024-03-21 16:22:00 +08:00
import 'package:sk_base_mobile/models/file.model.dart';
import 'package:sk_base_mobile/models/index.dart';
2024-03-26 15:30:43 +08:00
import 'package:sk_base_mobile/models/inventory.model.dart';
2024-03-21 16:22:00 +08:00
class InventoryInOutModel {
InventoryInOutModel({
required this.id,
required this.createdAt,
required this.updatedAt,
2024-04-07 17:32:46 +08:00
required this.inventoryInOutNumber,
2024-03-21 16:22:00 +08:00
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,
2024-03-26 15:30:43 +08:00
this.inventory,
2024-03-21 16:22:00 +08:00
});
final int? id;
final DateTime? createdAt;
final DateTime? updatedAt;
2024-04-07 17:32:46 +08:00
final String? inventoryInOutNumber;
2024-03-21 16:22:00 +08:00
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;
2024-03-26 15:30:43 +08:00
final List<FileModel> files;
2024-03-21 16:22:00 +08:00
final ProjectModel? project;
final ProductModel? product;
2024-03-26 15:30:43 +08:00
final InventoryModel? inventory;
2024-03-21 16:22:00 +08:00
factory InventoryInOutModel.fromJson(Map<String, dynamic> json) {
return InventoryInOutModel(
id: json["id"],
2024-04-07 17:32:46 +08:00
createdAt: DateTime.tryParse(json["createdAt"] ?? "")?.toLocal(),
updatedAt: DateTime.tryParse(json["updatedAt"] ?? "")?.toLocal(),
inventoryInOutNumber: json["inventoryInOutNumber"],
2024-03-21 16:22:00 +08:00
productId: json["productId"],
inOrOut: json["inOrOut"],
2024-04-07 17:32:46 +08:00
time: DateTime.tryParse(json["time"] ?? "")?.toLocal(),
2024-03-21 16:22:00 +08:00
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<FileModel>.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"]),
2024-03-26 15:30:43 +08:00
inventory: json['inventory'] == null
? null
: InventoryModel.fromJson(json["inventory"]),
2024-03-21 16:22:00 +08:00
);
}
Map<String, dynamic> toJson() => {
"id": id,
"createdAt": createdAt?.toIso8601String(),
"updatedAt": updatedAt?.toIso8601String(),
2024-04-07 17:32:46 +08:00
"inventoryInOutNumber": inventoryInOutNumber,
2024-03-21 16:22:00 +08:00
"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(),
2024-03-26 15:30:43 +08:00
"inventory": inventory?.toJson(),
2024-03-21 16:22:00 +08:00
};
}