feature, agregar funcionamiento para que facturacion cierre traficos y pueda descargar el zip entregable para el cliente

feature/ConsolidarPedimentos_20231229
Felix Morales 12 months ago
parent fff4ad3d80
commit ccf04e181b
  1. 142
      src/Components/Corresponsales/TraficoCorresponsales.tsx
  2. 2
      src/Components/Utils/FileManager/FileManager.tsx
  3. 4
      src/Services/Utils/FileManager.Services.ts

@ -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<ICatClavesPedimentos[]>([])
const FechaRegistro = currentDate()
const msgColor = 'primary'
const [idPdfCuentaMexicana, setIdPdfCuentaMexicana] = useState(0);
const [idXmlCuentaMexicana, setIdXmlCuentaMexicana] = useState(0);
const hiddenFileInputRef = useRef<HTMLInputElement>(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 (
<div>
<Card className="labelSize13px" style={{borderStyle:'none', height:'40rem', overflowY:'scroll'}}>
@ -3807,6 +3853,102 @@ export default function TraficoCorresponsales (props:IProps) {
</Row>
</Card> */}
</Tab>
<Tab
eventKey="ComprobantesFacturacion"
title="Comprobantes Facturacion"
tabClassName={Proceso >= 3 ? '' : 'd-none'}
>
<Card>
<Card.Body>
<Row>
<Col xs={4}>
<Form.Label>PDF Cuenta Mexicana</Form.Label>
</Col>
<Col xs={4}>
<Form.Label>XML Cuenta Mexicana</Form.Label>
</Col>
<Col xs={4}>
<Form.Label>Archivos Adicionales</Form.Label>
</Col>
</Row>
<Row>
<Col xs={4}>
<FileManager
IDUser={UserId}
width={'100%'}
height={100}
IDProcess={37}
IdFile={IDTrafico}
FileName={''}
canDelete={
Depto === 'Facturacion' && Proceso === 3
}
FileType={['pdf']}
Leyenda={`Seleccione el PDF para subirlo al servidor...`}
onAppendFM={function (idFile: number ): void {
setIdPdfCuentaMexicana(idFile);
}}
/>
</Col>
<Col xs={4}>
<FileManager
IDUser={UserId}
width={'100%'}
height={100}
IDProcess={38}
IdFile={IDTrafico}
FileName={''}
canDelete={
Depto === 'Facturacion' && Proceso === 3
}
FileType={['xml']}
Leyenda={`Seleccione el XML para subirlo al servidor...`}
onAppendFM={function (idFile: number): void {
setIdXmlCuentaMexicana(idFile);
}}
/>
</Col>
<Col xs={4}>
<FileManager
IDUser={UserId}
width={'100%'}
height={100}
IDProcess={39}
IdFile={IDTrafico}
FileName={''}
canDelete={
Depto === 'Facturacion' && Proceso === 3
}
FileType={['zip']}
Leyenda={`Seleccione el zip con los archivos adicionales para subirlo al servidor...`}
onAppendFM={function (idFile: number): void {
}}
/>
</Col>
</Row>
<Row className='justify-content-end'>
<Col xs={3} style={{display:'flex', justifyContent:'end'}}>
<Button
variant='primary'
onClick={GetClientesZip}
disabled={Proceso < 4}
style={{marginRight:'10px'}}
>
Descargar Zip
</Button>
<Button
variant='primary'
onClick={cerrarTrafico}
disabled={Proceso === 4}
>
Cerrar Cuenta
</Button>
</Col>
</Row>
</Card.Body>
</Card>
</Tab>
</Tabs>
</Card.Body>
</Card>

@ -49,7 +49,7 @@ export const FileManager: FC<IProps> = (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()

@ -27,5 +27,9 @@ class FileManagerDataService {
return http.get<IFileManager>(`/FileManager/ConvertExcel2New?id=${fileId}&Proceso=${process}`);
}
GetClientesZip(id: number){
return http.get(`/FileManager/GetClientesZip?id=${id}`, {responseType: 'blob'});
}
}
export default new FileManagerDataService();
Loading…
Cancel
Save