You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cloudsolutions-atoms/lib/models/device/asset.dart

442 lines
16 KiB
Dart

import 'package:test_sa/models/device/supplier.dart';
import 'package:test_sa/models/device/technical_guidance_book.dart';
import 'package:test_sa/models/lookup.dart';
6 months ago
import 'package:test_sa/models/new_models/mapped_sites.dart';
import 'package:test_sa/models/new_models/room_model.dart';
import '../new_models/building.dart';
import '../new_models/department.dart';
import '../new_models/floor.dart';
import '../new_models/site.dart';
import 'model_definition.dart';
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,
6 months ago
this.mappedSite,
this.mappedBuilding,
this.mappedDepartment,
this.mappedFloor,
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,
this.assetPhoto,
});
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 ? Lookup.fromJson(json['assetReplace']) : null;
oldAsset = json['oldAsset'] != null ? AssetInfo.fromJson(json['oldAsset']) : null;
isParent = json['isParent'] != null ? Lookup.fromJson(json['isParent']) : null;
parentAsset = json['parentAsset'] != null ? AssetInfo.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'] != null ? Rooms.fromJson(json['room']) : null;
testsDay = json['testsDay'];
purchasingPrice = json['purchasingPrice'];
nbv = json['nbv'];
currency = json['currency'] != null ? Lookup.fromJson(json['currency']) : null;
poNo = json['poNo'];
invoiceNumber = json['invoiceNumber'];
invoiceDate = json['invoiceDate'];
replacementDate = json['replacementDate'];
originDepartment = json['originDepartment'] != null ? Department.fromJson(json['originDepartment']) : null;
originSite = json['originSite'] != null ? Site.fromJson(json['originSite']) : null;
budgetYear = json['budgetYear'];
lastPOPrice = json['lastPOPrice'];
commissioningStatus = json['commissioningStatus'] != null ? Lookup.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 ? Lookup.fromJson(json['siteWarrantyMonths']) : null;
extendedWarrantyMonths = json['extendedWarrantyMonths'] != null ? Lookup.fromJson(json['extendedWarrantyMonths']) : null;
remainderWarrantyMonths = json['remainderWarrantyMonths'] != null ? Lookup.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(TechnicalGuidanceBook.fromJson(v)); // Use '!' since technicalGuidanceBooks is initialized here
});
}
comment = json['comment'];
tagCode = json['tagCode'];
assetPhoto = json['assetPhoto'];
}
num? id; // Now nullable
String? assetSerialNo; // Now nullable
String? systemID; // Now nullable
String? assetNumber; // Now nullable
ModelDefinition? modelDefinition; // Now nullable
Supplier? supplier; // Now nullable
String? ipAddress; // Now nullable
String? macAddress; // Now nullable
String? portNumber; // Now nullable
Lookup? assetReplace; // Now nullable
AssetInfo? oldAsset; // Now nullable
Lookup? isParent; // Now nullable
AssetInfo? parentAsset; // Now nullable
Lookup? assetType; // Now nullable
Site? site; // Now nullable
Building? building; // Now nullable
Floor? floor; // Now nullable
Department? department; // Now nullable
Rooms? room;
6 months ago
MappedSite? mappedSite; // Now nullable
MappedBuilding? mappedBuilding; // Now nullable
MappedFloor? mappedFloor; // Now nullable
MappedDepartment? mappedDepartment; //
num? testsDay; // Now nullable
num? purchasingPrice; // Now nullable
String? nbv; // Now nullable
Lookup? currency; // Now nullable
String? poNo; // Now nullable
String? invoiceNumber; // Now nullable
String? invoiceDate; // Now nullable
String? replacementDate; // Now nullable
Department? originDepartment; // Now nullable
Site? originSite; // Now nullable
num? budgetYear; // Now nullable
num? lastPOPrice; // Now nullable
Lookup? commissioningStatus; // Now nullable
String? productionDate; // Now nullable
String? edd; // Now nullable
String? technicalInspectionDate; // Now nullable
String? deliveryInspectionDate; // Now nullable
String? endUserAcceptanceDate; // Now nullable
String? receivingCommittee; // Now nullable
Lookup? siteWarrantyMonths; // Now nullable
Lookup? extendedWarrantyMonths; // Now nullable
Lookup? remainderWarrantyMonths; // Now nullable
num? eomWarrantyMonthsNo; // Now nullable
num? warrantyValue; // Now nullable
String? warrantyEndDate; // Now nullable
String? warrantyContractConditions; // Now nullable
List<TechnicalGuidanceBook>? technicalGuidanceBooks; // Now nullable
String? comment; // Now nullable
String? tagCode; // Now nullable
String? assetPhoto;
Asset copyWith({
num? id,
String? assetSerialNo,
String? systemID,
String? assetNumber,
ModelDefinition? modelDefinition,
Supplier? supplier,
String? ipAddress,
String? macAddress,
String? portNumber,
Lookup? assetReplace,
AssetInfo? oldAsset,
Lookup? isParent,
AssetInfo? parentAsset,
Lookup? assetType,
Site? site,
Building? building,
Floor? floor,
Department? department,
Rooms? room,
6 months ago
MappedSite? mappedSite,
MappedBuilding? mappedBuilding,
MappedDepartment? mappedDepartment,
MappedFloor? mappedFloor,
num? testsDay,
num? purchasingPrice,
String? nbv,
Lookup? currency,
String? poNo,
String? invoiceNumber,
String? invoiceDate,
String? replacementDate,
Department? originDepartment,
Site? originSite,
num? budgetYear,
num? lastPOPrice,
Lookup? commissioningStatus,
String? productionDate,
String? edd,
String? technicalInspectionDate,
String? deliveryInspectionDate,
String? endUserAcceptanceDate,
String? receivingCommittee,
Lookup? siteWarrantyMonths,
Lookup? extendedWarrantyMonths,
Lookup? remainderWarrantyMonths,
num? eomWarrantyMonthsNo,
num? warrantyValue,
String? warrantyEndDate,
String? warrantyContractConditions,
List<TechnicalGuidanceBook>? technicalGuidanceBooks,
String? comment,
String? tagCode,
String? assetPhoto,
}) =>
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,
6 months ago
mappedSite: mappedSite ?? this.mappedSite,
mappedDepartment: mappedDepartment ?? this.mappedDepartment,
mappedFloor: mappedFloor ?? this.mappedFloor,
mappedBuilding: mappedBuilding ?? this.mappedBuilding,
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,
assetPhoto: assetPhoto ?? this.assetPhoto,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['assetSerialNo'] = assetSerialNo;
map['systemID'] = systemID;
map['assetNumber'] = assetNumber;
if (modelDefinition != null) {
map['modelDefinition'] = modelDefinition!.toJson();
}
if (supplier != null) {
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();
}
if (assetType != null) {
map['assetType'] = assetType!.toJson();
}
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;
if (room != null) {
map['room'] = room!.toJson();
}
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;
map['assetPhoto'] = assetPhoto;
return map;
}
}
class AssetInfo {
AssetInfo({
this.id,
this.assetSerialNo,
this.assetNumber,
this.tagCode,
this.systemId,
this.assetName,
});
AssetInfo.fromJson(dynamic json) {
id = json['id'];
assetSerialNo = json['assetSerialNo'];
assetNumber = json['assetNumber'];
tagCode = json['tagCode'];
systemId = json['systemId'];
assetName = json['assetName'];
}
num? id; // Now nullable
String? assetSerialNo; // Now nullable
String? assetNumber; // Now nullable
String? tagCode; // Now nullable
String? systemId; // Now nullable
String? assetName; // Now nullable
AssetInfo copyWith({
num? id, // Parameters are now nullable
String? assetSerialNo,
String? assetNumber,
String? tagCode,
String? systemId,
String? assetName,
}) =>
AssetInfo(
id: id ?? this.id,
assetSerialNo: assetSerialNo ?? this.assetSerialNo,
assetNumber: assetNumber ?? this.assetNumber,
tagCode: tagCode ?? this.tagCode,
systemId: systemId ?? this.systemId,
assetName: assetName ?? this.assetName,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['assetSerialNo'] = assetSerialNo;
map['assetNumber'] = assetNumber;
map['tagCode'] = tagCode;
map['systemId'] = systemId;
map['assetName'] = assetName;
return map;
}
}