279 lines
7.3 KiB
Dart
279 lines
7.3 KiB
Dart
class ExpenseDetailModel {
|
|
final String id;
|
|
final Project project;
|
|
final ExpensesType expensesType;
|
|
final PaymentMode paymentMode;
|
|
final Person paidBy;
|
|
final Person createdBy;
|
|
final String transactionDate;
|
|
final String createdAt;
|
|
final String supplerName;
|
|
final double amount;
|
|
final ExpenseStatus status;
|
|
final List<ExpenseStatus> nextStatus;
|
|
final bool preApproved;
|
|
final String transactionId;
|
|
final String description;
|
|
final String location;
|
|
final List<ExpenseDocument> documents;
|
|
final String? gstNumber;
|
|
final int noOfPersons;
|
|
final bool isActive;
|
|
|
|
ExpenseDetailModel({
|
|
required this.id,
|
|
required this.project,
|
|
required this.expensesType,
|
|
required this.paymentMode,
|
|
required this.paidBy,
|
|
required this.createdBy,
|
|
required this.transactionDate,
|
|
required this.createdAt,
|
|
required this.supplerName,
|
|
required this.amount,
|
|
required this.status,
|
|
required this.nextStatus,
|
|
required this.preApproved,
|
|
required this.transactionId,
|
|
required this.description,
|
|
required this.location,
|
|
required this.documents,
|
|
this.gstNumber,
|
|
required this.noOfPersons,
|
|
required this.isActive,
|
|
});
|
|
|
|
factory ExpenseDetailModel.fromJson(Map<String, dynamic> json) {
|
|
return ExpenseDetailModel(
|
|
id: json['id'] ?? '',
|
|
project: json['project'] != null ? Project.fromJson(json['project']) : Project.empty(),
|
|
expensesType: json['expensesType'] != null ? ExpensesType.fromJson(json['expensesType']) : ExpensesType.empty(),
|
|
paymentMode: json['paymentMode'] != null ? PaymentMode.fromJson(json['paymentMode']) : PaymentMode.empty(),
|
|
paidBy: json['paidBy'] != null ? Person.fromJson(json['paidBy']) : Person.empty(),
|
|
createdBy: json['createdBy'] != null ? Person.fromJson(json['createdBy']) : Person.empty(),
|
|
transactionDate: json['transactionDate'] ?? '',
|
|
createdAt: json['createdAt'] ?? '',
|
|
supplerName: json['supplerName'] ?? '',
|
|
amount: (json['amount'] as num?)?.toDouble() ?? 0.0,
|
|
status: json['status'] != null ? ExpenseStatus.fromJson(json['status']) : ExpenseStatus.empty(),
|
|
nextStatus: (json['nextStatus'] as List?)?.map((e) => ExpenseStatus.fromJson(e)).toList() ?? [],
|
|
preApproved: json['preApproved'] ?? false,
|
|
transactionId: json['transactionId'] ?? '',
|
|
description: json['description'] ?? '',
|
|
location: json['location'] ?? '',
|
|
documents: (json['documents'] as List?)?.map((e) => ExpenseDocument.fromJson(e)).toList() ?? [],
|
|
gstNumber: json['gstNumber']?.toString(),
|
|
noOfPersons: json['noOfPersons'] ?? 0,
|
|
isActive: json['isActive'] ?? true,
|
|
);
|
|
}
|
|
}
|
|
|
|
class Project {
|
|
final String id;
|
|
final String name;
|
|
final String shortName;
|
|
final String projectAddress;
|
|
final String contactPerson;
|
|
final String startDate;
|
|
final String endDate;
|
|
final String projectStatusId;
|
|
|
|
Project({
|
|
required this.id,
|
|
required this.name,
|
|
required this.shortName,
|
|
required this.projectAddress,
|
|
required this.contactPerson,
|
|
required this.startDate,
|
|
required this.endDate,
|
|
required this.projectStatusId,
|
|
});
|
|
|
|
factory Project.fromJson(Map<String, dynamic> json) {
|
|
return Project(
|
|
id: json['id'] ?? '',
|
|
name: json['name'] ?? '',
|
|
shortName: json['shortName'] ?? '',
|
|
projectAddress: json['projectAddress'] ?? '',
|
|
contactPerson: json['contactPerson'] ?? '',
|
|
startDate: json['startDate'] ?? '',
|
|
endDate: json['endDate'] ?? '',
|
|
projectStatusId: json['projectStatusId'] ?? '',
|
|
);
|
|
}
|
|
|
|
factory Project.empty() => Project(
|
|
id: '',
|
|
name: '',
|
|
shortName: '',
|
|
projectAddress: '',
|
|
contactPerson: '',
|
|
startDate: '',
|
|
endDate: '',
|
|
projectStatusId: '',
|
|
);
|
|
}
|
|
|
|
class ExpensesType {
|
|
final String id;
|
|
final String name;
|
|
final bool noOfPersonsRequired;
|
|
final String description;
|
|
|
|
ExpensesType({
|
|
required this.id,
|
|
required this.name,
|
|
required this.noOfPersonsRequired,
|
|
required this.description,
|
|
});
|
|
|
|
factory ExpensesType.fromJson(Map<String, dynamic> json) {
|
|
return ExpensesType(
|
|
id: json['id'] ?? '',
|
|
name: json['name'] ?? '',
|
|
noOfPersonsRequired: json['noOfPersonsRequired'] ?? false,
|
|
description: json['description'] ?? '',
|
|
);
|
|
}
|
|
|
|
factory ExpensesType.empty() => ExpensesType(
|
|
id: '',
|
|
name: '',
|
|
noOfPersonsRequired: false,
|
|
description: '',
|
|
);
|
|
}
|
|
|
|
class PaymentMode {
|
|
final String id;
|
|
final String name;
|
|
final String description;
|
|
|
|
PaymentMode({
|
|
required this.id,
|
|
required this.name,
|
|
required this.description,
|
|
});
|
|
|
|
factory PaymentMode.fromJson(Map<String, dynamic> json) {
|
|
return PaymentMode(
|
|
id: json['id'] ?? '',
|
|
name: json['name'] ?? '',
|
|
description: json['description'] ?? '',
|
|
);
|
|
}
|
|
|
|
factory PaymentMode.empty() => PaymentMode(
|
|
id: '',
|
|
name: '',
|
|
description: '',
|
|
);
|
|
}
|
|
|
|
class Person {
|
|
final String id;
|
|
final String firstName;
|
|
final String lastName;
|
|
final String photo;
|
|
final String jobRoleId;
|
|
final String jobRoleName;
|
|
|
|
Person({
|
|
required this.id,
|
|
required this.firstName,
|
|
required this.lastName,
|
|
required this.photo,
|
|
required this.jobRoleId,
|
|
required this.jobRoleName,
|
|
});
|
|
|
|
factory Person.fromJson(Map<String, dynamic> json) {
|
|
return Person(
|
|
id: json['id'] ?? '',
|
|
firstName: json['firstName'] ?? '',
|
|
lastName: json['lastName'] ?? '',
|
|
photo: json['photo'] is String ? json['photo'] : '',
|
|
jobRoleId: json['jobRoleId'] ?? '',
|
|
jobRoleName: json['jobRoleName'] ?? '',
|
|
);
|
|
}
|
|
|
|
factory Person.empty() => Person(
|
|
id: '',
|
|
firstName: '',
|
|
lastName: '',
|
|
photo: '',
|
|
jobRoleId: '',
|
|
jobRoleName: '',
|
|
);
|
|
}
|
|
|
|
class ExpenseStatus {
|
|
final String id;
|
|
final String name;
|
|
final String displayName;
|
|
final String description;
|
|
final String? permissionIds;
|
|
final String color;
|
|
final bool isSystem;
|
|
|
|
ExpenseStatus({
|
|
required this.id,
|
|
required this.name,
|
|
required this.displayName,
|
|
required this.description,
|
|
required this.permissionIds,
|
|
required this.color,
|
|
required this.isSystem,
|
|
});
|
|
|
|
factory ExpenseStatus.fromJson(Map<String, dynamic> json) {
|
|
return ExpenseStatus(
|
|
id: json['id'] ?? '',
|
|
name: json['name'] ?? '',
|
|
displayName: json['displayName'] ?? '',
|
|
description: json['description'] ?? '',
|
|
permissionIds: json['permissionIds']?.toString(),
|
|
color: json['color'] ?? '',
|
|
isSystem: json['isSystem'] ?? false,
|
|
);
|
|
}
|
|
|
|
factory ExpenseStatus.empty() => ExpenseStatus(
|
|
id: '',
|
|
name: '',
|
|
displayName: '',
|
|
description: '',
|
|
permissionIds: null,
|
|
color: '',
|
|
isSystem: false,
|
|
);
|
|
}
|
|
|
|
class ExpenseDocument {
|
|
final String documentId;
|
|
final String fileName;
|
|
final String contentType;
|
|
final String preSignedUrl;
|
|
final String thumbPreSignedUrl;
|
|
|
|
ExpenseDocument({
|
|
required this.documentId,
|
|
required this.fileName,
|
|
required this.contentType,
|
|
required this.preSignedUrl,
|
|
required this.thumbPreSignedUrl,
|
|
});
|
|
|
|
factory ExpenseDocument.fromJson(Map<String, dynamic> json) {
|
|
return ExpenseDocument(
|
|
documentId: json['documentId'] ?? '',
|
|
fileName: json['fileName'] ?? '',
|
|
contentType: json['contentType'] ?? '',
|
|
preSignedUrl: json['preSignedUrl'] ?? '',
|
|
thumbPreSignedUrl: json['thumbPreSignedUrl'] ?? '',
|
|
);
|
|
}
|
|
}
|