diff --git a/src/Components/Reportes/RptFacturasPedimentosPagados.tsx b/src/Components/Reportes/RptFacturasPedimentosPagados.tsx new file mode 100644 index 0000000..2ead9b9 --- /dev/null +++ b/src/Components/Reportes/RptFacturasPedimentosPagados.tsx @@ -0,0 +1,322 @@ +import React, { FC, useEffect, useState } from 'react' +// Bootstrap components +import { Button, Card, Form } from 'react-bootstrap' +import { BsSearch, BsFileEarmarkExcel } from 'react-icons/bs' +// Interfaces +import IClientes from '../../Interfaces/Catalogos/IClientes' +import IArchivoElectronico from '../../Interfaces/IArchivoElectronico' +// DTOs +import DTOReporte from '../../DTO/DTOReporte' +// Services +import reportsDataService from '../../Services/Reportes/reportes.services' +import ClientesDataService from '../../Services/Catalogos/Clientes.Services' + +import { useDispatch } from 'react-redux' +import { setArchivoElectronico } from '../../store/features/Reportes/ArchivoElectronico' +// GUI components +import { MsgInformativo } from '../Utils/Toast/msgInformativo' +import { AgGridReact } from 'ag-grid-react' +import { RowClickedEvent } from 'ag-grid-community' +import { TargetURL } from '../../Constants/TargetURL' +//Other +import moment from 'moment' +import * as XLSX from 'xlsx' +import IRptFacturasPedimentosPagados from '../../Interfaces/Reportes/IRptFacturasPedimentosPagados' +interface IProps {} + +const RptFacturasPedimentosPagados: FC = (props) => { + const [UserId, setUserId] = useState(() => { + const stickyValue = window.localStorage.getItem('UserId') + return stickyValue !== null ? JSON.parse(stickyValue) : 0 + }) + const [Data, setData] = useState>([]) + const [filteredData, setFilteredData] = useState< + Array + >([]) + const [Inicio, setInicio] = useState(currentDate()) + const [Fin, setFin] = useState(currentDate()) + const [TipoOperacion, setTipoOperacion] = useState(1) + const [Cliente, setCliente] = useState(0) + const [Clientes, setClientes] = useState>() + const [msgColor, setMsgColor] = React.useState('primary') + const [show, setShowMsg] = useState(false) + const [header, setHeader] = useState('') + const [msg, setMsg] = useState('') + const [filtro, setFiltro] = useState('') + const gridRef = React.useRef(null) + const [columnaVerPDF, setcolumnaVerPDF] = useState(false) + const dispatch = useDispatch() + const [columnDefs] = useState([ + { + field: 'referencia', + headerName: 'Referencia', + sortable: true, + filter: true, + width: 300 + }, + { + field: 'pedido', + headerName: 'Pedido', + sortable: true, + filter: true, + width: 300 + }, + { + field: 'factura', + headerName: 'Factura', + sortable: true, + filter: true, + width: 400 + }, + { + field: 'uuid', + headerName: 'UUID', + sortable: true, + filter: true, + width: 350 + }, + { + field: 'fecha', + headerName: 'Fecha', + sortable: true, + filter: true, + width: 300 + }, + + { + field: 'razonSocial', + headerName: 'RazonSocial', + sortable: true, + filter: true, + width: 300 + } + ]) + + function currentDate(): string { + var today = new Date() + var dd = String(today.getDate()).padStart(2, '0') + var mm = String(today.getMonth() + 1).padStart(2, '0') //January is 0! + var yyyy = today.getFullYear() + return yyyy + '-' + mm + '-' + dd + } + + const closeToast = (show: boolean): void => { + setShowMsg(false) + } + + const generaReporte = () => { + if (Cliente === 0) { + setHeader('Error') + setMsg('Seleccion el cliente') + setShowMsg(true) + return + } + const data: DTOReporte = { + Inicio: moment(Inicio).format('YYYY-MM-DD'), + Fin: moment(Fin).format('YYYY-MM-DD'), + TipoOperacion: TipoOperacion, + NoCliente: Cliente, + IdUsuario: UserId + } + reportsDataService + .getRptFacturasPedimentosPagados(data) + .then((response) => { + setData(response.data) + setFilteredData(response.data) + setHeader('Informativo') + setMsg('Se encontro la siguiente informacion...') + setShowMsg(true) + }) + .catch((e: Error) => { + setHeader('Error') + setMsg('Ocurrio un error: ' + e) + setShowMsg(true) + return + }) + } + + useEffect(() => { + ClientesDataService.getAllClientes(parseInt(UserId)) + .then((response) => { + setClientes(response.data) + }) + .catch((e: Error) => { + setHeader('Error') + setMsg('Ocurrio un error: ' + e) + setShowMsg(true) + return + }) + }, []) + + const downloadExcel = () => { + exportExcel(Data, 'FacturasEnPedimentos') + } + + function exportExcel(jsonData: any[], fileName: string): void { + let Heading = [ + ['Referencia', 'Pedido', 'Factura', 'UUID', 'Fecha', 'RazonSocial'] + ] + const wb = XLSX.utils.book_new() + const ws: XLSX.WorkSheet = XLSX.utils.json_to_sheet([]) + XLSX.utils.sheet_add_aoa(ws, Heading) + XLSX.utils.sheet_add_json(ws, jsonData, { origin: 'A2', skipHeader: true }) + XLSX.utils.book_append_sheet(wb, ws, 'Sheet1') + XLSX.writeFile(wb, fileName + '.xlsx') + var range = XLSX.utils.decode_range(ws['!ref?']) + for (var C = range.s.c; C <= range.e.c; ++C) { + var address = XLSX.utils.encode_col(C) + '1' // <-- first row, column number C + if (!ws[address]) continue + ws[address].v = ws[address].v.toUpperCase() + } + } + + const filtraReporte = (e: any) => { + setFiltro(e.target.value) + gridRef.current.api.setQuickFilter(e.target.value) + } + + async function getAE(e: any) { + if (e.column.colId === 'ver pedimento') { + setcolumnaVerPDF(true) + } else { + setcolumnaVerPDF(false) + } + } + + const formatNumber = (number: string, digits: number) => { + number = parseFloat(number).toFixed(digits) + let value = Number(number).toLocaleString('en') + if (!value.indexOf('NaN')) return '0.00' + return value + } + + return ( +
+ + +
+
+ setInicio(e.target.value)} + size="sm" + /> +
+
+ setFin(e.target.value)} + size="sm" + /> +
+
+ Tipo oper +
+
+ setTipoOperacion(parseInt(e.target.value))} + className="form-select form-select-sm" + > + + + +
+
+ Cliente +
+
+ { + setCliente(parseInt(e.target.value)) + }} + className="form-select form-select-sm" + > + + {Clientes + ? Clientes.map((c) => { + return c.agrupado === 1 ? ( + + ) : ( + '' + ) + }) + : null} + +
+
+ +
+
+
+
 
