import '../base.dart';

class SparePartsWorkOrders extends Base {
  SparePartsWorkOrders({this.id, this.sparePart, this.qty, this.returnQty, this.installQty}) : super(identifier: id?.toString(), name: sparePart?.partName);

  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;
    if (sparePart != null) {
      map['sparePart'] = sparePart!.toJson();
    }
    map['qty'] = qty ?? 0;
    map['returnQty'] = returnQty;
    map['installQty'] = installQty;
    return map;
  }
}

class SparePart extends Base {
  SparePart({
    this.id,
    this.partNo,
    this.partName,
    this.oracleCode,
    this.assetId,
  }) : super(identifier: id?.toString(), name: partName);

  SparePart.fromJson(dynamic json) {
    id = json['id'];
    identifier = id?.toString();
    partNo = json['partNo'];
    partName = json['partName'];
    oracleCode = json['oracleCode'];
    name = partName;
    assetId = json['assetId'];
  }

  num? id;
  String? partNo;
  String? partName;
  String? oracleCode;
  num? assetId;

  SparePart copyWith({num? id, String? partNo, String? partName, num? assetId,String?oracleCode}) =>
      SparePart(id: id ?? this.id,oracleCode: oracleCode?? this.oracleCode, partNo: partNo ?? this.partNo, partName: partName ?? this.partName, assetId: assetId ?? this.assetId);

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id;
    map['partNo'] = partNo;
    map['partName'] = partName;
    map['oracleCode'] = oracleCode;
    map['assetId'] = assetId;
    return map;
  }
}
