import 'package:unit2/model/utils/industry_class.dart'; import '../utils/agency.dart'; import '../utils/position.dart'; class WorkHistory { final PositionTitle? position; final Agency? agency; final Supervisor? supervisor; final int? id; final DateTime? fromDate; final DateTime? toDate; final int? agencydepid; final double? monthlysalary; final String? statusAppointment; final int? salarygrade; final int? sgstep; final List? accomplishment; final List? actualDuties; WorkHistory({ required this.position, required this.agency, required this.supervisor, required this.id, required this.fromDate, required this.toDate, required this.agencydepid, required this.monthlysalary, required this.statusAppointment, required this.salarygrade, required this.sgstep, required this.accomplishment, required this.actualDuties, }); factory WorkHistory.fromJson(Map json) => WorkHistory( position: PositionTitle.fromJson(json["position"]), agency: json['agency'] == null?null: Agency.fromJson(json["agency"]), supervisor: json['supervisor'] == null?null: Supervisor.fromJson(json["supervisor"]), id: json["id"], fromDate: json['from_date'] == null?null: DateTime.tryParse(json["from_date"]), toDate: json['to_date'] == null?null: DateTime.tryParse(json["to_date"]), agencydepid: json["agencydepid"], monthlysalary: json["monthlysalary"], statusAppointment: json["status_appointment"], salarygrade: json["salarygrade"], sgstep: json["sgstep"], accomplishment:json['accomplishment'] == null?null: json['accomplishment'] == null?null: List.from( json["accomplishment"].map((x) => Accomplishment.fromJson(x))), actualDuties: json['actual_duties'] == null?null: List.from( json["actual_duties"].map((x) => ActualDuty.fromJson(x))), ); Map toJson() => { "position": position?.toJson(), "agency": agency?.toJson(), "supervisor": supervisor?.toJson(), "id": id, "from_date": "${fromDate?.year.toString().padLeft(4, '0')}-${fromDate?.month.toString().padLeft(2, '0')}-${fromDate?.day.toString().padLeft(2, '0')}", "to_date": toDate, "agencydepid": agencydepid, "monthlysalary": monthlysalary, "status_appointment": statusAppointment, "salarygrade": salarygrade, "sgstep": sgstep, "accomplishment": List.from(accomplishment!.map((x) => x.toJson())), "actual_duties": List.from(actualDuties!.map((x) => x.toJson())), }; } class Accomplishment { final int? id; final int? workExperienceId; final String? accomplishment; Accomplishment({ required this.id, required this.workExperienceId, required this.accomplishment, }); factory Accomplishment.fromJson(Map json) => Accomplishment( id: json["id"], workExperienceId: json["work_experience_id"], accomplishment: json["accomplishment"], ); Map toJson() => { "id": id, "work_experience_id": workExperienceId, "accomplishment": accomplishment, }; } class ActualDuty { final int? id; final int? workExperienceId; final String description; ActualDuty({ required this.id, required this.workExperienceId, required this.description, }); factory ActualDuty.fromJson(Map json) => ActualDuty( id: json["id"], workExperienceId: json["work_experience_id"], description: json["description"], ); Map toJson() => { "id": id, "work_experience_id": workExperienceId, "description": description, }; } class Supervisor { final int? id; final int? agencyId; final String? lastname; final String? firstname; final String? middlename; final String? stationName; Supervisor({ required this.id, required this.agencyId, required this.lastname, required this.firstname, required this.middlename, required this.stationName, }); factory Supervisor.fromJson(Map json) => Supervisor( id: json["id"], agencyId: json["agency_id"], lastname: json["lastname"], firstname: json["firstname"], middlename: json["middlename"], stationName: json["station_name"], ); Map toJson() => { "id": id, "agency_id": agencyId, "lastname": lastname, "firstname": firstname, "middlename": middlename, "station_name": stationName, }; }