diff --git a/src/Components/Reportes/RptArcosa.tsx b/src/Components/Reportes/RptArcosa.tsx new file mode 100644 index 0000000..913f568 --- /dev/null +++ b/src/Components/Reportes/RptArcosa.tsx @@ -0,0 +1,401 @@ +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 IRptArcosa from '../../Interfaces/Reportes/IRptArcosa' +interface IProps {} + +const RptArcosa: 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>([]) + 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: 'patente', + headerName: 'Patente', + sortable: true, + filter: true, + width: 150 + }, + { + field: 'pedimento', + headerName: 'Pedimento', + sortable: true, + filter: true, + width: 150 + }, + { + field: 'pagoPedimento', + headerName: 'PagoPedimento', + sortable: true, + filter: true, + width: 200 + }, + { + field: 'regimen', + headerName: 'Regimen', + sortable: true, + filter: true, + width: 150 + }, + { + field: 'valorDls', + headerName: 'ValorDls', + sortable: true, + filter: true, + width: 150 + }, + + { + field: 'valorAduana', + headerName: 'ValorAduana', + sortable: true, + filter: true, + width: 150 + }, + { + field: 'aduana', + headerName: 'Aduana', + sortable: true, + filter: true, + width: 150 + }, + { + field: 'planta', + headerName: 'Planta', + sortable: true, + filter: true, + width: 150 + }, + { + field: 'dta', + headerName: 'DTA', + sortable: true, + filter: true, + width: 150 + }, + { + field: 'prev', + headerName: 'PREV', + sortable: true, + filter: true, + width: 150 + }, + + { + field: 'iva', + headerName: 'IVA', + sortable: true, + filter: true, + width: 150 + }, + { + field: 'ivaprev', + headerName: 'IVAPREV', + sortable: true, + filter: true, + width: 150 + }, + { + field: 'igi', + headerName: 'IGI', + sortable: true, + filter: true, + width: 150 + }, + { + field: 'cc', + headerName: 'CC', + sortable: true, + filter: true, + width: 150 + }, + { + field: 'total', + headerName: 'Total', + sortable: true, + filter: true, + width: 150 + } + ]) + + 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 + .getRptArcosa(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, 'Reporte Mensual Arcosa') + } + + function exportExcel(jsonData: any[], fileName: string): void { + let Heading = [ + [ + 'Patente', + 'Pedimento', + 'PagoPedimento', + 'Regimen', + 'ValorDls', + 'ValorAduana', + 'Aduana', + 'Planta', + 'DTA', + 'PREV', + 'IVA', + 'IVAPREV', + 'IGI', + 'CC', + 'Total' + ] + ] + + 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 RptArcosa diff --git a/src/Interfaces/Reportes/IRptArcosa.ts b/src/Interfaces/Reportes/IRptArcosa.ts new file mode 100644 index 0000000..4e62a05 --- /dev/null +++ b/src/Interfaces/Reportes/IRptArcosa.ts @@ -0,0 +1,18 @@ +export default interface IRptArcosa{ + Patente: string, + Pedimento: string, + PagoPedimento: string, + Regimen: string, + ValorDls: Number, + ValorAduana: Number, + Aduana: Number, + Planta: string, + DTA: string, + PREV : string + IVA: string, + IGI : string, + CC: string, + Total : number + +} + diff --git a/src/Services/Reportes/reportes.services.ts b/src/Services/Reportes/reportes.services.ts index 70d4020..1d3e991 100644 --- a/src/Services/Reportes/reportes.services.ts +++ b/src/Services/Reportes/reportes.services.ts @@ -22,6 +22,7 @@ import { data } from 'cypress/types/jquery' import IRptMision from '../../Interfaces/Reportes/IRptOperacionesPagadasMisionFood' import IRptOperacionesPagadasMissionFood from '../../Interfaces/Reportes/IRptOperacionesPagadasMisionFood' import IRptFacturasPedimentosPagados from '../../Interfaces/Reportes/IRptFacturasPedimentosPagados' +import IRptArcosa from '../../Interfaces/Reportes/IRptArcosa' class reportsDataService { getRptPedimentosPagados(data: DTOReporte) { return http.post>( @@ -140,6 +141,11 @@ class reportsDataService { ) } + getRptArcosa(data: DTOReporte){ + return http.post>( + '/reportes/RptArcosa', data + ); + } } diff --git a/src/index.tsx b/src/index.tsx index 6c72c7e..40f0a68 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -68,6 +68,7 @@ import RptFacturasFraccion from './Components/Reportes/RptContsFacturasFraccion' import CatConceptosConsulta from './Components/Clientes/Amazon/Catalogos/CatConceptosConsulta' import RptOperacionesPagadasMisionFood from './Components/Reportes/RptOperacionesPagadasMisionFood' import RptFacturasPedimentosPagados from './Components/Reportes/RptFacturasPedimentosPagados' +import RptArcosa from './Components/Reportes/RptArcosa' require(`./css/${process.env.REACT_APP_ENVIRONMENT}-home.css`) @@ -263,6 +264,7 @@ ReactDOM.render( path="/RptFacturasPedimentosPagados" element={} /> + } /> } />