import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/timer_model.dart';

import '../fault_description.dart';

class SearchWorkOrder {
  SearchWorkOrder({
    this.id,
    this.parentWOId,
    this.workOrderNo,
    this.workOrderYear,
    this.workOrderSequennce,
    this.callRequest,
    this.assetType,
    this.assignedEmployee,
    this.visitDate,
    this.assistantEmployees,
    this.supplier,
    this.vendorTicketNumber,
    this.contactPersonWorkOrders,
    this.calllastSituation,
    this.currentSituation,
    this.repairLocation,
    this.reason,
    // this.startofWorkTime,
    // this.endofWorkTime,
    this.workingHours,
    this.travelingHours,
    this.travelingExpenses,
    this.faultDescription,
    this.sparePartsWorkOrders,
    this.reviewComment,
    this.comment,
    this.attachmentsWorkOrder,
    this.equipmentStatus,
    this.suppEngineerWorkOrders,
    this.engSignature,
    this.nurseSignature,
    this.woParentDto,
    this.timer,
  });

  SearchWorkOrder.fromJson(dynamic json) {
    id = json['id'];
    parentWOId = json['parentWOId'];
    workOrderNo = json['workOrderNo'];
    workOrderYear = json['workOrderYear'];
    workOrderSequennce = json['workOrderSequennce'];
    callRequest = json['callRequest'] != null ? CallRequest.fromJson(json['callRequest']) : null;
    assetType = json['assetType'] != null ? Lookup.fromJson(json['assetType']) : null;
    assignedEmployee = json['assignedEmployee'] != null ? AssignedEmployee.fromJson(json['assignedEmployee']) : null;
    visitDate = json['visitDate'];
    if (json['assistantEmployees'] != null) {
      assistantEmployees = [];
      json['assistantEmployees'].forEach((v) {
        assistantEmployees.add(AssistantEmployees.fromJson(v));
      });
    }
    supplier = json['supplier'] != null ? SupplierModel.fromJson(json['supplier']) : null;
    vendorTicketNumber = json['vendorTicketNumber'];
    if (json['contactPersonWorkOrders'] != null) {
      contactPersonWorkOrders = [];
      json['contactPersonWorkOrders'].forEach((v) {
        contactPersonWorkOrders.add(ContactPersonWorkOrders.fromJson(v));
      });
    }
    calllastSituation = json['calllastSituation'] != null ? Lookup.fromJson(json['calllastSituation']) : null;
    currentSituation = json['currentSituation'] != null ? Lookup.fromJson(json['currentSituation']) : null;
    repairLocation = json['repairLocation'] != null ? Lookup.fromJson(json['repairLocation']) : null;
    reason = json['reason'] != null ? Lookup.fromJson(json['reason']) : null;
    // startofWorkTime = json['startofWorkTime'];
    // endofWorkTime = json['endofWorkTime'];
    if (json['startofWorkTime'] != null || json['endofWorkTime'] != null) {
      timer = TimerModel();
    }
    if (json['startofWorkTime'] != null) timer.startAt = DateTime.tryParse(json['startofWorkTime']);
    if (json['endofWorkTime'] != null) timer.endAt = DateTime.tryParse(json['endofWorkTime']);
    workingHours = json['workingHours'];
    travelingHours = json['travelingHours'];
    travelingExpenses = json['travelingExpenses'];
    faultDescription = json['faultDescription'] != null ? FaultDescription.fromJson(json['faultDescription']) : null;
    if (json['sparePartsWorkOrders'] != null) {
      sparePartsWorkOrders = [];
      json['sparePartsWorkOrders'].forEach((v) {
        sparePartsWorkOrders.add(SparePartsWorkOrders.fromJson(v));
      });
    }
    reviewComment = json['reviewComment'];
    comment = json['comment'];
    if (json['attachmentsWorkOrder'] != null) {
      attachmentsWorkOrder = [];
      json['attachmentsWorkOrder'].forEach((v) {
        attachmentsWorkOrder.add(AttachmentsWorkOrder.fromJson(v));
      });
    }
    equipmentStatus = json['equipmentStatus'] != null ? Lookup.fromJson(json['equipmentStatus']) : null;
    if (json['suppEngineerWorkOrders'] != null) {
      suppEngineerWorkOrders = [];
      json['suppEngineerWorkOrders'].forEach((v) {
        suppEngineerWorkOrders.add(SuppEngineerWorkOrders.fromJson(v));
      });
    }
    engSignature = json['engSignature'];
    nurseSignature = json['nurseSignature'];
    woParentDto = json['woParentDto'] != null ? WoParentDto.fromJson(json['woParentDto']) : null;
  }

  void copyFrom(SearchWorkOrder wo) {
    parentWOId = wo.parentWOId ?? parentWOId;
    workOrderNo = wo.workOrderNo ?? workOrderNo;
    workOrderYear = wo.workOrderYear ?? workOrderYear;
    workOrderSequennce = wo.workOrderSequennce ?? workOrderSequennce;
    callRequest = wo.callRequest ?? callRequest;
    if (wo.assetType != null) assetType = Lookup.fromJson((wo.assetType)?.toMap() ?? {});
    if (wo.assignedEmployee != null) assignedEmployee = AssignedEmployee.fromJson((wo.assignedEmployee)?.toJson() ?? {});
    visitDate = wo.visitDate ?? visitDate;
    assistantEmployees = (wo.assistantEmployees ?? assistantEmployees)
            ?.map((e) => AssistantEmployees.fromJson({
                  "id": e?.id,
                  "user": {"name": e?.user?.name, "id": (e?.user?.id) ?? "0"}
                }))
            ?.toList() ??
        [];
    if (wo.supplier != null) supplier = SupplierModel.fromJson((wo.supplier)?.toJson() ?? {});
    vendorTicketNumber = wo.vendorTicketNumber ?? vendorTicketNumber;
    contactPersonWorkOrders = (wo.contactPersonWorkOrders ?? contactPersonWorkOrders)?.map((e) => ContactPersonWorkOrders.fromJson(e?.toJson() ?? {}))?.toList() ?? [];
    calllastSituation = Lookup.fromJson((wo.calllastSituation ?? calllastSituation)?.toMap() ?? {});
    if (wo.currentSituation != null) currentSituation = Lookup.fromJson((wo.currentSituation)?.toMap() ?? {});
    repairLocation = Lookup.fromJson((wo.repairLocation ?? repairLocation)?.toMap() ?? {});
    reason = Lookup.fromJson((wo.reason ?? reason)?.toMap() ?? {});
    // startofWorkTime = wo.startofWorkTime ?? startofWorkTime;
    // endofWorkTime = wo.endofWorkTime ?? endofWorkTime;
    timer = wo.timer ?? timer;
    workingHours = wo.workingHours ?? workingHours;
    travelingHours = wo.travelingHours ?? travelingHours;
    travelingExpenses = wo.travelingExpenses ?? travelingExpenses;
    faultDescription = FaultDescription.fromJson((wo.faultDescription ?? faultDescription)?.toJson() ?? {});
    sparePartsWorkOrders = (wo.sparePartsWorkOrders ?? sparePartsWorkOrders)?.map((e) => SparePartsWorkOrders.fromJson(e?.toJson() ?? {}))?.toList() ?? [];
    reviewComment = wo.reviewComment ?? reviewComment;
    comment = wo.comment ?? comment;
    attachmentsWorkOrder = (wo.attachmentsWorkOrder ?? attachmentsWorkOrder)?.map((e) => AttachmentsWorkOrder.fromJson(e?.toJson() ?? {}))?.toList() ?? [];
    equipmentStatus = Lookup.fromJson((wo.equipmentStatus ?? equipmentStatus)?.toMap() ?? {});
    suppEngineerWorkOrders = (wo.suppEngineerWorkOrders ?? suppEngineerWorkOrders)?.map((e) => SuppEngineerWorkOrders.fromJson(e?.toJson() ?? {}))?.toList() ?? [];
    engSignature = wo.engSignature ?? engSignature;
    nurseSignature = wo.nurseSignature ?? nurseSignature;
    woParentDto = wo.woParentDto ?? woParentDto;
  }

  num id;
  num parentWOId;
  String workOrderNo;
  num workOrderYear;
  num workOrderSequennce;
  CallRequest callRequest;
  Lookup assetType;
  AssignedEmployee assignedEmployee;
  String visitDate;
  List<AssistantEmployees> assistantEmployees;
  SupplierModel supplier;
  String vendorTicketNumber;
  List<ContactPersonWorkOrders> contactPersonWorkOrders;
  Lookup calllastSituation;
  Lookup currentSituation;
  Lookup repairLocation;
  Lookup reason;
  // String startofWorkTime;
  // String endofWorkTime;
  num workingHours;
  num travelingHours;
  num travelingExpenses;
  FaultDescription faultDescription;
  List<SparePartsWorkOrders> sparePartsWorkOrders;
  String reviewComment;
  String comment;
  List<AttachmentsWorkOrder> attachmentsWorkOrder;
  Lookup equipmentStatus;
  List<SuppEngineerWorkOrders> suppEngineerWorkOrders;
  String engSignature;
  String nurseSignature;
  WoParentDto woParentDto;
  TimerModel timer;

