﻿import React, { Fragment } from "react";
import { SiteRutas, ImagenesRutas, baseUrl } from "../../request/RutasConfig.jsx";
import { faReply, faPrint, faPlus, faTrash, faSync } from '@fortawesome/free-solid-svg-icons';
import {
    TipoAsiento_Listar_Request, EncabezadoAsientosReporte_Listar, Parametros_Listar_Request, SubTiposCuentas_Listar_Request,
    CatalogoHist_ListarPeriodos_Request, EncabezadoAsiento_Listar_Request, EmpresasImagen_Consulta_Request,
    SaldoComprometidoXCuenta_Request, CentrosCostos_Listar_Request, CentrosUtilidad_Listar_Request
} from "../../request/MantenimientosRequest.jsx";
//librerias
import { Notificacion } from '../../components/Util/Notificacion/Notificacion.jsx';
import { Get_Description_Report_Request, SetParametrosReporte_Request } from "../../request/ReportesRequest.jsx";
import { Empresa_Consulta_Request, Empresa_Foto_Request, Seg_Usuario_Listar_Request } from "../../request/SeguridadRequest.jsx";
import { Catalogo_Lista_Request, CentroCosto_Lista_CCC_Request, MesesCerrados_Consulta_Request, Consulta_Comprometidos_Request } from '../../request/ServicioRequest.jsx';
//Componentes
import Session from '../../components/Util/session/index.jsx';
import { fechaUltimoDia, fechaPrimerDia, listaRangoNumeros, datosArbol, addMonths } from "../../components/Util/Util.jsx";
import ModalSpinner from '../../components/UI/modalSpinner/modalSpinner.jsx';
import { muestraArbolEmpleados, itemSelect, validarNumeros, farmatearMontos, Round } from '../../components/Util/Util.jsx';
import Config from "../../components/Util/constantes.js";
import moment from "moment";
import BotonArriba from '../../components/UI/botonArriba/botonArriba.jsx';
import ParametrosReportes from "./parametrosReportes.jsx";
import { CodeSharp } from "@material-ui/icons";

