From 5258397b2f93b69e6f95e79b90abe5c5c18b7a56 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Dec 2022 17:23:31 -0600 Subject: [PATCH] Sele agrega al reporte la facultad de filtrar por fechas y en el search a nivel header y detail --- .../CasaCuervo/Reportes/RptPedidos.tsx | 7 +- .../Heineken/Services/Heineken.Services.ts | 4 +- .../Reportes/RptFacturasTxtHeineken.tsx | 125 ++++++++++++++++-- 3 files changed, 124 insertions(+), 12 deletions(-) diff --git a/src/Components/Clientes/CasaCuervo/Reportes/RptPedidos.tsx b/src/Components/Clientes/CasaCuervo/Reportes/RptPedidos.tsx index 7d49a7b..d865947 100644 --- a/src/Components/Clientes/CasaCuervo/Reportes/RptPedidos.tsx +++ b/src/Components/Clientes/CasaCuervo/Reportes/RptPedidos.tsx @@ -335,7 +335,12 @@ export const RptPedidos: FC = (props) => { row.estatus.includes(e.target.value) || row.comentarioGEMCO.includes(e.target.value) || row.fechaCompromiso.includes(e.target.value) || - row.fechaCruce.includes(e.target.value) + row.fechaCruce.includes(e.target.value) || + row.factura.includes(e.target.value) || + row.uuid.includes(e.target.value) || + row.trafico.includes(e.target.value) || + row.pedimento.includes(e.target.value) || + row.patente.includes(e.target.value) ) }) ) diff --git a/src/Components/Clientes/Heineken/Services/Heineken.Services.ts b/src/Components/Clientes/Heineken/Services/Heineken.Services.ts index 49c1247..35ee557 100644 --- a/src/Components/Clientes/Heineken/Services/Heineken.Services.ts +++ b/src/Components/Clientes/Heineken/Services/Heineken.Services.ts @@ -26,8 +26,8 @@ class C1868HeinekenDataService { console.log(error) }) } - GetFacturasTxt() { - return http.get(`/C2206Reportes/Rpt2206FacturasTxt`); + GetFacturasTxt(Inicio: string, Fin: string) { + return http.get(`/C2206Reportes/Rpt2206FacturasTxt?Inicio=${Inicio}&Fin=${Fin}`); } } export default new C1868HeinekenDataService(); \ No newline at end of file diff --git a/src/Components/Reportes/RptFacturasTxtHeineken.tsx b/src/Components/Reportes/RptFacturasTxtHeineken.tsx index ac8ac38..ba114cf 100644 --- a/src/Components/Reportes/RptFacturasTxtHeineken.tsx +++ b/src/Components/Reportes/RptFacturasTxtHeineken.tsx @@ -17,6 +17,7 @@ import { BsChevronRight, BsFillPencilFill, BsPaperclip, + BsSearch, BsXLg } from 'react-icons/bs' import { HiOutlineRefresh } from 'react-icons/hi' @@ -38,6 +39,10 @@ export const RptFacturasTxtHeineken: FC = (props) => { const [ShowDeleteDialog, setShowDeleteDialog] = useState(false) const [ShowDocumentsDialog, setShowDocumentsDialog] = useState(false) const [Data, setData] = useState([]) + const [DataOriginal, setDataOriginal] = useState([]) + const [Inicio, setInicio] = useState(currentDate(0)) + const [Fin, setFin] = useState(currentDate(0)) + const [filtro, setFiltro] = useState('') const [IDViaje, setIDViaje] = useState(0) const [IDCliente, setIDCliente] = useState(0) const [SCliente, setSCliente] = useState('') @@ -45,15 +50,21 @@ export const RptFacturasTxtHeineken: FC = (props) => { const [IDUsuario, setIDUsuario] = useState(0) const [toggle, setToggle] = useState(false) - const loadEveryting = () => { - loadReport() + 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 } - const loadReport = () => { - DSHeineken.GetFacturasTxt() + const loadReport = (Inicio: string, Fin: string) => { + DSHeineken.GetFacturasTxt(Inicio, Fin) .then((response) => { console.log(response.data) setData(response.data) + setDataOriginal(response.data) }) .catch((e: Error) => { alert('Ocurrio un error' + e.message.toString()) @@ -61,7 +72,7 @@ export const RptFacturasTxtHeineken: FC = (props) => { } useEffect(() => { - loadEveryting() + loadReport(currentDate(0), currentDate(0)) }, []) const changeToggle = (row: I2206FacturasTxt) => { @@ -80,13 +91,109 @@ export const RptFacturasTxtHeineken: FC = (props) => { } } + const filtraReporte = (e: any) => { + setFiltro(e.target.value) + if (e.target.value.length > 0) { + setData( + Data + .filter(function (row) { + return ( + row.delivery.toLowerCase().includes(e.target.value.toLocaleLowerCase()) || + row.fecha.toLowerCase().includes(e.target.value.toLocaleLowerCase()) || + row.factura.toLowerCase().includes(e.target.value.toLocaleLowerCase()) || + row.poCliente.toLowerCase().includes(e.target.value.toLocaleLowerCase()) || + row.heineken.toLowerCase().includes(e.target.value.toLocaleLowerCase()) || + row.destino.toLowerCase().includes(e.target.value.toLocaleLowerCase()) || + row.moneda.toLowerCase().includes(e.target.value.toLocaleLowerCase()) || + row.numero4.toString().includes(e.target.value) || + row.numero5.toString().includes(e.target.value) || + row.numero6.toString().includes(e.target.value) || + row.unidad.toLowerCase().includes(e.target.value.toLocaleLowerCase()) || + row.numero7.toString().includes(e.target.value) || + row.numero8.toString().includes(e.target.value) || + row.incoterm.toLowerCase().includes(e.target.value.toLocaleLowerCase()) || + row.incoterm2.toLowerCase().includes(e.target.value.toLocaleLowerCase()) || + row.pedidoSAP.toLowerCase().includes(e.target.value.toLocaleLowerCase()) || + row.transportista.toLowerCase().includes(e.target.value.toLocaleLowerCase()) || + row.caja.toLowerCase().includes(e.target.value.toLocaleLowerCase()) || + row.numero12.toString().includes(e.target.value) || + row.detail.filter (det => + det.seisDigitos.toString().includes(e.target.value) || + det.veinteDigitos.toString().includes(e.target.value) || + det.descripcion.toLocaleLowerCase().includes(e.target.value.toLocaleLowerCase()) || + det.medida.toString().includes(e.target.value) || + det.num1.toString().includes(e.target.value) || + det.num2.toString().includes(e.target.value) || + det.num3.toString().includes(e.target.value) || + det.unidad.toLowerCase().includes(e.target.value.toLowerCase()) || + det.hNumero4.toString().includes(e.target.value) || + det.hNumero6.toString().includes(e.target.value) || + det.hNumero7.toString().includes(e.target.value) || + det.hNumero8.toString().includes(e.target.value) + ).length>0 + ) + }) + ) + } else { + setData(DataOriginal) + } + } + return (
- - Reporte de facturas TXT: Heineken - - + + + + Reporte de facturas TXT: Heineken + + Inicio + setInicio(e.target.value)} + size="sm" + /> + Hasta + setFin(e.target.value)} + size="sm" + /> + + + { + filtraReporte(e) + }} + /> + + + +