  SearchWorkOrder copyWith({
    num id,
    num parentWOId,
    String workOrderNo,
    num workOrderYear,
    num workOrderSequennce,
    CallRequest callRequest,
    Lookup assetType,
    AssignedEmployee assignedEmployee,
    String visitDate,
    List<AssistantEmployees> assistantEmployees,
    SupplierModel supplier,
    String vendorTicketNumber,
    List<ContactPersonWorkOrders> contactPersonWorkOrders,
    Lookup calllastSituation,
    Lookup currentSituation,
    Lookup repairLocation,
    Lookup reason,
    // String startofWorkTime,
    // String endofWorkTime,
    num workingHours,
    num travelingHours,
    num travelingExpenses,
    FaultDescription faultDescription,
    List<SparePartsWorkOrders> sparePartsWorkOrders,
    String reviewComment,
    String comment,
    List<AttachmentsWorkOrder> attachmentsWorkOrder,
    Lookup equipmentStatus,
    List<SuppEngineerWorkOrders> suppEngineerWorkOrders,
    String engSignature,
    String nurseSignature,
    WoParentDto woParentDto,
    TimerModel timer,
  }) =>
      SearchWorkOrder(
        id: id ?? this.id,
        parentWOId: parentWOId ?? this.parentWOId,
        workOrderNo: workOrderNo ?? this.workOrderNo,
        workOrderYear: workOrderYear ?? this.workOrderYear,
        workOrderSequennce: workOrderSequennce ?? this.workOrderSequennce,
        callRequest: callRequest ?? this.callRequest,
        assetType: assetType ?? this.assetType,
        assignedEmployee: assignedEmployee ?? this.assignedEmployee,
        visitDate: visitDate ?? this.visitDate,
        assistantEmployees: assistantEmployees ?? this.assistantEmployees,
        supplier: supplier ?? this.supplier,
        vendorTicketNumber: vendorTicketNumber ?? this.vendorTicketNumber,
        contactPersonWorkOrders: contactPersonWorkOrders ?? this.contactPersonWorkOrders,
        calllastSituation: calllastSituation ?? this.calllastSituation,
        currentSituation: currentSituation ?? this.currentSituation,
        repairLocation: repairLocation ?? this.repairLocation,
        reason: reason ?? this.reason,
        // startofWorkTime: startofWorkTime ?? this.startofWorkTime,
        // endofWorkTime: endofWorkTime ?? this.endofWorkTime,
        workingHours: workingHours ?? this.workingHours,
        travelingHours: travelingHours ?? this.travelingHours,
        travelingExpenses: travelingExpenses ?? this.travelingExpenses,
        faultDescription: faultDescription ?? this.faultDescription,
        sparePartsWorkOrders: sparePartsWorkOrders ?? this.sparePartsWorkOrders,
        reviewComment: reviewComment ?? this.reviewComment,
        comment: comment ?? this.comment,
        attachmentsWorkOrder: attachmentsWorkOrder ?? this.attachmentsWorkOrder,
        equipmentStatus: equipmentStatus ?? this.equipmentStatus,
        suppEngineerWorkOrders: suppEngineerWorkOrders ?? this.suppEngineerWorkOrders,
        engSignature: engSignature ?? this.engSignature,
        nurseSignature: nurseSignature ?? this.nurseSignature,
        woParentDto: woParentDto ?? this.woParentDto,
        timer: timer ?? this.timer,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['parentWOId'] = parentWOId;
    map['workOrderNo'] = workOrderNo;
    map['workOrderYear'] = workOrderYear;
    map['workOrderSequennce'] = workOrderSequennce;
    if (callRequest != null) {
      map['callRequest'] = callRequest.toJson();
    }
    if (assetType != null) {
      map['assetType'] = assetType.toMap();
    }
    if (assignedEmployee != null) {
      map['assignedEmployee'] = assignedEmployee.toJson();
    }
    map['visitDate'] = visitDate;
    if (assistantEmployees != null) {
      map['assistantEmployees'] = assistantEmployees.map((v) => v?.toJson()).toList();
    }
    if (supplier != null) {
      map['supplier'] = supplier.toJson();
    }
    map['vendorTicketNumber'] = vendorTicketNumber;
    if (contactPersonWorkOrders != null) {
      map['contactPersonWorkOrders'] = contactPersonWorkOrders.map((v) => v.toJson()).toList();
    }
    if (calllastSituation != null) {
      map['calllastSituation'] = calllastSituation.toMap();
    }
    map['currentSituation'] = currentSituation?.toMap();
    if (repairLocation?.id != null) {
      map['repairLocation'] = repairLocation.toMap();
    }
    if (reason != null) {
      map['reason'] = reason.toMap();
    }
    // map['startofWorkTime'] = startofWorkTime;
    // map['endofWorkTime'] = endofWorkTime;
    map['startofWorkTime'] = timer?.startAt?.toIso8601String();
    map['endofWorkTime'] = timer?.endAt?.toIso8601String();
    map['workingHours'] = workingHours;
    map['travelingHours'] = travelingHours;
    map['travelingExpenses'] = travelingExpenses;

    if (faultDescription?.id != null) {
      map['faultDescription'] = faultDescription.toJson();
    }
    if (sparePartsWorkOrders != null) {
      map['sparePartsWorkOrders'] = sparePartsWorkOrders.map((v) => v.toJson()).toList();
    }
    map['reviewComment'] = reviewComment;
    map['comment'] = comment;
    if (attachmentsWorkOrder != null) {
      map['attachmentsWorkOrder'] = attachmentsWorkOrder.map((v) => v.toJson()).toList();
    }
    if (equipmentStatus != null) {
      map['equipmentStatus'] = equipmentStatus.toMap();
    }
    if (suppEngineerWorkOrders != null) {
      map['suppEngineerWorkOrders'] = suppEngineerWorkOrders.map((v) => v.toJson()).toList();
    }
    map['engSignature'] = engSignature;
    map['nurseSignature'] = nurseSignature;
    if (woParentDto != null) {
      map['woParentDto'] = woParentDto.toJson();
    }
    return map;
  }
}

class WoParentDto {
  WoParentDto({
    this.callLastSituation,
    this.supplier,
    this.assetType,
    this.vendorTicketNumber,
    this.callId,
    this.id,
    this.stepsWorkOrderDto,
    this.suppEngineerWorkOrders,
    this.equipmentStatus,
    this.currentSituation,
  });

  WoParentDto.fromJson(dynamic json) {
    callLastSituation = json['callLastSituation'] != null ? Lookup.fromJson(json['callLastSituation']) : null;
    supplier = json['supplier'] != null ? SupplierModel.fromJson(json['supplier']) : null;
    assetType = json['assetType'] != null ? Lookup.fromJson(json['assetType']) : null;
    vendorTicketNumber = json['vendorTicketNumber'];
    callId = json['callId'];
    id = json['id'];
    stepsWorkOrderDto = json['stepsWorkOrderDto'] != null ? StepsWorkOrderDto.fromJson(json['stepsWorkOrderDto']) : null;
    if (json['suppEngineerWorkOrders'] != null) {
      suppEngineerWorkOrders = [];
      json['suppEngineerWorkOrders'].forEach((v) {
        suppEngineerWorkOrders.add(SuppEngineerWorkOrders.fromJson(v));
      });
    }
    equipmentStatus = json['equipmentStatus'] != null ? Lookup.fromJson(json['equipmentStatus']) : null;
    currentSituation = json['currentSituation'] != null ? Lookup.fromJson(json['currentSituation']) : null;
  }
  Lookup callLastSituation;
  SupplierModel supplier;
  Lookup assetType;
  String vendorTicketNumber;
  num callId;
  num id;
  StepsWorkOrderDto stepsWorkOrderDto;
  List<SuppEngineerWorkOrders> suppEngineerWorkOrders;
  Lookup equipmentStatus;
  Lookup currentSituation;
  WoParentDto copyWith({
    Lookup callLastSituation,
    SupplierModel supplier,
    Lookup assetType,
    String vendorTicketNumber,
    num callId,
    num id,
    StepsWorkOrderDto stepsWorkOrderDto,
    List<SuppEngineerWorkOrders> suppEngineerWorkOrders,
    Lookup equipmentStatus,
    Lookup currentSituation,
  }) =>
      WoParentDto(
        callLastSituation: callLastSituation ?? this.callLastSituation,
        supplier: supplier ?? this.supplier,
        assetType: assetType ?? this.assetType,
        vendorTicketNumber: vendorTicketNumber ?? this.vendorTicketNumber,
        callId: callId ?? this.callId,
        id: id ?? this.id,
        stepsWorkOrderDto: stepsWorkOrderDto ?? this.stepsWorkOrderDto,
        suppEngineerWorkOrders: suppEngineerWorkOrders ?? this.suppEngineerWorkOrders,
        equipmentStatus: equipmentStatus ?? this.equipmentStatus,
        currentSituation: currentSituation ?? this.currentSituation,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    if (callLastSituation != null) {
      map['callLastSituation'] = callLastSituation.toMap();
    }
    if (supplier != null) {
      map['supplier'] = supplier.toJson();
    }
    if (assetType != null) {
      map['assetType'] = assetType.toMap();
    }
    map['vendorTicketNumber'] = vendorTicketNumber;
    map['callId'] = callId ?? 0;
    map['id'] = id ?? 0;
    if (stepsWorkOrderDto != null) {
      map['stepsWorkOrderDto'] = stepsWorkOrderDto.toJson();
    }
    if (suppEngineerWorkOrders != null) {
      map['suppEngineerWorkOrders'] = suppEngineerWorkOrders.map((v) => v.toJson()).toList();
    }
    if (equipmentStatus != null) {
      map['equipmentStatus'] = equipmentStatus.toMap();
    }
    if (currentSituation != null) {
      map['currentSituation'] = currentSituation.toMap();
    }
    return map;
  }
}

class SuppEngineerWorkOrders {
  SuppEngineerWorkOrders({
    this.id,
    this.supplierContactId,
    this.personName,
    this.personRoleName,
    this.contact,
    this.externalEngCode,
    this.email,
  });

