From ccf04e181b775b8bdcfffcc3e094e18b90e60c7f Mon Sep 17 00:00:00 2001 From: Felix Morales Date: Tue, 17 Oct 2023 17:05:10 -0500 Subject: [PATCH] feature, agregar funcionamiento para que facturacion cierre traficos y pueda descargar el zip entregable para el cliente --- .../Corresponsales/TraficoCorresponsales.tsx | 142 ++++++++++++++++++ .../Utils/FileManager/FileManager.tsx | 2 +- src/Services/Utils/FileManager.Services.ts | 4 + 3 files changed, 147 insertions(+), 1 deletion(-) diff --git a/src/Components/Corresponsales/TraficoCorresponsales.tsx b/src/Components/Corresponsales/TraficoCorresponsales.tsx index 2b7c973..99c4320 100644 --- a/src/Components/Corresponsales/TraficoCorresponsales.tsx +++ b/src/Components/Corresponsales/TraficoCorresponsales.tsx @@ -117,6 +117,7 @@ import { TargetURL } from '../../Constants/TargetURL' import CentrosCostosService from '../../Services/Catalogos/CentrosCostos.Service' import ClavesPedimentosService from '../../Services/Catalogos/ClavesPedimentos.Service' import { ICatClavesPedimentos } from '../../Interfaces/Catalogos/ICatClavesPedimentos' +import FileManagerServices from '../../Services/Utils/FileManager.Services' interface IProps { IDTrafico: number @@ -318,6 +319,8 @@ export default function TraficoCorresponsales (props:IProps) { const [ClavesPedimentos, setClavesPedimentos] = useState([]) const FechaRegistro = currentDate() const msgColor = 'primary' + const [idPdfCuentaMexicana, setIdPdfCuentaMexicana] = useState(0); + const [idXmlCuentaMexicana, setIdXmlCuentaMexicana] = useState(0); const hiddenFileInputRef = useRef(null); var txtContenedores: ICorresponsalContenedores[] = []; @@ -1383,6 +1386,49 @@ export default function TraficoCorresponsales (props:IProps) { } } + const cerrarTrafico = () => { + FileManagerServices.GetClientesZip(IDTrafico) + .then(response => { + CTrafDataService.ValidateComplete({id: IDTrafico, idUsuario:UserId, estatus: 4, comentarios:'Todo Correcto'}) + .then(resp => { + setProceso(4); + setHeader('Informativo') + setMsg('Cuenta cerrada con éxito.') + setShowMsg(true) + }).catch(e => { + setHeader('Error') + setMsg('Ocurrio un error al cerrar la cuenta. Favor de intentarlo nuevamente') + setShowMsg(true) + }); + }).catch(error => { + setHeader('Error') + setMsg('No se han encontrado uno o más de los archivos obligatorios para cerrar la cuenta.') + setShowMsg(true) + return + }) + } + + const GetClientesZip = () => { + FileManagerServices.GetClientesZip(IDTrafico) + .then(response => { + downloadFile(response.data); + }).catch(error => { + setHeader('Error') + setMsg('No se han encontrado uno o más de los archivos obligatorios para cerrar la cuenta.') + setShowMsg(true) + return + }) + } + + const downloadFile = (blob: Blob) => { + const url = window.URL.createObjectURL(new Blob([blob])); + const link = document.createElement('a'); + link.href = url; + link.setAttribute('download', `expediente_${FolioTrafico}.zip`); + document.body.appendChild(link); + link.click(); + } + return (
@@ -3807,6 +3853,102 @@ export default function TraficoCorresponsales (props:IProps) { */} + = 3 ? '' : 'd-none'} + > + + + + + PDF Cuenta Mexicana + + + XML Cuenta Mexicana + + + Archivos Adicionales + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Components/Utils/FileManager/FileManager.tsx b/src/Components/Utils/FileManager/FileManager.tsx index 25c8f58..82f7aec 100644 --- a/src/Components/Utils/FileManager/FileManager.tsx +++ b/src/Components/Utils/FileManager/FileManager.tsx @@ -49,7 +49,7 @@ export const FileManager: FC = (props) => { return false } */ var ext = file.name.substr(file.name.lastIndexOf('.') + 1) - if (!props.FileType.includes(ext)) { + if (!props.FileType.includes(ext.toLocaleLowerCase())) { return false } const reader = new FileReader() diff --git a/src/Services/Utils/FileManager.Services.ts b/src/Services/Utils/FileManager.Services.ts index faddf06..4b5eb83 100644 --- a/src/Services/Utils/FileManager.Services.ts +++ b/src/Services/Utils/FileManager.Services.ts @@ -27,5 +27,9 @@ class FileManagerDataService { return http.get(`/FileManager/ConvertExcel2New?id=${fileId}&Proceso=${process}`); } + GetClientesZip(id: number){ + return http.get(`/FileManager/GetClientesZip?id=${id}`, {responseType: 'blob'}); + } + } export default new FileManagerDataService(); \ No newline at end of file