import 'dart:convert';

PaymentRequestResponse paymentRequestResponseFromJson(String str) =>
    PaymentRequestResponse.fromJson(json.decode(str));

String paymentRequestResponseToJson(PaymentRequestResponse data) =>
    json.encode(data.toJson());

class PaymentRequestResponse {
  PaymentRequestResponse({
    required this.success,
    required this.message,
    required this.data,
  });

  bool? success;
  String? message;
  PaymentRequestData? data;

  factory PaymentRequestResponse.fromJson(Map<String, dynamic> json) =>
      PaymentRequestResponse(
        success: json["success"],
        message: json["message"],
        data: json["data"] != null
            ? PaymentRequestData.fromJson(json["data"])
            : null,
      );

  Map<String, dynamic> toJson() => {
        "success": success,
        "message": message,
        "data": data?.toJson(),
      };
}

class PaymentRequestData {
  PaymentRequestData({
    required this.currentPage,
    required this.totalPages,
    required this.totalEntities,
    required this.data,
  });

  int? currentPage;
  int? totalPages;
  int? totalEntities;
  List<PaymentRequest>? data;

  factory PaymentRequestData.fromJson(Map<String, dynamic> json) =>
      PaymentRequestData(
        currentPage: json["currentPage"],
        totalPages: json["totalPages"],
        totalEntities: json["totalEntities"],
        data: json["data"] != null
            ? List<PaymentRequest>.from(
                json["data"].map((x) => PaymentRequest.fromJson(x)))
            : [],
      );

  Map<String, dynamic> toJson() => {
        "currentPage": currentPage,
        "totalPages": totalPages,
        "totalEntities": totalEntities,
        "data": data?.map((x) => x.toJson()).toList(),
      };
}

class PaymentRequest {
  PaymentRequest({
    required this.id,
    required this.title,
    required this.description,
    this.recurringPayment,
    required this.paymentRequestUID,
    required this.payee,
    required this.currency,
    required this.amount,
    required this.dueDate,
    required this.project,
    required this.expenseCategory,
    required this.expenseStatus,
    required this.isAdvancePayment,
    required this.createdAt,
    required this.createdBy,
    required this.isActive,
    required this.isExpenseCreated,
  });

  String? id;
  String? title;
  String? description;
  dynamic recurringPayment;
  String? paymentRequestUID;
  String? payee;
  Currency? currency;
  num? amount;
  DateTime? dueDate;
  Project? project;
  ExpenseCategory? expenseCategory;
  ExpenseStatus? expenseStatus;
  bool? isAdvancePayment;
  DateTime? createdAt;
  CreatedBy? createdBy;
  bool? isActive;
  bool? isExpenseCreated;

  factory PaymentRequest.fromJson(Map<String, dynamic> json) => PaymentRequest(
        id: json["id"],
        title: json["title"],
        description: json["description"],
        recurringPayment: json["recurringPayment"],
        paymentRequestUID: json["paymentRequestUID"],
        payee: json["payee"],
        currency: json["currency"] != null
            ? Currency.fromJson(json["currency"])
            : null,
        amount: json["amount"],
        dueDate: json["dueDate"] != null
            ? DateTime.parse(json["dueDate"])
            : null,
        project:
            json["project"] != null ? Project.fromJson(json["project"]) : null,
        expenseCategory: json["expenseCategory"] != null
            ? ExpenseCategory.fromJson(json["expenseCategory"])
            : null,
        expenseStatus: json["expenseStatus"] != null
            ? ExpenseStatus.fromJson(json["expenseStatus"])
            : null,
        isAdvancePayment: json["isAdvancePayment"],
        createdAt: json["createdAt"] != null
            ? DateTime.parse(json["createdAt"])
            : null,
        createdBy: json["createdBy"] != null
            ? CreatedBy.fromJson(json["createdBy"])
            : null,
        isActive: json["isActive"],
        isExpenseCreated: json["isExpenseCreated"],
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "title": title,
        "description": description,
        "recurringPayment": recurringPayment,
        "paymentRequestUID": paymentRequestUID,
        "payee": payee,
        "currency": currency?.toJson(),
        "amount": amount,
        "dueDate": dueDate?.toIso8601String(),
        "project": project?.toJson(),
        "expenseCategory": expenseCategory?.toJson(),
        "expenseStatus": expenseStatus?.toJson(),
        "isAdvancePayment": isAdvancePayment,
        "createdAt": createdAt?.toIso8601String(),
        "createdBy": createdBy?.toJson(),
        "isActive": isActive,
        "isExpenseCreated": isExpenseCreated,
      };
}