  SuppEngineerWorkOrders.fromJson(dynamic json) {
    id = json['id'];
    supplierContactId = json['supplierContactId'];
    personName = json['personName'];
    personRoleName = json['personRoleName'];
    contact = json['contact'];
    externalEngCode = json['externalEngCode'];
    email = json['email'];
  }
  num id;
  num supplierContactId;
  String personName;
  String personRoleName;
  String contact;
  String externalEngCode;
  String email;
  SuppEngineerWorkOrders copyWith({
    num id,
    num supplierContactId,
    String personName,
    String personRoleName,
    String contact,
    String externalEngCode,
    String email,
  }) =>
      SuppEngineerWorkOrders(
        id: id ?? this.id,
        supplierContactId: supplierContactId ?? this.supplierContactId,
        personName: personName ?? this.personName,
        personRoleName: personRoleName ?? this.personRoleName,
        contact: contact ?? this.contact,
        externalEngCode: externalEngCode ?? this.externalEngCode,
        email: email ?? this.email,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['supplierContactId'] = supplierContactId;
    map['personName'] = personName;
    map['personRoleName'] = personRoleName;
    map['contact'] = contact;
    map['externalEngCode'] = externalEngCode;
    map['email'] = email;
    return map;
  }
}

class StepsWorkOrderDto {
  StepsWorkOrderDto({
    this.sequence,
    this.id,
    this.name,
    this.statusValue,
    this.typeTransaction,
    this.processed,
    this.parentWOId,
    this.callId,
  });

  StepsWorkOrderDto.fromJson(dynamic json) {
    sequence = json['sequence'];
    id = json['id'];
    name = json['name'];
    statusValue = json['statusValue'];
    typeTransaction = json['typeTransaction'];
    processed = json['processed'];
    parentWOId = json['parentWOId'];
    callId = json['callId'];
  }
  num sequence;
  num id;
  String name;
  num statusValue;
  String typeTransaction;
  bool processed;
  num parentWOId;
  num callId;
  StepsWorkOrderDto copyWith({
    num sequence,
    num id,
    String name,
    num statusValue,
    String typeTransaction,
    bool processed,
    num parentWOId,
    num callId,
  }) =>
      StepsWorkOrderDto(
        sequence: sequence ?? this.sequence,
        id: id ?? this.id,
        name: name ?? this.name,
        statusValue: statusValue ?? this.statusValue,
        typeTransaction: typeTransaction ?? this.typeTransaction,
        processed: processed ?? this.processed,
        parentWOId: parentWOId ?? this.parentWOId,
        callId: callId ?? this.callId,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['sequence'] = sequence;
    map['id'] = id ?? 0;
    map['name'] = name;
    map['statusValue'] = statusValue;
    map['typeTransaction'] = typeTransaction;
    map['processed'] = processed;
    map['parentWOId'] = parentWOId;
    map['callId'] = callId;
    return map;
  }
}

class SupplierModel {
  SupplierModel({
    this.id,
    this.suppliername,
    this.name,
    this.website,
    this.email,
    this.code,
    this.suppNo,
    this.suppStatusId,
    this.cityId,
    this.person,
    this.comment,
    this.zipcode,
    this.contact,
    this.telephones,
    this.faxes,
    this.addresses,
    this.attachments,
    this.suppPersons,
    this.suppTCodes,
  });

  SupplierModel.fromJson(dynamic json) {
    id = json['id'] ?? 0;
    suppliername = json['suppliername'];
    name = json['name'];
    website = json['website'];
    email = json['email'];
    code = json['code'];
    suppNo = json['suppNo'];
    suppStatusId = json['suppStatusId'];
    cityId = json['cityId'];
    person = json['person'];
    comment = json['comment'];
    zipcode = json['zipcode'];
    contact = json['contact'];
    if (json['telephones'] != null) {
      telephones = [];
      json['telephones'].forEach((v) {
        telephones.add(Telephones.fromJson(v));
      });
    }
    if (json['faxes'] != null) {
      faxes = [];
      json['faxes'].forEach((v) {
        faxes.add(Faxes.fromJson(v));
      });
    }
    if (json['addresses'] != null) {
      addresses = [];
      json['addresses'].forEach((v) {
        addresses.add(Addresses.fromJson(v));
      });
    }
    if (json['attachments'] != null) {
      attachments = [];
      json['attachments'].forEach((v) {
        attachments.add(Attachments.fromJson(v));
      });
    }
    if (json['suppPersons'] != null) {
      suppPersons = [];
      json['suppPersons'].forEach((v) {
        suppPersons.add(SuppPersons.fromJson(v));
      });
    }
    if (json['suppTCodes'] != null) {
      suppTCodes = [];
      json['suppTCodes'].forEach((v) {
        suppTCodes.add(SuppTCodes.fromJson(v));
      });
    }
  }
  num id;
  String suppliername;
  String name;
  String website;
  String email;
  String code;
  num suppNo;
  num suppStatusId;
  num cityId;
  String person;
  String comment;
  num zipcode;
  String contact;
  List<Telephones> telephones;
  List<Faxes> faxes;
  List<Addresses> addresses;
  List<Attachments> attachments;
  List<SuppPersons> suppPersons;
  List<SuppTCodes> suppTCodes;
  SupplierModel copyWith({
    num id,
    String suppliername,
    String name,
    String website,
    String email,
    String code,
    num suppNo,
    num suppStatusId,
    num cityId,
    String person,
    String comment,
    num zipcode,
    String contact,
    List<Telephones> telephones,
    List<Faxes> faxes,
    List<Addresses> addresses,
    List<Attachments> attachments,
    List<SuppPersons> suppPersons,
    List<SuppTCodes> suppTCodes,
  }) =>
      SupplierModel(
        id: id ?? this.id ?? 0,
        suppliername: suppliername ?? this.suppliername,
        name: name ?? this.name,
        website: website ?? this.website,
        email: email ?? this.email,
        code: code ?? this.code,
        suppNo: suppNo ?? this.suppNo,
        suppStatusId: suppStatusId ?? this.suppStatusId,
        cityId: cityId ?? this.cityId,
        person: person ?? this.person,
        comment: comment ?? this.comment,
        zipcode: zipcode ?? this.zipcode,
        contact: contact ?? this.contact,
        telephones: telephones ?? this.telephones,
        faxes: faxes ?? this.faxes,
        addresses: addresses ?? this.addresses,
        attachments: attachments ?? this.attachments,
        suppPersons: suppPersons ?? this.suppPersons,
        suppTCodes: suppTCodes ?? this.suppTCodes,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['suppliername'] = suppliername;
    map['name'] = name;
    map['website'] = website;
    map['email'] = email;
    map['code'] = code;
    map['suppNo'] = suppNo;
    map['suppStatusId'] = suppStatusId;
    map['cityId'] = cityId;
    map['person'] = person;
    map['comment'] = comment;
    map['zipcode'] = zipcode;
    map['contact'] = contact;
    if (telephones != null) {
      map['telephones'] = telephones.map((v) => v.toJson()).toList();
    }
    if (faxes != null) {
      map['faxes'] = faxes.map((v) => v.toJson()).toList();
    }
    if (addresses != null) {
      map['addresses'] = addresses.map((v) => v.toJson()).toList();
    }
    if (attachments != null) {
      map['attachments'] = attachments.map((v) => v.toJson()).toList();
    }
    if (suppPersons != null) {
      map['suppPersons'] = suppPersons.map((v) => v.toJson()).toList();
    }
    if (suppTCodes != null) {
      map['suppTCodes'] = suppTCodes.map((v) => v.toJson()).toList();
    }
    return map;
  }
}

class SuppTCodes {
  SuppTCodes({
    this.id,
    this.supplierId,
    this.codeTypeId,
    this.codeValue,
  });

  SuppTCodes.fromJson(dynamic json) {
    id = json['id'];
    supplierId = json['supplierId'];
    codeTypeId = json['codeTypeId'];
    codeValue = json['codeValue'];
  }
  num id;
  num supplierId;
  num codeTypeId;
  String codeValue;
  SuppTCodes copyWith({
    num id,
    num supplierId,
    num codeTypeId,
    String codeValue,
  }) =>
      SuppTCodes(
        id: id ?? this.id ?? 0,
        supplierId: supplierId ?? this.supplierId,
        codeTypeId: codeTypeId ?? this.codeTypeId,
        codeValue: codeValue ?? this.codeValue,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['supplierId'] = supplierId;
    map['codeTypeId'] = codeTypeId;
    map['codeValue'] = codeValue;
    return map;
  }
}

class SuppPersons {
  SuppPersons({
    this.id,
    this.supplierId,
    this.personName,
    this.personRoleId,
    this.contact,
    this.externalEngCode,
    this.email,
  });

  SuppPersons.fromJson(dynamic json) {
    id = json['id'];
    supplierId = json['supplierId'];
    personName = json['personName'];
    personRoleId = json['personRoleId'];
    contact = json['contact'];
    externalEngCode = json['externalEngCode'];
    email = json['email'];
  }
  num id;
  num supplierId;
  String personName;
  num personRoleId;
  String contact;
  String externalEngCode;
  String email;
  SuppPersons copyWith({
    num id,
    num supplierId,
    String personName,
    num personRoleId,
    String contact,
    String externalEngCode,
    String email,
  }) =>
      SuppPersons(
        id: id ?? this.id,
        supplierId: supplierId ?? this.supplierId,
        personName: personName ?? this.personName,
        personRoleId: personRoleId ?? this.personRoleId,
        contact: contact ?? this.contact,
        externalEngCode: externalEngCode ?? this.externalEngCode,
        email: email ?? this.email,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['supplierId'] = supplierId;
    map['personName'] = personName;
    map['personRoleId'] = personRoleId;
    map['contact'] = contact;
    map['externalEngCode'] = externalEngCode;
    map['email'] = email;
    return map;
  }
}