+
+ { + filtraReporte(e) + }} + /> +
+
+ +
+
+
+
+
+
+ getAE(e)} + > +
+ +
+ ) +} +export default RptFacturasPedimentosPagados diff --git a/src/Components/Reportes/RptOperacionesPagadasMisionFood.tsx b/src/Components/Reportes/RptOperacionesPagadasMisionFood.tsx index 2230c02..5e8c4c8 100644 --- a/src/Components/Reportes/RptOperacionesPagadasMisionFood.tsx +++ b/src/Components/Reportes/RptOperacionesPagadasMisionFood.tsx @@ -60,7 +60,20 @@ const RptOperacionesPagadasMisionFood: FC = (props) => { sortable: true, filter: true }, - { field: 'sNumero', headerName: 'Numero', sortable: true, filter: true }, + { + field: 'uuid', + headerName: 'UUID', + sortable: true, + filter: true, + width: 400 + }, + { + field: 'folioFactura', + headerName: 'FolioFactura', + sortable: true, + filter: true, + width: 500 + }, { field: 'dFechaFirmaBanco', headerName: 'FechaFirmaBanco', @@ -91,13 +104,15 @@ const RptOperacionesPagadasMisionFood: FC = (props) => { field: 'sHRazonSocial', headerName: 'SHRazonSocial', sortable: true, - filter: true + filter: true, + width: 300 }, { field: 'sHidentificadorProv', headerName: 'HidentificadorProv', sortable: true, - filter: true + filter: true, + width: 300 }, { field: 'aa', @@ -133,7 +148,8 @@ const RptOperacionesPagadasMisionFood: FC = (props) => { field: 'transportista', headerName: 'Transportista', sortable: true, - filter: true + filter: true, + width: 300 } ]) @@ -202,7 +218,8 @@ const RptOperacionesPagadasMisionFood: FC = (props) => { [ 'TipoOperacion', 'Pedimento', - 'Numero', + 'UUID', + 'FolioFactura', 'FechaFirmaBanco', 'RazonSocial', 'RFC', diff --git a/src/Interfaces/Reportes/IRptFacturasPedimentosPagados.ts b/src/Interfaces/Reportes/IRptFacturasPedimentosPagados.ts new file mode 100644 index 0000000..68fd2f2 --- /dev/null +++ b/src/Interfaces/Reportes/IRptFacturasPedimentosPagados.ts @@ -0,0 +1,10 @@ +export default interface IRptFacturasPedimentosPagados{ + +Referencia: string +Pedido: string +Factura: string +UUID: string +Fecha : string +RazonSocial : string + +} \ No newline at end of file diff --git a/src/Interfaces/Reportes/IRptOperacionesPagadasMisionFood.ts b/src/Interfaces/Reportes/IRptOperacionesPagadasMisionFood.ts index a272a6e..2578355 100644 --- a/src/Interfaces/Reportes/IRptOperacionesPagadasMisionFood.ts +++ b/src/Interfaces/Reportes/IRptOperacionesPagadasMisionFood.ts @@ -2,7 +2,8 @@ export default interface IRptOperacionesPagadasMissionFood { TipoOperacion : string, sPedimento: string, -sNumero :string, +UUID :string, +FolioFactura : string, dFechaFirmaBanco : string, sRazonSocial : string, sRFC : string, diff --git a/src/Services/Reportes/reportes.services.ts b/src/Services/Reportes/reportes.services.ts index b7039b6..70d4020 100644 --- a/src/Services/Reportes/reportes.services.ts +++ b/src/Services/Reportes/reportes.services.ts @@ -21,6 +21,7 @@ import { IRptFacturasFraccion } from '../../Interfaces/Reportes/IRptContsFactura import { data } from 'cypress/types/jquery' import IRptMision from '../../Interfaces/Reportes/IRptOperacionesPagadasMisionFood' import IRptOperacionesPagadasMissionFood from '../../Interfaces/Reportes/IRptOperacionesPagadasMisionFood' +import IRptFacturasPedimentosPagados from '../../Interfaces/Reportes/IRptFacturasPedimentosPagados' class reportsDataService { getRptPedimentosPagados(data: DTOReporte) { return http.post>( @@ -133,7 +134,11 @@ class reportsDataService { ); } - + getRptFacturasPedimentosPagados(data: DTOReporte){ + return http.post>( + '/reportes/RptFacturasPedimetosPagados', data + ) + } diff --git a/src/index.tsx b/src/index.tsx index 4dd695b..551ea09 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -66,6 +66,7 @@ import RptMonitoreoFacturasPagadasAmazon from './Components/Reportes/RptMonitore import CatFraccionesVulnerables from './Components/Catalogos/CatFraccionesVulnerables/CatFraccionesVulnerables' import RptFacturasFraccion from './Components/Reportes/RptContsFacturasFraccion' import RptOperacionesPagadasMisionFood from './Components/Reportes/RptOperacionesPagadasMisionFood' +import RptFacturasPedimentosPagados from './Components/Reportes/RptFacturasPedimentosPagados' require(`./css/${process.env.REACT_APP_ENVIRONMENT}-home.css`) @@ -252,6 +253,11 @@ ReactDOM.render( element={} /> + } + /> + } />