class Currency {
  Currency({
    required this.id,
    required this.currencyCode,
    required this.currencyName,
    required this.symbol,
    required this.isActive,
  });

  String? id;
  String? currencyCode;
  String? currencyName;
  String? symbol;
  bool? isActive;

  factory Currency.fromJson(Map<String, dynamic> json) => Currency(
        id: json["id"],
        currencyCode: json["currencyCode"],
        currencyName: json["currencyName"],
        symbol: json["symbol"],
        isActive: json["isActive"],
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "currencyCode": currencyCode,
        "currencyName": currencyName,
        "symbol": symbol,
        "isActive": isActive,
      };
}

class Project {
  Project({
    required this.id,
    required this.name,
  });

  String? id;
  String? name;

  factory Project.fromJson(Map<String, dynamic> json) => Project(
        id: json["id"],
        name: json["name"],
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "name": name,
      };
}

class ExpenseCategory {
  ExpenseCategory({
    required this.id,
    required this.name,
    required this.noOfPersonsRequired,
    required this.isAttachmentRequried,
    required this.description,
  });

  String? id;
  String? name;
  bool? noOfPersonsRequired;
  bool? isAttachmentRequried;
  String? description;

  factory ExpenseCategory.fromJson(Map<String, dynamic> json) =>
      ExpenseCategory(
        id: json["id"],
        name: json["name"],
        noOfPersonsRequired: json["noOfPersonsRequired"],
        isAttachmentRequried: json["isAttachmentRequried"],
        description: json["description"],
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "name": name,
        "noOfPersonsRequired": noOfPersonsRequired,
        "isAttachmentRequried": isAttachmentRequried,
        "description": description,
      };
}

class ExpenseStatus {
  ExpenseStatus({
    required this.id,
    required this.name,
    required this.displayName,
    required this.description,
    this.permissionIds,
    required this.color,
    required this.isSystem,
  });

  String? id;
  String? name;
  String? displayName;
  String? description;
  dynamic permissionIds;
  String? color;
  bool? isSystem;

  factory ExpenseStatus.fromJson(Map<String, dynamic> json) => ExpenseStatus(
        id: json["id"],
        name: json["name"],
        displayName: json["displayName"],
        description: json["description"],
        permissionIds: json["permissionIds"],
        color: json["color"],
        isSystem: json["isSystem"],
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "name": name,
        "displayName": displayName,
        "description": description,
        "permissionIds": permissionIds,
        "color": color,
        "isSystem": isSystem,
      };
}

class CreatedBy {
  CreatedBy({
    required this.id,
    required this.firstName,
    required this.lastName,
    required this.email,
    required this.photo,
    required this.jobRoleId,
    required this.jobRoleName,
  });

  String? id;
  String? firstName;
  String? lastName;
  String? email;
  String? photo;
  String? jobRoleId;
  String? jobRoleName;

  factory CreatedBy.fromJson(Map<String, dynamic> json) => CreatedBy(
        id: json["id"],
        firstName: json["firstName"],
        lastName: json["lastName"],
        email: json["email"],
        photo: json["photo"],
        jobRoleId: json["jobRoleId"],
        jobRoleName: json["jobRoleName"],
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "firstName": firstName,
        "lastName": lastName,
        "email": email,
        "photo": photo,
        "jobRoleId": jobRoleId,
        "jobRoleName": jobRoleName,
      };
}