class Attachments {
  Attachments({
    this.id,
    this.supplierId,
    this.attachmentName,
    this.attachmentURL,
  });

  Attachments.fromJson(dynamic json) {
    id = json['id'];
    supplierId = json['supplierId'];
    attachmentName = json['attachmentName'];
    attachmentURL = json['attachmentURL'];
  }
  num id;
  num supplierId;
  String attachmentName;
  String attachmentURL;
  Attachments copyWith({
    num id,
    num supplierId,
    String attachmentName,
    String attachmentURL,
  }) =>
      Attachments(
        id: id ?? this.id,
        supplierId: supplierId ?? this.supplierId,
        attachmentName: attachmentName ?? this.attachmentName,
        attachmentURL: attachmentURL ?? this.attachmentURL,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['supplierId'] = supplierId;
    map['attachmentName'] = attachmentName;
    map['attachmentURL'] = attachmentURL;
    return map;
  }
}

class Addresses {
  Addresses({
    this.id,
    this.supplierId,
    this.address,
  });

  Addresses.fromJson(dynamic json) {
    id = json['id'];
    supplierId = json['supplierId'];
    address = json['address'];
  }
  num id;
  num supplierId;
  String address;
  Addresses copyWith({
    num id,
    num supplierId,
    String address,
  }) =>
      Addresses(
        id: id ?? this.id,
        supplierId: supplierId ?? this.supplierId,
        address: address ?? this.address,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['supplierId'] = supplierId;
    map['address'] = address;
    return map;
  }
}

class Faxes {
  Faxes({
    this.id,
    this.supplierId,
    this.fax,
  });

  Faxes.fromJson(dynamic json) {
    id = json['id'];
    supplierId = json['supplierId'];
    fax = json['fax'];
  }
  num id;
  num supplierId;
  String fax;
  Faxes copyWith({
    num id,
    num supplierId,
    String fax,
  }) =>
      Faxes(
        id: id ?? this.id,
        supplierId: supplierId ?? this.supplierId,
        fax: fax ?? this.fax,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['supplierId'] = supplierId;
    map['fax'] = fax;
    return map;
  }
}

class Telephones {
  Telephones({
    this.id,
    this.supplierId,
    this.telephone,
  });

  Telephones.fromJson(dynamic json) {
    id = json['id'];
    supplierId = json['supplierId'];
    telephone = json['telephone'];
  }
  num id;
  num supplierId;
  String telephone;
  Telephones copyWith({
    num id,
    num supplierId,
    String telephone,
  }) =>
      Telephones(
        id: id ?? this.id,
        supplierId: supplierId ?? this.supplierId,
        telephone: telephone ?? this.telephone,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['supplierId'] = supplierId;
    map['telephone'] = telephone;
    return map;
  }
}

class AttachmentsWorkOrder {
  AttachmentsWorkOrder({
    this.id,
    this.name,
  });

  AttachmentsWorkOrder.fromJson(dynamic json) {
    id = json['id'];
    name = json['name'];
  }
  num id;
  String name;
  AttachmentsWorkOrder copyWith({
    num id,
    String name,
  }) =>
      AttachmentsWorkOrder(
        id: id ?? this.id,
        name: name ?? this.name,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['name'] = name;
    return map;
  }
}

class SparePartsWorkOrders {
  SparePartsWorkOrders({
    this.id,
    this.sparePart,
    this.qty,
    this.returnQty,
    this.installQty,
  });

  SparePartsWorkOrders.fromJson(dynamic json) {
    id = json['id'];
    sparePart = json['sparePart'] != null ? SparePart.fromJson(json['sparePart']) : null;
    qty = json['qty'];
    returnQty = json['returnQty'];
    installQty = json['installQty'];
  }
  num id;
  SparePart sparePart;
  num qty;
  num returnQty;
  num installQty;
  SparePartsWorkOrders copyWith({
    num id,
    SparePart sparePart,
    num qty,
    num returnQty,
    num installQty,
  }) =>
      SparePartsWorkOrders(
        id: id ?? this.id,
        sparePart: sparePart ?? this.sparePart,
        qty: qty ?? this.qty,
        returnQty: returnQty ?? this.returnQty,
        installQty: installQty ?? this.installQty,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    if (sparePart != null) {
      map['sparePart'] = sparePart.toJson();
    }
    map['qty'] = qty;
    map['returnQty'] = returnQty;
    map['installQty'] = installQty;
    return map;
  }
}

class SparePart {
  SparePart({
    this.id,
    this.partNo,
    this.partName,
  });

  SparePart.fromJson(dynamic json) {
    id = json['id'];
    partNo = json['partNo'];
    partName = json['partName'];
  }
  num id;
  String partNo;
  String partName;
  SparePart copyWith({
    num id,
    String partNo,
    String partName,
  }) =>
      SparePart(
        id: id ?? this.id,
        partNo: partNo ?? this.partNo,
        partName: partName ?? this.partName,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['partNo'] = partNo;
    map['partName'] = partName;
    return map;
  }
}

class ContactPersonWorkOrders {
  ContactPersonWorkOrders({
    this.id,
    this.employeeCode,
    this.name,
    this.telephone,
    this.job,
    this.email,
    this.land,
    this.contactUserId,
  });

  ContactPersonWorkOrders.fromJson(dynamic json) {
    id = json['id'];
    employeeCode = json['employeeCode'];
    name = json['name'];
    telephone = json['telephone'];
    job = json['job'];
    email = json['email'];
    land = json['land'];
    contactUserId = json['contactUserId'];
  }
  num id;
  String employeeCode;
  String name;
  String telephone;
  String job;
  String email;
  String land;
  String contactUserId;
  ContactPersonWorkOrders copyWith({
    num id,
    String employeeCode,
    String name,
    String telephone,
    String job,
    String email,
    String land,
    String contactUserId,
  }) =>
      ContactPersonWorkOrders(
        id: id ?? this.id,
        employeeCode: employeeCode ?? this.employeeCode,
        name: name ?? this.name,
        telephone: telephone ?? this.telephone,
        job: job ?? this.job,
        email: email ?? this.email,
        land: land ?? this.land,
        contactUserId: contactUserId ?? this.contactUserId,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['employeeCode'] = employeeCode;
    map['name'] = name;
    map['telephone'] = telephone;
    map['job'] = job;
    map['email'] = email;
    map['land'] = land;
    map['contactUserId'] = contactUserId;
    return map;
  }
}

class AssistantEmployees {
  AssistantEmployees({
    this.id,
    this.user,
  });

  AssistantEmployees.fromJson(dynamic json) {
    id = json['id'];
    user = json['user'] != null ? UserModel.fromJson(json['user']) : UserModel(name: json['userName'], id: json['userId']);
  }
  num id;
  UserModel user;
  AssistantEmployees copyWith({
    num id,
    UserModel user,
  }) =>
      AssistantEmployees(
        id: id ?? this.id,
        user: user ?? this.user,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    if (user != null) {
      map['user'] = user.toJson();
    }
    return map;
  }
}

class UserModel {
  UserModel({
    this.id,
    this.name,
  });

  UserModel.fromJson(dynamic json) {
    id = json['id'];
    name = json['name'];
  }
  String id;
  String name;
  UserModel copyWith({
    String id,
    String name,
  }) =>
      UserModel(
        id: id ?? this.id,
        name: name ?? this.name,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['name'] = name;
    return map;
  }
}

class AssignedEmployee {
  AssignedEmployee({
    this.id,
    this.name,
  });

  AssignedEmployee.fromJson(dynamic json) {
    id = json['id'];
    name = json['name'];
  }
  String id;
  String name;
  AssignedEmployee copyWith({
    String id,
    String name,
  }) =>
      AssignedEmployee(
        id: id ?? this.id,
        name: name ?? this.name,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['name'] = name;
    return map;
  }
}

class CallRequest {
  CallRequest({
    this.id,
    this.callNo,
    this.callComments,
    this.asset,
    this.assignedEmployee,
    this.callSiteContactPerson,
    this.status,
    this.callLastSituation,
    this.defectType,
    this.firstAction,
    this.assetType,
  });

