mobile_skt/lib/models/sale_quotaion_component.mod...

76 lines
1.9 KiB
Dart
Raw Normal View History

2024-04-12 09:56:00 +08:00
class SaleQuotationComponentModel {
SaleQuotationComponentModel({
required this.id,
required this.createdAt,
required this.updatedAt,
required this.name,
required this.componentSpecification,
required this.unitId,
required this.unitPrice,
required this.remark,
required this.isDelete,
required this.unit,
});
final int? id;
final DateTime? createdAt;
final DateTime? updatedAt;
final String? name;
final String? componentSpecification;
final int? unitId;
final double? unitPrice;
final String? remark;
final int? isDelete;
final Unit? unit;
factory SaleQuotationComponentModel.fromJson(Map<String, dynamic> json) {
return SaleQuotationComponentModel(
id: json["id"],
createdAt: DateTime.tryParse(json["createdAt"] ?? ""),
updatedAt: DateTime.tryParse(json["updatedAt"] ?? ""),
name: json["name"],
componentSpecification: json["componentSpecification"],
unitId: json["unitId"],
unitPrice: double.parse(json["unitPrice"]),
remark: json["remark"],
isDelete: json["isDelete"],
unit: json["unit"] == null ? null : Unit.fromJson(json["unit"]),
);
}
Map<String, dynamic> toJson() => {
"id": id,
"createdAt": createdAt?.toIso8601String(),
"updatedAt": updatedAt?.toIso8601String(),
"name": name,
"componentSpecification": componentSpecification,
"unitId": unitId,
"unitPrice": unitPrice,
"remark": remark,
"isDelete": isDelete,
"unit": unit?.toJson(),
};
}
class Unit {
Unit({
required this.id,
required this.label,
});
final int? id;
final String? label;
factory Unit.fromJson(Map<String, dynamic> json) {
return Unit(
id: json["id"],
label: json["label"],
);
}
Map<String, dynamic> toJson() => {
"id": id,
"label": label,
};
}