taxgilde/lib/model/detail_model.dart
2026-04-11 10:21:31 +05:30

236 lines
6.1 KiB
Dart

import 'dart:convert';
/// ------------------------------
/// JSON Helpers
/// ------------------------------
DetailModel detailModelFromJson(String str) =>
DetailModel.fromJson(json.decode(str));
String detailModelToJson(DetailModel data) => json.encode(data.toJson());
/// ------------------------------
/// Root Model
/// ------------------------------
class DetailModel {
final String? status;
final DetailData? data;
DetailModel({this.status, this.data});
factory DetailModel.fromJson(Map<String, dynamic> json) => DetailModel(
status: json["status"],
data: json["data"] == null ? null : DetailData.fromJson(json["data"]),
);
Map<String, dynamic> toJson() => {"status": status, "data": data?.toJson()};
}
/// ------------------------------
/// Detail Data Model
/// ------------------------------
class DetailData {
final int? id;
final int? firmId;
final String? dueDate;
final String? service;
final String? serviceStatus;
final String? paymentStatus;
final String? paidStatus;
final String? paymentDate;
final String? paymentAmount;
final String? invoice;
final String? invoiceNumber;
final String? proforma;
final int? proformaId;
final String? proformaNumber;
final String? proformastatus;
final String? createdDate;
final String? createdTime;
final String? createdBy;
final String? message;
final String? completedDate;
final String? paidBy;
final List<UserUploadedDocument> userUploadedDocuments;
final List<UserHandoverDocument> userHandoverDocuments;
final String? chatId;
final String? completedChatId;
DetailData({
this.id,
this.firmId,
this.dueDate,
this.service,
this.proformastatus,
this.serviceStatus,
this.paymentStatus,
this.paidStatus,
this.paymentDate,
this.paymentAmount,
this.invoice,
this.invoiceNumber,
this.proforma,
this.proformaId,
this.proformaNumber,
this.createdDate,
this.createdTime,
this.createdBy,
this.message,
this.completedDate,
this.paidBy,
required this.userUploadedDocuments,
required this.userHandoverDocuments,
this.chatId,
this.completedChatId,
});
factory DetailData.fromJson(Map<String, dynamic> json) => DetailData(
id: json["id"],
firmId: json["firm_id"],
dueDate: json["due_date"],
service: json["service"],
serviceStatus: json["service_status"],
paymentStatus: json["payment_status"],
proformastatus: json["proforma_status"],
paidStatus: json["paid_status"],
paymentDate: json["payment_date"],
paymentAmount: json["payment_amount"]?.toString(),
invoice: json["invoice"],
invoiceNumber: json["invoice_number"],
proforma: json["proforma"],
proformaId: json["proforma_id"],
proformaNumber: json["proforma_number"],
createdDate: json["created_date"],
createdTime: json["created_time"],
createdBy: json["created_by"],
message: json["message"],
completedDate: json["completed_date"],
paidBy: json["paid_by"],
userUploadedDocuments: json["user_uploaded_documents"] == null
? []
: List<UserUploadedDocument>.from(
json["user_uploaded_documents"].map(
(x) => UserUploadedDocument.fromJson(x),
),
),
userHandoverDocuments: json["user_handover_documents"] == null
? []
: List<UserHandoverDocument>.from(
json["user_handover_documents"].map(
(x) => UserHandoverDocument.fromJson(x),
),
),
chatId: json["chat_id"]?.toString(),
completedChatId: json["completed_chat_id"]?.toString(),
);
Map<String, dynamic> toJson() => {
"id": id,
"firm_id": firmId,
"due_date": dueDate,
"service": service,
"service_status": serviceStatus,
"payment_status": paymentStatus,
"paid_status": paidStatus,
"payment_date": paymentDate,
"payment_amount": paymentAmount,
"invoice": invoice,
"proforma_status": proformastatus,
"invoice_number": invoiceNumber,
"proforma": proforma,
"proforma_id": proformaId,
"proforma_number": proformaNumber,
"created_date": createdDate,
"created_time": createdTime,
"created_by": createdBy,
"message": message,
"completed_date": completedDate,
"paid_by": paidBy,
"user_uploaded_documents": userUploadedDocuments
.map((x) => x.toJson())
.toList(),
"user_handover_documents": userHandoverDocuments
.map((x) => x.toJson())
.toList(),
"chat_id": chatId,
"completed_chat_id": completedChatId,
};
}
/// ------------------------------
/// User Uploaded Document
/// ------------------------------
class UserUploadedDocument {
final int? id;
final String? filePath;
final String? fileName;
final String? uploadedBy;
final bool? viewable;
UserUploadedDocument({
this.id,
this.filePath,
this.fileName,
this.uploadedBy,
this.viewable,
});
factory UserUploadedDocument.fromJson(Map<String, dynamic> json) =>
UserUploadedDocument(
id: json["id"],
filePath: json["file_path"],
fileName: json["file_name"],
uploadedBy: json["uploaded_by"],
viewable: json["viewable"],
);
Map<String, dynamic> toJson() => {
"id": id,
"file_path": filePath,
"file_name": fileName,
"uploaded_by": uploadedBy,
"viewable": viewable,
};
}
/// ------------------------------
/// User Handover Document
/// ------------------------------
class UserHandoverDocument {
final String? filePath;
final String? fileName;
UserHandoverDocument({this.filePath, this.fileName});
factory UserHandoverDocument.fromJson(Map<String, dynamic> json) =>
UserHandoverDocument(
filePath: json["file_path"],
fileName: json["file_name"],
);
Map<String, dynamic> toJson() => {
"file_path": filePath,
"file_name": fileName,
};
}