  CallRequest.fromJson(dynamic json) {
    id = json['id'];
    callNo = json['callNo'];
    callComments = json['callComments'];
    asset = json['asset'] != null ? Asset.fromJson(json['asset']) : null;
    assignedEmployee = json['assignedEmployee'] != null ? AssignedEmployee.fromJson(json['assignedEmployee']) : null;
    if (json['callSiteContactPerson'] != null) {
      callSiteContactPerson = [];
      json['callSiteContactPerson'].forEach((v) {
        callSiteContactPerson.add(CallSiteContactPerson.fromJson(v));
      });
    }
    status = json['status'] != null ? Status.fromJson(json['status']) : null;
    callLastSituation = json['callLastSituation'] != null ? Lookup.fromJson(json['callLastSituation']) : null;
    defectType = json['defectType'] != null ? DefectType.fromJson(json['defectType']) : null;
    firstAction = json['firstAction'] != null ? FirstAction.fromJson(json['firstAction']) : null;
    assetType = json['assetType'];
  }
  num id;
  String callNo;
  String callComments;
  Asset asset;
  AssignedEmployee assignedEmployee;
  List<CallSiteContactPerson> callSiteContactPerson;
  Status status;
  Lookup callLastSituation;
  DefectType defectType;
  FirstAction firstAction;
  num assetType;
  CallRequest copyWith({
    num id,
    String callNo,
    String callComments,
    Asset asset,
    AssignedEmployee assignedEmployee,
    List<CallSiteContactPerson> callSiteContactPerson,
    Status status,
    Lookup callLastSituation,
    DefectType defectType,
    FirstAction firstAction,
    num assetType,
  }) =>
      CallRequest(
        id: id ?? this.id,
        callNo: callNo ?? this.callNo,
        callComments: callComments ?? this.callComments,
        asset: asset ?? this.asset,
        assignedEmployee: assignedEmployee ?? this.assignedEmployee,
        callSiteContactPerson: callSiteContactPerson ?? this.callSiteContactPerson,
        status: status ?? this.status,
        callLastSituation: callLastSituation ?? this.callLastSituation,
        defectType: defectType ?? this.defectType,
        firstAction: firstAction ?? this.firstAction,
        assetType: assetType ?? this.assetType,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['callNo'] = callNo;
    map['callComments'] = callComments;
    if (asset != null) {
      map['asset'] = asset.toJson();
    }
    if (assignedEmployee != null) {
      map['assignedEmployee'] = assignedEmployee.toJson();
    }
    if (callSiteContactPerson != null) {
      map['callSiteContactPerson'] = callSiteContactPerson.map((v) => v.toJson()).toList();
    }
    if (status != null) {
      map['status'] = status.toJson();
    }
    if (callLastSituation != null) {
      map['callLastSituation'] = callLastSituation.toMap();
    }
    if (defectType != null) {
      map['defectType'] = defectType.toJson();
    }
    if (firstAction != null) {
      map['firstAction'] = firstAction.toJson();
    }
    map['assetType'] = assetType;
    return map;
  }
}

class FirstAction {
  FirstAction({
    this.id,
    this.name,
    this.value,
  });

  FirstAction.fromJson(dynamic json) {
    id = json['id'];
    name = json['name'];
    value = json['value'];
  }
  num id;
  String name;
  num value;
  FirstAction copyWith({
    num id,
    String name,
    num value,
  }) =>
      FirstAction(
        id: id ?? this.id,
        name: name ?? this.name,
        value: value ?? this.value,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['name'] = name;
    map['value'] = value;
    return map;
  }
}

class DefectType {
  DefectType({
    this.id,
    this.name,
    this.value,
  });

  DefectType.fromJson(dynamic json) {
    id = json['id'];
    name = json['name'];
    value = json['value'];
  }
  num id;
  String name;
  num value;
  DefectType copyWith({
    num id,
    String name,
    num value,
  }) =>
      DefectType(
        id: id ?? this.id,
        name: name ?? this.name,
        value: value ?? this.value,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['name'] = name;
    map['value'] = value;
    return map;
  }
}

class Status {
  Status({
    this.id,
    this.name,
    this.value,
  });

  Status.fromJson(dynamic json) {
    id = json['id'];
    name = json['name'];
    value = json['value'];
  }
  num id;
  String name;
  num value;
  Status copyWith({
    num id,
    String name,
    num value,
  }) =>
      Status(
        id: id ?? this.id,
        name: name ?? this.name,
        value: value ?? this.value,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['name'] = name;
    map['value'] = value;
    return map;
  }
}

class CallSiteContactPerson {
  CallSiteContactPerson({
    this.id,
    this.employeeCode,
    this.name,
    this.telephone,
    this.job,
    this.email,
    this.land,
    this.contactUserId,
  });

  CallSiteContactPerson.fromJson(dynamic json) {
    id = json['id'];
    employeeCode = json['employeeCode'];
    name = json['name'];
    telephone = json['telephone'];
    job = json['job'];
    email = json['email'];
    land = json['land'];
    contactUserId = json['contactUserId'];
  }
  num id;
  String employeeCode;
  String name;
  String telephone;
  String job;
  String email;
  String land;
  String contactUserId;
  CallSiteContactPerson copyWith({
    num id,
    String employeeCode,
    String name,
    String telephone,
    String job,
    String email,
    String land,
    String contactUserId,
  }) =>
      CallSiteContactPerson(
        id: id ?? this.id,
        employeeCode: employeeCode ?? this.employeeCode,
        name: name ?? this.name,
        telephone: telephone ?? this.telephone,
        job: job ?? this.job,
        email: email ?? this.email,
        land: land ?? this.land,
        contactUserId: contactUserId ?? this.contactUserId,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['employeeCode'] = employeeCode;
    map['name'] = name;
    map['telephone'] = telephone;
    map['job'] = job;
    map['email'] = email;
    map['land'] = land;
    map['contactUserId'] = contactUserId;
    return map;
  }
}

class Asset {
  Asset({
    this.id,
    this.assetSerialNo,
    this.systemID,
    this.assetNumber,
    this.modelDefinition,
    this.supplier,
    this.ipAddress,
    this.macAddress,
    this.portNumber,
    this.assetReplace,
    this.oldAsset,
    this.isParent,
    this.parentAsset,
    this.assetType,
    this.site,
    this.building,
    this.floor,
    this.department,
    this.room,
    this.testsDay,
    this.purchasingPrice,
    this.nbv,
    this.currency,
    this.poNo,
    this.invoiceNumber,
    this.invoiceDate,
    this.replacementDate,
    this.originDepartment,
    this.originSite,
    this.budgetYear,
    this.lastPOPrice,
    this.commissioningStatus,
    this.productionDate,
    this.edd,
    this.technicalInspectionDate,
    this.deliveryInspectionDate,
    this.endUserAcceptanceDate,
    this.receivingCommittee,
    this.siteWarrantyMonths,
    this.extendedWarrantyMonths,
    this.remainderWarrantyMonths,
    this.eomWarrantyMonthsNo,
    this.warrantyValue,
    this.warrantyEndDate,
    this.warrantyContractConditions,
    this.technicalGuidanceBooks,
    this.comment,
    this.tagCode,
  });

