You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
class Part {
|
|
|
|
|
int id;
|
|
|
|
|
int reportPartID;
|
|
|
|
|
String code;
|
|
|
|
|
String name;
|
|
|
|
|
int quantity;
|
|
|
|
|
|
|
|
|
|
Part({
|
|
|
|
|
this.id,
|
|
|
|
|
this.reportPartID,
|
|
|
|
|
this.code,
|
|
|
|
|
this.name,
|
|
|
|
|
this.quantity = 1,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson() {
|
|
|
|
|
return {
|
|
|
|
|
"id": reportPartID ?? 0,
|
|
|
|
|
"sparePart": {"id": id, "partNo": code, "partName": name},
|
|
|
|
|
"qty": quantity
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
factory Part.fromJson(Map<String, dynamic> parsedJson, {Map<String, dynamic> reportJson}) {
|
|
|
|
|
return Part(
|
|
|
|
|
id: parsedJson["id"],
|
|
|
|
|
reportPartID: reportJson != null ? reportJson["id"] : null,
|
|
|
|
|
code: parsedJson["partNo"],
|
|
|
|
|
name: parsedJson["partName"],
|
|
|
|
|
quantity: reportJson != null ? (reportJson["qty"] ?? 1).toInt() : 1,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|