class SaldosCartera {
  SaldosCartera({
    this.result,
    required this.response,
    required this.message,
  });

  Result? result;
  bool response;
  String message;

  factory SaldosCartera.fromJson(Map<String, dynamic> json) => SaldosCartera(
    result: Result.fromJson(json["result"]),
    response: json["response"],
    message: json["message"],
  );

  Map<String, dynamic> toJson() => {
    "result": result == null ? null : result!.toJson(),
    "response": response,
    "message": message,
  };
}

class Result {
  Result({
    required this.registros,
    required this.datosGenerales,
    required this.carteraVencer,
  });

  List<Registro> registros;
  DatosGenerales datosGenerales;
  Map<String, CarteraVencer> carteraVencer;

  factory Result.fromJson(Map<String, dynamic> json) => Result(
    registros: List<Registro>.from(json["registros"].map((x) => Registro.fromJson(x))),
    datosGenerales: DatosGenerales.fromJson(json["datosGenerales"]),
    carteraVencer: Map.from(json["carteraVencer"]).map((k, v) => MapEntry<String, CarteraVencer>(k, CarteraVencer.fromJson(v))),
  );

  Map<String, dynamic> toJson() => {
    "registros": List<dynamic>.from(registros.map((x) => x.toJson())),
    "datosGenerales": datosGenerales.toJson(),
    "carteraVencer": Map.from(carteraVencer).map((k, v) => MapEntry<String, dynamic>(k, v.toJson())),
  };
}

class CarteraVencer {
  CarteraVencer({
    this.the45,
    this.the015,
    this.the1630,
    this.the3145,
    this.total,
  });

  String? the45;
  String? the015;
  String? the1630;
  String? the3145;
  String? total;

  factory CarteraVencer.fromJson(Map<String, dynamic> json) => CarteraVencer(
    the45: json["45"],
    the015: json["0_15"],
    the1630: json["16_30"],
    the3145: json["31_45"],
    total: json["total"],
  );

  Map<String, dynamic> toJson() => {
    "45": the45,
    "0_15": the015,
    "16_30": the1630,
    "31_45": the3145,
    "total": total,
  };
}

class DatosGenerales {
  DatosGenerales({
    required this.mxp,
    required this.usd
  });

  Mxp mxp;
  Usd usd;

  factory DatosGenerales.fromJson(Map<String, dynamic> json) => DatosGenerales(
      mxp: Mxp.fromJson(json["MXP"]),
      usd: Usd.fromJson(json["USD"])
  );

  Map<String, dynamic> toJson() => {
    "MXP": mxp.toJson(),

  };
}

class Mxp {
  Mxp({
    required this.moneda,
    required this.totalCartera,
    this.totalCarteraVencida,
    this.totalCarteraVencer,
    this.pendientePorAplicar,
    required this.total
  });

  String moneda;
  String totalCartera;
  String? totalCarteraVencida;
  String? totalCarteraVencer;
  String? pendientePorAplicar;
  String total;

  factory Mxp.fromJson(Map<String, dynamic> json) => Mxp(
    moneda: json["moneda"],
    totalCartera: json["totalCartera"],
    totalCarteraVencida: json["totalCartera_Vencida"],
    totalCarteraVencer: json["totalCarteraVencer"],
    pendientePorAplicar: json["pendientePorAplicar"],
    total: json["total"],
  );

  Map<String, dynamic> toJson() => {
    "moneda": moneda,
    "totalCartera": totalCartera,
    "totalCartera_Vencida": totalCarteraVencida,
    "totalCarteraVencer": totalCarteraVencer,
    "pendientePorAplicar": pendientePorAplicar,
    "total": total,
  };
}

class Usd {
  Usd({
    required this.moneda,
    required this.totalCartera,
    this.totalCarteraVencida,
    this.totalCarteraVencer,
    this.pendientePorAplicar,
    required this.total
  });

  String moneda;
  String totalCartera;
  String? totalCarteraVencida;
  String? totalCarteraVencer;
  String? pendientePorAplicar;
  String total;

  factory Usd.fromJson(Map<String, dynamic> json) => Usd(
    moneda: json["moneda"],
    totalCartera: json["totalCartera"],
    totalCarteraVencida: json["totalCartera_Vencida"],
    totalCarteraVencer: json["totalCarteraVencer"],
    pendientePorAplicar: json["pendientePorAplicar"],
    total: json["total"],
  );

  Map<String, dynamic> toJson() => {
    "moneda": moneda,
    "totalCartera": totalCartera,
    "totalCartera_Vencida": totalCarteraVencida,
    "totalCarteraVencer": totalCarteraVencer,
    "pendientePorAplicar": pendientePorAplicar,
    "total": total,
  };
}

class Registro {
  Registro({
    required this.doc,
    required this.folio,
    required this.fechaEmision,
    required this.fechaVencimiento,
    required this.pedido,
    required this.total,
    required this.diasdevencimiento,
    required this.importePendiente,
    required this.referenciaPago,
    required this.moneda,
    required this.tipo,
    required this.pagina,
  });

  String doc;
  String folio;
  String fechaEmision;
  String fechaVencimiento;
  String pedido;
  String total;
  int diasdevencimiento;
  String importePendiente;
  String referenciaPago;
  String moneda;
  String tipo;
  int pagina;

  factory Registro.fromJson(Map<String, dynamic> json) => Registro(
    doc: json["DOC"],
    folio: json["FOLIO"],
    fechaEmision: json["FECHA_EMISION"],
    fechaVencimiento: json["FECHA_VENCIMIENTO"],
    pedido: json["PEDIDO"],
    total: json["TOTAL"],
    diasdevencimiento: json["DIASDEVENCIMIENTO"],
    importePendiente: json["IMPORTE_PENDIENTE"],
    referenciaPago: json["REFERENCIA_PAGO"],
    moneda: json["MONEDA"],
    tipo: json["TIPO"],
    pagina: json["pagina"],
  );

  Map<String, dynamic> toJson() => {
    "DOC": doc,
    "FOLIO": folio,
    "FECHA_EMISION": fechaEmision,
    "FECHA_VENCIMIENTO": fechaVencimiento,
    "PEDIDO": pedido,
    "TOTAL": total,
    "DIASDEVENCIMIENTO": diasdevencimiento,
    "IMPORTE_PENDIENTE": importePendiente,
    "REFERENCIA_PAGO": referenciaPago,
    "MONEDA": moneda,
    "TIPO": tipo,
    "pagina": pagina,
  };
}