  Asset.fromJson(dynamic json) {
    id = json['id'];
    assetSerialNo = json['assetSerialNo'];
    systemID = json['systemID'];
    assetNumber = json['assetNumber'];
    modelDefinition = json['modelDefinition'] != null ? ModelDefinition.fromJson(json['modelDefinition']) : null;
    supplier = json['supplier'] != null ? Supplier.fromJson(json['supplier']) : null;
    ipAddress = json['ipAddress'];
    macAddress = json['macAddress'];
    portNumber = json['portNumber'];
    assetReplace = json['assetReplace'] != null ? AssetReplace.fromJson(json['assetReplace']) : null;
    oldAsset = json['oldAsset'] != null ? OldAsset.fromJson(json['oldAsset']) : null;
    isParent = json['isParent'] != null ? IsParent.fromJson(json['isParent']) : null;
    parentAsset = json['parentAsset'] != null ? ParentAsset.fromJson(json['parentAsset']) : null;
    assetType = json['assetType'] != null ? Lookup.fromJson(json['assetType']) : null;
    site = json['site'] != null ? Site.fromJson(json['site']) : null;
    building = json['building'] != null ? Building.fromJson(json['building']) : null;
    floor = json['floor'] != null ? Floor.fromJson(json['floor']) : null;
    department = json['department'] != null ? Department.fromJson(json['department']) : null;
    room = json['room'];
    testsDay = json['testsDay'];
    purchasingPrice = json['purchasingPrice'];
    nbv = json['nbv'];
    currency = json['currency'] != null ? Currency.fromJson(json['currency']) : null;
    poNo = json['poNo'];
    invoiceNumber = json['invoiceNumber'];
    invoiceDate = json['invoiceDate'];
    replacementDate = json['replacementDate'];
    originDepartment = json['originDepartment'] != null ? OriginDepartment.fromJson(json['originDepartment']) : null;
    originSite = json['originSite'] != null ? OriginSite.fromJson(json['originSite']) : null;
    budgetYear = json['budgetYear'];
    lastPOPrice = json['lastPOPrice'];
    commissioningStatus = json['commissioningStatus'] != null ? CommissioningStatus.fromJson(json['commissioningStatus']) : null;
    productionDate = json['productionDate'];
    edd = json['edd'];
    technicalInspectionDate = json['technicalInspectionDate'];
    deliveryInspectionDate = json['deliveryInspectionDate'];
    endUserAcceptanceDate = json['endUserAcceptanceDate'];
    receivingCommittee = json['receivingCommittee'];
    siteWarrantyMonths = json['siteWarrantyMonths'] != null ? SiteWarrantyMonths.fromJson(json['siteWarrantyMonths']) : null;
    extendedWarrantyMonths = json['extendedWarrantyMonths'] != null ? ExtendedWarrantyMonths.fromJson(json['extendedWarrantyMonths']) : null;
    remainderWarrantyMonths = json['remainderWarrantyMonths'] != null ? RemainderWarrantyMonths.fromJson(json['remainderWarrantyMonths']) : null;
    eomWarrantyMonthsNo = json['eomWarrantyMonthsNo'];
    warrantyValue = json['warrantyValue'];
    warrantyEndDate = json['warrantyEndDate'];
    warrantyContractConditions = json['warrantyContractConditions'];
    if (json['technicalGuidanceBooks'] != null) {
      technicalGuidanceBooks = [];
      json['technicalGuidanceBooks'].forEach((v) {
        technicalGuidanceBooks.add(TechnicalGuidanceBooks.fromJson(v));
      });
    }
    comment = json['comment'];
    tagCode = json['tagCode'];
  }
  num id;
  String assetSerialNo;
  String systemID;
  String assetNumber;
  ModelDefinition modelDefinition;
  Supplier supplier;
  String ipAddress;
  String macAddress;
  String portNumber;
  AssetReplace assetReplace;
  OldAsset oldAsset;
  IsParent isParent;
  ParentAsset parentAsset;
  Lookup assetType;
  Site site;
  Building building;
  Floor floor;
  Department department;
  String room;
  num testsDay;
  num purchasingPrice;
  String nbv;
  Currency currency;
  String poNo;
  String invoiceNumber;
  String invoiceDate;
  String replacementDate;
  OriginDepartment originDepartment;
  OriginSite originSite;
  num budgetYear;
  num lastPOPrice;
  CommissioningStatus commissioningStatus;
  String productionDate;
  String edd;
  String technicalInspectionDate;
  String deliveryInspectionDate;
  String endUserAcceptanceDate;
  String receivingCommittee;
  SiteWarrantyMonths siteWarrantyMonths;
  ExtendedWarrantyMonths extendedWarrantyMonths;
  RemainderWarrantyMonths remainderWarrantyMonths;
  num eomWarrantyMonthsNo;
  num warrantyValue;
  String warrantyEndDate;
  String warrantyContractConditions;
  List<TechnicalGuidanceBooks> technicalGuidanceBooks;
  String comment;
  String tagCode;
  Asset copyWith({
    num id,
    String assetSerialNo,
    String systemID,
    String assetNumber,
    ModelDefinition modelDefinition,
    SupplierModel supplier,
    String ipAddress,
    String macAddress,
    String portNumber,
    AssetReplace assetReplace,
    OldAsset oldAsset,
    IsParent isParent,
    ParentAsset parentAsset,
    Lookup assetType,
    Site site,
    Building building,
    Floor floor,
    Department department,
    String room,
    num testsDay,
    num purchasingPrice,
    String nbv,
    Currency currency,
    String poNo,
    String invoiceNumber,
    String invoiceDate,
    String replacementDate,
    OriginDepartment originDepartment,
    OriginSite originSite,
    num budgetYear,
    num lastPOPrice,
    CommissioningStatus commissioningStatus,
    String productionDate,
    String edd,
    String technicalInspectionDate,
    String deliveryInspectionDate,
    String endUserAcceptanceDate,
    String receivingCommittee,
    SiteWarrantyMonths siteWarrantyMonths,
    ExtendedWarrantyMonths extendedWarrantyMonths,
    RemainderWarrantyMonths remainderWarrantyMonths,
    num eomWarrantyMonthsNo,
    num warrantyValue,
    String warrantyEndDate,
    String warrantyContractConditions,
    List<TechnicalGuidanceBooks> technicalGuidanceBooks,
    String comment,
    String tagCode,
  }) =>
      Asset(
        id: id ?? this.id,
        assetSerialNo: assetSerialNo ?? this.assetSerialNo,
        systemID: systemID ?? this.systemID,
        assetNumber: assetNumber ?? this.assetNumber,
        modelDefinition: modelDefinition ?? this.modelDefinition,
        supplier: supplier ?? this.supplier,
        ipAddress: ipAddress ?? this.ipAddress,
        macAddress: macAddress ?? this.macAddress,
        portNumber: portNumber ?? this.portNumber,
        assetReplace: assetReplace ?? this.assetReplace,
        oldAsset: oldAsset ?? this.oldAsset,
        isParent: isParent ?? this.isParent,
        parentAsset: parentAsset ?? this.parentAsset,
        assetType: assetType ?? this.assetType,
        site: site ?? this.site,
        building: building ?? this.building,
        floor: floor ?? this.floor,
        department: department ?? this.department,
        room: room ?? this.room,
        testsDay: testsDay ?? this.testsDay,
        purchasingPrice: purchasingPrice ?? this.purchasingPrice,
        nbv: nbv ?? this.nbv,
        currency: currency ?? this.currency,
        poNo: poNo ?? this.poNo,
        invoiceNumber: invoiceNumber ?? this.invoiceNumber,
        invoiceDate: invoiceDate ?? this.invoiceDate,
        replacementDate: replacementDate ?? this.replacementDate,
        originDepartment: originDepartment ?? this.originDepartment,
        originSite: originSite ?? this.originSite,
        budgetYear: budgetYear ?? this.budgetYear,
        lastPOPrice: lastPOPrice ?? this.lastPOPrice,
        commissioningStatus: commissioningStatus ?? this.commissioningStatus,
        productionDate: productionDate ?? this.productionDate,
        edd: edd ?? this.edd,
        technicalInspectionDate: technicalInspectionDate ?? this.technicalInspectionDate,
        deliveryInspectionDate: deliveryInspectionDate ?? this.deliveryInspectionDate,
        endUserAcceptanceDate: endUserAcceptanceDate ?? this.endUserAcceptanceDate,
        receivingCommittee: receivingCommittee ?? this.receivingCommittee,
        siteWarrantyMonths: siteWarrantyMonths ?? this.siteWarrantyMonths,
        extendedWarrantyMonths: extendedWarrantyMonths ?? this.extendedWarrantyMonths,
        remainderWarrantyMonths: remainderWarrantyMonths ?? this.remainderWarrantyMonths,
        eomWarrantyMonthsNo: eomWarrantyMonthsNo ?? this.eomWarrantyMonthsNo,
        warrantyValue: warrantyValue ?? this.warrantyValue,
        warrantyEndDate: warrantyEndDate ?? this.warrantyEndDate,
        warrantyContractConditions: warrantyContractConditions ?? this.warrantyContractConditions,
        technicalGuidanceBooks: technicalGuidanceBooks ?? this.technicalGuidanceBooks,
        comment: comment ?? this.comment,
        tagCode: tagCode ?? this.tagCode,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['assetSerialNo'] = assetSerialNo;
    map['systemID'] = systemID;
    map['assetNumber'] = assetNumber;
    if (modelDefinition != null) {
      map['modelDefinition'] = modelDefinition.toJson();
    }
    map['supplier'] = supplier?.toJson();

    map['ipAddress'] = ipAddress;
    map['macAddress'] = macAddress;
    map['portNumber'] = portNumber;
    if (assetReplace != null) {
      map['assetReplace'] = assetReplace.toJson();
    }
    if (oldAsset != null) {
      map['oldAsset'] = oldAsset.toJson();
    }
    if (isParent != null) {
      map['isParent'] = isParent.toJson();
    }
    if (parentAsset != null) {
      map['parentAsset'] = parentAsset.toJson();
    }

    map['assetType'] = assetType?.toMap();
    print("supplier : ${supplier?.toJson()}");
    print("supplier 2 : ${map['supplier']}");
    print("asset type : ${assetType?.toMap()}");
    print("asset type 2: ${map['assetType']}");
    if (site != null) {
      map['site'] = site.toJson();
    }
    if (building != null) {
      map['building'] = building.toJson();
    }
    if (floor != null) {
      map['floor'] = floor.toJson();
    }
    if (department != null) {
      map['department'] = department.toJson();
    }
    map['room'] = room;
    map['testsDay'] = testsDay;
    map['purchasingPrice'] = purchasingPrice;
    map['nbv'] = nbv;
    if (currency != null) {
      map['currency'] = currency.toJson();
    }
    map['poNo'] = poNo;
    map['invoiceNumber'] = invoiceNumber;
    map['invoiceDate'] = invoiceDate;
    map['replacementDate'] = replacementDate;
    if (originDepartment != null) {
      map['originDepartment'] = originDepartment.toJson();
    }
    if (originSite != null) {
      map['originSite'] = originSite.toJson();
    }
    map['budgetYear'] = budgetYear;
    map['lastPOPrice'] = lastPOPrice;
    if (commissioningStatus != null) {
      map['commissioningStatus'] = commissioningStatus.toJson();
    }
    map['productionDate'] = productionDate;
    map['edd'] = edd;
    map['technicalInspectionDate'] = technicalInspectionDate;
    map['deliveryInspectionDate'] = deliveryInspectionDate;
    map['endUserAcceptanceDate'] = endUserAcceptanceDate;
    map['receivingCommittee'] = receivingCommittee;
    if (siteWarrantyMonths != null) {
      map['siteWarrantyMonths'] = siteWarrantyMonths.toJson();
    }
    if (extendedWarrantyMonths != null) {
      map['extendedWarrantyMonths'] = extendedWarrantyMonths.toJson();
    }
    if (remainderWarrantyMonths != null) {
      map['remainderWarrantyMonths'] = remainderWarrantyMonths.toJson();
    }
    map['eomWarrantyMonthsNo'] = eomWarrantyMonthsNo;
    map['warrantyValue'] = warrantyValue;
    map['warrantyEndDate'] = warrantyEndDate;
    map['warrantyContractConditions'] = warrantyContractConditions;
    if (technicalGuidanceBooks != null) {
      map['technicalGuidanceBooks'] = technicalGuidanceBooks.map((v) => v.toJson()).toList();
    }
    map['comment'] = comment;
    map['tagCode'] = tagCode;
    return map;
  }
}

class TechnicalGuidanceBooks {
  TechnicalGuidanceBooks({
    this.id,
    this.guidanceBook,
  });

  TechnicalGuidanceBooks.fromJson(dynamic json) {
    id = json['id'];
    guidanceBook = json['guidanceBook'] != null ? GuidanceBook.fromJson(json['guidanceBook']) : null;
  }
  num id;
  GuidanceBook guidanceBook;
  TechnicalGuidanceBooks copyWith({
    num id,
    GuidanceBook guidanceBook,
  }) =>
      TechnicalGuidanceBooks(
        id: id ?? this.id,
        guidanceBook: guidanceBook ?? this.guidanceBook,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    if (guidanceBook != null) {
      map['guidanceBook'] = guidanceBook.toJson();
    }
    return map;
  }
}

