From 344dc15e6b81bd688e68cec599f2dfa4d76a0703 Mon Sep 17 00:00:00 2001 From: Felix Morales Date: Thu, 22 Feb 2024 09:52:39 -0600 Subject: [PATCH] Creacion de la vista para descargar el reporte de cuentas cerradas --- .../CuentasCerradas.tsx/CuentasCerradas.tsx | 210 ++++++++++++++++++ .../DTOReporteCuentasCerradas.ts | 21 ++ .../ReporteCuentasCerradas.Service.ts | 8 + src/index.tsx | 2 + 4 files changed, 241 insertions(+) create mode 100644 src/Components/ReportesClientes/CuentasCerradas.tsx/CuentasCerradas.tsx create mode 100644 src/DTO/Reportes/CuentasCerradas/DTOReporteCuentasCerradas.ts create mode 100644 src/Services/Reportes/ReporteCuentasCerradas.Service.ts diff --git a/src/Components/ReportesClientes/CuentasCerradas.tsx/CuentasCerradas.tsx b/src/Components/ReportesClientes/CuentasCerradas.tsx/CuentasCerradas.tsx new file mode 100644 index 0000000..bdeeb4e --- /dev/null +++ b/src/Components/ReportesClientes/CuentasCerradas.tsx/CuentasCerradas.tsx @@ -0,0 +1,210 @@ +import { useEffect, useState } from "react"; +import { Button, Card, Col, Form, Row } from "react-bootstrap"; +import ReportesAlenService from "../../../Services/Reportes/ReportesAlen.Service"; +import { MsgInformativo } from "../../Utils/Toast/msgInformativo"; +import ClientesServices from "../../../Services/Catalogos/Clientes.Services"; +import IClientes from "../../../Interfaces/Catalogos/IClientes"; +import { useSelector } from "react-redux"; +import { RootState } from "../../../store/store"; +import ICatCorresponsales from "../../../Interfaces/Catalogos/ICatCorresponsales"; +import CorresponsalesServices from "../../../Services/Catalogos/Corresponsales.Services"; +import ReporteCuentasCerradasService from "../../../Services/Reportes/ReporteCuentasCerradas.Service"; +export const CuentasCerradas: React.FC<{}> = () => { + const [Inicio, setInicio] = useState(currentDate(-7)) + const [Fin, setFin] = useState(currentDate(0)) + const [show, setShowMsg] = useState(false) + const [header, setHeader] = useState('') + const [msg, setMsg] = useState('') + const [msgColor, setMsgColor] = useState('primary') + const [TipoOperacion, setTipoOperacion] = useState(0) + const [IDCliente, setIDCliente] = useState(0) + const [Clientes, setClientes] = useState>() + const [IDCorresponsal, setIDCorresponsal] = useState(0) + const [Corresponsales, setCorresponsales] = useState>() + + function currentDate(days: number): string { + var today = new Date() + today.setDate(today.getDate() + days) + var dd = String(today.getDate()).padStart(2, '0') + var mm = String(today.getMonth() + 1).padStart(2, '0') + var yyyy = today.getFullYear() + return yyyy + '-' + mm + '-' + dd + } + + useEffect(() => { + ClientesServices.getAllClientes(0) + .then((response) => { + //clientes = response.data; + setClientes(response.data) + }) + .catch((e: Error) => { + setHeader('Error') + setMsg('Ocurrio un error: ' + e) + setShowMsg(true) + return + }) + CorresponsalesServices.getAll() + .then((response) => { + setCorresponsales(response.data) + }) + .catch((e: Error) => { + setHeader('Error') + setMsg('Ocurrio un error: ' + e) + setShowMsg(true) + return + }) + }, []) + + const GetExcel = () => { + if(IDCliente === 0 && IDCorresponsal === 0){ + setHeader('Error') + setMsg('Debe seleccionar un cliente o un corresponsal') + setShowMsg(true) + return + } + ReporteCuentasCerradasService.DownloadExcel(Inicio, Fin, TipoOperacion, IDCliente, IDCorresponsal) + .then(resp => { + const url = window.URL.createObjectURL(new Blob([resp.data])); + const link = document.createElement('a'); + link.href = url; + link.setAttribute('download', `Cuentas Cerradas ${Inicio} - ${Fin}.xlsx`); + document.body.appendChild(link); + link.click(); + }).catch(e => { + setHeader('Error') + setMsg('Ocurrio un error al generar el reporte. Por favor, intentelo de nuevo.') + setShowMsg(true) + return + }) + } + return( + <> + + + +

Reporte de Cuentas Cerradas

+ + + + + Inicio + setInicio(e.target.value)} + size='sm' + /> + + + + + Fin + setFin(e.target.value)} + size='sm' + /> + + + + + Tipo de OperaciĆ³n + + setTipoOperacion(parseInt(e.target.value)) + } + value={TipoOperacion} + className="form-select form-select-sm" + > + + + + + + + + + + + Cliente + { + setIDCliente(parseInt(e.target.value)) + }} + value={IDCliente} + className="form-select form-select-sm" + > + + {Clientes + ? Clientes.map((c) => { + return ( + + ) + }) + : null} + + + + + + Corresponsal + { + setIDCorresponsal(parseInt(e.target.value)) + }} + className="form-select form-select-sm" + value={IDCorresponsal} + > + + {Corresponsales + ? Corresponsales.map((item, index) => { + return ( + + ) + }) + : ''} + + + + + + + + +
+ + +
+ { + setShowMsg(false) + }} + /> + + ) +} \ No newline at end of file diff --git a/src/DTO/Reportes/CuentasCerradas/DTOReporteCuentasCerradas.ts b/src/DTO/Reportes/CuentasCerradas/DTOReporteCuentasCerradas.ts new file mode 100644 index 0000000..4828554 --- /dev/null +++ b/src/DTO/Reportes/CuentasCerradas/DTOReporteCuentasCerradas.ts @@ -0,0 +1,21 @@ +export interface DTOReporteCuentasCerradas{ + Trafico: string, + TipoOperacion: string, + Cliente: string, + Proveedor: string, + Corresponsal: string, + Aduana: string, + Patente: string, + Pedimento: string, + FechaPago: string, + Facturas: string, + Descripcion: string, + FechaAlta: string, + Clave: string, + ValorMn: string, + ValorDls: string, + TipoCambio: string, + ValorComercial: string, + Fracciones: string, + Caja: string +} \ No newline at end of file diff --git a/src/Services/Reportes/ReporteCuentasCerradas.Service.ts b/src/Services/Reportes/ReporteCuentasCerradas.Service.ts new file mode 100644 index 0000000..c1ca570 --- /dev/null +++ b/src/Services/Reportes/ReporteCuentasCerradas.Service.ts @@ -0,0 +1,8 @@ +import http from "../common/http-common"; +class ReporteGC50Service{ + DownloadExcel(Inicio: string, Fin: string, TipoOperacion: number, NoCliente: number, IdCorresponsal: number){ + return http.get(`ReporteCuentasCerradas/GetExcel?Inicio=${Inicio}&Fin=${Fin}&TipoOperacion=${TipoOperacion}&NoCliente=${NoCliente}&IdCorresponsal=${IdCorresponsal}`, {responseType: 'blob'}); + } +} + +export default new ReporteGC50Service(); \ No newline at end of file diff --git a/src/index.tsx b/src/index.tsx index 656d3ad..a951121 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -29,6 +29,7 @@ import { ReporteGC50 } from './Components/ReportesClientes/GC50/ReporteGC50' import RptClientesTraficos from './Components/Clientes/Traficos/RptClientesTraficos' import { RelacionFacturas } from './Components/ReportesClientes/Alen/RelacionFacturas' import { ReporteFacturasConsolidados } from './Components/ReportesClientes/Alen/ReporteFacturasConsolidados' +import { CuentasCerradas } from './Components/ReportesClientes/CuentasCerradas.tsx/CuentasCerradas' require (`./css/${process.env.REACT_APP_ENVIRONMENT}-home.css`) function PageNotFound() { @@ -86,6 +87,7 @@ root.render( }/> }/> }/> + }/> }> }/> }/>