const _AnnoActual = new Date().getFullYear();
const _ListaAnnos = listaRangoNumeros(Config.anoAntiguedad, _AnnoActual);
const listaOrdenado = [{ value: '1', label: 'Digitación' }, { value: '2', label: 'Cuenta' }, { value: '3', label: 'Débitos/Crédito' }];
const DatosImagen = {
    "Consecutivo": 0,
    "Empresa": 0,
    //"Empleado":0,
    "Nombre": "",
    "Fecha_Ultima_Actualizacion": new Date()
};
class reporte extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            titulo: "",
            botones: [],
            Datos: {
                /**/Asientos: { value: "", attributes: { readOnly: false, focus: false, label: "Asientos", hidden: "none", id: 1 }, },
                /**/MovimientosCb: { value: true, attributes: { readOnly: false, focus: false, label: "Movimientos", hidden: "none", id: 2, }, },
                /**/MovimientosDe: { value: moment().toDate(), attributes: { readOnly: false, label: 'De', hidden: 'none', id: 2, minDate: fechaPrimerDia(new Date(Config.anoAntiguedad, 0, 1)), maxDate: fechaUltimoDia(new Date(_AnnoActual, 11, 1)), ListaAnnos: _ListaAnnos, formatDate: Config.formatoMesAno } },
                /**/MovimientosAl: { value: moment().toDate(), attributes: { readOnly: false, label: 'Al', hidden: 'none', id: 2, minDate: fechaPrimerDia(new Date(Config.anoAntiguedad, 0, 1)), maxDate: fechaUltimoDia(new Date(_AnnoActual, 11, 1)), ListaAnnos: _ListaAnnos, formatDate: Config.formatoMesAno } },
                PeriodoMes: { attributes: { readOnly: true, focus: false, label: "Mes", hidden: "none", id: 3, }, },
                PeriodoAnio: { value: 1900, attributes: { readOnly: true, focus: false, label: "Año", maxLength: 4, hidden: "none", id: 4, }, },
                PeriodoMesHasta: { attributes: { readOnly: false, focus: false, label: "Mes", hidden: "none", id: 5, }, },
                PeriodoAnioHasta: { value: 1900, attributes: { readOnly: false, focus: false, label: "Año", maxLength: 4, hidden: "none", id: 6, }, },
                /**/OrdenadoPor: { value: "", attributes: { readOnly: false, focus: false, label: "Ordenado Por", hidden: "none", id: 7, }, },
                /**/Digitados: { value: false, attributes: { readOnly: false, focus: false, label: "Digitados", hidden: "none", id: 8, }, },
                /**/DigitadosDel: { value: moment().toDate(), attributes: { readOnly: true, label: 'Fecha de Inicio', hidden: 'none', id: 8, minDate: fechaPrimerDia(new Date(Config.anoAntiguedad, 0, 1)), maxDate: fechaUltimoDia(new Date(_AnnoActual, 11, 1)), ListaAnnos: _ListaAnnos, formatDate: Config.formatoMesAno } },
                /**/DigitadosAl: { value: moment().toDate(), attributes: { readOnly: true, label: 'Fecha Fin', hidden: 'none', id: 8, minDate: fechaPrimerDia(new Date(Config.anoAntiguedad, 0, 1)), maxDate: fechaUltimoDia(new Date(_AnnoActual, 11, 1)), ListaAnnos: _ListaAnnos, formatDate: Config.formatoMesAno } },
                FechaInicio: { value: new Date("1900/01/01"), attributes: { readOnly: false, label: "Desde", hidden: "none", id: 9, }, },
                FechaFinal: { value: new Date("1900/01/01"), attributes: { readOnly: false, label: "Hasta", hidden: "none", id: 10, }, },
                /**/Numeros: { value: false, attributes: { readOnly: false, focus: false, label: "Números", hidden: "none", id: 11, }, },
                /**/NumerosDel: { value: "", attributes: { readOnly: true, focus: false, label: "Del", hidden: "none", id: 11 }, },
                /**/NumerosAl: { value: "", attributes: { readOnly: true, focus: false, label: "Al", hidden: "none", id: 11 }, },
                /**/TipoAsiento: { value: "", attributes: { readOnly: true, focus: false, label: "Tipo Asiento", hidden: "none", id: 12 }, },
                /**/fecMesAno: { value: moment().toDate(), attributes: { readOnly: false, label: 'Del Periodo', hidden: 'none', id: 13, minDate: fechaPrimerDia(new Date(Config.anoAntiguedad, 0, 1)), maxDate: fechaUltimoDia(new Date(_AnnoActual, 11, 1)), ListaAnnos: _ListaAnnos, formatDate: Config.formatoMesAno } },
                /**/Consolidado: { value: false, attributes: { readOnly: false, focus: false, label: "Consolidado", hidden: "none", id: 14, }, },
                /**/ImprimirLogo: { value: false, attributes: { readOnly: false, focus: false, label: "Imprimir Logo", hidden: "none", id: 15, }, },
                /**/RadioCuentas: { value: "", attributes: { readOnly: false, focus: false, label: "", hidden: "none", id: 16, }, },
                /**/CkCuentas: { value: false, attributes: { readOnly: false, focus: false, label: "Cuentas", hidden: "none", id: 17, }, },
                /**/Cuenta: { value: "", attributes: { readOnly: true, readOnlyBoton: true, focus: false, label: "Cuenta Inicial", maxLength: 20, hidden: "none", id: 18, }, },
                /**/NombreCuenta: { value: "", attributes: { readOnly: true, focus: false, label: "Nombre", hidden: "none", id: 18, }, },
                /**/CuentaAl: { value: "", attributes: { readOnly: true, readOnlyBoton: true, focus: false, label: "Cuenta Final", maxLength: 20, hidden: "none", id: 19, }, },
                /**/NombreCuentaAl: { value: "", attributes: { readOnly: true, focus: false, label: "Nombre", hidden: "none", id: 19, }, },
                /**/CkCentroDeCosto: { value: false, attributes: { readOnly: false, focus: false, label: "Centro de Costo", hidden: "none", id: 20, }, },
                /**/CodigoCCosto: { value: "", attributes: { readOnly: true, readOnlyBoton: true, focus: false, label: "Código", hidden: "none", id: 20, }, },
                /**/NombreCCosto: { value: "", attributes: { readOnly: true, focus: false, label: "Nombre", hidden: "none", id: 20, }, },
                /**/CkOcultaDocumentos: { value: false, attributes: { readOnly: false, focus: false, label: "Ocultar Documentos", hidden: "none", id: 21, }, },
                TipoMovimiento: { value: "", attributes: { readOnly: false, focus: false, label: "Tipo Movimiento", hidden: "none", id: 23, }, },
                /**/Referencia: { value: "", attributes: { readOnly: false, focus: false, label: "Referencia", hidden: "none", id: 24, }, },
                /**/Documento: { value: "", attributes: { readOnly: false, focus: false, label: "Documento", hidden: "none", id: 25, }, },
                Nivel: { value: 1, attributes: { readOnly: false, focus: false, label: "Nivel", hidden: "none", maxLength: "3", id: 26, }, },
                MostrarCuentasCero: { value: false, attributes: { readOnly: false, focus: false, label: "Mostrar cuentas con saldos cero y sin movimientos", hidden: "none", id: 27, }, },
                /**/RadioDatosRep: { value: "", attributes: { readOnly: false, focus: false, label: "Datos del Reporte", hidden: "none", id: 28, }, },
                FormaImpresion: { value: "", attributes: { readOnly: false, focus: false, label: "Forma de Impresión", hidden: "none", id: 29, }, },
                EstadosFinancieros: { value: "", attributes: { readOnly: false, focus: false, label: "Estados Financieros", hidden: "none", id: 30, }, },
                /**/TipoCuenta: { value: "", attributes: { readOnly: true, focus: false, label: "Tipo de Cuenta", hidden: "none", id: 31 }, },
                Periodo: { value: moment().toDate(), attributes: { readOnly: false, focus: false, label: 'Período', hidden: 'none', minDate: fechaPrimerDia(new Date(Config.anoAntiguedad, 0, 1)), maxDate: fechaUltimoDia(new Date(_AnnoActual, 11, 1)), ListaAnnos: _ListaAnnos, formatDate: Config.formatoMesAno, id: 32 } },
                DatosReporte: { value: "", attributes: { readOnly: false, focus: false, label: "Datos Reporte", hidden: "none", id: 33 }, },
                Catalogo: { value: "", attributes: { readOnly: false, focus: false, label: "Catalogo", hidden: "none", id: 34 }, },
                TipoGeneral: { value: "", attributes: { readOnly: false, focus: false, label: "General", hidden: "none", id: 35 }, },
                TipoEspecifico: { value: "", attributes: { readOnly: false, focus: false, label: "Específico", hidden: "none", id: 36 }, },
                FormatoMovimientos: { value: "", attributes: { readOnly: false, focus: false, label: "Formato Movimientos", hidden: "none", id: 37 }, },
                EstadosAsientos: { value: "", attributes: { readOnly: false, focus: false, label: "Estados Asientos", hidden: "none", id: 38 }, },
                Usuarios: { value: "", attributes: { readOnly: false, focus: false, label: "Usuarios", hidden: "none", id: 39 }, },
                CCosto: { value: "", attributes: { readOnly: false, focus: false, label: "Centro de Costo", hidden: "none", id: 40 }, },
                TipoFiltroCuentas: { value: "", attributes: { readOnly: false, focus: false, label: "Filtro Cuentas", hidden: "none", id: 41, }, },
                /**/FolioInicial: { value: "", attributes: { readOnly: false, focus: false, label: 'Folio Inicial', hidden: 'none', maxLength: "9", id: 42 } },
                /**/ImprimeFH: { value: true, attributes: { readOnly: false, focus: false, label: "Imprime Fecha y Hora de Impresión", hidden: "none", id: 43, }, },
                /**/CkDescCrece: { value: false, attributes: { readOnly: false, focus: false, label: "Descripción puede crecer", hidden: "none", id: 44, }, },
                /**/RadioTipoImp: { value: "", attributes: { readOnly: false, focus: false, label: "Forma de Impresión", hidden: "none", id: 45, }, },
                /**/ListPeriodo: { value: moment().toDate(), attributes: { readOnly: false, label: 'Periodo', hidden: 'none', id: 46 } },
                TipoCtaGeneral: { value: "", attributes: { readOnly: false, focus: false, label: "Tipo General", hidden: "none", id: 47 }, },
                TipoCtaEspecifico: { value: "", attributes: { readOnly: false, focus: false, label: "Tipo Específico", hidden: "none", id: 48 }, },
                CkNivel: { value: false, attributes: { readOnly: false, focus: false, label: "Nivel", hidden: "none", id: 49, }, },
                RadioFormatoMov: { value: "", attributes: { readOnly: false, focus: false, label: "", hidden: "none", id: 50, }, },
                TablaParametros: { value: "", attributes: { readOnly: false, focus: false, label: "", hidden: "none", id: 51, }, },
                /**/BotonesForm: { value: "", attributes: { readOnly: false, focus: false, label: "", hidden: "none", id: 53, }, },
                /**/TipoAsientoMarca: { value: "", attributes: { readOnly: false, focus: false, label: "Asientos Para Marcar", hidden: "none", id: 54 }, },
                /**/RangoDel: { value: "", attributes: { readOnly: true, focus: false, label: "Rango de Asientos Del", hidden: "none", id: 54 }, },
                /**/RangoAl: { value: "", attributes: { readOnly: true, focus: false, label: "Rango de Asientos Al", hidden: "none", id: 54 }, },
                UbicacionImagen: { value: ImagenesRutas.PicDefault, attributes: { readOnly: false, focus: false, label: 'Ubicacion imagen', hidden: 'unset', Editando: false, maxLength: "255" } },
                ListaReportes: { value: '', attributes: { readOnly: false, focus: false, label: 'Lista de Reportes', hidden: 'none', id: 55 } },
                CkUsuarios: { value: false, attributes: { readOnly: false, focus: false, label: "Todos", hidden: "none", id: 56, }, },
                CodigoUsuarios: { value: "", attributes: { readOnly: true, readOnlyBoton: true, focus: false, label: "Usuario", maxLength: 40, hidden: "none", id: 56, }, },
                NombreUsuarios: { value: "", attributes: { readOnly: true, focus: false, label: "Nombre", hidden: "none", id: 56, }, },
                /**/BotonAg: { value: "", attributes: { readOnly: false, focus: false, label: "", hidden: "none", id: 57, }, },
            },
            /**/datosEmpresa: [],
            /**/listCuentas: [],
            /**/ListCC: [],
            /**/ListCentrosCosto: [],
            /**/listCuentasContTemp: [],
            /**/ListaPeriodos: [],
            listaCheck: [],
            listaComprometidos: [],
            listaEstadosAsientos: [],
            /**/listaAsientos: Config.listaEstadoAsientos,
            /**/listaOrdenadoPor: listaOrdenado,
            listaTipoAsiento: [],
            listaTipoAsientoMarca: [],
            listaAsientoConsolid: [],
            listaFiltroCuentas: [],
            listaTiposMovimientos: [],
            listaFormaImpresion: [{ value: 'P', text: 'Portrait' }, { value: 'L', text: 'Landscape' }],
            listaEstadosFinancieros: [],
            listaTiposCuenta: [],
            listaCentrosCosto: [],
            listaPeriodo: [],
            /**/listaDatosReporte: [],
            listaCatalogo: [{ value: 'T', text: 'Todo el catálogo' }, { value: 'G', text: 'General' }, { value: 'E', text: 'Específico' }],
            listaTipoAsientoGeneral: [],
            listaTipoAsientoEspecifico: [],
            ListaTipoCta: Config.listaSubTiposCuentasTipo,
            ListaSubTipoCta: [],
            listaDatos: [],
            listaFormatosMovimiento: [{ value: 'R', text: 'Resumen', reverso: true }, { value: 'D', text: 'Detalle', reverso: true },],
            listaUsuarios: [],
            PermiteCrecer: false,
            /**/radioOptions: [],
            /**/seleccionAsiento: (itemSelect(1, Config.listaEstadoAsientos)),
            seleccionPeriodoMes: null,
            seleccionPeriodoMesHasta: null,
            /**/seleccionOrdenadoPor: (itemSelect(1, listaOrdenado)),
            /**/selectedCuentas: null,
            /**/selectedDatosRep: null,
            /**/selectedCuentaTree: undefined,
            /**/selectedCuentaTreeCC: undefined,
            /**/selectedCC: 0,
            /**/selectedNivelIni: 0,
            /**/selectedNivelFin: 0,
            /**/seleccionTipoDeCuentas: null,
            seleccionTipoMovimiento: null,
            seleccionPeriodo: null,
            seleccionTipoGeneral: null,
            seleccionTipoEspecifico: null,
            seleccionEstadoAsiento: null,
            seleccionTipoCtaGeneral: null,
            seleccionTipoCtaEspecifico: null,
            seleccionCCosto: null,
            selectModalTree: false,
            selectModalTreeCC: false,
            selectedFormatoMovimiento: null,
            idModalTree: "",
            /**/seleccionTipoAsiento: null,
            /**/seleccionTipoAsientoMarca: null,
            /**/token: '',
            /**/empresa: 0,
            /**/mostrarSpinnerModal: { mostrar: false, label: '', tipo: 3 },
            FinPeriodo: new Date(1900, 1, 1),
            ReportId: 0,
            //tabla de parametros
            columnasPAR: [
                { dataField: 'Cuenta', text: 'Número', csvText: 'No Accion', hidden: false, sort: true, editable: false },
                { dataField: 'Nombre', text: 'Descripción', classes: "ColumnText", csvText: 'Descripcion', hidden: false, sort: true, editable: false },
                { dataField: 'llave', text: 'llave', hidden: true, sort: true, editable: false, csvExport: false },
            ], itemCuentaPAR: { 'Cuenta': '', 'Nombre': '', 'llave': -1 },
            listaGralPAR: [], FilaSeleccionada: undefined,
            botonesLista: [
                {
                    name: "btnDigitarAs",
                    clase: "btn btn-sm pull-right flipInX animated",
                    evento: () => this.handleAgregar(),
                    leyenda: "",
                    iclase: faPlus,
                    tooltip: "Agregar"
                }, {
                    name: "btnAprobarAs",
                    clase: "btn btn-sm pull-right flipInX animated",
                    evento: () => this.handleEliminar(),
                    leyenda: "",
                    iclase: faTrash,
                    tooltip: "Elminar"

                }
            ],
            botonesForm: [
                {
                    name: "btnbotonesForm",
                    clase: "btn btn-sm pull-right flipInX animated",
                    evento: () => this.handleRefrescar(),
                    leyenda: "",
                    iclase: faSync,
                    tooltip: "Refrescar"
                }
            ],
            botonesAg: [
                {
                    name: "btnDigitarAs",
                    clase: "btn btn-sm pull-right flipInX animated",
                    evento: () => this.handleAgregar(),
                    leyenda: "",
                    iclase: faPlus,
                    tooltip: "Agregar"
                }
            ],
            listaReportes: [], seleccionReportes: itemSelect('G', Config.listaReportesCC),
            selectModalUsuario: false, selectedUsuario: null,
            columnasUsuario: [{ dataField: 'Login', text: 'Número', sort: true, align: 'right' }, { dataField: 'Nombre', text: 'Nombre', sort: true }],
            tituloTabla: undefined
        };

    }

    spinnerModalMostrar = (pSpinnerModal, pSpinnerLabel, pSpinnerTipo) => {
        this.setState({ mostrarSpinnerModal: { mostrar: pSpinnerModal, label: pSpinnerLabel, tipo: pSpinnerTipo } });
    };

    cargarTiposAsiento = async (pToken, pEmpresa, pTodos) => {
        if (pEmpresa !== 0) {
            const response = await TipoAsiento_Listar_Request(pToken, pEmpresa);

            let lista = [], listaMarca = [];

            if (pTodos) {
                lista.push({ value: 0, label: "Todos los tipos", mensual: "Mensual" });
            }

            if (response.Exitoso) {

                if (Array.isArray(response.Datos) && response.Datos.length > 0) {
                    response.Datos.map(x => (lista.push({ value: x.ID, label: x.Nombre, mensual: x.Mensual })));
                    response.Datos.map(x => (listaMarca.push({ value: x.ID, label: x.Nombre, mensual: x.Mensual })));
                    this.setState({ listaTipoAsiento: lista, listaTipoAsientoMarca: listaMarca, seleccionTipoAsiento: lista[0], seleccionTipoAsientoMarca: listaMarca[0] });
                } else {
                    this.volverAtras();
                }

            }
            else {
                Notificacion.error(response.Mensaje);
                this.volverAtras();
            }
            return lista;
        }
    };

    cargaSubCuentas = async (pToken, pEmpresa) => {
        if (pEmpresa !== 0) {
            const response = await SubTiposCuentas_Listar_Request(pToken, pEmpresa);

            let lista = [];

            if (response.Exitoso) {

                if (Array.isArray(response.Datos) && response.Datos.length > 0) {
                    response.Datos.map(x => (lista.push({ value: x.ID, label: x.Nombre })));
                    this.setState({ listaTipoAsiento: lista, seleccionTipoAsiento: lista[0] });
                } else {
                    this.volverAtras();
                }

            }
            else {
                Notificacion.error(response.Mensaje);
                this.volverAtras();
            }
            return lista;
        }
    }

    cargaSubTipoCuentas = async (pToken, pEmpresa) => {
        if (pEmpresa !== 0) {
            const response = await SubTiposCuentas_Listar_Request(pToken, pEmpresa);

            let lista = [];

            if (response.Exitoso) {

                if (Array.isArray(response.Datos) && response.Datos.length > 0) {
                    response.Datos.map(x => (lista.push({ value: x.ID, label: x.Nombre })));
                    return lista;
                } else {
                    Notificacion.error(`Sucedió un error al consultar los subtipos de las cuentas(TipoEspecífico).`);
                    this.volverAtras();
                    return lista;
                }

            }
            else {
                Notificacion.error(`Sucedió un error al consultar los subtipos de las cuentas(TipoEspecífico). ${response.Mensaje}`);
                this.volverAtras();
                return lista;
            }
            return lista;
        }
    }

    cargaPeriodos = async (pToken, pEmpresa) => {
        if (pEmpresa !== 0) {
            const response = await CatalogoHist_ListarPeriodos_Request(pToken, pEmpresa);

            let lista = [];

            if (response.Exitoso) {

                for (let i in response.Datos) {
                    lista.push({ value: i, label: `Periodo: ${moment(response.Datos[i].InicioPeriodo).format(Config.formatoFechaStandard)} al ${moment(response.Datos[i].FinPeriodo).format(Config.formatoFechaStandard)}`, Inicio: response.Datos[i].InicioPeriodo, Fin: response.Datos[i].FinPeriodo });
                }

                this.setState({ ListaPeriodos: lista, seleccionPeriodo: lista[0] });

            }
            else {
                Notificacion.error("Sucedió un error al consultar los periodos de la empresa.");
                this.volverAtras();
            }
            return lista;
        }
    }

    cargaUsuarios = async (pToken, pEmpresa) => {

        const response = await Seg_Usuario_Listar_Request(pToken, '', -1);
        let listaUsu = [];
        if (response.Exitoso) {

            listaUsu = response.Datos.sort((a, b) => {
                if (a.Login < b.Login) {
                    return -1;
                }
                if (a.Login > b.Login) {
                    return 1;
                }
                return 0;
            });

            this.setState({ listaUsuarios: listaUsu });

        }
        else {
            Notificacion.error("Sucedió un error al consultar los usuarios.");
            this.spinnerModalMostrar(false, '', 3);
            //if (!_login) { historyMenu.push(SiteRutas.Empleados); }
            return false;

        }


    }

    componentDidMount = async () => {

        try {

            this.spinnerModalMostrar(true, 'Cargando datos', 3);

            muestraArbolEmpleados(false);
            const session = new Session();
            const _Empresa = session.get("empresaCON");
            const _EmpresaNombre = session.get("empresaNombreCON");
            const token = session.get('tokenCON');
            const Pais = session.get('paisCON');
            let ReportId = parseInt(this.props.match.params.ReportId);
            let _comp = this.props.match.params.Sec;
            let listaCuentas = [], listaCC = [], cargaListaCC = false, cargaListaCuentas = false;

            let radioOptions = [], selectedCuentas = 0, listaDatosReporte = [], selectedDatosRep = 0;
            let seleccionTipoCtaGeneral = {}, seleccionTipoCtaEspecifico = {};
            let ListaSubTipoCta = [];
            //Analizar cuales elementos se deben mostrar según parámetros de URL    
            let _Datos = this.habilitarFiltros(this.props.match.params.Sec);
            let selectedFormatoMovimiento = 'R';
            let _columnasPAR = [];
            let _listaReportes = [];
            let _botonesLista = this.state.botonesLista;
            let _seleccionReportes = itemSelect('G', Config.listaReportesCC);
            let tituloTabla = undefined;

            //Cargar tipos de asiento si se necesita mostrar la lista
            if (_Datos.TipoAsiento.attributes.hidden === "unset") {

                let pTodos = false;

                if (_Datos.Numeros.attributes.hidden === "none") {
                    _Datos.TipoAsiento.attributes.readOnly = false;
                    _Datos.TipoAsiento.attributes.label = "Tipo Movimiento";
                    pTodos = true;
                }

                this.cargarTiposAsiento(token, _Empresa, pTodos);
            }

            const _botones = [
                {
                    name: "btnHomeEmp",
                    clase: "btn btn-sm pull-right flipInX animated",
                    evento: this.volverAtras,
                    leyenda: "",
                    iclase: faReply,
                    tooltip: "Volver",
                },
                {
                    name: "btnAplicar",
                    clase: "btn btn-sm pull-right flipInX animated",
                    evento: this.onGenerarReporte,
                    leyenda: "",
                    iclase: faPrint,
                    tooltip: "Imprimir",
                },
            ];

            let NombreEmpresa = '';
            let CedulaJuridica = '';
            let Telefono = '';
            let NombreComercial = '';
            let _FinPeriodo = new Date();
            let _listaGralPAR = [];
            //Consulta de empresa
            const result = await Empresa_Consulta_Request(token, _Empresa);

            if (result.Exitoso) {
                NombreEmpresa = result.Datos.Nombre;
                CedulaJuridica = result.Datos.Cedula_Juridica;
                Telefono = result.Datos.Telefono;
                NombreComercial = result.Datos.Nombre_Comercial;
                _Datos.fecMesAno.value = new Date(result.Datos.Periodo);
                _Datos.MovimientosDe.value = new Date(result.Datos.Periodo);
                _Datos.MovimientosAl.value = new Date(result.Datos.Periodo);
                _FinPeriodo = new Date(result.Datos.FinPeriodo);//.setHours(0,0,0,0);

                if (ReportId === Config.Reportes.AsientosDelCierre) {
                    _Datos.Periodo.value = moment(result.Datos.Periodo).toDate();
                }
                let _EmpresaImagen = DatosImagen;
                _EmpresaImagen = await this.EmpresasImagen_Consulta(token, _Empresa);
                _Datos = await this.cargaFotoEmpresa(token, _Datos, _EmpresaImagen);
            }

            let titulo = "", PermiteCrecer = false;

            const ReporteDesc = await this.obtieneDescripcionReporte(token, ReportId);

            if (ReporteDesc.Exitoso) {
                titulo = ReporteDesc.Datos.ReportTitulo;
            }

            if (ReportId === Config.Reportes.AsientosDiario) {
                _Datos.FolioInicial.attributes.hidden = (Pais == Config.PaisGuatemala) ? 'unset' : 'none';
                _Datos.ImprimeFH.attributes.hidden = (Pais == Config.PaisGuatemala) ? 'unset' : 'none';

                const parametros = await Parametros_Listar_Request(token, _Empresa);

                if (parametros.Exitoso) {
                    titulo = parametros.Datos[0].Rep_AsientoDiario;
                    PermiteCrecer = parametros.Datos[0].PermiteCrecer;
                } else {
                    Notificacion.error("Sucedió un error al consultar los datos del reporte.");
                }
            }

            if (ReportId === Config.Reportes.DiarioGeneral) {

                _Datos.FolioInicial.attributes.hidden = (Pais == Config.PaisGuatemala) ? 'unset' : 'none';
                _Datos.ImprimeFH.attributes.hidden = (Pais == Config.PaisGuatemala) ? 'unset' : 'none';

                radioOptions = Config.listaOptionsCuentas;
                selectedCuentas = 1;

                cargaListaCC = true;
                cargaListaCuentas = true;

                const parametros = await Parametros_Listar_Request(token, _Empresa);

                if (parametros.Exitoso) {
                    titulo = parametros.Datos[0].Rep_DiarioGral;
                } else {
                    Notificacion.error("Sucedió un error al consultar los datos del reporte.");
                }

            }

            if (ReportId == Config.Reportes.AsientosFinancieros) {

                _Datos.MovimientosCb.attributes.hidden = 'none';
                _Datos.MovimientosCb.value = true;
                _Datos.MovimientosDe.attributes.label = 'De'
                _Datos.MovimientosDe.attributes.readOnly = false;
                _Datos.MovimientosDe.value = new Date(result.Datos.Periodo);//.setHours(0,0,0,0);
                _Datos.MovimientosAl.attributes.label = 'Comparado';
                _Datos.MovimientosAl.attributes.readOnly = false;
                _Datos.MovimientosAl.value = fechaPrimerDia(new Date(addMonths(new Date(result.Datos.Periodo), -1)));//.setHours(0,0,0,0);
                _Datos.Consolidado.attributes.label = 'Mostrar cuentas con saldos cero y sin movimientos';
                _Datos.CkOcultaDocumentos.attributes.label = 'Mostrar Comparativo';
                _Datos.CkOcultaDocumentos.value = true;
                _Datos.FolioInicial.attributes.hidden = (Pais == Config.PaisGuatemala) ? 'unset' : 'none';
                _Datos.ImprimeFH.attributes.hidden = (Pais == Config.PaisGuatemala) ? 'unset' : 'none';
                //Pais == Config.PaisGuatemala

                cargaListaCC = true;
            }

            if (ReportId == Config.Reportes.BalanceSituacion) {

                _Datos.MovimientosCb.attributes.hidden = 'none';
                _Datos.MovimientosCb.value = true;
                _Datos.MovimientosDe.attributes.label = 'De'
                _Datos.MovimientosDe.attributes.readOnly = false;
                _Datos.MovimientosDe.value = new Date(result.Datos.Periodo);//.setHours(0,0,0,0);
                _Datos.MovimientosAl.attributes.label = 'Comparado';
                _Datos.MovimientosAl.attributes.readOnly = false;
                _Datos.MovimientosAl.value = fechaPrimerDia(new Date(addMonths(new Date(result.Datos.Periodo), -1)));//.setHours(0,0,0,0);
                _Datos.CkOcultaDocumentos.attributes.label = 'Mostrar Comparativo';
                _Datos.CkOcultaDocumentos.value = true;
                _Datos.FolioInicial.attributes.hidden = (Pais == Config.PaisGuatemala) ? 'unset' : 'none';
                _Datos.ImprimeFH.attributes.hidden = (Pais == Config.PaisGuatemala) ? 'unset' : 'none';
                //Pais == Config.PaisGuatemala

                cargaListaCC = true;
            }

            if (ReportId === Config.Reportes.BalanceComprobacion) {
                radioOptions = Config.listaOptionsImpresion;
                _Datos.RadioCuentas.attributes.label = "Forma de Impresión"
                _Datos.MovimientosCb.attributes.hidden = 'none';
                selectedCuentas = 1;
                cargaListaCC = true;
                cargaListaCuentas = true;
                _Datos.Nivel.value = 3;
            }

            if (ReportId === Config.Reportes.BalanceComprobacionEstimado) {
                radioOptions = Config.listaOptionsImpresion;
                _Datos.RadioCuentas.attributes.label = "Forma de Impresión"
                _Datos.MovimientosCb.attributes.hidden = "none";
                _Datos.MovimientosAl.attributes.hidden = 'none';
                _Datos.MovimientosDe.attributes.label = 'Del:';
                selectedCuentas = 1;
                cargaListaCC = true;
                cargaListaCuentas = true;
                _Datos.Nivel.value = 3;
            }

            if (ReportId === Config.Reportes.ImpresionDeCuentas) {
                _Datos.Cuenta.attributes.readOnly = false;
                _Datos.Cuenta.attributes.readOnlyBoton = false;
                cargaListaCuentas = true;
            }

            if (ReportId === Config.Reportes.ImpresionDeCatalogo) {
                radioOptions = Config.listaOptionsTipoCuentas;
                _Datos.RadioCuentas.attributes.label = "Tipos"
                _Datos.Nivel.attributes.readOnly = true;
                _Datos.TipoCtaGeneral.attributes.readOnly = true;
                _Datos.TipoCtaEspecifico.attributes.readOnly = true;
                seleccionTipoCtaGeneral = this.state.ListaTipoCta[0];
                ListaSubTipoCta = await this.cargaSubTipoCuentas(token, _Empresa);
                seleccionTipoCtaEspecifico = ListaSubTipoCta[0];
                selectedCuentas = 1;
                _Datos.Nivel.value = 1;
            }

            if (ReportId === Config.Reportes.HistoricoSaldos) {
                selectedCuentas = 1;
                radioOptions = Config.listaOptionsEstadosF;
                _Datos.RadioCuentas.attributes.label = "Estados Financieros";

                listaDatosReporte = Config.listaOptionsDatosRep;
                cargaListaCC = true;
                selectedDatosRep = 1;

                await this.cargaSubCuentas(token, _Empresa);
                await this.cargaPeriodos(token, _Empresa)
            }

            if (ReportId == Config.Reportes.MovimientosSinAPlicar) {

                _Datos.MovimientosCb.attributes.hidden = 'none';
                _Datos.MovimientosCb.value = true;
                _Datos.MovimientosDe.attributes.label = 'Periodo'
                _Datos.MovimientosDe.attributes.readOnly = false;
                _Datos.MovimientosDe.value = new Date(result.Datos.Periodo);//.setHours(0,0,0,0);
                _Datos.MovimientosAl.attributes.hidden = 'none';
                //_Datos.MovimientosAl.value = fechaPrimerDia(new Date(addMonths(new Date(result.Datos.Periodo), -1)));//.setHours(0,0,0,0);
                radioOptions = this.state.listaFormatosMovimiento;
                _Datos.RadioFormatoMov.attributes.label = ""
                _Datos.Cuenta.attributes.readOnly = false;
                _Datos.Cuenta.attributes.readOnlyBoton = false;
                cargaListaCuentas = true;
                selectedFormatoMovimiento = 'R';

                _columnasPAR = [
                    { dataField: 'Cuenta', text: 'Número', csvText: 'No Accion', hidden: false, sort: true, editable: false },
                    { dataField: 'Nombre', text: 'Descripción', classes: "ColumnText", csvText: 'Descripcion', hidden: false, sort: true, editable: false },
                    { dataField: 'llave', text: 'llave', hidden: true, sort: true, editable: false, csvExport: false },
                ]

                _botonesLista = [
                    {
                        name: "btnAprobarAs",
                        clase: "btn btn-sm pull-right flipInX animated",
                        evento: () => this.handleEliminar(),
                        leyenda: "",
                        iclase: faTrash,
                        tooltip: "Elminar"
                    }
                ]
            }

            if (ReportId === Config.Reportes.ImpresionCentroCosto) {
                radioOptions = Config.listaOptionsCC;
                selectedCuentas = 1;
                _Datos.Nivel.attributes.readOnly = true;
                //_Datos.Nivel.attributes.label = '';
            }

            if (ReportId === Config.Reportes.ConsolidaciondeCuentas) {

                _columnasPAR = [
                    { dataField: 'pNumero', text: 'Tipo', csvText: 'No Accion', hidden: false, sort: true, editable: false },
                    { dataField: 'Numero', text: 'Número', csvText: 'No Accion', hidden: false, sort: true, editable: false },
                    { dataField: 'Descripcion', text: 'Descripción', classes: "ColumnText", csvText: 'Descripcion', hidden: false, sort: true, editable: false },
                    { dataField: 'Debitos', text: 'Débitos', csvText: 'Débitos', hidden: false, sort: true, editable: false, formatter: (row, cell) => { return farmatearMontos(cell.Debitos) }, },
                    { dataField: 'Creditos', text: 'Créditos', csvText: 'Créditos', hidden: false, sort: true, editable: false, formatter: (row, cell) => { return farmatearMontos(cell.Creditos) }, },
                    { dataField: 'id', text: 'id', hidden: true, sort: true, editable: false, csvExport: false },
                ]

                _botonesLista = [];

                tituloTabla = "Lista de Asientos";

            }

            if (ReportId === Config.Reportes.Comprometido) {
                cargaListaCuentas = true;
                _Datos.fecMesAno.attributes.label = "Periodo";
                _Datos.Cuenta.attributes.label = "Cuenta";
                _Datos.Cuenta.attributes.readOnly = false;
                _Datos.Cuenta.attributes.readOnlyBoton = false;

                _columnasPAR = [
                    { dataField: 'Cuenta', text: 'Cuenta', csvText: 'Cuenta', hidden: false, sort: true, align: 'right', footerAlign: 'right', editable: false, footer: '' },
                    { dataField: 'Nombre', text: 'Nombre', csvText: 'Nombre', hidden: false, sort: true, align: 'right', footerAlign: 'right', editable: false, footer: 'Totales' },
                    { dataField: 'Digitado', text: 'Digitado', classes: "ColumnText", csvText: 'Digitado', hidden: false, sort: true, align: 'right', footerAlign: 'right', editable: false, formatter: (row, cell) => { return farmatearMontos(cell.Digitado) }, footer: (columnData, column, columnIndex) => { const total = columnData.reduce((acc, item) => acc + item, 0); return farmatearMontos(Round(total, 2)); }, },
                    { dataField: 'Aprobado', text: 'Aprobado', csvText: 'Aprobado', hidden: false, sort: true, align: 'right', footerAlign: 'right', editable: false, formatter: (row, cell) => { return farmatearMontos(cell.Aprobado) }, footer: (columnData, column, columnIndex) => { const total = columnData.reduce((acc, item) => acc + item, 0); return farmatearMontos(Round(total, 2)) } },
                    { dataField: 'Comprometido', text: 'Comprometido', csvText: 'Comprometido', hidden: false, sort: true, align: 'right', footerAlign: 'right', editable: false, formatter: (row, cell) => { return farmatearMontos(cell.Comprometido) }, footer: (columnData, column, columnIndex) => { const total = columnData.reduce((acc, item) => acc + item, 0); return farmatearMontos(Round(total, 2)) } },
                    { dataField: 'Mensual', text: 'Mensual', csvText: 'Mensual', hidden: false, sort: true, align: 'right', footerAlign: 'right', editable: false, csvExport: false, formatter: (row, cell) => { return farmatearMontos(cell.Mensual) }, footer: (columnData, column, columnIndex) => { const total = columnData.reduce((acc, item) => acc + item, 0); return farmatearMontos(Round(total, 2)); } },
                    { dataField: 'Acumulado', text: 'Acumulado', csvText: 'Acumulado', hidden: false, sort: true, align: 'right', footerAlign: 'right', editable: false, csvExport: false, formatter: (row, cell) => { return farmatearMontos(cell.Acumulado) }, footer: (columnData, column, columnIndex) => { const total = columnData.reduce((acc, item) => acc + item, 0); return farmatearMontos(Round(total, 2)); } },
                    { dataField: 'Mens_Est', text: 'Mensual Est.', csvText: 'Mensual Est.', hidden: false, sort: true, align: 'right', footerAlign: 'right', editable: false, csvExport: false, formatter: (row, cell) => { return farmatearMontos(cell.Mens_Est) }, footer: (columnData, column, columnIndex) => { const total = columnData.reduce((acc, item) => acc + item, 0); return farmatearMontos(Round(total, 2)); } },
                    { dataField: 'Acum_Est', text: 'Acum. Est.', csvText: 'Acum. Est.', hidden: false, sort: true, align: 'right', footerAlign: 'right', editable: false, csvExport: false, formatter: (row, cell) => { return farmatearMontos(cell.Acum_Est) }, footer: (columnData, column, columnIndex) => { const total = columnData.reduce((acc, item) => acc + item, 0); return farmatearMontos(Round(total, 2)); } },
                ];

                _botonesLista = [
                    {
                        name: "btnAprobarAs",
                        clase: "btn btn-sm pull-right flipInX animated",
                        evento: () => this.handleEliminar(),
                        leyenda: "",
                        iclase: faTrash,
                        tooltip: "Elminar"
                    }
                ]
            }

            if (ReportId == Config.Reportes.ReportesCentroCostos) {

                _Datos.MovimientosCb.attributes.hidden = 'none';
                _Datos.MovimientosCb.value = true;
                _Datos.MovimientosDe.attributes.label = 'De'
                _Datos.MovimientosDe.attributes.readOnly = false;
                _Datos.MovimientosDe.value = new Date(result.Datos.Periodo);//.setHours(0,0,0,0);
                _Datos.MovimientosAl.attributes.label = 'Comparado con los Saldos de';
                _Datos.MovimientosAl.attributes.readOnly = false;
                _Datos.MovimientosAl.value = fechaPrimerDia(new Date(addMonths(new Date(result.Datos.Periodo), -1)));//.setHours(0,0,0,0);
                _Datos.ListaReportes.attributes.label = 'Reportes de Centros de Costos';
                _Datos.ListPeriodo.attributes.readOnly = true;
                _listaReportes = Config.listaReportesCC;
                _seleccionReportes = itemSelect('G', Config.listaReportesCC);
                await this.cargaPeriodos(token, _Empresa);
                _listaGralPAR = await this.cargaCC(token, _Empresa);
                _columnasPAR = [
                    { dataField: 'ID', text: 'Número', csvText: 'No Accion', hidden: false, sort: true, editable: false },
                    { dataField: 'Nombre', text: 'Descripción', classes: "ColumnText", csvText: 'Descripcion', hidden: false, sort: true, editable: false },
                    { dataField: 'llave', text: 'llave', hidden: true, sort: true, editable: false, csvExport: false },
                ]
                _botonesLista = [];
                cargaListaCC = true;
                tituloTabla = "Lista de Centros de Costo";
            }

            if (ReportId == Config.Reportes.ReportesCentroUtilidades) {

                _Datos.MovimientosCb.attributes.hidden = 'none';
                _Datos.MovimientosCb.value = true;
                _Datos.MovimientosDe.attributes.label = 'De'
                _Datos.MovimientosDe.attributes.readOnly = false;
                _Datos.MovimientosDe.value = new Date(result.Datos.Periodo);//.setHours(0,0,0,0);
                _Datos.MovimientosAl.attributes.label = 'Comparado con los Saldos de';
                _Datos.MovimientosAl.attributes.readOnly = false;
                _Datos.MovimientosAl.value = fechaPrimerDia(new Date(addMonths(new Date(result.Datos.Periodo), -1)));//.setHours(0,0,0,0);
                _Datos.ListaReportes.attributes.label = 'Reportes de Centros de Utilidad';
                _Datos.ListPeriodo.attributes.readOnly = true;
                _listaReportes = Config.listaReportesCU;
                _seleccionReportes = itemSelect('U', Config.listaReportesCU);
                await this.cargaPeriodos(token, _Empresa);
                _listaGralPAR = await this.cargaCU(token, _Empresa);
                _columnasPAR = [
                    { dataField: 'ID', text: 'Número', csvText: 'No Accion', hidden: false, sort: true, editable: false },
                    { dataField: 'Nombre', text: 'Descripción', classes: "ColumnText", csvText: 'Descripcion', hidden: false, sort: true, editable: false },
                    { dataField: 'llave', text: 'llave', hidden: true, sort: true, editable: false, csvExport: false },
                ]
                _botonesLista = [];
                cargaListaCC = true;

                tituloTabla = "Lista Centros de Utilidad";
            }

            if (ReportId == Config.Reportes.BitacoraGeneral) {
                _Datos.CkUsuarios.value = true;
                _Datos.DigitadosDel.attributes.label = 'Desde';
                _Datos.DigitadosAl.attributes.label = 'Hasta';
                _Datos.Digitados.attributes.label = 'Fecha';
                _Datos.Digitados.value = false;

                await this.cargaUsuarios(token, _Empresa);
                _Datos.CodigoUsuarios.value = "";
                _Datos.CodigoUsuarios.attributes.readOnly = true;
                _Datos.CodigoUsuarios.attributes.readOnlyBoton = true;

            }

            if (ReportId === Config.Reportes.EstadoResultadosPresupuesto) {
                _Datos.MovimientosCb.attributes.hidden = 'none';
                _Datos.MovimientosAl.attributes.hidden = 'none';
                cargaListaCC = true;
            }

            if (ReportId === Config.Reportes.CierreFiscal) {
                cargaListaCC = true;
                await this.cargaPeriodos(token, _Empresa)
            }

            if (ReportId === Config.Reportes.BalanceSituacionPresupuesto) {
                _Datos.MovimientosCb.attributes.hidden = 'none';
                _Datos.MovimientosAl.attributes.hidden = 'none';
                cargaListaCC = true;
            }

            if (ReportId === Config.Reportes.CentroCostosPresupuesto) {
                _Datos.MovimientosCb.attributes.hidden = 'none';
                _Datos.MovimientosAl.attributes.hidden = 'none';

                _listaGralPAR = await this.cargaCC(token, _Empresa);
                _columnasPAR = [
                    { dataField: 'ID', text: 'Número', csvText: 'No Accion', hidden: false, sort: true, editable: false },
                    { dataField: 'Nombre', text: 'Descripción', classes: "ColumnText", csvText: 'Descripcion', hidden: false, sort: true, editable: false },
                    { dataField: 'llave', text: 'llave', hidden: true, sort: true, editable: false, csvExport: false },
                ]
                _botonesLista = [];
                tituloTabla = "Lista de Centros de Costo";

            }
            if (ReportId === Config.Reportes.CentroUtilidadesPresupuesto) {
                _Datos.MovimientosCb.attributes.hidden = 'none';
                _Datos.MovimientosAl.attributes.hidden = 'none';

                _listaGralPAR = await this.cargaCU(token, _Empresa);
                _columnasPAR = [
                    { dataField: 'ID', text: 'Número', csvText: 'No Accion', hidden: false, sort: true, editable: false },
                    { dataField: 'Nombre', text: 'Descripción', classes: "ColumnText", csvText: 'Descripcion', hidden: false, sort: true, editable: false },
                    { dataField: 'llave', text: 'llave', hidden: true, sort: true, editable: false, csvExport: false },
                ]
                _botonesLista = [];

                tituloTabla = "Lista Centros de Utilidad";

            }


            if (cargaListaCC) {
                listaCC = await this.carga_ListTreeCC(token, _Empresa, _EmpresaNombre);
            }

            if (cargaListaCuentas) {
                listaCuentas = await this.carga_ListTree(token, _Empresa, _EmpresaNombre);
            }

            if (_columnasPAR.length === 0) {
                _columnasPAR = this.state.columnasPAR;
            }

            this.setState({
                botones: _botones,
                _Datos,
                ReportId,
                ReporteDesc,
                titulo,
                token,
                NombreEmpresa,
                CedulaJuridica,
                Telefono,
                NombreComercial,
                radioOptions: radioOptions,
                selectedCuentas,
                empresa: _Empresa,
                listCuentasContTemp: listaCuentas,
                ListCC: listaCC,
                datosEmpresa: result.Datos,
                FinPeriodo: _FinPeriodo,
                PermiteCrecer,
                selectedDatosRep: selectedDatosRep,
                listaDatosReporte: listaDatosReporte,
                seleccionTipoCtaGeneral,
                seleccionTipoCtaEspecifico,
                ListaSubTipoCta,
                selectedFormatoMovimiento,
                columnasPAR: _columnasPAR,
                listaReportes: _listaReportes,
                seleccionReportes: _seleccionReportes,
                listaGralPAR: _listaGralPAR,
                botonesLista: _botonesLista,
                tituloTabla: tituloTabla
            });
        } catch (e) {
            Notificacion.error(`Error: ${e.message}`);
        } finally {
            this.spinnerModalMostrar(false, '', 3);
        }
    };

    EmpresasImagen_Consulta = async (pToken, pEmpresa) => {
        let datos = [];
        const response = await EmpresasImagen_Consulta_Request(pToken, pEmpresa);
        if (response.Exitoso) {
            datos = response.Datos;
        } else {
            Notificacion.error(`EmpresasImagen_Consulta_Request ${response.Mensaje}`);
            //volverAtras();
        }
        return datos;
    };

    cargaFotoEmpresa = async (pToken, pEmpresa, pEmpresaImagen) => {
        let response = [];
        response = await Empresa_Foto_Request(pToken, pEmpresaImagen.Nombre);
        pEmpresa.UbicacionImagen.value = (response.Exitoso == true ? response.Mensaje : ImagenesRutas.PicDefault);
        return pEmpresa;
    }

    compararFechas = (pFecha, pFechaInicP) => {
        let resultado = false;
        let Hoy = new Date(pFechaInicP);
        Hoy.setMinutes(Hoy.getMinutes() + Hoy.getTimezoneOffset())

        let fechaRevisa = new Date(pFecha);
        fechaRevisa.setMinutes(fechaRevisa.getMinutes() + fechaRevisa.getTimezoneOffset())

        const AnyoFecha = fechaRevisa.getFullYear();
        const MesFecha = fechaRevisa.getMonth();
        const DiaFecha = fechaRevisa.getDate();

        const AnyoHoy = Hoy.getFullYear();
        const MesHoy = Hoy.getMonth();
        const DiaHoy = Hoy.getDate();

        if (AnyoFecha < AnyoHoy) {
            resultado = false;
        }
        else {
            if (AnyoFecha == AnyoHoy && MesFecha < MesHoy) {
                resultado = false;
            }
            else {
                if (AnyoFecha == AnyoHoy && MesFecha == MesHoy && DiaFecha < DiaHoy) {
                    resultado = false;
                }
                else {
                    resultado = true;
                }
            }
        }
        return resultado;
    };

    componentDidUpdate = async (prevProps, prevState) => {
        if (prevProps.match.params.ReportId !== this.props.match.params.ReportId) {
            let titulo = "";

            const ReportId = parseInt(this.props.match.params.ReportId);
            const session = new Session();
            const _Empresa = session.get("empresaCON");
            const token = session.get('tokenCON');
            const Pais = session.get('paisCON');
            const Datos = this.habilitarFiltros(this.props.match.params.Sec);
            const pToken = this.state.token;
            const ReporteDesc = await this.obtieneDescripcionReporte(pToken, ReportId);

            if (ReporteDesc.Exitoso) {
                titulo = ReporteDesc.Datos.ReportTitulo;
            }

            const botones = [
                {
                    name: "btnHomeEmp",
                    clase: "btn btn-sm pull-right flipInX animated",
                    evento: this.volverAtras,
                    leyenda: "",
                    iclase: faReply,
                    tooltip: "Volver",
                },
                {
                    name: "btnAplicar",
                    clase: "btn btn-sm pull-right flipInX animated",
                    evento: this.onGenerarReporte,
                    leyenda: "",
                    iclase: faPrint,
                    tooltip: "Aceptar",
                },
            ];

            this.setState({
                titulo,
                Datos,
                ReportId,
                ReporteDesc,
                botones,
            });
        }
    };

    obtieneDescripcionReporte = async (pToken, pReporte) => {
        let datos = await Get_Description_Report_Request(pToken, pReporte);
        return datos;
    };

    habilitarFiltros = (pFiltros) => {
        let Datos = this.state.Datos;
        const listFiltro = pFiltros.split("|");

        for (let key in Datos) {
            Datos[key].attributes.hidden = "none";
        };

        for (let key in Datos) {
            listFiltro.forEach(function (valor, indice, array) {
                if (parseInt(Datos[key].attributes.id) == parseInt(valor)) {
                    Datos[key].attributes.hidden = "unset";
                }
            });
        };

        return Datos;
    };

    volverAtras = () => {
        this.props.history.push(`${SiteRutas.Asientos}`);
    };

    getObjectId = (obj) => {
        return obj.Id;
    };

    compare = (a, b) => {
        if (a.text < b.text) {
            return -1;
        }
        if (a.text > b.text) {
            return 1;
        }
        return 0;
    };

    handleSelectChange = (value, name) => {

        if (this.state.ReportId === Config.Reportes.ConsolidaciondeCuentas) {

            if (name === "seleccionTipoAsientoMarca") {

                let ListaFiltro = this.state.listaGralPAR.filter(item => item.Tipo == value.value);
                let Minimo = undefined, numeroCiclo = 0, MinimoSelec = {}, Maximo = undefined, MaximoSelec = {};

                for (let i in ListaFiltro) {

                    numeroCiclo = ListaFiltro[i].Numero;

                    if (Minimo === undefined) {
                        Minimo = ListaFiltro[i].Numero;
                    }
                    if (Maximo === undefined) {
                        Maximo = numeroCiclo;
                    }

                    if (numeroCiclo <= Minimo) {
                        MinimoSelec = ListaFiltro[i];
                        Minimo = numeroCiclo;
                    }
                    if (numeroCiclo >= Maximo) {
                        MaximoSelec = ListaFiltro[i];
                        Maximo = numeroCiclo;
                    }

                }

                let Datos = this.state.Datos;

                Datos.RangoDel.value = MinimoSelec.pNumero !== undefined ? MinimoSelec.pNumero : "";
                Datos.RangoAl.value = MaximoSelec.pNumero !== undefined ? MaximoSelec.pNumero : "";

                this.setState({ Datos });
            }

        }
        if (this.state.ReportId === Config.Reportes.ReportesCentroCostos) {
            if (name === "seleccionReportes") {
                const _Rep = value.value;
                let Datos = this.state.Datos;
                Datos.MovimientosAl.attributes.label = (_Rep == 'G') ? 'Comparado con los Saldos de' : 'Al';
                Datos.MovimientosAl.attributes.readOnly = (_Rep == 'H') ? true : false;
                Datos.MovimientosDe.attributes.readOnly = (_Rep == 'H') ? true : false;
                Datos.ListPeriodo.attributes.readOnly = (_Rep == 'H') ? false : true;;
                this.setState({ Datos });
            }

        }
        if (this.state.ReportId === Config.Reportes.ReportesCentroUtilidades) {
            if (name === "seleccionReportes") {
                const _Rep = value.value;
                let Datos = this.state.Datos;
                Datos.MovimientosAl.attributes.label = (_Rep == 'U') ? 'Comparado con los Saldos de' : 'Al';
                Datos.MovimientosAl.attributes.readOnly = (_Rep == 'H') ? true : false;
                Datos.MovimientosDe.attributes.readOnly = (_Rep == 'H') ? true : false;
                Datos.ListPeriodo.attributes.readOnly = (_Rep == 'H') ? false : true;;
                this.setState({ Datos });
            }

        }

        if (this.state.ReportId === Config.Reportes.ConsolidaciondeCuentas && (name === "seleccionAsiento" || name === "seleccionTipoAsiento")) {

            let lista = "listaGralPAR", listCheck = "listaCheck";

            this.setState({
                ...this.state,
                [name]: value,
                [lista]: [],
                [listCheck]: []
            });

        } else {
            this.setState({
                ...this.state,
                [name]: value,
            });
        }
    };

    onChangeInput = (e) => {
        const name = e.target.name;
        const value = e.target.value;

        let newAttributes = this.state.Datos[name].attributes;
        let Datos = Object.assign({}, this.state.Datos, {
            [name]: { value: value, attributes: newAttributes },
        });

        this.setState({ Datos });
    };

    onChangeInputNumero = (e) => {

        const name = e.target.name;
        const value = e.target.value;
        const valido = validarNumeros(value);
        if (valido) {
            let newAttributes = this.state.Datos[name].attributes;
            let Datos = Object.assign({}, this.state.Datos, {
                [name]: { value: value, attributes: newAttributes },
            });

            this.setState({ Datos });
        }
    }

    handleCheckBox = (event) => {
        const name = event.target.name;
        const value = event.target.checked;
        let newAttributes = this.state.Datos[name].attributes;

        let Datos = Object.assign({}, this.state.Datos, {
            [name]: { value: value, attributes: newAttributes },
        });

        if (name === "Digitados") {
            if (value) {
                Datos.DigitadosDel.attributes.readOnly = false;
                Datos.DigitadosAl.attributes.readOnly = false;
            } else {
                Datos.DigitadosDel.attributes.readOnly = true;
                Datos.DigitadosAl.attributes.readOnly = true;
            }
        }

        if (name === "Numeros") {
            if (value) {
                Datos.TipoAsiento.attributes.readOnly = false;
                Datos.NumerosDel.attributes.readOnly = false;
                Datos.NumerosAl.attributes.readOnly = false;
            } else {
                Datos.TipoAsiento.attributes.readOnly = true;
                Datos.NumerosDel.attributes.readOnly = true;
                Datos.NumerosAl.attributes.readOnly = true;
            }
        }

        if (name === "MovimientosCb") {
            if (value) {
                Datos.MovimientosDe.attributes.readOnly = false;
                Datos.MovimientosAl.attributes.readOnly = false;
            } else {
                Datos.MovimientosDe.attributes.readOnly = true;
                Datos.MovimientosAl.attributes.readOnly = true;
            }
        }

        if (name === "CkCentroDeCosto") {
            if (value) {
                Datos.CodigoCCosto.attributes.readOnly = false;
                Datos.CodigoCCosto.attributes.readOnlyBoton = false;
            } else {
                Datos.CodigoCCosto.attributes.readOnly = true;
                Datos.CodigoCCosto.attributes.readOnlyBoton = true;
            }
        }

        if (name === "CkCuentas") {
            if (value) {
                Datos.Cuenta.attributes.readOnly = false;
                Datos.Cuenta.attributes.readOnlyBoton = false;
                Datos.CuentaAl.attributes.readOnly = false;
                Datos.CuentaAl.attributes.readOnlyBoton = false;

                if (this.state.ReportId === Config.Reportes.BalanceComprobacion || this.state.ReportId === Config.Reportes.BalanceComprobacionEstimado) {
                    Datos.Nivel.attributes.readOnly = true
                }

            } else {
                Datos.Cuenta.attributes.readOnly = true;
                Datos.Cuenta.attributes.readOnlyBoton = true;
                Datos.CuentaAl.attributes.readOnly = true;
                Datos.CuentaAl.attributes.readOnlyBoton = true;

                if (this.state.ReportId === Config.Reportes.BalanceComprobacion || this.state.ReportId === Config.Reportes.BalanceComprobacionEstimado) {
                    Datos.Nivel.attributes.readOnly = false
                }
            }
        }
        if (name == "CkNivel") {
            Datos.Nivel.attributes.readOnly = !value;
        }

        if (name == "CkUsuarios") {
            Datos.CodigoUsuarios.attributes.readOnly = value;
            Datos.CodigoUsuarios.attributes.readOnlyBoton = value;
            Datos.CodigoUsuarios.value = "";
            Datos.NombreUsuarios.value = "";
        }

        this.setState({ Datos });
    };

    parametrosAsientos = (Empresa, NombreEmpresa, Fecha, FechaInicio, FechaFinal, ReportNombre) => {

        let Resumen = '';
        let IncluirResumen = false;

        return {
            Empresa,
            NombreEmpresa,
            Fecha,
            FechaInicio,
            FechaFinal,
            ReportNombre,
            Resumen,
            IncluirResumen
        };

    };

    generarItem = () => {

        return {
            NumeroInicio: 0,
            NumeroFinal: 0,
            Tipo: 0,
            FechaInicio: "1900-01-01",
            FechaFinal: "1900-01-01",
            OrdenadoPor: 0
        };

    };

    generarItemListaComprom = () => {

        return {
            llave: 0,
            Cuenta: "",
            Nombre: "",
            Digitado: 0,
            Aprobado: 0,
            Comprometido: 0,
            Mensual: 0,
            Acumulado: 0,
            Mens_Est: 0,
            Acum_Est: 0
        };

    };

    parametrosAsientosDiario = async (Empresa, NombreEmpresa, ReportNombre, pUsuarioNombre, pPais, pUbicacionImagen) => {

        if (this.state.Datos.fecMesAno.value === null) {
            Notificacion.warning("Debe ingresar un periodo válido.");
            return false;
        }

        const {
            Datos,
            token,
            seleccionAsiento,
            seleccionTipoAsiento,
            seleccionOrdenadoPor,
            PermiteCrecer
        } = this.state;

        let item = this.generarItem();
        let Fecha = moment(Datos.fecMesAno.value).format("YYYY/MM/DD");
        let FechaFormatoMA = (new Date(Datos.fecMesAno.value).toLocaleDateString('es-cr', { year: "numeric", month: "long" })).toString().replace("de ", "");
        let imprimirLogo = Datos.ImprimirLogo.value, ImprimeFH = true;

        const imprimeFH = Datos.ImprimeFH.value, FolioInicial = Datos.FolioInicial.value, Consolidado = Datos.Consolidado.value;

        item.OrdenadoPor = seleccionOrdenadoPor.value;

        if (Datos.Digitados.value) {
            item.FechaInicio = Datos.DigitadosDel.value;
            item.FechaFinal = Datos.DigitadosAl.value;
        };

        if (pPais === Config.PaisGuatemala) {
            ImprimeFH = imprimeFH;
        }

        if (Datos.Numeros.value) {
            item.Tipo = seleccionTipoAsiento.value

            if (Datos.NumerosDel.value !== "" && !isNaN(Datos.NumerosDel.value)) {
                item.NumeroInicio = Datos.NumerosDel.value;
            }

            if (Datos.NumerosAl.value !== "" && !isNaN(Datos.NumerosAl.value)) {
                item.NumeroFinal = Datos.NumerosAl.value;
            }
        }

        let pTipo = item.Tipo, pNumeroInicio = item.NumeroInicio, pNumeroFinal = item.NumeroFinal,
            pFechaInicio = item.FechaInicio, pFechaFinal = item.FechaFinal, pOrdenado = item.OrdenadoPor;

        let response = await EncabezadoAsientosReporte_Listar(token, Empresa, seleccionAsiento.value, Fecha, pTipo, pNumeroInicio, pNumeroFinal, pFechaInicio, pFechaFinal);

        if (response.Exitoso) {

            if (response.Datos.length > 0) {

                let EstadoNombre = seleccionAsiento.label;

                return {
                    NombreEmpresa: NombreEmpresa,
                    Empresa: Empresa,
                    ReportNombre: ReportNombre,
                    UbicacionImagen: pUbicacionImagen,
                    Tipo: pTipo,
                    Reporte: Config.Reportes.AsientosDiario,
                    Fecha: Fecha,
                    Periodo: FechaFormatoMA,
                    Estado: seleccionAsiento.value,
                    EstadoNombre: EstadoNombre,
                    NumIni: pNumeroInicio,
                    NumFin: pNumeroFinal,
                    FechaInicio: pFechaInicio,
                    FechaFinal: pFechaFinal,
                    UsuarioNombre: pUsuarioNombre,
                    ImprimirLogo: imprimirLogo,
                    OrdenadoPor: pOrdenado,
                    ImprimeFH,
                    FolioInicial,
                    Consolidado,
                    PermiteCrecer
                };

            } else {
                Notificacion.warning(response.Mensaje);
                return false;
            }

        } else {

            if (response.Mensaje === "No hay datos por mostrar") {
                Notificacion.warning(response.Mensaje);
            } else {
                Notificacion.error("Sucedió un error al validar los datos de los asientos.");
            }

            return false
        }

    };

    capitalizarPrimeraLetra(str) {
        return str.charAt(0).toUpperCase() + str.slice(1);
    }

    parametrosAsientosCierre = async (Empresa, NombreEmpresa, Fecha, ReportNombre, UsuarioNombre, imprimirLogo, pUbicacionImagen) => {

        let Resumen = '';
        let IncluirResumen = false;

        if ((this.state.Datos.Periodo.value) === null) {
            Notificacion.warning("Debe seleccionar una fecha válida.");
            return;
        }

        const FechaInicio = (new Date(Fecha).toLocaleDateString('es-cr', { year: "numeric", month: "long" })).toString().replace(" de", ",");
        const FechaMayus = this.capitalizarPrimeraLetra(FechaInicio);

        const Descripcion = `Fecha del Cierre: ${FechaMayus} `;
        const formato = moment(this.state.Datos.Periodo.value).format(Config.formatoFechaAMD);

        let respuesta = await MesesCerrados_Consulta_Request(this.state.token, Empresa, formato);

        if (respuesta.Exitoso) {
            if (respuesta.Datos.Empresa === 0 || respuesta.Datos.Periodo === "1900-01-01T00:00:00") {
                Notificacion.warning("El mes no está cerrado.");
                return false;
            }
        } else {
            Notificacion.error("Sucedió un error al consultar los datos del periodo.");
            return false;
        }

        return {
            Empresa,
            NombreEmpresa,
            UbicacionImagen: pUbicacionImagen,
            Fecha,
            ReportNombre,
            Resumen,
            UsuarioNombre,
            IncluirResumen,
            imprimirLogo,
            Descripcion
        };

    };

    parametrosAsientosFinancieros = (Empresa, NombreEmpresa, ReportNombre, UsuarioNombre, imprimirLogo, pPais, pUbicacionImagen) => {

        const Datos = this.state.Datos;
        const _FinPeriodo = this.state.FinPeriodo;

        if (Datos.MovimientosDe.value === null) {
            Notificacion.warning("Debe seleccionar una fecha de inicio válida.");
            return;
        }

        if (Datos.MovimientosAl.value === null) {
            Notificacion.warning("Debe seleccionar una fecha final válida.");
            return;
        }

        if (Datos.Nivel.value.toString().trim().length == 0) {
            Notificacion.warning("Debe ingresar un nivel válido.");
            return false;
        }
        if (Datos.Nivel.value <= 0) {
            Notificacion.warning("Debe ingresar un nivel válido.");
            return false;
        }
        if (Datos.FolioInicial.value.toString().trim().length == 0) {
            Datos.FolioInicial.value = 0;
        }
        if (Datos.CkCentroDeCosto.value) {
            if (Datos.NombreCCosto.value.toString().trim().length == 0) {
                Notificacion.warning("Debe ingresar un centro costo válido.");
                return false;
            }
        }

        if (_FinPeriodo < Datos.MovimientosDe.value) {
            Notificacion.warning('El período seleccionado del estado no debe ser mayor al fin del período de trabajo.')
            return false;
        }

        if (_FinPeriodo < Datos.MovimientosAl.value) {
            Notificacion.warning('El período a comparar seleccionado no debe ser mayor al fin del período de trabajo.')
            return false;
        }

        let _MesAC = fechaUltimoDia(Datos.MovimientosDe.value);
        let _MesCo = fechaUltimoDia(Datos.MovimientosAl.value);
        const _Meses = Config.listaMeses;
        let _MesAct = _Meses.filter(x => x.value == (_MesAC.getMonth() + 1));
        let _MesComp = _Meses.filter(x => x.value == (_MesCo.getMonth() + 1));


        const _FechaMesActEncab = `Al ${_MesAC.getDate()} de ${_MesAct[0].label} de ${_MesAC.getFullYear()}`;
        const _FechaMesCompEncab = `Al ${_MesCo.getDate()} de ${_MesComp[0].label} de ${_MesCo.getFullYear()}`;


        const FechaDe = moment(Datos.MovimientosDe.value).format(Config.formatoFechaStandard),
            FechaComparar = moment(Datos.MovimientosAl.value).format(Config.formatoFechaStandard),
            CuentasSaldoCeroSM = Datos.Consolidado.value,
            MostrarComparativo = Datos.CkOcultaDocumentos.value,
            FolioInicial = Datos.FolioInicial.value,
            ImprimeFH = (pPais === Config.PaisGuatemala) ? Datos.ImprimeFH.value : true,
            Busca_CentroCosto = Datos.CkCentroDeCosto.value,
            CentroCosto = Datos.CodigoCCosto,
            Nivel = Datos.Nivel.value,
            FechaMesActEncab = _FechaMesActEncab,
            FechaMesCompEncab = _FechaMesCompEncab;
        return {
            Empresa,
            NombreEmpresa,
            UbicacionImagen: pUbicacionImagen,
            ReportNombre,
            UsuarioNombre,
            imprimirLogo,
            FechaDe,
            FechaComparar,
            CuentasSaldoCeroSM,
            MostrarComparativo,
            FolioInicial,
            ImprimeFH,
            Busca_CentroCosto,
            CentroCosto,
            Nivel,
            FechaMesActEncab,
            FechaMesCompEncab
        };

    };

    parametrosBalanceSituacion = (Empresa, NombreEmpresa, ReportNombre, UsuarioNombre, imprimirLogo, pPais, pUbicacionImagen) => {

        const Datos = this.state.Datos;
        const _FinPeriodo = this.state.FinPeriodo;

        if (Datos.MovimientosDe.value === null) {
            Notificacion.warning("Debe seleccionar una fecha de inicio válida.");
            return;
        }

        if (Datos.MovimientosAl.value === null) {
            Notificacion.warning("Debe seleccionar una fecha final válida.");
            return;
        }

        if (Datos.Nivel.value.toString().trim().length == 0) {
            Notificacion.warning("Debe ingresar un nivel válido.");
            return false;
        }
        if (Datos.Nivel.value <= 0) {
            Notificacion.warning("Debe ingresar un nivel válido.");
            return false;
        }
        if (Datos.FolioInicial.value.toString().trim().length == 0) {
            Datos.FolioInicial.value = 0;
        }
        if (Datos.CkCentroDeCosto.value) {
            if (Datos.NombreCCosto.value.toString().trim().length == 0) {
                Notificacion.warning("Debe ingresar un centro costo válido.");
                return false;
            }
        }

        if (_FinPeriodo < Datos.MovimientosDe.value) {
            Notificacion.warning('El período seleccionado del estado no debe ser mayor al fin del período de trabajo.')
            return false;
        }

        if (_FinPeriodo < Datos.MovimientosAl.value) {
            Notificacion.warning('El período a comparar seleccionado no debe ser mayor al fin del período de trabajo.')
            return false;
        }

        let _MesAC = fechaUltimoDia(Datos.MovimientosDe.value);
        let _MesCo = fechaUltimoDia(Datos.MovimientosAl.value);
        const _Meses = Config.listaMeses;
        let _MesAct = _Meses.filter(x => x.value == (_MesAC.getMonth() + 1));
        let _MesComp = _Meses.filter(x => x.value == (_MesCo.getMonth() + 1));


        const _FechaMesActEncab = `Al ${_MesAC.getDate()} de ${_MesAct[0].label} de ${_MesAC.getFullYear()}`;
        const _FechaMesCompEncab = `Al ${_MesCo.getDate()} de ${_MesComp[0].label} de ${_MesCo.getFullYear()}`;


        const FechaDe = moment(new Date(addMonths(Datos.MovimientosDe.value, -1))).format(Config.formatoFechaStandard),
            FechaDeHasta = moment(Datos.MovimientosDe.value).format(Config.formatoFechaStandard),
            FechaComparar = moment(new Date(addMonths(Datos.MovimientosAl.value, -1))).format(Config.formatoFechaStandard),
            FechaCompararHasta = moment(Datos.MovimientosAl.value).format(Config.formatoFechaStandard),
            CuentasSaldoCeroSM = Datos.Consolidado.value,
            MostrarComparativo = Datos.CkOcultaDocumentos.value,
            FolioInicial = Datos.FolioInicial.value,
            ImprimeFH = (pPais === Config.PaisGuatemala) ? Datos.ImprimeFH.value : true,
            Busca_CentroCosto = Datos.CkCentroDeCosto.value,
            CentroCosto = Datos.CodigoCCosto,
            Nivel = Datos.Nivel.value,
            FechaMesActEncab = _FechaMesActEncab,
            FechaMesCompEncab = _FechaMesCompEncab;
        return {
            Empresa,
            NombreEmpresa,
            UbicacionImagen: pUbicacionImagen,
            ReportNombre,
            UsuarioNombre,
            imprimirLogo,
            FechaDe,
            FechaDeHasta,
            FechaComparar,
            FechaCompararHasta,
            CuentasSaldoCeroSM,
            MostrarComparativo,
            FolioInicial,
            ImprimeFH,
            Busca_CentroCosto,
            CentroCosto,
            Nivel,
            FechaMesActEncab,
            FechaMesCompEncab
        };

    };

    parametrosDiarioGeneral = (Empresa, NombreEmpresa, ReportNombre, UsuarioNombre, imprimirLogo, pPais, pUbicacionImagen) => {

        let Resumen = '';
        let IncluirResumen = false;
        const Datos = this.state.Datos;

        const FechaInicio = Datos.MovimientosDe.value, FechaFinal = Datos.MovimientosAl.value, Tipo = this.state.seleccionTipoAsiento.value,
            Cuentas = this.state.selectedCuentas, Referencia = Datos.Referencia.value, selectedCC = this.state.selectedCC,
            Documento = Datos.Documento.value, Busca_CentroCosto = Datos.CkCentroDeCosto.value, Consolidado = Datos.Consolidado.value,
            Busca_Movimientos = Datos.MovimientosCb.value, BuscaPorDigitados = Datos.Digitados.value, FechaInicial = Datos.DigitadosDel.value,
            FechaFin = Datos.DigitadosAl.value, OcultaDocumento = Datos.CkOcultaDocumentos.value, imprimeFH = Datos.ImprimeFH.value,
            Folio = Datos.FolioInicial.value, NombreCuenta = Datos.NombreCuenta.value, NombreCuentaAl = Datos.NombreCuentaAl.value;


        let esHistorico = false, CuentaInicial = Datos.Cuenta.value, CuentaFinal = Datos.CuentaAl.value, Filtrado = false, ImprimeFH = true, FolioInicial;

        if (Cuentas > 1) {

            if (NombreCuenta.toString().trim() === "") {
                Notificacion.warning("Debe ingresar una cuenta inicial válida.");
                return;
            }

            if (NombreCuentaAl.toString().trim() === "") {
                Notificacion.warning("Debe ingresar una cuenta final válida.");
                return;
            }

            if (Cuentas === 3) {
                const nivelIni = this.state.selectedNivelIni;
                const nivelFin = this.state.selectedNivelFin;
                if (nivelIni !== nivelFin) {
                    Notificacion.warning("Las cuentas deben ser del mismo nivel.");
                    return;
                }
            }

        } else {
            CuentaInicial = "";
            CuentaFinal = "999999999";
        }

        if (BuscaPorDigitados) {
            if (!this.compararFechas(FechaFin, FechaInicial)) {
                Notificacion.warning("La fecha fin no puede ser menor a la fecha de inicio.");
                return false;
            }
        }

        if (Busca_Movimientos) {

            if (FechaInicio === null) {
                Notificacion.warning("Debe seleccionar una fecha de inicio válida.");
                return;
            }

            if (FechaFinal === null) {
                Notificacion.warning("Debe seleccionar una fecha final válida.");
                return;
            }

            if (!this.compararFechas(FechaFinal, FechaInicio)) {
                Notificacion.warning("La fecha fin de los movimientos no puede ser menor a la fecha de inicio.");
                return false;
            }
        }

        if (Busca_CentroCosto) {
            if (selectedCC === 0) {
                Notificacion.warning("Debe seleccionar un centro de costo válido.");
                return false;
            }
        }

        if (Tipo != 0 || Referencia.toString().trim() != '' || Documento.toString().trim() != '') {
            Filtrado = true;
        }

        if (Folio.toString().trim == "") {
            FolioInicial = 0
        } else {
            FolioInicial = Folio;
        }

        const iniPeriodoEmpresa = this.state.datosEmpresa.InicioPeriodo;
        let Periodo;

        esHistorico = this.compararFechas(FechaInicio, iniPeriodoEmpresa) ? false : true;

        if (esHistorico) {
            let fechaPeriodo = new Date(iniPeriodoEmpresa);
            fechaPeriodo.setFullYear(fechaPeriodo.getFullYear() - 1);
            Periodo = moment(fechaPeriodo).format(Config.formatoFechaAMD);
        } else {
            Periodo = iniPeriodoEmpresa;
        }

        if (pPais === Config.PaisGuatemala) {
            ImprimeFH = imprimeFH;
        }

        let FechaFormatoInicial = `Movimientos de ${(new Date(FechaInicio).toLocaleDateString('es-cr', { year: "numeric", month: "long" })).toString()}`;
        let FechaFormatoFinal = `A ${(new Date(FechaFinal).toLocaleDateString('es-cr', { year: "numeric", month: "long" })).toString()}`;

        const Descripcion = moment(FechaInicio).format(Config.formatoFechaAMD) == moment(FechaFinal).format(Config.formatoFechaAMD) ? FechaFormatoInicial : `${FechaFormatoInicial} ${FechaFormatoFinal}`;

        ////////////////////////////

        let FechaDig = `Movimientos de asientos digitados del ${moment(FechaInicial).format(Config.formatoFechaStandard)} Al ${moment(FechaFin).format(Config.formatoFechaStandard)}`;
        const Subtitulo = FechaDig;

        return {
            Empresa,
            NombreEmpresa,
            UbicacionImagen: pUbicacionImagen,
            ReportNombre,
            Resumen,
            UsuarioNombre,
            IncluirResumen,
            imprimirLogo,
            CuentaInicial,
            CuentaFinal,
            Cuentas,
            Tipo,
            Referencia,
            Documento,
            Busca_CentroCosto,
            CentroCosto: Busca_CentroCosto ? selectedCC : 0,
            Consolidado,
            Busca_Movimientos,
            FechaInicial,
            FechaFin,
            FechaInicio,
            FechaFinal,
            BuscaPorDigitados,
            OcultaDocumento,
            esHistorico,
            Periodo,
            Estado: Config.eaAplicado,
            Filtrado,
            ImprimeFH,
            FolioInicial,
            Descripcion,
            Subtitulo
        };

    };

    parametrosBalanceComprobacion = (Empresa, NombreEmpresa, ReportNombre, UsuarioNombre, imprimirLogo, pUbicacionImagen) => {

        let Resumen = '';
        let IncluirResumen = false;

        const datos = this.state.Datos;

        const FechaInicio = datos.MovimientosDe.value, FechaEnd = datos.MovimientosAl.value, Busca_CentroCosto = datos.CkCentroDeCosto.value,
            CK_Cuentas = datos.CkCuentas.value, nivelIni = this.state.selectedNivelIni, nivelFin = this.state.selectedNivelFin,
            CuentaIni = datos.Cuenta.value, CuentaFin = datos.CuentaAl.value, NombreCuenta = datos.NombreCuenta.value,
            NombreCuentaAl = datos.NombreCuentaAl.value, selectedCC = this.state.selectedCC, PermiteCrecer = datos.CkDescCrece.value,
            TipoImpresion = this.state.selectedCuentas;

        if (FechaInicio === null) {
            Notificacion.warning("Debe seleccionar una fecha de inicio válida.");
            return;
        }

        if (FechaEnd === null) {
            Notificacion.warning("Debe seleccionar una fecha fin válida.");
            return;
        }

        let Nivel, CuentaInicial, CuentaFinal;

        if (!this.compararFechas(FechaEnd, FechaInicio)) {
            Notificacion.warning("La fecha fin no puede ser menor a la fecha de inicio.");
            return false;
        }

        if (CK_Cuentas) {

            if (NombreCuenta.toString().trim() === "") {
                Notificacion.warning("Debe ingresar una cuenta inicial válida.");
                return false;
            }

            if (NombreCuentaAl.toString().trim() === "") {
                Notificacion.warning("Debe ingresar una cuenta final válida.");
                return false;
            }

            if (nivelIni !== nivelFin) {
                Notificacion.warning("Las cuentas deben ser del mismo nivel.");
                return false;
            }

            CuentaInicial = CuentaIni;
            CuentaFinal = CuentaFin;

            Nivel = nivelIni;

        } else {
            CuentaInicial = "0";
            CuentaFinal = "999999999";
            Nivel = datos.Nivel.value;
        }

        const _FechaFin = new Date(FechaEnd.getFullYear(), FechaEnd.getMonth() + 1, 0);
        const FechaFin = moment(_FechaFin).format(Config.formatoFechaStandard)

        if (Busca_CentroCosto) {
            if (selectedCC === 0) {
                Notificacion.warning("Debe seleccionar un centro de costo válido.");
                return false;
            }
        }

        let FechaFormatoInicial = `Del ${(new Date(FechaInicio).toLocaleDateString('es-cr', { year: "numeric", month: "long", day: "numeric" })).toString()}`;
        let FechaFormatoFinal = `Al ${(new Date(_FechaFin).toLocaleDateString('es-cr', { year: "numeric", month: "long", day: "numeric" })).toString()}`;

        const Descripcion = moment(FechaInicio).format(Config.formatoFechaAMD) == moment(FechaEnd).format(Config.formatoFechaAMD) ? FechaFormatoFinal : `${FechaFormatoInicial} ${FechaFormatoFinal}`;

        return {
            Empresa,
            NombreEmpresa,
            UbicacionImagen: pUbicacionImagen,
            ReportNombre,
            Resumen,
            UsuarioNombre,
            IncluirResumen,
            imprimirLogo,
            Busca_CentroCosto,
            CentroCosto: Busca_CentroCosto ? selectedCC : 0,
            FechaInicio,
            FechaFin,
            Nivel,
            CuentaInicial,
            CuentaFinal,
            PermiteCrecer,
            TipoImpresion,
            Descripcion
        };

    };

    parametrosBalanceComprobacionEstimado = (Empresa, NombreEmpresa, ReportNombre, UsuarioNombre, imprimirLogo, pUbicacionImagen) => {

        let Resumen = '';
        let IncluirResumen = false;

        const datos = this.state.Datos;

        const FechaInicio = datos.MovimientosDe.value, Busca_CentroCosto = datos.CkCentroDeCosto.value,
            CK_Cuentas = datos.CkCuentas.value, nivelIni = this.state.selectedNivelIni, nivelFin = this.state.selectedNivelFin,
            CuentaIni = datos.Cuenta.value, CuentaFin = datos.CuentaAl.value, NombreCuenta = datos.NombreCuenta.value,
            NombreCuentaAl = datos.NombreCuentaAl.value, selectedCC = this.state.selectedCC, PermiteCrecer = datos.CkDescCrece.value,
            TipoImpresion = this.state.selectedCuentas;

        if (FechaInicio === null) {
            Notificacion.warning("Debe seleccionar una fecha de inicio válida.");
            return;
        }

        let Nivel, CuentaInicial, CuentaFinal, FechaPeriodo = this.state.FinPeriodo;

        if (moment(FechaInicio).format(Config.formatoFechaAMD) === moment(FechaPeriodo).format(Config.formatoFechaAMD)) {
            Notificacion.warning("Para poder visualizar este reporte debe seleccionar una fecha que sea superior al periodo fiscal actual.");
            return false;
        } else {
            if (!this.compararFechas(FechaInicio, FechaPeriodo)) {
                Notificacion.warning("Para poder visualizar este reporte debe seleccionar una fecha que sea superior al periodo fiscal actual.");
                return false;
            }
        }

        if (CK_Cuentas) {

            if (NombreCuenta.toString().trim() === "") {
                Notificacion.warning("Debe ingresar una cuenta inicial válida.");
                return false;
            }

            if (NombreCuentaAl.toString().trim() === "") {
                Notificacion.warning("Debe ingresar una cuenta final válida.");
                return false;
            }

            if (nivelIni !== nivelFin) {
                Notificacion.warning("Las cuentas deben ser del mismo nivel.");
                return false;
            }

            CuentaInicial = CuentaIni;
            CuentaFinal = CuentaFin;

            Nivel = nivelIni;

        } else {
            CuentaInicial = "0";
            CuentaFinal = "999999999";
            Nivel = datos.Nivel.value;
        }

        //const FechaFin = new Date(FechaEnd.getFullYear(), FechaEnd.getMonth() + 1, 0);

        if (Busca_CentroCosto) {
            if (selectedCC === 0) {
                Notificacion.warning("Debe seleccionar un centro de costo válido.");
                return false;
            }
        }

        const _FechaFin = new Date(FechaInicio.getFullYear(), FechaInicio.getMonth() + 1, 0);
        const Descripcion = `Al ${(new Date(_FechaFin).toLocaleDateString('es-cr', { year: "numeric", month: "long", day: "numeric" })).toString()}`;

        Nivel = Nivel > 0 ? Nivel : 1;

        return {
            Empresa,
            NombreEmpresa,
            UbicacionImagen: pUbicacionImagen,
            ReportNombre,
            Resumen,
            UsuarioNombre,
            IncluirResumen,
            imprimirLogo,
            Busca_CentroCosto,
            CentroCosto: Busca_CentroCosto ? selectedCC : 0,
            FechaInicio,
            Nivel,
            CuentaInicial,
            CuentaFinal,
            PermiteCrecer,
            TipoImpresion,
            Descripcion
        };

    };

    parametrosImpresionDeCuentas = (Empresa, NombreEmpresa, ReportNombre, UsuarioNombre, imprimirLogo, pUbicacionImagen) => {

        const datos = this.state.Datos;

        const
            CuentaIni = datos.Cuenta.value, CuentaFin = datos.CuentaAl.value, NombreCuenta = datos.NombreCuenta.value

        let CuentaInicial, CuentaFinal;


        CuentaInicial = CuentaIni;
        CuentaFinal = CuentaIni;//CuentaFin;
        if (NombreCuenta.toString().trim() === "") {
            Notificacion.warning("Debe ingresar una cuenta válida.");
            return false;
        }

        //console.log(`${pUbicacionImagen}`);
        return {
            Empresa,
            NombreEmpresa,
            UbicacionImagen: pUbicacionImagen,
            ReportNombre,
            UsuarioNombre,
            imprimirLogo,
            CuentaInicial,
            CuentaFinal,
        };

    };

    parametrosImpresionDeCatalogo = (Empresa, NombreEmpresa, ReportNombre, UsuarioNombre, imprimirLogo, pUbicacionImagen) => {

        const datos = this.state.Datos;
        if (datos.CkNivel.value) {
            if (datos.Nivel.value.toString().trim().length == 0) {
                Notificacion.warning("Debe ingresar un nivel válido.");
                return false;
            }
            if (datos.Nivel.value <= 0) {
                Notificacion.warning("Debe ingresar un nivel válido.");
                return false;
            }
        }

        const Nivel = (datos.CkNivel.value == false) ? 0 : datos.Nivel.value;
        let TipoCta = -1;
        let SubTipo = -1;
        switch (this.state.selectedCuentas) {
            case 1:
                TipoCta = -1;
                SubTipo = -1;
                break;
            case 2:
                TipoCta = this.state.seleccionTipoCtaGeneral.value,
                    SubTipo = -1;
                break;
            case 3:
                TipoCta = -1;
                SubTipo = this.state.seleccionTipoCtaEspecifico.value;
                break;
            default:
                break;
        }


        return {
            Empresa,
            NombreEmpresa,
            UbicacionImagen: pUbicacionImagen,
            ReportNombre,
            UsuarioNombre,
            imprimirLogo,
            Nivel,
            TipoCta,
            SubTipo
        };

    };

    parametrosImpresionDeCentroCosto = (Empresa, NombreEmpresa, ReportNombre, UsuarioNombre, imprimirLogo, pUbicacionImagen) => {

        const datos = this.state.Datos;
        if (datos.CkNivel.value) {
            if (datos.Nivel.value.toString().trim().length == 0) {
                Notificacion.warning("Debe ingresar un nivel válido.");
                return false;
            }
            if (datos.Nivel.value <= 0) {
                Notificacion.warning("Debe ingresar un nivel válido.");
                return false;
            }
        }

        const Nivel = (datos.CkNivel.value == false) ? 1000 : datos.Nivel.value;

        return {
            Empresa,
            NombreEmpresa,
            UbicacionImagen: pUbicacionImagen,
            ReportNombre,
            UsuarioNombre,
            imprimirLogo,
            Nivel
        };

    };

    parametrosHistoricoSaldos = (Empresa, NombreEmpresa, ReportNombre, UsuarioNombre, imprimirLogo, pUbicacionImagen) => {

        const datos = this.state.Datos;

        const Busca_CentroCosto = datos.CkCentroDeCosto.value, selectedCC = this.state.selectedCC, selectedFinan = this.state.selectedCuentas,
            selectedDatosRep = this.state.selectedDatosRep, SelectedTCuenta = this.state.seleccionTipoAsiento, MuestraCeros = datos.MostrarCuentasCero.value,
            InicioPeriodo = this.state.seleccionPeriodo.Inicio, FinPeriodo = this.state.seleccionPeriodo.Fin;

        if (Busca_CentroCosto) {
            if (selectedCC === 0) {
                Notificacion.warning("Debe seleccionar un centro de costo válido.");
                return false;
            }
        }

        const IniciaPeriodo = new Date(InicioPeriodo).toLocaleDateString('es-cr', { year: "numeric", month: "long" });
        const FinalPeriodo = new Date(FinPeriodo).toLocaleDateString('es-cr', { year: "numeric", month: "long" });

        const Descripcion = selectedDatosRep === 1 ? "Saldos del Mes" : "Saldos Acumulados", Subtitulo = `Periodo de ${IniciaPeriodo} A ${FinalPeriodo}`;
        const FinPeriodoEmpresa = this.state.datosEmpresa.FinPeriodo, InicioPeriodoEmpresa = this.state.datosEmpresa.InicioPeriodo;
        let Prefijo, EsHistorico, EsMayor = false;

        if (Busca_CentroCosto) {

            if (parseInt(moment(FinPeriodoEmpresa).format("YYYY")) > parseInt(moment(FinPeriodo).format("YYYY"))) {
                EsHistorico = true;
            } else {
                EsHistorico = false;

                if (!this.compararFechas(FinPeriodoEmpresa, FinPeriodo)) {
                    EsMayor = true;
                    Notificacion.warning("El periodo seleccionado es mayor al periodo actual. Se desplegará el periodo actual");
                }
            }

            Prefijo = "A."

        } else {

            if (parseInt(moment(FinPeriodoEmpresa).format("YYYY")) > parseInt(moment(FinPeriodo).format("YYYY"))) {
                EsHistorico = true;
                Prefijo = "A."
            } else {
                Prefijo = ""
                EsHistorico = false;

                if (!this.compararFechas(FinPeriodoEmpresa, FinPeriodo)) {
                    Notificacion.warning("El periodo seleccionado es mayor al periodo actual. Se desplegará el periodo actual");
                    EsMayor = true;
                }
            }

        }

        //////////////////

        const FechaCorrecta = new Date(InicioPeriodo);
        const Primera = new Date(InicioPeriodo);
        const FinCorrecto = new Date(FinPeriodo);

        let ultimaFecha = FechaCorrecta, arrayFechas = [];
        arrayFechas.push(moment(Primera).format("MM"));

        while (moment(ultimaFecha).format("YYYY/MM") !== moment(FinCorrecto).format("YYYY/MM")) {

            let MesNuevo = new Date(FechaCorrecta.setMonth(FechaCorrecta.getMonth() + 1));

            arrayFechas.push(moment(MesNuevo).format("MM"));

            ultimaFecha = MesNuevo;

        }

        const Mes_01 = arrayFechas[0], Mes_02 = arrayFechas[1], Mes_03 = arrayFechas[2], Mes_04 = arrayFechas[3], Mes_05 = arrayFechas[4], Mes_06 = arrayFechas[5],
            Mes_07 = arrayFechas[6], Mes_08 = arrayFechas[7], Mes_09 = arrayFechas[8], Mes_10 = arrayFechas[9], Mes_11 = arrayFechas[10], Mes_12 = arrayFechas[11];

        //////////////////

        return {
            Empresa,
            NombreEmpresa,
            UbicacionImagen: pUbicacionImagen,
            ReportNombre,
            UsuarioNombre,
            imprimirLogo,
            EstadoFinanciero: selectedFinan,
            DatoReporte: selectedDatosRep,
            SubTipo: selectedFinan === 1 ? -1 : SelectedTCuenta.value,
            FechaInicio: EsMayor ? InicioPeriodoEmpresa : InicioPeriodo,
            FechaFin: FinPeriodo,
            Busca_CentroCosto,
            CentroCosto: Busca_CentroCosto ? selectedCC : 0,
            CuentasSaldoCeroSM: MuestraCeros,
            Descripcion,
            Subtitulo,
            Prefijo,
            EsHistorico,
            Mes_01,
            Mes_02,
            Mes_03,
            Mes_04,
            Mes_05,
            Mes_06,
            Mes_07,
            Mes_08,
            Mes_09,
            Mes_10,
            Mes_11,
            Mes_12,
        };

    };

    parametrosMovimientosSinAplicar = (Empresa, NombreEmpresa, ReportNombre, UsuarioNombre, imprimirLogo, pUbicacionImagen) => {

        let Resumen = '';
        let IncluirResumen = false;

        const datos = this.state.Datos, FechaInicio = datos.MovimientosDe.value;

        if (FechaInicio === null) {
            Notificacion.warning("Debe seleccionar un periodo válido.");
            return;
        }

        const _listaGralPAR = this.state.listaGralPAR;
        let Cuentas = '';

        if (this.state.Datos.MovimientosDe.value === null) {
            Notificacion.warning("Debe ingresar un periodo válido.");
            return false;
        }
        if (_listaGralPAR.length == 0) {
            Notificacion.warning("Debe ingresar al menos una cuenta válida.");
            return false;
        }

        _listaGralPAR.map((x) => {
            Cuentas = (Cuentas.toString().trim().length == 0) ? x.llave.toString() : Cuentas + ',' + x.llave.toString();
        })

        const EsDetallado = (this.state.selectedFormatoMovimiento == 'R') ? false : true;

        const Descripcion = `Período: ${(new Date(FechaInicio).toLocaleDateString('es-cr', { year: "numeric", month: "long" })).toString()}`;

        return {
            Empresa,
            NombreEmpresa,
            UbicacionImagen: pUbicacionImagen,
            ReportNombre,
            Resumen,
            UsuarioNombre,
            IncluirResumen,
            imprimirLogo,
            EsDetallado,
            Cuentas,
            Descripcion,
            FechaInicio
        };

    };

    parametrosConsolidacioDeCuentas = (Empresa, NombreEmpresa, ReportNombre, UsuarioNombre, imprimirLogo, pUbicacionImagen) => {

        let Resumen = '';
        let IncluirResumen = false;

        const datos = this.state.Datos, EstadoNombre = this.state.seleccionAsiento.label;
        const FechaInicio = datos.fecMesAno.value;

        if ((FechaInicio) === null) {
            Notificacion.warning("Debe seleccionar un periodo válido.");
            return false;
        }

        if (this.state.listaCheck.length === 0) {
            Notificacion.warning("Debe seleccionar al menos un asiento.");
            return;
        }

        let Asientos = '';
        Asientos = (this.state.listaCheck).toString().replace("[", "").replace("]", "");

        const Descripcion = `De: ${(new Date(FechaInicio).toLocaleDateString('es-cr', { year: "numeric", month: "long" })).toString()} en estado ${EstadoNombre}`;

        return {
            Empresa,
            NombreEmpresa,
            UbicacionImagen: pUbicacionImagen,
            ReportNombre,
            Resumen,
            UsuarioNombre,
            IncluirResumen,
            imprimirLogo,
            Asientos,
            Descripcion,
        };

    };

    parametrosComprometido = (Empresa, NombreEmpresa, ReportNombre, UsuarioNombre, imprimirLogo, pUbicacionImagen) => {

        let Resumen = '';
        let IncluirResumen = false;

        const datos = this.state.Datos, Cuentas = this.state.listaGralPAR, FechaInicio = datos.fecMesAno.value;
        let ArrayCuentas = [];

        if (FechaInicio === null) {
            Notificacion.warning("Debe seleccionar un periodo válido.");
            return;
        }

        if (Cuentas.length === 0) {
            Notificacion.warning("Debe seleccionar al menos una cuenta.");
            return;
        }

        for (let i in Cuentas) {
            ArrayCuentas.push(Cuentas[i].llave);
        }

        let ArrayModif = (ArrayCuentas).toString().replace("[", "").replace("]", "");

        const Descripcion = `Periodo: ${(new Date(FechaInicio).toLocaleDateString('es-cr', { year: "numeric", month: "long" })).toString()}`;

        const Mes = new Date(FechaInicio).toLocaleDateString('es-cr', { month: "numeric" });

        return {
            Empresa,
            NombreEmpresa,
            UbicacionImagen: pUbicacionImagen,
            ReportNombre,
            Resumen,
            UsuarioNombre,
            IncluirResumen,
            imprimirLogo,
            Descripcion,
            Cuentas: ArrayModif,
            FechaInicio,
            Mes
        };

    };

    parametrosCentrosCostos = (Empresa, NombreEmpresa, ReportNombre, UsuarioNombre, imprimirLogo, pUbicacionImagen) => {

        const seleccionReportes = this.state.seleccionReportes;
        let Resumen = '';
        let IncluirResumen = false;
        const Datos = this.state.Datos;

        if (Datos.MovimientosDe.value === null) {
            Notificacion.warning("Debe seleccionar una fecha de inicio válida.");
            return;
        }

        if (Datos.MovimientosAl.value === null) {
            Notificacion.warning("Debe seleccionar una fecha final válida.");
            return;
        }

        //validaciones
        if (seleccionReportes.value == "G") {
            if (Datos.MovimientosAl.value > Datos.MovimientosDe.value) {
                Notificacion.warning('La fecha del saldo acumulado debe ser menor a la fecha del saldo actual.')
                return false;
            }
        }
        let _itemCuentaPAR
        if (this.state.FilaSeleccionada) {
            _itemCuentaPAR = this.state.FilaSeleccionada;
        } else {
            Notificacion.warning(`Debe seleccionar un centro de costos.`);
            return false;

        }

        let _Descripcion = '';

        //G,D
        let _MesAC = fechaUltimoDia(Datos.MovimientosDe.value);
        let _MesCo = fechaUltimoDia(Datos.MovimientosAl.value);
        const _Meses = Config.listaMeses;
        let _MesAct = _Meses.filter(x => x.value == (_MesAC.getMonth() + 1));
        let _MesComp = _Meses.filter(x => x.value == (_MesCo.getMonth() + 1));

        const FechaDe = (seleccionReportes.value == "G") ? moment(new Date(addMonths(Datos.MovimientosDe.value, -1))).format(Config.formatoFechaStandard) : moment(Datos.MovimientosDe.value).format(Config.formatoFechaStandard),
            FechaDeHasta = moment(Datos.MovimientosDe.value).format(Config.formatoFechaStandard),
            FechaComparar = (seleccionReportes.value == "G") ? moment(new Date(addMonths(Datos.MovimientosAl.value, -1))).format(Config.formatoFechaStandard) : moment(Datos.MovimientosAl.value).format(Config.formatoFechaStandard),
            FechaCompararHasta = moment(Datos.MovimientosAl.value).format(Config.formatoFechaStandard);
        const _FechaMesActEncab = (seleccionReportes.value == "G") ? `De ${_MesAct[0].label}, ${_MesAC.getFullYear()}` : `Al ${_MesAC.getDate()} de ${_MesAct[0].label} de ${_MesAC.getFullYear()}`;
        const _FechaMesCompEncab = (seleccionReportes.value == "G") ? `Compración, ${_MesComp[0].label}, ${_MesCo.getFullYear()}` : `Al ${_MesCo.getDate()} de ${_MesComp[0].label} de ${_MesCo.getFullYear()}`;
        const FechaInicio = Datos.MovimientosDe.value, FechaFinal = Datos.MovimientosAl.value;
        let FechaFormatoInicial = `Movimientos de ${(new Date(FechaInicio).toLocaleDateString('es-cr', { year: "numeric", month: "long" })).toString()}`;
        let FechaFormatoFinal = `a ${(new Date(FechaFinal).toLocaleDateString('es-cr', { year: "numeric", month: "long" })).toString()}`;
        const InicioPeriodo = this.state.seleccionPeriodo.Inicio, FinPeriodo = this.state.seleccionPeriodo.Fin;

        //Historico
        const Busca_CentroCosto = false, MuestraCeros = Datos.MostrarCuentasCero.value, selectedCC = 0, selectedDatosRep = 0, selectedFinan = 3;
        const IniciaPeriodo = new Date(InicioPeriodo).toLocaleDateString('es-cr', { year: "numeric", month: "long" });
        const FinalPeriodo = new Date(FinPeriodo).toLocaleDateString('es-cr', { year: "numeric", month: "long" });


        const Descripcion = selectedDatosRep === 0 ? "Saldos del Mes" : "Saldos Acumulados", Subtitulo = `Periodo de ${IniciaPeriodo} A ${FinalPeriodo}`;
        const Descripcion2 = moment(FechaInicio).format(Config.formatoFechaAMD) == moment(FechaFinal).format(Config.formatoFechaAMD) ? FechaFormatoInicial : `${FechaFormatoInicial} ${FechaFormatoFinal}`;
        const FinPeriodoEmpresa = this.state.datosEmpresa.FinPeriodo, InicioPeriodoEmpresa = this.state.datosEmpresa.InicioPeriodo;
        let Prefijo, EsHistorico, EsMayor = false;

        if (Busca_CentroCosto) {

            if (parseInt(moment(FinPeriodoEmpresa).format("YYYY")) > parseInt(moment(FinPeriodo).format("YYYY"))) {
                EsHistorico = true;
            } else {
                EsHistorico = false;

                if (!this.compararFechas(FinPeriodoEmpresa, FinPeriodo)) {
                    EsMayor = true;
                    Notificacion.warning("El periodo seleccionado es mayor al periodo actual. Se desplegará el periodo actual");
                }
            }

            Prefijo = "A."

        } else {

            if (parseInt(moment(FinPeriodoEmpresa).format("YYYY")) > parseInt(moment(FinPeriodo).format("YYYY"))) {
                EsHistorico = true;
                Prefijo = "A."
            } else {
                Prefijo = ""
                EsHistorico = false;

                if (!this.compararFechas(FinPeriodoEmpresa, FinPeriodo)) {
                    Notificacion.warning("El periodo seleccionado es mayor al periodo actual. Se desplegará el periodo actual");
                    EsMayor = true;
                }
            }

        }

        const FechaCorrecta = new Date(InicioPeriodo);
        const Primera = new Date(InicioPeriodo);
        const FinCorrecto = new Date(FinPeriodo);

        let ultimaFecha = FechaCorrecta, arrayFechas = [];
        arrayFechas.push(moment(Primera).format("MM"));

        while (moment(ultimaFecha).format("YYYY/MM") !== moment(FinCorrecto).format("YYYY/MM")) {

            let MesNuevo = new Date(FechaCorrecta.setMonth(FechaCorrecta.getMonth() + 1));

            arrayFechas.push(moment(MesNuevo).format("MM"));

            ultimaFecha = MesNuevo;

        }

        const Mes_01 = arrayFechas[0], Mes_02 = arrayFechas[1], Mes_03 = arrayFechas[2], Mes_04 = arrayFechas[3], Mes_05 = arrayFechas[4], Mes_06 = arrayFechas[5],
            Mes_07 = arrayFechas[6], Mes_08 = arrayFechas[7], Mes_09 = arrayFechas[8], Mes_10 = arrayFechas[9], Mes_11 = arrayFechas[10], Mes_12 = arrayFechas[11];


        const Referencia = seleccionReportes.value;
        _Descripcion = (Referencia == "H") ? Descripcion : (Referencia == 'G') ? _itemCuentaPAR.Nombre : Descripcion2;
        const _NombreEmpresa = (Referencia == "H") ? 'Histórico de Saldos' : ReportNombre;
        const Estado = Config.eaAplicado;

        return {
            Empresa,
            NombreEmpresa,
            UbicacionImagen: pUbicacionImagen,
            ReportNombre: _NombreEmpresa,
            Resumen,
            UsuarioNombre,
            IncluirResumen,
            imprimirLogo,
            FechaDe, //Gastos/Diario
            FechaDeHasta,
            FechaComparar,
            FechaCompararHasta,
            FechaMesActEncab: _FechaMesActEncab,
            FechaMesCompEncab: _FechaMesCompEncab,//
            EstadoFinanciero: selectedFinan, //Historico
            DatoReporte: selectedDatosRep,
            SubTipo: _itemCuentaPAR.ID,
            FechaInicio: EsMayor ? InicioPeriodoEmpresa : InicioPeriodo,
            FechaFin: FinPeriodo,
            Busca_CentroCosto,
            CentroCosto: _itemCuentaPAR.ID,
            CuentasSaldoCeroSM: MuestraCeros,
            Descripcion: _Descripcion,
            Subtitulo,
            Prefijo,
            EsHistorico,
            Mes_01,
            Mes_02,
            Mes_03,
            Mes_04,
            Mes_05,
            Mes_06,
            Mes_07,
            Mes_08,
            Mes_09,
            Mes_10,
            Mes_11,
            Mes_12,
            Referencia,
            Estado,
        };


    }

    parametrosCentrosUtilidad = (Empresa, NombreEmpresa, ReportNombre, UsuarioNombre, imprimirLogo, pUbicacionImagen) => {

        const seleccionReportes = this.state.seleccionReportes, Datos = this.state.Datos, MuestraCeros = Datos.MostrarCuentasCero.value,
            InicioPeriodo = this.state.seleccionPeriodo.Inicio, FinPeriodo = this.state.seleccionPeriodo.Fin,
            Primera = new Date(InicioPeriodo), Referencia = seleccionReportes.value, FinCorrecto = new Date(FinPeriodo),
            FechaInicio = Datos.MovimientosDe.value, FechaFinal = Datos.MovimientosAl.value,
            InicioPeriodoEmpresa = this.state.datosEmpresa.InicioPeriodo, FechaCorrecta = new Date(InicioPeriodo);

        let Resumen = '', IncluirResumen = false, arrayFechas = [], EsHistorico = false, EsMayor = false,
            ultimaFecha = FechaCorrecta, Descripcion, Subtitulo, FechaDe = addMonths(Datos.MovimientosDe.value, -1), FechaDeHasta = Datos.MovimientosDe.value,
            FechaComparar = addMonths(Datos.MovimientosAl.value, -1), FechaCompararHasta = Datos.MovimientosAl.value;

        arrayFechas.push(moment(Primera).format("MM"));

        while (moment(ultimaFecha).format("YYYY/MM") !== moment(FinCorrecto).format("YYYY/MM")) {

            let MesNuevo = new Date(FechaCorrecta.setMonth(FechaCorrecta.getMonth() + 1));

            arrayFechas.push(moment(MesNuevo).format("MM"));

            ultimaFecha = MesNuevo;

        }

        //validaciones
        if (seleccionReportes.value === "U") {

            if ((Datos.MovimientosDe.value) === null) {
                Notificacion.warning("Debe seleccionar una fecha de inicio válida.");
                return false;
            }

            if ((Datos.MovimientosAl.value) === null) {
                Notificacion.warning("Debe seleccionar una fecha válida para comparar los saldos.");
                return false;
            }

            if (Datos.MovimientosAl.value >= Datos.MovimientosDe.value) {
                Notificacion.warning('La fecha del saldo acumulado debe ser menor a la fecha del saldo actual.')
                return false;
            }

            Descripcion = `${new Date(FechaDeHasta).toLocaleDateString('es-cr', { year: "numeric", month: "long" })}`;
            Subtitulo = `${new Date(FechaCompararHasta).toLocaleDateString('es-cr', { year: "numeric", month: "long" })}`;
        }

        if (seleccionReportes.value === "D") {

            if ((Datos.MovimientosDe.value) === null) {
                Notificacion.warning("Debe seleccionar una fecha de inicio válida.");
                return false;
            }

            if ((Datos.MovimientosAl.value) === null) {
                Notificacion.warning("Debe seleccionar una fecha final válida.");
                return false;
            }

            let FechaFormatoInicial = `Movimientos de ${(new Date(FechaInicio).toLocaleDateString('es-cr', { year: "numeric", month: "long" })).toString()}`;
            let FechaFormatoFinal = `A ${(new Date(FechaFinal).toLocaleDateString('es-cr', { year: "numeric", month: "long" })).toString()}`;

            Descripcion = moment(FechaInicio).format(Config.formatoFechaAMD) == moment(FechaFinal).format(Config.formatoFechaAMD) ? FechaFormatoInicial : `${FechaFormatoInicial} ${FechaFormatoFinal}`;

        }


        if (seleccionReportes.value === 'H') {
            const IniciaPeriodo = new Date(InicioPeriodo).toLocaleDateString('es-cr', { year: "numeric", month: "long" });
            const FinalPeriodo = new Date(FinPeriodo).toLocaleDateString('es-cr', { year: "numeric", month: "long" });

            Descripcion = `Periodo de ${IniciaPeriodo} A ${FinalPeriodo}`;
        }

        let _itemCuentaPAR;
        if (this.state.FilaSeleccionada) {
            _itemCuentaPAR = this.state.FilaSeleccionada;
        } else {
            Notificacion.warning(`Debe seleccionar un centro de utilidad.`);
            return;
        }

        const Mes_01 = arrayFechas[0], Mes_02 = arrayFechas[1], Mes_03 = arrayFechas[2], Mes_04 = arrayFechas[3], Mes_05 = arrayFechas[4], Mes_06 = arrayFechas[5],
            Mes_07 = arrayFechas[6], Mes_08 = arrayFechas[7], Mes_09 = arrayFechas[8], Mes_10 = arrayFechas[9], Mes_11 = arrayFechas[10], Mes_12 = arrayFechas[11];

        const FinPeriodoEmpresa = this.state.datosEmpresa.FinPeriodo

        if (parseInt(moment(FinPeriodoEmpresa).format("YYYY")) > parseInt(moment(FinPeriodo).format("YYYY"))) {
            EsHistorico = true;
        } else {
            EsHistorico = false;

            if (!this.compararFechas(FinPeriodoEmpresa, FinPeriodo)) {
                EsMayor = true;
                Notificacion.warning("El periodo seleccionado es mayor al periodo actual. Se desplegará el periodo actual");
            }
        }

        return {
            Empresa,
            NombreEmpresa,
            UbicacionImagen: pUbicacionImagen,
            ReportNombre,
            Resumen,
            UsuarioNombre,
            IncluirResumen,
            imprimirLogo,
            Descripcion,
            Subtitulo,
            EsHistorico,
            CentroUtilidad: _itemCuentaPAR.ID,
            FechaDe,
            FechaDeHasta,
            FechaComparar,
            FechaCompararHasta,
            CuentasSaldoCeroSM: MuestraCeros,
            Referencia,
            FechaInicio: EsMayor ? InicioPeriodoEmpresa : InicioPeriodo,
            FechaFin: FinPeriodo,
            FechaInicial: FechaInicio,
            FechaFinal,
            Mes_01,
            Mes_02,
            Mes_03,
            Mes_04,
            Mes_05,
            Mes_06,
            Mes_07,
            Mes_08,
            Mes_09,
            Mes_10,
            Mes_11,
            Mes_12,
            Estado: Config.eaAplicado
        };


    }

    parametrosBitacoraGeneral = (Empresa, NombreEmpresa, ReportNombre, UsuarioNombre, imprimirLogo, pUbicacionImagen) => {

        const datos = this.state.Datos;
        if (!datos.CkUsuarios.value) {
            if (datos.NombreUsuarios.value.toString().trim().length == 0) {
                Notificacion.warning("Debe ingresar un usuario válido.");
                return false;
            }
        }


        const _FechaInicio = datos.DigitadosDel.value;
        const _FechaFinal = datos.DigitadosAl.value;
        const _Usuario = (datos.CkUsuarios.value) ? "NA" : datos.CodigoUsuarios.value;
        const _Todos = datos.CkUsuarios.value;
        const _PorFecha = datos.Digitados.value;

        const _Descripcion = (_PorFecha) ? ((_Todos) ? `Modificación de asientos del ${moment(_FechaInicio).format(Config.formatoFechaStandard)} al ${moment(_FechaFinal).format(Config.formatoFechaStandard)}` : `Usuarios que modificaron asientos desde: ${moment(_FechaInicio).format(Config.formatoFechaStandard)} hasta: ${moment(_FechaFinal).format(Config.formatoFechaStandard)} `)
            : (_Todos) ? `Modificaciones de los asientos sin rango de fechas` : `Lista de modificaciones sin rango de horas`;

        return {
            Empresa,
            NombreEmpresa,
            UbicacionImagen: pUbicacionImagen,
            ReportNombre,
            UsuarioNombre,
            imprimirLogo,
            FechaInicio: _FechaInicio,
            FechaFin: _FechaFinal,
            Todos: _Todos,
            PorFecha: _PorFecha,
            Usuario: _Usuario,
            Descripcion: _Descripcion

        };


    }

    parametrosEstadoResultadosPresup = (Empresa, NombreEmpresa, ReportNombre, UsuarioNombre, imprimirLogo, pUbicacionImagen) => {

        const datos = this.state.Datos;

        const FechaInicio = datos.MovimientosDe.value, Busca_CentroCosto = datos.CkCentroDeCosto.value, selectedCC = this.state.selectedCC,
            MuestraCeros = datos.MostrarCuentasCero.value, Nivel = datos.Nivel.value, InicioPeriodoEmpresa = this.state.datosEmpresa.InicioPeriodo;

        if (FechaInicio === null) {
            Notificacion.warning("Debe seleccionar una fecha válida.");
            return;
        }

        if (Busca_CentroCosto) {
            if (selectedCC === 0) {
                Notificacion.warning("Debe seleccionar un centro de costo válido.");
                return false;
            }
        }

        if (Nivel.toString().trim() !== "") {

            if (Nivel < 1) {
                Notificacion.warning("El nivel no puede ser menor a 1.");
                return false;
            }

        } else {
            Notificacion.warning("Debe indicar un nivel válido.");
            return false;
        }

        let Descripcion = (new Date(FechaInicio).toLocaleDateString('es-cr', { year: "numeric", month: "long" })), EsHistorico = false;
        const Mes = new Date(FechaInicio).toLocaleDateString('es-cr', { month: "numeric" }), compara = this.compararFechas(moment(InicioPeriodoEmpresa).format(Config.formatoFechaStandard), moment(FechaInicio).format(Config.formatoFechaStandard));

        let Subtitulo = Descripcion.replace(" de", ",");

        if (compara) {
            if (moment(InicioPeriodoEmpresa).format(Config.formatoFechaStandard) !== moment(FechaInicio).format(Config.formatoFechaStandard)) {
                EsHistorico = true;
            }
        }

        return {
            Empresa,
            NombreEmpresa,
            UbicacionImagen: pUbicacionImagen,
            ReportNombre: "Balance de Situación - Real vrs Presupuesto",
            UsuarioNombre,
            imprimirLogo,
            Busca_CentroCosto,
            CentroCosto: Busca_CentroCosto ? selectedCC : 1,
            CuentasSaldoCeroSM: MuestraCeros,
            Descripcion: `A ${Descripcion}`,
            FechaDe: FechaInicio,
            FechaDeHasta: FechaInicio,
            FechaComparar: new Date("1900/01/01"),
            FechaCompararHasta: new Date("1900/01/01"),
            Nivel,
            Mes,
            EsHistorico,
            Subtitulo
        };

    }

    parametrosCierreFiscal = (Empresa, NombreEmpresa, ReportNombre, UsuarioNombre, imprimirLogo, pUbicacionImagen) => {

        const datos = this.state.Datos;

        const InicioPeriodo = this.state.seleccionPeriodo.Inicio,
            FinPeriodo = this.state.seleccionPeriodo.Fin,
            Busca_CentroCosto = datos.CkCentroDeCosto.value, selectedCC = this.state.selectedCC,
            InicioPeriodoEmpresa = this.state.datosEmpresa.InicioPeriodo;

        if (Busca_CentroCosto) {
            if (selectedCC === 0) {
                Notificacion.warning("Debe seleccionar un centro de costo válido.");
                return false;
            }
        }

        const IniciaPeriodo = new Date(InicioPeriodo).toLocaleDateString('es-cr', { year: "numeric", month: "long" });
        const FinalPeriodo = new Date(FinPeriodo).toLocaleDateString('es-cr', { year: "numeric", month: "long" });

        let EsHistorico;

        const Descripcion = `Periodo de ${IniciaPeriodo} A ${FinalPeriodo}`;
        EsHistorico = false;

        const compara = this.compararFechas(moment(InicioPeriodoEmpresa).format(Config.formatoFechaStandard), moment(IniciaPeriodo).format(Config.formatoFechaStandard));

        if (compara) {
            if (moment(InicioPeriodoEmpresa).format(Config.formatoFechaStandard) !== moment(IniciaPeriodo).format(Config.formatoFechaStandard)) {
                EsHistorico = true;
            }
        }

        return {
            Empresa,
            NombreEmpresa,
            UbicacionImagen: pUbicacionImagen,
            ReportNombre,
            UsuarioNombre,
            imprimirLogo,
            Busca_CentroCosto,
            CentroCosto: Busca_CentroCosto ? selectedCC : 0,
            Descripcion,
            EsHistorico,
            Fecha: new Date(InicioPeriodo)
        };

    }

    parametrosBalanceSituacioPresupuesto = (Empresa, NombreEmpresa, ReportNombre, UsuarioNombre, imprimirLogo, pUbicacionImagen) => {

        const Datos = this.state.Datos;
        const _FinPeriodo = this.state.FinPeriodo;

        if (Datos.Nivel.value.toString().trim().length == 0) {
            Notificacion.warning("Debe ingresar un nivel válido.");
            return false;
        }
        if (Datos.Nivel.value <= 0) {
            Notificacion.warning("Debe ingresar un nivel válido.");
            return false;
        }

        if (Datos.CkCentroDeCosto.value) {
            if (Datos.NombreCCosto.value.toString().trim().length == 0) {
                Notificacion.warning("Debe ingresar un centro costo válido.");
                return false;
            }
        }

        if (_FinPeriodo < Datos.MovimientosDe.value) {
            Notificacion.warning('El período seleccionado del estado no debe ser mayor al fin del período de trabajo.')
            return false;
        }


        const FechaInicio = Datos.MovimientosDe.value, Busca_CentroCosto = Datos.CkCentroDeCosto.value,
            MuestraCeros = Datos.MostrarCuentasCero.value, Nivel = Datos.Nivel.value, InicioPeriodoEmpresa = this.state.datosEmpresa.InicioPeriodo,
            CentroCosto = this.state.selectedCC;// Datos.CodigoCCosto;

        let _MesAC = fechaUltimoDia(Datos.MovimientosDe.value);
        //let _MesCo = fechaUltimoDia(Datos.MovimientosAl.value);
        const _Meses = Config.listaMeses;
        let _MesAct = _Meses.filter(x => x.value == (_MesAC.getMonth() + 1));
        //let _MesComp = _Meses.filter(x => x.value == (_MesCo.getMonth() + 1));


        //const _FechaMesCompEncab = `Al ${_MesCo.getDate()} de ${_MesComp[0].label} de ${_MesCo.getFullYear()}`;

        const _FechaMesActEncab = `Al ${_MesAC.getDate()} de ${_MesAct[0].label} de ${_MesAC.getFullYear()}`,
            _FechaMesCompEncab = _FechaMesActEncab,
            FechaDe = moment(new Date(addMonths(Datos.MovimientosDe.value, -1))).format(Config.formatoFechaStandard),
            FechaDeHasta = moment(Datos.MovimientosDe.value).format(Config.formatoFechaStandard),
            FechaComparar = moment(new Date("1900/01/01")).format(Config.formatoFechaStandard),
            FechaCompararHasta = moment(new Date("1900/01/01")).format(Config.formatoFechaStandard);

        let Descripcion = `Al ${_MesAC.getDate()} de ${_MesAct[0].label} de ${_MesAC.getFullYear()}`, EsHistorico = false;
        //const Mes = new Date(FechaInicio).toLocaleDateString('es-cr', { month: "numeric" }), compara = this.compararFechas(moment(InicioPeriodoEmpresa).format(Config.formatoFechaStandard), moment(FechaInicio).format(Config.formatoFechaStandard));

        let Subtitulo = Descripcion.replace(" de", ",");

        // if (compara) {
        if (moment(InicioPeriodoEmpresa).format(Config.formatoFechaStandard) !== moment(FechaInicio).format(Config.formatoFechaStandard)) {
            EsHistorico = true;
        }
        //}

        return {
            Empresa,
            NombreEmpresa,
            UbicacionImagen: pUbicacionImagen,
            ReportNombre: "Balance de Situación - Real vrs Presupuesto",
            UsuarioNombre,
            imprimirLogo,
            Busca_CentroCosto,
            CentroCosto,
            CuentasSaldoCeroSM: MuestraCeros,
            Descripcion: Descripcion,
            FechaDe,
            FechaDeHasta,
            FechaComparar,
            FechaCompararHasta,
            Nivel,
            //Mes,
            EsHistorico,
            Subtitulo,
            FechaMesActEncab: _FechaMesActEncab,
            FechaMesCompEncab: _FechaMesCompEncab,
            MostrarComparativo: true,
        };

    }

    parametrosCentrosCostosPresupuesto = (Empresa, NombreEmpresa, ReportNombre, UsuarioNombre, imprimirLogo, pUbicacionImagen) => {

        let Resumen = '', IncluirResumen = false, EsHistorico = false, _itemCuentaPAR, _Descripcion = '';;
        const Datos = this.state.Datos, FechaInicio = Datos.MovimientosDe.value, InicioPeriodoEmpresa = this.state.datosEmpresa.InicioPeriodo;

        if (FechaInicio === null) {
            Notificacion.warning("Debe seleccionar una fecha válida.");
            return;
        }

        if (this.state.FilaSeleccionada) {
            _itemCuentaPAR = this.state.FilaSeleccionada;
        } else {
            Notificacion.warning(`Debe seleccionar un centro de costos.`);
            return false;
        }

        const FechaDe = moment(new Date(addMonths(FechaInicio, -1))).format(Config.formatoFechaStandard),
            FechaDeHasta = moment(FechaInicio).format(Config.formatoFechaStandard),
            FechaComparar = new Date("1900/01/01"),
            FechaCompararHasta = new Date("1900/01/01");

        const MuestraCeros = Datos.MostrarCuentasCero.value;

        _Descripcion = _itemCuentaPAR.Nombre;
        let Fecha = new Date(FechaInicio).toLocaleDateString('es-cr', { year: "numeric", month: "long" });
        let Subtitulo = this.capitalizarPrimeraLetra(Fecha.replace(" de", ","));
        const Mes = new Date(FechaInicio).toLocaleDateString('es-cr', { month: "numeric" })

        const compara = this.compararFechas(moment(InicioPeriodoEmpresa).format(Config.formatoFechaStandard), moment(FechaInicio).format(Config.formatoFechaStandard));

        if (compara) {
            if (moment(InicioPeriodoEmpresa).format(Config.formatoFechaStandard) !== moment(FechaInicio).format(Config.formatoFechaStandard)) {
                EsHistorico = true;
            }
        }

        return {
            Empresa,
            NombreEmpresa,
            UbicacionImagen: pUbicacionImagen,
            ReportNombre: ReportNombre,
            Resumen,
            UsuarioNombre,
            IncluirResumen,
            imprimirLogo,
            FechaDe,
            FechaDeHasta,
            FechaComparar,
            FechaCompararHasta,
            CentroCosto: _itemCuentaPAR.ID,
            CuentasSaldoCeroSM: MuestraCeros,
            Descripcion: _Descripcion,
            Subtitulo,
            Mes,
            EsHistorico
        };

    }

    parametrosCentrosUtilidadPresupuesto = (Empresa, NombreEmpresa, ReportNombre, UsuarioNombre, imprimirLogo, pUbicacionImagen) => {
        //No se termina ya que en delphi no es funcional el reporte, el reporte gener varios errores, como si el repote se hubiera dejado a medio contruir
        const seleccionReportes = this.state.seleccionReportes, Datos = this.state.Datos, MuestraCeros = Datos.MostrarCuentasCero.value,
            InicioPeriodo = this.state.seleccionPeriodo.Inicio, FinPeriodo = this.state.seleccionPeriodo.Fin,
            Primera = new Date(InicioPeriodo), Referencia = seleccionReportes.value, FinCorrecto = new Date(FinPeriodo),
            FechaInicio = Datos.MovimientosDe.value, FechaFinal = Datos.MovimientosAl.value,
            InicioPeriodoEmpresa = this.state.datosEmpresa.InicioPeriodo, FechaCorrecta = new Date(InicioPeriodo);

        let Resumen = '', IncluirResumen = false, arrayFechas = [], EsHistorico = false, EsMayor = false,
            ultimaFecha = FechaCorrecta, Descripcion, Subtitulo, FechaDe = addMonths(Datos.MovimientosDe.value, -1), FechaDeHasta = Datos.MovimientosDe.value,
            FechaComparar = addMonths(Datos.MovimientosAl.value, -1), FechaCompararHasta = Datos.MovimientosAl.value;

        arrayFechas.push(moment(Primera).format("MM"));

        while (moment(ultimaFecha).format("YYYY/MM") !== moment(FinCorrecto).format("YYYY/MM")) {

            let MesNuevo = new Date(FechaCorrecta.setMonth(FechaCorrecta.getMonth() + 1));

            arrayFechas.push(moment(MesNuevo).format("MM"));

            ultimaFecha = MesNuevo;

        }

        //validaciones
        if (seleccionReportes.value === "U") {
            if (Datos.MovimientosAl.value >= Datos.MovimientosDe.value) {
                Notificacion.warning('La fecha del saldo acumulado debe ser menor a la fecha del saldo actual.')
                return false;
            }

            Descripcion = `${new Date(FechaDeHasta).toLocaleDateString('es-cr', { year: "numeric", month: "long" })}`;
            Subtitulo = `${new Date(FechaCompararHasta).toLocaleDateString('es-cr', { year: "numeric", month: "long" })}`;
        }

        if (seleccionReportes.value === "D") {
            /*if (Datos.MovimientosDe.value <= Datos.MovimientosAl.value) {
                Notificacion.warning('La fecha fin debe ser mayor a la fecha de inicio.')
                return false;
            }*/

            let FechaFormatoInicial = `Movimientos de ${(new Date(FechaInicio).toLocaleDateString('es-cr', { year: "numeric", month: "long" })).toString()}`;
            let FechaFormatoFinal = `A ${(new Date(FechaFinal).toLocaleDateString('es-cr', { year: "numeric", month: "long" })).toString()}`;

            Descripcion = moment(FechaInicio).format(Config.formatoFechaAMD) == moment(FechaFinal).format(Config.formatoFechaAMD) ? FechaFormatoInicial : `${FechaFormatoInicial} ${FechaFormatoFinal}`;

        }


        if (seleccionReportes.value === 'H') {
            const IniciaPeriodo = new Date(InicioPeriodo).toLocaleDateString('es-cr', { year: "numeric", month: "long" });
            const FinalPeriodo = new Date(FinPeriodo).toLocaleDateString('es-cr', { year: "numeric", month: "long" });

            Descripcion = `Periodo de ${IniciaPeriodo} A ${FinalPeriodo}`;
        }

        let _itemCuentaPAR;
        if (this.state.FilaSeleccionada) {
            _itemCuentaPAR = this.state.FilaSeleccionada;
        } else {
            Notificacion.warning(`Debe seleccionar un centro de utilidad.`);
            return;
        }

        const Mes_01 = arrayFechas[0], Mes_02 = arrayFechas[1], Mes_03 = arrayFechas[2], Mes_04 = arrayFechas[3], Mes_05 = arrayFechas[4], Mes_06 = arrayFechas[5],
            Mes_07 = arrayFechas[6], Mes_08 = arrayFechas[7], Mes_09 = arrayFechas[8], Mes_10 = arrayFechas[9], Mes_11 = arrayFechas[10], Mes_12 = arrayFechas[11];

        const FinPeriodoEmpresa = this.state.datosEmpresa.FinPeriodo

        if (parseInt(moment(FinPeriodoEmpresa).format("YYYY")) > parseInt(moment(FinPeriodo).format("YYYY"))) {
            EsHistorico = true;
        } else {
            EsHistorico = false;

            if (!this.compararFechas(FinPeriodoEmpresa, FinPeriodo)) {
                EsMayor = true;
                Notificacion.warning("El periodo seleccionado es mayor al periodo actual. Se desplegará el periodo actual");
            }
        }

        return {
            Empresa,
            NombreEmpresa,
            UbicacionImagen: pUbicacionImagen,
            ReportNombre,
            Resumen,
            UsuarioNombre,
            IncluirResumen,
            imprimirLogo,
            Descripcion,
            Subtitulo,
            EsHistorico,
            CentroUtilidad: _itemCuentaPAR.ID,
            FechaDe,
            FechaDeHasta,
            FechaComparar,
            FechaCompararHasta,
            CuentasSaldoCeroSM: MuestraCeros,
            Referencia,
            FechaInicio: EsMayor ? InicioPeriodoEmpresa : InicioPeriodo,
            FechaFin: FinPeriodo,
            FechaInicial: FechaInicio,
            FechaFinal,
            Mes_01,
            Mes_02,
            Mes_03,
            Mes_04,
            Mes_05,
            Mes_06,
            Mes_07,
            Mes_08,
            Mes_09,
            Mes_10,
            Mes_11,
            Mes_12,
            Estado: Config.eaAplicado
        };


    }

    validarAnio = (ev) => {
        const text = /^[0-9]+$/;
        const year = ev.target.value;

        let { Datos } = this.state;

        if (
            ev.type == "blur" ||
            (year.length == 4 && ev.keyCode != 8 && ev.keyCode != 46)
        ) {
            if (year != 0) {
                const current_year = new Date().getFullYear();

                if (year != "" && !text.test(year)) {
                    if (ev.target.id == "PeriodoAnio") {
                        Datos.PeriodoAnio.value = current_year;
                    } else if (event.target.name == "PeriodoAnioHasta") {
                        Datos.PeriodoAnioHasta.value = current_year;
                    }

                    this.setState({ Datos });

                    Notificacion.warning("Debe ingresar un valor numérico.");

                    return false;
                }

                if (year.length != 4) {
                    if (ev.target.id == "PeriodoAnio") {
                        Datos.PeriodoAnio.value = current_year;
                    } else if (event.target.name == "PeriodoAnioHasta") {
                        Datos.PeriodoAnioHasta.value = current_year;
                    }

                    this.setState({ Datos });

                    Notificacion.warning("Debe ingresar un año válido.");

                    return false;
                }

                if (year < 1900 || year > current_year) {
                    if (ev.target.id == "PeriodoAnio") {
                        Datos.PeriodoAnio.value = current_year;
                    } else if (event.target.name == "PeriodoAnioHasta") {
                        Datos.PeriodoAnioHasta.value = current_year;
                    }

                    this.setState({ Datos });

                    Notificacion.warning("Debe ingresar un año válido.");

                    return false;
                }
                return true;
            }
        }
    };

    validarSoloNumeros = (ev) => {
        const text = /^[0-9]+$/;

        const value = ev.target.value;
        let { Datos } = this.state;

        if (ev.type == "blur" && ev.keyCode != 8 && ev.keyCode != 46) {
            if (value != "" && !text.test(value)) {
                if (ev.target.name == "CodigoEmpleado") {
                    Datos.CodigoEmpleado.value = "";
                    this.setState({ Datos });
                }

                Notificacion.warning("Debe ingresar un valor numérico.");
                return false;
            } else if (value == "") {
                return false;
            }
        }

        return true;
    };

    onhandleChangeDate = (date, id) => {
        const name = id;
        const value = date;
        const _ReportId = this.state.ReportId;
        let newAttributes = this.state.Datos[name].attributes;

        let Datos = Object.assign({}, this.state.Datos, { [name]: { value: value, attributes: newAttributes } })

        if ((_ReportId == Config.Reportes.BalanceSituacion) || (_ReportId == Config.Reportes.AsientosFinancieros)) {
            if (name == "MovimientosDe") {
                Datos.MovimientosAl.value = addMonths(new Date(Datos.MovimientosDe.value), -1);
            }

        }

        if ((_ReportId == Config.Reportes.ReportesCentroCostos) || _ReportId == Config.Reportes.ReportesCentroCostos) {
            if ((this.state.seleccionReportes.value == 'G') || (this.state.seleccionReportes.value == 'U')) {
                if (name == "MovimientosDe") {
                    Datos.MovimientosAl.value = addMonths(new Date(Datos.MovimientosDe.value), -1);
                }
            }
        }

        if (_ReportId === Config.Reportes.Comprometido || _ReportId === Config.Reportes.ConsolidaciondeCuentas) {
            this.setState({ listaGralPAR: [], listaCheck: [] });
        }

        this.setState({ Datos });

    };

    validarDatos = () => {
        return true;
    }

    onGenerarReporte = async () => {

        let pSpinnerLabel = "Cargando datos..."
        this.spinnerModalMostrar(true, pSpinnerLabel, 3);

        const {
            ReportId,
            Datos,
            titulo,
        } = this.state;

        const session = new Session();

        //Cambiar por fecha actual
        const Fecha = moment(Datos.fecMesAno.value).format("YYYY/MM/DD");
        let FechaInicio = moment(Datos.FechaInicio.value).format("YYYY/MM/DD");
        let FechaFinal = moment(Datos.FechaFinal.value).format("YYYY/MM/DD");

        const Empresa = session.get("empresaCON");
        const Pais = session.get("paisCON");
        const usuarioNombre = session.get("usuarioNombreCON");

        const { NombreEmpresa, CedulaJuridica, Telefono } = this.state;

        const imprimirLogo = Datos.ImprimirLogo.value;
        const fechaAsCie = moment(Datos.Periodo.value).format(Config.formatoFechaStandard);
        const UbicacionImagen = Datos.UbicacionImagen.value;

        let params = {};

        switch (parseInt(ReportId)) {

            case parseInt(Config.Reportes.Generalempleados):
                params = this.parametrosAsientos(Empresa, NombreEmpresa, Fecha, FechaInicio, FechaFinal, titulo, UbicacionImagen);
                break;
            case parseInt(Config.Reportes.AsientosDiario):
                params = await this.parametrosAsientosDiario(Empresa, NombreEmpresa, titulo, usuarioNombre, Pais, UbicacionImagen);
                break;
            case parseInt(Config.Reportes.DiarioGeneral):
                params = this.parametrosDiarioGeneral(Empresa, NombreEmpresa, titulo, usuarioNombre, imprimirLogo, Pais, UbicacionImagen);
                break;
            case parseInt(Config.Reportes.AsientosDelCierre):
                params = await this.parametrosAsientosCierre(Empresa, NombreEmpresa, fechaAsCie, titulo, usuarioNombre, imprimirLogo, UbicacionImagen);
                break;
            case parseInt(Config.Reportes.AsientosFinancieros):
                params = this.parametrosAsientosFinancieros(Empresa, NombreEmpresa, titulo, usuarioNombre, imprimirLogo, Pais, UbicacionImagen);
                break;
            case parseInt(Config.Reportes.BalanceSituacion):
                params = this.parametrosBalanceSituacion(Empresa, NombreEmpresa, titulo, usuarioNombre, imprimirLogo, Pais, UbicacionImagen);
                break;
            case parseInt(Config.Reportes.BalanceComprobacion):
                params = this.parametrosBalanceComprobacion(Empresa, NombreEmpresa, titulo, usuarioNombre, imprimirLogo, UbicacionImagen);
                break;
            case parseInt(Config.Reportes.ImpresionDeCuentas):
                params = this.parametrosImpresionDeCuentas(Empresa, NombreEmpresa, titulo, usuarioNombre, imprimirLogo, UbicacionImagen);
                break;
            case parseInt(Config.Reportes.BalanceComprobacionEstimado):
                params = this.parametrosBalanceComprobacionEstimado(Empresa, NombreEmpresa, titulo, usuarioNombre, imprimirLogo, UbicacionImagen);
                break;
            case parseInt(Config.Reportes.ImpresionDeCatalogo):
                params = this.parametrosImpresionDeCatalogo(Empresa, NombreEmpresa, titulo, usuarioNombre, imprimirLogo, UbicacionImagen);
                break;
            case parseInt(Config.Reportes.HistoricoSaldos):
                params = this.parametrosHistoricoSaldos(Empresa, NombreEmpresa, titulo, usuarioNombre, imprimirLogo, UbicacionImagen);
                break;
            case parseInt(Config.Reportes.ImpresionCentroCosto):
                params = this.parametrosImpresionDeCentroCosto(Empresa, NombreEmpresa, titulo, usuarioNombre, imprimirLogo, UbicacionImagen);
                break;
            case parseInt(Config.Reportes.MovimientosSinAPlicar):
                params = this.parametrosMovimientosSinAplicar(Empresa, NombreEmpresa, titulo, usuarioNombre, imprimirLogo, UbicacionImagen);
                break;
            case parseInt(Config.Reportes.ConsolidaciondeCuentas):
                params = this.parametrosConsolidacioDeCuentas(Empresa, NombreEmpresa, titulo, usuarioNombre, imprimirLogo, UbicacionImagen);
                break;
            case parseInt(Config.Reportes.Comprometido):
                params = this.parametrosComprometido(Empresa, NombreEmpresa, titulo, usuarioNombre, imprimirLogo, UbicacionImagen);
                break;
            case parseInt(Config.Reportes.ReportesCentroCostos):
                params = this.parametrosCentrosCostos(Empresa, NombreEmpresa, titulo, usuarioNombre, imprimirLogo, UbicacionImagen);
                break;
            case parseInt(Config.Reportes.ReportesCentroUtilidades):
                params = this.parametrosCentrosUtilidad(Empresa, NombreEmpresa, titulo, usuarioNombre, imprimirLogo, UbicacionImagen);
                break;
            case parseInt(Config.Reportes.BitacoraGeneral):
                params = this.parametrosBitacoraGeneral(Empresa, NombreEmpresa, titulo, usuarioNombre, imprimirLogo, UbicacionImagen);
                break;
            case parseInt(Config.Reportes.EstadoResultadosPresupuesto):
                params = this.parametrosEstadoResultadosPresup(Empresa, NombreEmpresa, titulo, usuarioNombre, imprimirLogo, UbicacionImagen);
                break;
            case parseInt(Config.Reportes.CierreFiscal):
                params = this.parametrosCierreFiscal(Empresa, NombreEmpresa, titulo, usuarioNombre, imprimirLogo, UbicacionImagen);
                break;
            case parseInt(Config.Reportes.BalanceSituacionPresupuesto):
                params = this.parametrosBalanceSituacioPresupuesto(Empresa, NombreEmpresa, titulo, usuarioNombre, imprimirLogo, UbicacionImagen);
                break;
            case parseInt(Config.Reportes.CentroCostosPresupuesto):
                params = this.parametrosCentrosCostosPresupuesto(Empresa, NombreEmpresa, titulo, usuarioNombre, imprimirLogo, UbicacionImagen);
                break;
            case parseInt(Config.Reportes.CentroUtilidadesPresupuesto):
                //se saca del proceso por que no esta terminado en delphi
                this.spinnerModalMostrar(false, "", 3);
                return false;
                params = this.parametrosCentrosUtilidadPresupuesto(Empresa, NombreEmpresa, titulo, usuarioNombre, imprimirLogo, UbicacionImagen);
                break;

            default:
                break;

        }

        if (!params) {
            this.spinnerModalMostrar(false, "", 3);
        } else {

            try {
                let pToken = this.state.token;

                let data = await SetParametrosReporte_Request(pToken, params);

                const myWindow = window.open();

                if (myWindow === null) {
                    Notificacion.error("Error: No se puede redireccionar al reporte.");
                    return;
                }

                if (data.hasOwnProperty("Error")) {
                    Notificacion.error(`${data.Error}`);
                } else {
                    setTimeout(() => {
                        myWindow.location.replace(
                            `${baseUrl}ReportesSSR/MuestraReporte.aspx?ReporteId=${ReportId}&Empresa=${Empresa}&Pais=${Pais}`
                        );
                    }, 1);
                }
            } catch (err) {
                Notificacion.error(`Error: ${err}`);

            }
            this.spinnerModalMostrar(false, "", 3);
            //}
        }
    };

    handleRadioButtonTipo = (e, id) => {
        const reportId = this.state.ReportId;
        const name = id;
        const valor = parseInt(e.target.value);

        let Datos = { ...this.state.Datos };

        if (reportId === Config.Reportes.DiarioGeneral) {
            const selectedCuentas = valor;

            switch (valor) {
                case 1:
                    Datos.Cuenta.attributes.readOnly = true;
                    Datos.Cuenta.attributes.readOnlyBoton = true;
                    Datos.CuentaAl.attributes.readOnly = true;
                    Datos.CuentaAl.attributes.readOnlyBoton = true;
                    break;
                case 2:
                    Datos.Cuenta.attributes.readOnly = false;
                    Datos.Cuenta.attributes.readOnlyBoton = false;
                    Datos.CuentaAl.attributes.readOnly = false;
                    Datos.CuentaAl.attributes.readOnlyBoton = false;
                    break;
                case 3:
                    Datos.Cuenta.attributes.readOnly = false;
                    Datos.Cuenta.attributes.readOnlyBoton = false;
                    Datos.CuentaAl.attributes.readOnly = false;
                    Datos.CuentaAl.attributes.readOnlyBoton = false;
                    break;
                default:
                    break;
            }

            this.setState({ Datos, selectedCuentas: selectedCuentas });
        }

        if (reportId === Config.Reportes.BalanceComprobacion || reportId === Config.Reportes.BalanceComprobacionEstimado) {
            const selectedCuentas = valor;
            this.setState({ selectedCuentas: selectedCuentas });
        }

        if (reportId === Config.Reportes.HistoricoSaldos) {
            const selectedCuentas = valor;

            switch (valor) {
                case 1:
                    Datos.TipoCuenta.attributes.readOnly = true;
                    break;
                case 2:
                    Datos.TipoCuenta.attributes.readOnly = false;
                    break;
                default:
                    break;
            }

            this.setState({ Datos, selectedCuentas: selectedCuentas });
        }

        if (reportId === Config.Reportes.ImpresionDeCatalogo) {
            const selectedCuentas = valor;

            switch (valor) {
                case 1:
                    Datos.TipoCtaGeneral.attributes.readOnly = true;
                    Datos.TipoCtaEspecifico.attributes.readOnly = true;
                    break;
                case 2:
                    Datos.TipoCtaGeneral.attributes.readOnly = false;
                    Datos.TipoCtaEspecifico.attributes.readOnly = true;
                    break;
                case 3:
                    Datos.TipoCtaGeneral.attributes.readOnly = true;
                    Datos.TipoCtaEspecifico.attributes.readOnly = false;
                    break;
                default:
                    break;
            }

            this.setState({ Datos, selectedCuentas: selectedCuentas });
        }
        if (reportId === Config.Reportes.MovimientosSinAPlicar) {
            const selectedFormatoMovimiento = e.target.value;
            this.setState({ selectedFormatoMovimiento: selectedFormatoMovimiento });

        }

    };

    handleRadioButtonDatosRep = (e, id) => {
        const reportId = this.state.ReportId;
        const valor = parseInt(e.target.value);

        let Datos = { ...this.state.Datos };

        if (reportId === Config.Reportes.HistoricoSaldos) {

            const selectedDatosRep = valor;
            this.setState({ selectedDatosRep: selectedDatosRep });

        }
    };

    onChangeInputCue = (e) => {
        const name = e.target.name;
        const value = e.target.value;

        let newAttributes = this.state.Datos[name].attributes;
        let Datos = Object.assign({}, this.state.Datos, {
            [name]: { value: value, attributes: newAttributes },
        });

        if (name == "CodigoEmpleado") Datos.NombreEmpleado.value = "";
        if (name == "CodigoEmpleadoFirma") Datos.NombreEmpleadoFirma.value = "";
        if (name == "CodigoCCosto") {
            Datos.NombreCCosto.value = "";
            this.setState({ selectedCC: 0 });
        }
        if (name === "Cuenta") {
            Datos.NombreCuenta.value = "";
            Datos.Nivel.value = 0;
            this.setState({ selectedNivelIni: 0 });
        }

        if (name === "CuentaAl") {
            Datos.NombreCuentaAl.value = "";
            Datos.Nivel.value = 0;
            this.setState({ selectedNivelFin: 0 });
        }

        this.setState({ Datos });
    };

    handleModalTree = (pId) => {
        const selectModalTree = true;
        this.setState({ selectModalTree, idModalTree: pId });
    }

    handleModalCC = () => {
        const selectModalTreeCC = true;
        this.setState({ selectModalTreeCC });
    }

    cerrarModalCC = () => {
        const selectModalTreeCC = false;
        this.setState({ selectModalTreeCC });
    }

    cerrarModalTree = () => {
        const selectModalTree = false;
        this.setState({ selectModalTree });
    }

    onRowSelectBusquedaTree = (row, pIdModal) => {

        if (pIdModal === "ModalCuentas") {
            const selectedCuentaTree = row;
            this.setState({ selectedCuentaTree });
        } else if (pIdModal === "ModalCC") {
            const selectedCuentaTreeCC = row;
            this.setState({ selectedCuentaTreeCC });
        }

    }

    carga_ListTree = async (pToken, pEmpresa, pEmpresaNombre) => {
        const response = await Catalogo_Lista_Request(pToken, pEmpresa, 0);
        let _lista = [];
        if (response.Exitoso) {
            const _listCuentas = response.Datos;
            const _listCuentasCont = this.llenadoListaArbol(_listCuentas, pEmpresaNombre);
            _lista = datosArbol(_listCuentasCont);
            this.setState({ listCuentas: _listCuentas });
        }
        else {
            Notificacion.error(response.Mensaje);
            this.volverAtras();
        }
        return _lista;
    }

    carga_ListTreeCC = async (pToken, pEmpresa, pEmpresaNombre) => {

        const response = await CentroCosto_Lista_CCC_Request(pToken, pEmpresa);
        let _lista = [];
        if (response.Exitoso) {
            const _listCC = response.Datos;
            const _listCentroC = this.llenadoListaArbolCC(_listCC, pEmpresaNombre);
            _lista = datosArbol(_listCentroC);

            this.setState({ ListCentrosCosto: _listCC });
        }
        else {
            Notificacion.error("Sucedió un error al consultar los centros de costo.");
        }

        return _lista;

    }

    llenadoListaArbol = (pLista, pEmpresaNombre) => {
        let _Datos = [];
        const _Lista = pLista;
        _Datos.push({ "title": pEmpresaNombre, "subtitle": "", "padre": -1, "value": 0 });

        _Lista.map(function (item, index) {
            _Datos.push({ "title": item.Cuenta + " " + item.Nombre, "subtitle": "", "padre": (item.Padres.length > 0 ? parseInt(item.Padres.substring(item.Padres.length - 6, item.Padres.length)) : 0), "value": item.ID });
        });

        return _Datos;
    }

    llenadoListaArbolCC = (pLista, pEmpresaNombre) => {
        let _Datos = [];
        const _Lista = pLista;
        _Datos.push({ "title": pEmpresaNombre, "subtitle": "", "padre": -1, "value": 0 });

        _Lista.map(function (item, index) {
            _Datos.push({ "title": item.CentroCosto + " " + item.Nombre, "subtitle": "", "padre": (item.Padres.length > 0 ? parseInt(item.Padres.substring(item.Padres.length - 6, item.Padres.length)) : 0), "value": item.ID });
        });

        return _Datos;
    }

    seleccionModalTree = async (pId) => {

        if (pId === "ModalCuentas") {

            const selectedCuenta = this.state.selectedCuentaTree;
            const listCuentas = this.state.listCuentas;
            if (!!selectedCuenta) {
                if (!selectedCuenta.node.children) {
                    const listCCont = listCuentas.filter(item => item.ID == selectedCuenta.node.value);

                    if (this.state.ReportId === Config.Reportes.Comprometido) {

                        let pSpinnerLabel = "Buscando Datos...";
                        this.spinnerModalMostrar(true, pSpinnerLabel, 3);

                        const session = new Session();
                        const Empresa = session.get("empresaCON"), Fecha = moment(this.state.Datos.fecMesAno.value).format(Config.formatoFechaAMD);
                        const response = await Consulta_Comprometidos_Request(this.state.token, Empresa, listCCont[0].ID, Fecha);

                        if (response.Exitoso) {

                            if (response.Datos.ID > 0 && response.Datos.Nombre !== "") {

                                this.state.Datos.Cuenta.value = listCCont[0].Cuenta;
                                this.state.Datos.NombreCuenta.value = listCCont[0].Nombre;

                                this.setState({ selectModalTree: false, selectedCuentaTree: undefined });

                                this.spinnerModalMostrar(false, '', 3);
                            } else {
                                this.spinnerModalMostrar(false, '', 3);
                                Notificacion.warning("La cuenta contable no tiene comprometidos para el mes indicado.");
                                return;
                            }

                        } else {
                            Notificacion.error("Sucedió un error al consultar los comprometidos de la cuenta.");
                            return;
                        }

                    } else {

                        const idCuenta = this.state.idModalTree;
                        if (idCuenta === "Cuenta") {
                            this.state.Datos.Cuenta.value = listCCont[0].Cuenta;
                            this.state.Datos.NombreCuenta.value = listCCont[0].Nombre;
                        } else {
                            this.state.Datos.CuentaAl.value = listCCont[0].Cuenta;
                            this.state.Datos.NombreCuentaAl.value = listCCont[0].Nombre;
                        }
                        this.setState({ selectModalTree: false, selectedCuentaTree: undefined });

                    }

                }
                else {
                    if ((this.state.ReportId === Config.Reportes.BalanceComprobacion) || (this.state.ReportId === Config.Reportes.ImpresionDeCuentas) || (this.state.ReportId === Config.Reportes.BalanceComprobacionEstimado)) {
                        const listCCont = listCuentas.filter(item => item.ID == selectedCuenta.node.value);
                        const idCuenta = this.state.idModalTree;
                        if (idCuenta === "Cuenta") {
                            this.state.Datos.Cuenta.value = listCCont[0].Cuenta;
                            this.state.Datos.NombreCuenta.value = listCCont[0].Nombre;
                        } else {
                            this.state.Datos.CuentaAl.value = listCCont[0].Cuenta;
                            this.state.Datos.NombreCuentaAl.value = listCCont[0].Nombre;
                        }
                        this.setState({ selectModalTree: false, selectedCuentaTree: undefined });
                    } else {
                        Notificacion.error('La cuenta seleccionada es padre.');
                        this.setState({ selectModalTree: false, selectedCuentaTree: undefined });
                    }
                }
            }
            else {
                Notificacion.warning('Debe seleccionar un registro.');
            }

        } else if (pId === "ModalCC") {

            const selectedCC = this.state.selectedCuentaTreeCC;
            const listCentroC = this.state.ListCentrosCosto;

            if (!!selectedCC) {
                if (!selectedCC.node.children) {

                    const listaCCFilter = listCentroC.filter(item => item.ID == selectedCC.node.value);
                    this.state.Datos.CodigoCCosto.value = listaCCFilter[0].CentroCosto;
                    this.state.Datos.NombreCCosto.value = listaCCFilter[0].Nombre;
                    this.setState({ selectModalTreeCC: false, selectedCuentaTreeCC: undefined, selectedCC: listaCCFilter[0].ID });

                } else {
                    Notificacion.error('La cuenta seleccionada es padre.');
                    this.setState({ selectModalTreeCC: false, selectedCuentaTreeCC: undefined });
                }
            } else {
                Notificacion.warning('Debe seleccionar un registro.');
            }

        }

    }

    revisaCuenta = async (pCuenta, esInicial) => {

        const listCuentas = this.state.listCuentas;

        const validacion = await this.validacionCuenta(listCuentas, pCuenta, esInicial, false);

        if (validacion.length > 0) {
            Notificacion.warning(validacion);
        }

    }

    validacionCuenta = async (plista, pcuenta, esInicial, pImprime) => {
        let Datos = this.state.Datos;
        let cuenta = new RegExp(pcuenta + '-.*');
        const { ReportId } = this.state;

        const listCuentasCont = plista.filter(item => item.Cuenta == pcuenta);

        if (listCuentasCont.length == 0) {
            if (esInicial) {
                return 'La Cuenta Inicial no existe.'
            } else {
                return 'La Cuenta Final no existe.'
            }
        } else {

            if ((ReportId == Config.Reportes.MovimientosSinAPlicar) || (ReportId == Config.Reportes.Comprometido) || (ReportId !== Config.Reportes.BalanceComprobacion) && (ReportId !== Config.Reportes.ImpresionDeCuentas) && (ReportId !== Config.Reportes.BalanceComprobacionEstimado)) {
                const listaCuenta = plista.filter(item => item.Cuenta.match(cuenta));

                if (listaCuenta.length > 0) {
                    return 'La cuenta es de mayor.'
                }
            }

        }

        if (esInicial) {

            if (this.state.ReportId === Config.Reportes.Comprometido) {

                let pSpinnerLabel = "Buscando Datos...";
                this.spinnerModalMostrar(true, pSpinnerLabel, 3);

                const session = new Session();
                const Empresa = session.get("empresaCON"), Fecha = moment(this.state.Datos.fecMesAno.value).format(Config.formatoFechaAMD);
                const response = await Consulta_Comprometidos_Request(this.state.token, Empresa, listCuentasCont[0].ID, Fecha);

                if (response.Exitoso) {

                    if (response.Datos.ID > 0 && response.Datos.Nombre !== "") {
                        this.spinnerModalMostrar(false, '', 3);
                    } else {
                        this.spinnerModalMostrar(false, '', 3);
                        return "La cuenta contable no tiene comprometidos para el mes indicado.";
                    }

                } else {
                    Notificacion.error("Sucedió un error al consultar los comprometidos de la cuenta.");
                    return;
                }

            }

            Datos.NombreCuenta.value = listCuentasCont[0].Nombre;

            const nivelFin = this.state.selectedNivelFin;

            if (listCuentasCont[0].Nivel === nivelFin) {
                Datos.Nivel.value = listCuentasCont[0].Nivel;
            } else {
                Datos.Nivel.value = 0;
            }

            this.setState({ Datos: Datos, selectedNivelIni: listCuentasCont[0].Nivel });

        } else {
            Datos.NombreCuentaAl.value = listCuentasCont[0].Nombre;

            const nivelIni = this.state.selectedNivelIni;

            if (listCuentasCont[0].Nivel === nivelIni) {
                Datos.Nivel.value = listCuentasCont[0].Nivel;
            } else {
                Datos.Nivel.value = 0;
            }

            this.setState({ Datos: Datos, selectedNivelFin: listCuentasCont[0].Nivel });
        }

        if (pImprime) {
            return listCuentasCont[0].Nivel;
        } else {
            return '';
        }
    }

    validaCentroCosto = () => {

        const CentroCosto = this.state.Datos.CodigoCCosto.value;
        const listaCCosto = this.state.ListCentrosCosto;

        if (CentroCosto.toString().trim().length > 0) {

            const validacion = this.validaCCosto(listaCCosto, CentroCosto);

            if (validacion.toString().length > 0) {
                Notificacion.warning(validacion);
            }

        }

    }

    validaCCosto = (plista, pCCosto) => {
        let Datos = this.state.Datos;
        let cCosto = new RegExp('^' + pCCosto + '-', 'i');

        const listCentroCosto = plista.filter(item => item.CentroCosto == pCCosto);
        if (listCentroCosto.length == 0) {
            Datos.NombreCCosto.value = "";
            this.setState({ Datos: Datos, selectedCC: 0 });
            return 'El centro de costo no existe'
        }
        else {
            const listaCCosto = plista.filter(item => item.CentroCosto.match(cCosto));
            if (listaCCosto.length > 0) {
                Datos.NombreCCosto.value = "";
                this.setState({ Datos: Datos, selectedCC: 0 });
                return 'El centro de costo es de mayor'
            }
        }

        Datos.NombreCCosto.value = listCentroCosto[0].Nombre;
        this.setState({ Datos: Datos, selectedCC: listCentroCosto[0].ID });

        return '';
    };

    handleKeyPress = (e) => {
        if (e.key === 'Enter') {
            this.validaCentroCosto();
        }
    }

    handleKeyPressCuentaDe = (e) => {
        if (e.key === 'Enter') {
            const cuentaDe = this.state.Datos.Cuenta.value;
            this.revisaCuenta(cuentaDe, true);
        }
    }

    handleKeyPressCuentaAl = (e) => {
        if (e.key === 'Enter') {
            const cuentaAl = this.state.Datos.CuentaAl.value;
            this.revisaCuenta(cuentaAl, false);
        }
    }

    //tabla parametros
    onRowSelectDet = (row, isSelect) => {

        this.setState({ FilaSeleccionada: row });
        return true;
    }

    handleAgregar = async () => {
        if (this.state.Datos.NombreCuenta.value.trim().length != 0) {

            if (!this.validarCuentasPAR()) {
                return false;
            }

            const _listCuentas = this.state.listCuentas.filter(item => item.Cuenta == this.state.Datos.Cuenta.value.trim());

            let _itemCuentaPAR = { ...this.state.itemCuentaPAR };

            if (this.state.ReportId === Config.Reportes.Comprometido) {

                let pSpinnerLabel = "Cargando Datos...";
                this.spinnerModalMostrar(true, pSpinnerLabel, 3);

                const session = new Session();
                const Empresa = session.get("empresaCON"), Fecha = moment(this.state.Datos.fecMesAno.value).format(Config.formatoFechaAMD);

                const Montos = await SaldoComprometidoXCuenta_Request(this.state.token, Empresa, _listCuentas[0].ID, Fecha, 1);

                if (!Montos.Exitoso) {
                    Notificacion.error("Sucedió un error al consultar los montos.");
                    return false;
                }

                let item = this.generarItemListaComprom();

                //console.log(_listCuentas);
                let MesNum = new Date(this.state.Datos.fecMesAno.value).toLocaleDateString('es-cr', { month: "numeric" });
                MesNum = MesNum < 10 ? `Saldo0${MesNum}` : `Saldo${MesNum}`;

                ///////////////////////////////////////////////////
                item.llave = _listCuentas[0].ID;
                item.Cuenta = _listCuentas[0].Cuenta;
                item.Nombre = _listCuentas[0].Nombre;
                item.Digitado = Montos.Datos.Debitos - Montos.Datos.Creditos;
                item.Aprobado = Montos.Datos.DebitosAprob - Montos.Datos.CreditosAprob;
                item.Comprometido = item.Digitado + item.Aprobado;
                item.Mensual = _listCuentas[0][MesNum];
                item.Mens_Est = item.Mensual + item.Comprometido;
                item.Acumulado = this.SumeMontos(_listCuentas[0]);
                item.Acum_Est = item.Acumulado + item.Comprometido;
                ///////////////////////////////////////////////////

                let _listaGralPAR = [...this.state.listaGralPAR];

                _listaGralPAR.push(item);

                let Datos = this.state.Datos;

                Datos.Cuenta.value = "";
                Datos.NombreCuenta.value = "";

                this.setState({ listaGralPAR: _listaGralPAR, Datos });

                this.spinnerModalMostrar(false, '', 3);

            } else {

                _itemCuentaPAR.llave = _listCuentas[0].ID;
                _itemCuentaPAR.Cuenta = _listCuentas[0].Cuenta;
                _itemCuentaPAR.Nombre = _listCuentas[0].Nombre;

                let _listaGralPAR = [...this.state.listaGralPAR];
                let Datos = this.state.Datos;

                _listaGralPAR.push(_itemCuentaPAR);
                Datos.Cuenta.value = "";
                Datos.NombreCuenta.value = "";

                this.setState({ listaGralPAR: _listaGralPAR, Datos });
            }

            return true;

        } else {
            Notificacion.warning(`Debe seleccionar una cuenta válida.`);
            //_Existe = [];
            return false;
        }
    };

    SumeMontos = (pArray) => {

        let resultado = 0;

        for (let i = 0; i <= 12; i++) {

            let Nombre = i < 10 ? "Saldo0" + i : "Saldo" + i;

            resultado = resultado + pArray[Nombre];

        }

        return resultado;

    }

    handleEliminar = () => {
        if (this.state.FilaSeleccionada) {
            let _itemCuentaPAR = this.state.FilaSeleccionada;
            let _listaGralPAR = this.state.listaGralPAR.filter(x => x.llave != _itemCuentaPAR.llave);
            this.setState({ listaGralPAR: _listaGralPAR, FilaSeleccionada: undefined });
        } else {
            Notificacion.error(`Debe seleccionar un registro.`);
        }
    }

    validarCuentasPAR = () => {

        let _listaGralPAR = [...this.state.listaGralPAR];
        const _listCuentasT = this.state.listCuentas;
        const _listCuentas = _listCuentasT.filter(item => item.Cuenta == this.state.Datos.Cuenta.value.trim());
        let _Existe = [];
        _Existe = _listaGralPAR.filter(item => item.llave == _listCuentas[0].ID);
        if (_Existe.length > 0) {
            Notificacion.warning(`La cuenta ya existe en la lista.`);
            return false;
        } else {
            return true;
        }

    }

    handleRefrescar = async () => {

        let pSpinnerLabel = "Cargando datos..."
        this.spinnerModalMostrar(true, pSpinnerLabel, 3);

        this.setState({ listaGralPAR: [], listaCheck: [] });

        const session = new Session();
        const Empresa = session.get("empresaCON");
        const Estado = this.state.seleccionAsiento.value, Fecha = this.state.Datos.fecMesAno.value, Tipo = this.state.seleccionTipoAsiento.value;

        const response = await EncabezadoAsiento_Listar_Request(this.state.token, Empresa, Estado, Fecha, Tipo);

        if (response.Exitoso) {

            if (this.state.seleccionTipoAsientoMarca.value !== undefined && this.state.seleccionTipoAsientoMarca.value > 0) {

                let ListaFiltro = response.Datos.filter(item => item.Tipo == this.state.seleccionTipoAsientoMarca.value);
                let Minimo = undefined, numeroCiclo = 0, MinimoSelec = {}, Maximo = undefined, MaximoSelec = {};

                for (let i in ListaFiltro) {
                    numeroCiclo = ListaFiltro[i].Numero;
                    if (Minimo === undefined) {
                        Minimo = ListaFiltro[i].Numero;
                    }
                    if (Maximo === undefined) {
                        Maximo = numeroCiclo;
                    }
                    if (numeroCiclo <= Minimo) {
                        MinimoSelec = ListaFiltro[i];
                        Minimo = numeroCiclo;
                    }
                    if (numeroCiclo >= Maximo) {
                        MaximoSelec = ListaFiltro[i];
                        Maximo = numeroCiclo;
                    }
                }

                let Datos = this.state.Datos;

                Datos.RangoDel.value = MinimoSelec.pNumero !== undefined ? MinimoSelec.pNumero : "";
                Datos.RangoAl.value = MaximoSelec.pNumero !== undefined ? MaximoSelec.pNumero : "";

                this.setState({ Datos });
            }

            this.setState({ listaGralPAR: response.Datos });

        } else {

            if (response.Mensaje === "No hay datos por mostrar") {
                Notificacion.warning("No se encontraron asientos según los filtros.");
                this.spinnerModalMostrar(false, '', 3);
                return;
            } else {
                Notificacion.error("Sucedió un error al buscar los asientos con los filtros seleccionados.");
                this.spinnerModalMostrar(false, '', 3);
                return;
            }
        }

        this.spinnerModalMostrar(false, '', 3);

    }

    onRowSelectTipo = (row, isSelect) => {

        let lista = this.state.listaCheck;

        if (isSelect) {
            lista.push(row.id);
        } else {
            lista = lista.filter(x => x !== row.id);
        }

        this.setState({ listaCheck: lista });
        return true;
    };

    handleOnSelectAllTipo = (isSelect, rows) => {

        let lista = this.state.listaGralPAR;
        let ids = lista.map(r => r.id);

        if (isSelect) {
            this.setState({ listaCheck: ids });
            return;
        } else {
            this.setState({ listaCheck: [] });
            return;
        }

    };

    cargaCC = async (pToken, pEmpresa) => {
        let arrayDatos = [];

        const responseCentrosCosto = await CentrosCostos_Listar_Request(pToken, pEmpresa, 0, 0, 0);

        if (responseCentrosCosto.Exitoso) {

            if (responseCentrosCosto.Datos.length > 1) {
                arrayDatos = responseCentrosCosto.Datos;
            } else {

                if (responseCentrosCosto.Datos[0].ID > 0 && responseCentrosCosto.Datos[0].Empresa > 0) {
                    arrayDatos = responseCentrosCosto.Datos;
                }

            }

        } else {
            Notificacion.error("Sucedió un error al consultar los centros de costo.");
            //volverAtras();
            return arrayDatos;
        }

        return arrayDatos;
    }

    cargaCU = async (pToken, pEmpresa) => {
        let arrayDatos = [];

        const responseCentrosCosto = await CentrosUtilidad_Listar_Request(pToken, pEmpresa);

        if (responseCentrosCosto.Exitoso) {

            if (responseCentrosCosto.Datos.length > 1) {
                arrayDatos = responseCentrosCosto.Datos;
            } else {

                if (responseCentrosCosto.Datos[0].ID > 0 && responseCentrosCosto.Datos[0].Empresa > 0) {
                    arrayDatos = responseCentrosCosto.Datos;
                }

            }

        } else {
            Notificacion.error("Sucedió un error al consultar los centros de costo.");
            //volverAtras();
            return arrayDatos;
        }

        return arrayDatos;
    }

    //busquedas de usuarios
    onChangeInputUsuario = (e) => {

        const name = e.target.name;
        const value = e.target.value;
        let Datos = this.state.Datos;
        let newAttributes = Datos[name].attributes;
        let _Datos = Object.assign({}, Datos, {
            [name]: { value: value, attributes: newAttributes },
        });

        if (name == "CodigoUsuarios") {
            _Datos.NombreUsuarios.value = "";
        };

        this.setState({ Datos: _Datos });

    }

    handleModalUsuario = () => {
        const selectModalUsuario = true;
        this.setState({ selectModalUsuario });
    };

    cerrarModalUsuario = () => {
        const selectModalUsuario = false;
        this.setState({ selectModalUsuario });
    };

    onKeyPressUsuario = async (e) => {

        const _usuario = e.target.value.toString().trim();

        if (e.charCode == 13) {

            let _Datos = { ...this.state.Datos };

            if (_usuario.length > 0) {
                const Usuario = this.state.listaUsuarios.filter(
                    (item) => item.Login.toString().toLowerCase().trim() === _usuario.toString().toLowerCase()
                );

                if (Usuario.length > 0) {

                    try {

                        this.spinnerModalMostrar(true, 'Cargando datos', 3);
                        _Datos.NombreUsuarios.value = Usuario[0].Nombre;
                        _Datos.CodigoUsuarios.value = Usuario[0].Login;

                    } catch (e) {
                        Notificacion.warning('Error ' + e.message);
                    } finally {
                        this.spinnerModalMostrar(false, '', 3);
                    }

                } else {
                    _Datos.CodigoUsuarios.value = "";
                    _Datos.NombreUsuarios.value = "";

                    Notificacion.warning("Usuario no existe");
                }
            } else {

                _Datos.CodigoUsuarios.value = "";
                _Datos.NombreUsuarios.value = "";

            }

            this.setState({ Datos: _Datos });
        }
    };

    onBlurUsuario = async (e) => {

        let _Datos = { ...this.state.Datos };

        if (_Datos.CodigoUsuarios.value.toString().trim().length > 0) {

            const Usuarios = this.state.listaUsuarios.filter(
                (item) => parseInt(item.Login) === parseInt(Datos.CodigoUsuarios.value.toString().trim())
            );

            if (Usuarios.length > 0) {

                try {

                    this.spinnerModalMostrar(true, 'Cargando datos', 3);
                    _Datos.NombreUsuarios.value = Usuarios[0].Nombre;
                    _Datos.CodigoUsuarios.value = Usuarios[0].Login;

                } catch (e) {
                    Notificacion.warning('Error ' + e.message);
                } finally {
                    this.spinnerModalMostrar(false, '', 3);
                }

            } else {
                _Datos.CodigoUsuarios.value = "";
                _Datos.NombreUsuarios.value = "";

                Notificacion.warning("Usuario no existe");
            }

        } else {

            _Datos.CodigoUsuarios.value = "";
            _Datos.NombreUsuarios.value = "";

        }
        this.setState({ Datos: _Datos });


    };

    onDoubleClickUsuario = async (e, row, rowIndex) => {

        let _Datos = { ...this.state.Datos };

        const Usuarios = this.state.listaUsuarios.filter(
            (item) => item.Login === row.Login
        );

        if (Usuarios.length > 0) {
            try {

                this.spinnerModalMostrar(true, 'Cargando datos', 3);

                _Datos.NombreUsuarios.value = Usuarios[0].Nombre;
                _Datos.CodigoUsuarios.value = Usuarios[0].Login;

                this.setState({ Datos: _Datos, selectModalUsuario: false, selectedUsuario: null })
            } catch (e) {
                Notificacion.warning('Error ' + e.message);
            } finally {
                this.spinnerModalMostrar(false, '', 3);
            }
        }

    };

    seleccionModalUsuario = async () => {

        let _Datos = { ...this.state.Datos };
        const selectedUsuario = this.state.selectedUsuario;
        if (!!this.state.selectedUsuario) {

            try {

                this.spinnerModalMostrar(true, 'Cargando datos', 3);

                _Datos.NombreUsuarios.value = selectedUsuario.Nombre;
                _Datos.CodigoUsuarios.value = selectedUsuario.Login;

                this.setState({ Datos: _Datos, selectModalUsuario: false, selectedUsuario: undefined })
            } catch (e) {
                Notificacion.warning('Error ' + e.message);
            } finally {
                this.spinnerModalMostrar(false, '', 3);
            }
        } else {
            Notificacion.warning("Debe seleccionar un usuario");
        }

    }

    onRowSelectUsuario = (row) => {
        this.setState({ selectedUsuario: row });
    };

    render() {
        const {
            botones, Datos, titulo, NombreEmpresa, mostrarSpinnerModal, seleccionOrdenadoPor, listaTipoAsiento,
            listaAsientos, seleccionAsiento, listaOrdenadoPor, seleccionTipoAsiento, radioOptions, selectedCuentas,
            selectModalTree, listCuentasContTemp, ListCC, selectModalTreeCC, listaDatosReporte, selectedDatosRep, ListaPeriodos,
            seleccionPeriodo, seleccionTipoCtaEspecifico, seleccionTipoCtaGeneral, ListaTipoCta, ListaSubTipoCta, selectedFormatoMovimiento,
            columnasPAR, listaGralPAR, botonesLista, botonesForm, seleccionTipoAsientoMarca, listaTipoAsientoMarca, seleccionReportes, listaReportes,
            selectModalUsuario, listaUsuarios, columnasUsuario, botonesAg, tituloTabla
        } = this.state;

        const selectRowPAR = {
            mode: 'radio', hideSelectColumn: true, bgColor: '#d73220',
            style: { color: '#ffffff' }, clickToSelect: true, classes: "colorListAs",
            onSelect: (row, isSelected) => this.onRowSelectDet(row, isSelected)
        };

        const selectRowCB = {
            mode: 'checkbox', hideSelectColumn: false, bgColor: '#d73220',
            style: { color: '#ffffff' }, clickToSelect: true, classes: "colorListAs",
            selected: this.state.listaCheck,
            onSelect: (row, isSelected) => this.onRowSelectTipo(row, isSelected),
            onSelectAll: (isSelect, rows) => this.handleOnSelectAllTipo(isSelect, rows),
        };
        // si hay mas hay que hacer un OR ||
        const selectRowTabla = (this.state.ReportId === Config.Reportes.ConsolidaciondeCuentas) ? selectRowCB : selectRowPAR

        const cellEditPAR = { mode: 'click', blurToSave: true, autoSelectText: true };

        const selectRowUsuario = { mode: 'radio', clickToSelect: true, hideSelectColumn: true, onSelect: this.onRowSelectUsuario, bgColor: '#10a599', blurToSave: true, autoSelectText: true };

        return (
            <Fragment>
                <ParametrosReportes
                    botones={botones}
                    Datos={Datos}
                    titulo={titulo}
                    NombreEmpresa={NombreEmpresa}
                    onGenerarReporte={this.onGenerarReporte}
                    seleccionAsiento={seleccionAsiento}
                    listaAsientos={listaAsientos}
                    listaDatosReporte={listaDatosReporte}
                    onChangeInput={this.onChangeInput}
                    validarAnio={this.validarAnio}
                    validarSoloNumeros={this.validarSoloNumeros}
                    handleCheckBox={this.handleCheckBox}
                    seleccionOrdenadoPor={seleccionOrdenadoPor}
                    listaOrdenadoPor={listaOrdenadoPor}
                    listaTipoAsiento={listaTipoAsiento}
                    listaTipoAsientoMarca={listaTipoAsientoMarca}
                    ListaPeriodos={ListaPeriodos}
                    onhandleChangeDate={this.onhandleChangeDate}
                    seleccionTipoAsiento={seleccionTipoAsiento}
                    seleccionTipoAsientoMarca={seleccionTipoAsientoMarca}
                    onhandleSelectedOptionEstados={this.onhandleSelectedOptionEstados}
                    onhandleSelectedOptionOrdenadoPor={this.onhandleSelectedOptionEstados}
                    onhandleSelectedOptionPeriodo={this.onhandleSelectedOptionPeriodo}
                    onhandlePeriodoAnioChange={this.onhandlePeriodoAnioChange}
                    handleSelectChange={this.handleSelectChange}
                    onhandleSelectedTipo={this.onhandleSelectedTipo}
                    onChangeInputNumero={this.onChangeInputNumero}
                    onChangeInputTexto={this.onChangeInputTexto}

                    handleRadioButtonTipo={this.handleRadioButtonTipo}
                    handleRadioButtonDatosRep={this.handleRadioButtonDatosRep}
                    radioOptions={radioOptions}
                    selectedCuentas={selectedCuentas}
                    selectedDatosRep={selectedDatosRep}
                    seleccionPeriodo={seleccionPeriodo}

                    onChangeInputCue={this.onChangeInputCue}
                    handleModalTree={this.handleModalTree}
                    handleModalCC={this.handleModalCC}
                    selectModalTree={selectModalTree}
                    selectModalTreeCC={selectModalTreeCC}
                    onRowSelectBusquedaTree={this.onRowSelectBusquedaTree}
                    cerrarModalTree={this.cerrarModalTree}
                    cerrarModalCC={this.cerrarModalCC}
                    listCuentasContTemp={listCuentasContTemp}
                    ListCC={ListCC}
                    seleccionModalTree={this.seleccionModalTree}

                    handleKeyPress={this.handleKeyPress}
                    handleKeyPressCuentaDe={this.handleKeyPressCuentaDe}
                    handleKeyPressCuentaAl={this.handleKeyPressCuentaAl}

                    seleccionTipoCtaEspecifico={seleccionTipoCtaEspecifico}
                    seleccionTipoCtaGeneral={seleccionTipoCtaGeneral}
                    ListaTipoCta={ListaTipoCta}
                    ListaSubTipoCta={ListaSubTipoCta}
                    selectedFormatoMovimiento={selectedFormatoMovimiento}

                    columnasPAR={columnasPAR}
                    listaGralPAR={listaGralPAR}
                    cellEditPAR={cellEditPAR}
                    selectRowPAR={selectRowTabla}
                    botonesLista={botonesLista}
                    botonesForm={botonesForm}
                    botonesAg={botonesAg}
                    seleccionReportes={seleccionReportes}
                    listaReportes={listaReportes}

                    tituloTabla={tituloTabla}
                    selectModalUsuario={selectModalUsuario}
                    columnasUsuario={columnasUsuario}
                    listaUsuarios={listaUsuarios}
                    onChangeInputUsuario={this.onChangeInputUsuario}
                    handleModalUsuario={this.handleModalUsuario}
                    cerrarModalUsuario={this.cerrarModalUsuario}
                    onKeyPressUsuario={this.onKeyPressUsuario}
                    onDoubleClickUsuario={this.onDoubleClickUsuario}
                    seleccionModalUsuario={this.seleccionModalUsuario}
                    onRowSelectUsuario={this.onRowSelectUsuario}
                    selectRowUsuario={selectRowUsuario}
                    keyField={this.state.ReportId === Config.Reportes.ConsolidaciondeCuentas ? "id" : "llave"}

                />
                <BotonArriba Delay={10} Visible={100} />
                <ModalSpinner
                    selectedModal={mostrarSpinnerModal.mostrar}
                    contentLabel={'spinnerModalProgress'}
                    label={mostrarSpinnerModal.label}
                    tipoSpinner={mostrarSpinnerModal.tipo}
                />
            </Fragment>
        );
    }
}

export default reporte;