class GuidanceBook {
  GuidanceBook({
    this.id,
    this.name,
    this.value,
  });

  GuidanceBook.fromJson(dynamic json) {
    id = json['id'];
    name = json['name'];
    value = json['value'];
  }
  num id;
  String name;
  num value;
  GuidanceBook copyWith({
    num id,
    String name,
    num value,
  }) =>
      GuidanceBook(
        id: id ?? this.id,
        name: name ?? this.name,
        value: value ?? this.value,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['name'] = name;
    map['value'] = value;
    return map;
  }
}

class RemainderWarrantyMonths {
  RemainderWarrantyMonths({
    this.id,
    this.name,
    this.value,
  });

  RemainderWarrantyMonths.fromJson(dynamic json) {
    id = json['id'];
    name = json['name'];
    value = json['value'];
  }
  num id;
  String name;
  num value;
  RemainderWarrantyMonths copyWith({
    num id,
    String name,
    num value,
  }) =>
      RemainderWarrantyMonths(
        id: id ?? this.id,
        name: name ?? this.name,
        value: value ?? this.value,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['name'] = name;
    map['value'] = value;
    return map;
  }
}

class ExtendedWarrantyMonths {
  ExtendedWarrantyMonths({
    this.id,
    this.name,
    this.value,
  });

  ExtendedWarrantyMonths.fromJson(dynamic json) {
    id = json['id'];
    name = json['name'];
    value = json['value'];
  }
  num id;
  String name;
  num value;
  ExtendedWarrantyMonths copyWith({
    num id,
    String name,
    num value,
  }) =>
      ExtendedWarrantyMonths(
        id: id ?? this.id,
        name: name ?? this.name,
        value: value ?? this.value,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['name'] = name;
    map['value'] = value;
    return map;
  }
}

class SiteWarrantyMonths {
  SiteWarrantyMonths({
    this.id,
    this.name,
    this.value,
  });

  SiteWarrantyMonths.fromJson(dynamic json) {
    id = json['id'];
    name = json['name'];
    value = json['value'];
  }
  num id;
  String name;
  num value;
  SiteWarrantyMonths copyWith({
    num id,
    String name,
    num value,
  }) =>
      SiteWarrantyMonths(
        id: id ?? this.id,
        name: name ?? this.name,
        value: value ?? this.value,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['name'] = name;
    map['value'] = value;
    return map;
  }
}

class CommissioningStatus {
  CommissioningStatus({
    this.id,
    this.name,
    this.value,
  });

  CommissioningStatus.fromJson(dynamic json) {
    id = json['id'];
    name = json['name'];
    value = json['value'];
  }
  num id;
  String name;
  num value;
  CommissioningStatus copyWith({
    num id,
    String name,
    num value,
  }) =>
      CommissioningStatus(
        id: id ?? this.id,
        name: name ?? this.name,
        value: value ?? this.value,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['name'] = name;
    map['value'] = value;
    return map;
  }
}

class OriginSite {
  OriginSite({
    this.id,
    this.customerCode,
    this.custName,
    this.buildings,
  });

  OriginSite.fromJson(dynamic json) {
    id = json['id'];
    customerCode = json['customerCode'];
    custName = json['custName'];
    if (json['buildings'] != null) {
      buildings = [];
      json['buildings'].forEach((v) {
        buildings.add(Buildings.fromJson(v));
      });
    }
  }
  num id;
  num customerCode;
  String custName;
  List<Buildings> buildings;
  OriginSite copyWith({
    num id,
    num customerCode,
    String custName,
    List<Buildings> buildings,
  }) =>
      OriginSite(
        id: id ?? this.id,
        customerCode: customerCode ?? this.customerCode,
        custName: custName ?? this.custName,
        buildings: buildings ?? this.buildings,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['customerCode'] = customerCode;
    map['custName'] = custName;
    if (buildings != null) {
      map['buildings'] = buildings.map((v) => v.toJson()).toList();
    }
    return map;
  }
}

class Buildings {
  Buildings({
    this.id,
    this.name,
    this.value,
    this.floors,
  });

  Buildings.fromJson(dynamic json) {
    id = json['id'];
    name = json['name'];
    value = json['value'];
    if (json['floors'] != null) {
      floors = [];
      json['floors'].forEach((v) {
        floors.add(Floors.fromJson(v));
      });
    }
  }
  num id;
  String name;
  num value;
  List<Floors> floors;
  Buildings copyWith({
    num id,
    String name,
    num value,
    List<Floors> floors,
  }) =>
      Buildings(
        id: id ?? this.id,
        name: name ?? this.name,
        value: value ?? this.value,
        floors: floors ?? this.floors,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['name'] = name;
    map['value'] = value;
    if (floors != null) {
      map['floors'] = floors.map((v) => v.toJson()).toList();
    }
    return map;
  }
}

class Floors {
  Floors({
    this.id,
    this.name,
    this.value,
    this.departments,
  });

  Floors.fromJson(dynamic json) {
    id = json['id'];
    name = json['name'];
    value = json['value'];
    if (json['departments'] != null) {
      departments = [];
      json['departments'].forEach((v) {
        departments.add(Departments.fromJson(v));
      });
    }
  }
  num id;
  String name;
  num value;
  List<Departments> departments;
  Floors copyWith({
    num id,
    String name,
    num value,
    List<Departments> departments,
  }) =>
      Floors(
        id: id ?? this.id,
        name: name ?? this.name,
        value: value ?? this.value,
        departments: departments ?? this.departments,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['name'] = name;
    map['value'] = value;
    if (departments != null) {
      map['departments'] = departments.map((v) => v.toJson()).toList();
    }
    return map;
  }
}

class Departments {
  Departments({
    this.id,
    this.name,
  });

  Departments.fromJson(dynamic json) {
    id = json['id'];
    name = json['name'];
  }
  num id;
  String name;
  Departments copyWith({
    num id,
    String name,
  }) =>
      Departments(
        id: id ?? this.id,
        name: name ?? this.name,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['name'] = name;
    return map;
  }
}

class OriginDepartment {
  OriginDepartment({
    this.id,
    this.departmentName,
    this.departmentCode,
    this.ntCode,
  });

  OriginDepartment.fromJson(dynamic json) {
    id = json['id'];
    departmentName = json['departmentName'];
    departmentCode = json['departmentCode'];
    ntCode = json['ntCode'];
  }
  num id;
  String departmentName;
  String departmentCode;
  String ntCode;
  OriginDepartment copyWith({
    num id,
    String departmentName,
    String departmentCode,
    String ntCode,
  }) =>
      OriginDepartment(
        id: id ?? this.id ?? 0,
        departmentName: departmentName ?? this.departmentName,
        departmentCode: departmentCode ?? this.departmentCode,
        ntCode: ntCode ?? this.ntCode,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id;
    map['departmentName'] = departmentName;
    map['departmentCode'] = departmentCode;
    map['ntCode'] = ntCode;
    return map;
  }
}

class Currency {
  Currency({
    this.id,
    this.name,
    this.value,
  });

  Currency.fromJson(dynamic json) {
    id = json['id'];
    name = json['name'];
    value = json['value'];
  }
  num id;
  String name;
  num value;
  Currency copyWith({
    num id,
    String name,
    num value,
  }) =>
      Currency(
        id: id ?? this.id,
        name: name ?? this.name,
        value: value ?? this.value,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['name'] = name;
    map['value'] = value;
    return map;
  }
}

class Department {
  Department({
    this.id,
    this.departmentName,
    this.departmentCode,
    this.ntCode,
  });

  Department.fromJson(dynamic json) {
    id = json['id'];
    departmentName = json['departmentName'];
    departmentCode = json['departmentCode'];
    ntCode = json['ntCode'];
  }
  num id;
  String departmentName;
  String departmentCode;
  String ntCode;
  Department copyWith({
    num id,
    String departmentName,
    String departmentCode,
    String ntCode,
  }) =>
      Department(
        id: id ?? this.id,
        departmentName: departmentName ?? this.departmentName,
        departmentCode: departmentCode ?? this.departmentCode,
        ntCode: ntCode ?? this.ntCode,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['departmentName'] = departmentName;
    map['departmentCode'] = departmentCode;
    map['ntCode'] = ntCode;
    return map;
  }
}

class Floor {
  Floor({
    this.id,
    this.name,
    this.value,
  });

  Floor.fromJson(dynamic json) {
    id = json['id'];
    name = json['name'];
    value = json['value'];
  }
  num id;
  String name;
  num value;
  Floor copyWith({
    num id,
    String name,
    num value,
  }) =>
      Floor(
        id: id ?? this.id,
        name: name ?? this.name,
        value: value ?? this.value,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['name'] = name;
    map['value'] = value;
    return map;
  }
}

class Building {
  Building({
    this.id,
    this.name,
    this.value,
  });

  Building.fromJson(dynamic json) {
    id = json['id'];
    name = json['name'];
    value = json['value'];
  }
  num id;
  String name;
  num value;
  Building copyWith({
    num id,
    String name,
    num value,
  }) =>
      Building(
        id: id ?? this.id,
        name: name ?? this.name,
        value: value ?? this.value,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['name'] = name;
    map['value'] = value;
    return map;
  }
}

class Site {
  Site({
    this.id,
    this.customerCode,
    this.custName,
    this.buildings,
  });

