class Part {
  String? id;
  String? code;
  String? name;
  int quantity;

  Part({
    this.id,
    this.code,
    this.name,
    this.quantity = 1,
  });

  factory Part.fromJson(Map<String, dynamic> parsedJson) {
    return Part(
      id: parsedJson["nid"] ?? parsedJson["id"],
      code: parsedJson["part_code"] ?? parsedJson["name"],
      name: parsedJson["part_name"],
      quantity: parsedJson["qty"] == null ? 1 : int.tryParse(parsedJson["qty"].toString()) ?? 1,
    );
  }
}