  Site.fromJson(dynamic json) {
    id = json['id'];
    customerCode = json['customerCode'];
    custName = json['custName'];
    if (json['buildings'] != null) {
      buildings = [];
      json['buildings'].forEach((v) {
        buildings.add(Buildings.fromJson(v));
      });
    }
  }
  num id;
  num customerCode;
  String custName;
  List<Buildings> buildings;
  Site copyWith({
    num id,
    num customerCode,
    String custName,
    List<Buildings> buildings,
  }) =>
      Site(
        id: id ?? this.id,
        customerCode: customerCode ?? this.customerCode,
        custName: custName ?? this.custName,
        buildings: buildings ?? this.buildings,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['customerCode'] = customerCode;
    map['custName'] = custName;
    if (buildings != null) {
      map['buildings'] = buildings.map((v) => v.toJson()).toList();
    }
    return map;
  }
}

class ParentAsset {
  ParentAsset({
    this.id,
    this.assetSerialNo,
    this.assetNumber,
    this.tagCode,
    this.systemId,
  });

  ParentAsset.fromJson(dynamic json) {
    id = json['id'];
    assetSerialNo = json['assetSerialNo'];
    assetNumber = json['assetNumber'];
    tagCode = json['tagCode'];
    systemId = json['systemId'];
  }
  num id;
  String assetSerialNo;
  String assetNumber;
  String tagCode;
  String systemId;
  ParentAsset copyWith({
    num id,
    String assetSerialNo,
    String assetNumber,
    String tagCode,
    String systemId,
  }) =>
      ParentAsset(
        id: id ?? this.id,
        assetSerialNo: assetSerialNo ?? this.assetSerialNo,
        assetNumber: assetNumber ?? this.assetNumber,
        tagCode: tagCode ?? this.tagCode,
        systemId: systemId ?? this.systemId,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['assetSerialNo'] = assetSerialNo;
    map['assetNumber'] = assetNumber;
    map['tagCode'] = tagCode;
    map['systemId'] = systemId;
    return map;
  }
}

class IsParent {
  IsParent({
    this.id,
    this.name,
    this.value,
  });

  IsParent.fromJson(dynamic json) {
    id = json['id'];
    name = json['name'];
    value = json['value'];
  }
  num id;
  String name;
  num value;
  IsParent copyWith({
    num id,
    String name,
    num value,
  }) =>
      IsParent(
        id: id ?? this.id,
        name: name ?? this.name,
        value: value ?? this.value,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['name'] = name;
    map['value'] = value;
    return map;
  }
}

class OldAsset {
  OldAsset({
    this.id,
    this.assetSerialNo,
    this.assetNumber,
    this.tagCode,
    this.systemId,
  });

  OldAsset.fromJson(dynamic json) {
    id = json['id'];
    assetSerialNo = json['assetSerialNo'];
    assetNumber = json['assetNumber'];
    tagCode = json['tagCode'];
    systemId = json['systemId'];
  }
  num id;
  String assetSerialNo;
  String assetNumber;
  String tagCode;
  String systemId;
  OldAsset copyWith({
    num id,
    String assetSerialNo,
    String assetNumber,
    String tagCode,
    String systemId,
  }) =>
      OldAsset(
        id: id ?? this.id ?? 0,
        assetSerialNo: assetSerialNo ?? this.assetSerialNo,
        assetNumber: assetNumber ?? this.assetNumber,
        tagCode: tagCode ?? this.tagCode,
        systemId: systemId ?? this.systemId,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id;
    map['assetSerialNo'] = assetSerialNo;
    map['assetNumber'] = assetNumber;
    map['tagCode'] = tagCode;
    map['systemId'] = systemId;
    return map;
  }
}

class AssetReplace {
  AssetReplace({
    this.id,
    this.name,
    this.value,
  });

  AssetReplace.fromJson(dynamic json) {
    id = json['id'];
    name = json['name'];
    value = json['value'];
  }
  num id;
  String name;
  num value;
  AssetReplace copyWith({
    num id,
    String name,
    num value,
  }) =>
      AssetReplace(
        id: id ?? this.id,
        name: name ?? this.name,
        value: value ?? this.value,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['name'] = name;
    map['value'] = value;
    return map;
  }
}

class Supplier {
  Supplier({
    this.id,
    this.suppliername,
  });

  Supplier.fromJson(dynamic json) {
    id = json['id'];
    suppliername = json['suppliername'];
  }
  num id;
  String suppliername;
  SupplierModel copyWith({
    num id,
    String suppliername,
  }) =>
      SupplierModel(
        id: id ?? this.id,
        suppliername: suppliername ?? this.suppliername,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['suppliername'] = suppliername;
    return map;
  }
}

class ModelDefinition {
  ModelDefinition({
    this.id,
    this.assetName,
    this.modelDefCode,
    this.modelName,
    this.manufacturerId,
    this.manufacturerName,
    this.supplierName,
    this.replacementDate,
    this.essentialEquipement,
    this.businessCritical,
    this.lifeSpan,
    this.modelDefRelatedDefects,
    this.suppliers,
  });

  ModelDefinition.fromJson(dynamic json) {
    id = json['id'];
    assetName = json['assetName'];
    modelDefCode = json['modelDefCode'];
    modelName = json['modelName'];
    manufacturerId = json['manufacturerId'];
    manufacturerName = json['manufacturerName'];
    supplierName = json['supplierName'];
    replacementDate = json['replacementDate'];
    essentialEquipement = json['essentialEquipement'];
    businessCritical = json['businessCritical'];
    lifeSpan = json['lifeSpan'];
    if (json['modelDefRelatedDefects'] != null) {
      modelDefRelatedDefects = [];
      json['modelDefRelatedDefects'].forEach((v) {
        modelDefRelatedDefects.add(ModelDefRelatedDefects.fromJson(v));
      });
    }
    if (json['suppliers'] != null) {
      suppliers = [];
      json['suppliers'].forEach((v) {
        suppliers.add(Suppliers.fromJson(v));
      });
    }
  }
  num id;
  String assetName;
  String modelDefCode;
  String modelName;
  num manufacturerId;
  String manufacturerName;
  String supplierName;
  String replacementDate;
  String essentialEquipement;
  String businessCritical;
  num lifeSpan;
  List<ModelDefRelatedDefects> modelDefRelatedDefects;
  List<Suppliers> suppliers;
  ModelDefinition copyWith({
    num id,
    String assetName,
    String modelDefCode,
    String modelName,
    num manufacturerId,
    String manufacturerName,
    String supplierName,
    String replacementDate,
    String essentialEquipement,
    String businessCritical,
    num lifeSpan,
    List<ModelDefRelatedDefects> modelDefRelatedDefects,
    List<Suppliers> suppliers,
  }) =>
      ModelDefinition(
        id: id ?? this.id,
        assetName: assetName ?? this.assetName,
        modelDefCode: modelDefCode ?? this.modelDefCode,
        modelName: modelName ?? this.modelName,
        manufacturerId: manufacturerId ?? this.manufacturerId,
        manufacturerName: manufacturerName ?? this.manufacturerName,
        supplierName: supplierName ?? this.supplierName,
        replacementDate: replacementDate ?? this.replacementDate,
        essentialEquipement: essentialEquipement ?? this.essentialEquipement,
        businessCritical: businessCritical ?? this.businessCritical,
        lifeSpan: lifeSpan ?? this.lifeSpan,
        modelDefRelatedDefects: modelDefRelatedDefects ?? this.modelDefRelatedDefects,
        suppliers: suppliers ?? this.suppliers,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['assetName'] = assetName;
    map['modelDefCode'] = modelDefCode;
    map['modelName'] = modelName;
    map['manufacturerId'] = manufacturerId;
    map['manufacturerName'] = manufacturerName;
    map['supplierName'] = supplierName;
    map['replacementDate'] = replacementDate;
    map['essentialEquipement'] = essentialEquipement;
    map['businessCritical'] = businessCritical;
    map['lifeSpan'] = lifeSpan;
    if (modelDefRelatedDefects != null) {
      map['modelDefRelatedDefects'] = modelDefRelatedDefects.map((v) => v.toJson()).toList();
    }
    if (suppliers != null) {
      map['suppliers'] = suppliers.map((v) => v.toJson()).toList();
    }
    return map;
  }
}

class Suppliers {
  Suppliers({
    this.id,
    this.suppliername,
  });

  Suppliers.fromJson(dynamic json) {
    id = json['id'];
    suppliername = json['suppliername'];
  }
  num id;
  String suppliername;
  Suppliers copyWith({
    num id,
    String suppliername,
  }) =>
      Suppliers(
        id: id ?? this.id,
        suppliername: suppliername ?? this.suppliername,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id ?? 0;
    map['suppliername'] = suppliername;
    return map;
  }
}

class ModelDefRelatedDefects {
  ModelDefRelatedDefects({
    this.id,
    this.defectName,
    this.workPerformed,
    this.estimatedTime,
  });

  ModelDefRelatedDefects.fromJson(dynamic json) {
    id = json['id'];
    defectName = json['defectName'];
    workPerformed = json['workPerformed'];
    estimatedTime = json['estimatedTime'];
  }
  num id;
  String defectName;
  String workPerformed;
  String estimatedTime;
  ModelDefRelatedDefects copyWith({
    num id,
    String defectName,
    String workPerformed,
    String estimatedTime,
  }) =>
      ModelDefRelatedDefects(
        id: id ?? this.id ?? 0,
        defectName: defectName ?? this.defectName,
        workPerformed: workPerformed ?? this.workPerformed,
        estimatedTime: estimatedTime ?? this.estimatedTime,
      );
  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id;
    map['defectName'] = defectName;
    map['workPerformed'] = workPerformed;
    map['estimatedTime'] = estimatedTime;
    return map;
  }
}
