From 8a798d224997697d4731de7a3017f9265a04c413 Mon Sep 17 00:00:00 2001 From: Felix Morales Date: Tue, 16 Jan 2024 12:13:18 -0600 Subject: [PATCH] Creacion del funcionamiento para agregar varias rectificaciones a un mismo trafico --- .../Clientes/Traficos/TraficoCliente.tsx | 688 ++++++------------ .../PedimentosConsolidados.tsx | 248 ++----- .../HistorialRectificaciones.tsx | 85 +++ .../Rectificaciones/NuevaRectificacion.tsx | 348 +++++++++ .../Corresponsales/TraficoCorresponsales.tsx | 94 +-- .../DTORectificacionHistorico.ts | 13 +- .../ICorresponsalRectificacionHistorico.ts | 3 +- .../Corresponsales.Trafico.Services.ts | 4 +- ...sponsalesPedimentosRectificacionesSlice.ts | 40 + src/store/store.ts | 4 +- 10 files changed, 839 insertions(+), 688 deletions(-) create mode 100644 src/Components/Corresponsales/Rectificaciones/HistorialRectificaciones.tsx create mode 100644 src/Components/Corresponsales/Rectificaciones/NuevaRectificacion.tsx create mode 100644 src/store/features/Corresponsales/CorresponsalesPedimentosRectificacionesSlice.ts diff --git a/src/Components/Clientes/Traficos/TraficoCliente.tsx b/src/Components/Clientes/Traficos/TraficoCliente.tsx index b133788..a897ed2 100644 --- a/src/Components/Clientes/Traficos/TraficoCliente.tsx +++ b/src/Components/Clientes/Traficos/TraficoCliente.tsx @@ -80,6 +80,11 @@ import FileManager from "../../Utils/FileManager/FileManager" import { MFileManager } from "../../Utils/MFileManager/MFileManager" import { MsgInformativo } from "../../Utils/Toast/msgInformativo" import DatePicker from 'react-datepicker' +import { populateRectificaciones } from "../../../store/features/Corresponsales/CorresponsalesPedimentosRectificacionesSlice" +import { NuevaRectificacion } from "../../Corresponsales/Rectificaciones/NuevaRectificacion" +import { PedimentosConsolidados } from "../../Corresponsales/PedimentosConsolidados/PedimentosConsolidados" +import { populatePedimentos } from "../../../store/features/Corresponsales/CorresponsalesPedimentosConsolidadosSlice" +import PedimentosConsolidadosService from '../../../Services/Corresponsalias/Corresponsales.Trafico.Pedimento.Consolidados.Service' interface IProps { IDTrafico: number onClose: (val: boolean) => void @@ -138,6 +143,9 @@ export default function TraficoCliente(props:IProps){ (state: RootState) => state.CCueCompEstatus.CorresponsalesCuentasComplementariasEstatus ) + const mCPedimentosConsolidados = useSelector( + (state:RootState) => state.CPedimentosConsolidados.PedimentosConsolidados + ) const mCProveedores = useSelector((state:RootState) => state.CatProveedores.CatalogoProveedores) const [ModalSize, setModalSize] = useState('sm') @@ -207,6 +215,8 @@ export default function TraficoCliente(props:IProps){ 'Facturas pagos a terceros' ) const [LblAnticipos, setLblAnticipos] = useState('Anticipos') + const [LblPedimentos, setLblPedimentos] = useState('Pedimentos Consolidados') + const [LblRectificaciones, setLblRectificaciones] = useState('Ped. Rectificados') const [StatusTrafico, setStatusTrafico] = useState(1) const [StatusColor, setStatusColor] = useState('#FFFFFF') const [PagosaTerceros, setPagosaTerceros] = useState(0) @@ -282,7 +292,7 @@ export default function TraficoCliente(props:IProps){ const [nextStepModalBody, setNextStepModalBody] = useState(""); const [CargoPara, setCargoPara] = useState(0); const [CausaRectificacion, setCausaRectificacion] = useState(''); - const [EncabezadoPedimento1, setEncabezadoPedimento1] = useState("Pedimento"); + const [EncabezadoPedimento1, setEncabezadoPedimento1] = useState("Pedimentos"); const [EncabezadoPedimento2, setEncabezadoPedimento2] = useState("."); const [CentroCostos, setCentroCostos] = useState(''); const [ClaveClienteFacturacion, setClaveClienteFacturacion] = useState(0); @@ -726,6 +736,10 @@ export default function TraficoCliente(props:IProps){ setShowMsg(true) return }) + PedimentosConsolidadosService.GetAll(IDTrafico) + .then((resp) => { + dispatch(populatePedimentos(resp.data)) + }) loadRectificacionHistorico() DoesThe2ZipFileExists() } @@ -733,15 +747,15 @@ export default function TraficoCliente(props:IProps){ const loadRectificacionHistorico = () => { CTrafDataService.GetRectificacionHistorico(IDTrafico) .then((response) => { - - if (response.data.id > 0) { - setEncabezadoPedimento1("Pedimento Rectificado") - setEncabezadoPedimento2("Pedimento Original") - setAduanaH(response.data.aduana.toString()) - setPatenteH(response.data.patente.toString()) - setPedimentoH(response.data.pedimento.toString()) - setClavePedimentoH(response.data.clave) - setFechaPagoH(response.data.fechaPago) + dispatch(populateRectificaciones(response.data)) + if (response.data.length > 0) { + let ultimaRectificacion = response.data[response.data.length-1] + setEncabezadoPedimento1("Pedimento Master Rectificado") + setAduanaH(ultimaRectificacion.aduana.toString()) + setPatenteH(ultimaRectificacion.patente.toString()) + setPedimentoH(ultimaRectificacion.pedimento.toString()) + setClavePedimentoH(ultimaRectificacion.clave) + setFechaPagoH(ultimaRectificacion.fechaPago) } }) .catch((e: Error) => { @@ -1035,6 +1049,12 @@ export default function TraficoCliente(props:IProps){ setValorFacturasDls(total) }, [mCFacturas, IDTrafico, IDCliente]) + useEffect(() => { + let ant = mCPedimentosConsolidados.filter(x => x.id > 0) + let label = `Pedimentos Consolidados (${ant.length})` + setLblPedimentos(label) + }, [mCPedimentosConsolidados]) + function calculateDaysBetweenDates(date1: Date, date2: Date) { var oneDay = 24 * 60 * 60 * 1000 var date1InMillis = date1.getTime() @@ -1186,37 +1206,6 @@ export default function TraficoCliente(props:IProps){ return time.getHours() > 12 ? 'text-success' : 'text-error' } - const generaRectificacion = () => { - if (Aduana && Patente && Pedimento && ClavePedimento.length>0 && FechaPago) { - const data : DTORectificacionHistorico = { - IdTrafico: IDTrafico, - IdUsuario: UserId - } - CTrafDataService.AppendRectificacionHistorico(data) - .then((response) => { - console.log(response); - if(response.data) loadRectificacionHistorico() - else{ - setHeader('Error') - setMsg('Para poder generar la rectificación asegurese de GUARDAR los datos: Patente, Aduana, Pedimento, Clave, Fecha pago') - setShowMsg(true) - return - } - }) - .catch((e: Error) => { - setHeader('Error') - setMsg('Ocurrio un error: ' + e) - setShowMsg(true) - return - }) - } else { - setHeader('Error') - setMsg('Parea poder generar este proceso es necesario que los siguientes campos tengan informacion: Patente, Aduana, Pedimento, Clave, Fecha pago') - setShowMsg(true) - return - } - } - const concatFacturasPedidos = (facturas: ICorresponsalFacturas[]) => { let pedidos = ""; facturas.forEach((factura, index) => { @@ -1309,6 +1298,10 @@ export default function TraficoCliente(props:IProps){ link.click(); } + const showHistorialRectificaciones = () => { + setLoadComponent(14); + setShowModal(true); + } return (
@@ -1342,10 +1335,7 @@ export default function TraficoCliente(props:IProps){ { - showModalBox(11) - }} - style={{ cursor: 'pointer', display: 'flex'}} + style={{ display: 'flex'}} > - - - {showModalBox(10)}} - style={{ cursor: 'pointer' }}> -  Precuenta - - - { - setIDTabulador(parseInt(e.target.value)) - }} - value={IDTabulador} - className="form-select form-select-sm" - > - - {Tabuladores - ? Tabuladores.map((t) => { - return ( - - ) - }) - : null} - - @@ -1579,14 +1541,7 @@ export default function TraficoCliente(props:IProps){ - { - return Depto === 'Corresponsalias' - ? showModalBox(1) - : '' - }} - style={{ cursor: 'pointer' }} - > + @@ -1789,168 +1744,181 @@ export default function TraficoCliente(props:IProps){
{EncabezadoPedimento1} - - - - Trafico - + + + + + + Trafico + { + setTrafico(e.target.value) + }} + /> + + + + + Aduana + + + + + + Patente + + + + + + + + + Pedimento + + { + const { value } = values + if(value.length === 7 ){ + CTrafDataService.ValidaTraficoDuplicado(Aduana, Patente, value, IDTrafico).then( response => { + if(response.data !== ""){ + setHeader('Informativo') + setMsg(`Pedimento Duplicado.\n\rLa referencia ${response.data} ya cuenta con los mismos datos de aduana, patente y pedimento`) + setShowMsg(true) + return + } + setPedimento(value.length === 0 ? 0 : value) + }) + } + }} + style={{ + fontSize: '18px', + backgroundColor: '#FEFDF5', + border: '2px solid #837F5D', + width: '100%', + textAlign: 'right', + borderRadius: '10px' + }} + /> + + + + + Clave + { + setClavePedimento(e.target.value) + }} + className="form-select form-select-sm" + value={ClavePedimento} + disabled={(Depto !== 'Corresponsalias')} + > + + {ClavesPedimentos + ? ClavesPedimentos.map((item, index) => { + return ( + + ) + }) + : ''} + + + + + + Fec. Pago + { - setTrafico(e.target.value) - }} - /> - - - - - Aduana - - - - - - Patente + onChange={(e) => setFechaPago(e.target.value)} + /> + + + + + Cargo A + { + setCargoPara(parseInt(e.target.value)) + }} + + > + + + + + + + + + + Causa Rectificacion: + + setCausaRectificacion(e.target.value)} + style={{visibility: AduanaH === '' ? 'hidden':'visible'}} /> - - - - - { - openSOIA() - }} - style={{ cursor: 'pointer' }} - > - Pedimento - - { - const { value } = values - setPedimento(value.length === 0 ? 0 : value) - }} - style={{ - fontSize: '18px', - backgroundColor: '#FEFDF5', - border: '2px solid #837F5D', - width: '100%', - textAlign: 'right', - borderRadius: '10px' - }} - /> - - - - - - - Clave - { - setClavePedimento(e.target.value) - }} - className="form-select form-select-sm" - value={ClavePedimento} - disabled={(Depto !== 'Corresponsalias')} - > - - {ClavesPedimentos - ? ClavesPedimentos.map((item, index) => { - return ( - - ) - }) - : ''} - - - - - - Fec. Pago - setFechaPago(e.target.value)} - /> - - - - - Cargo A - { - setCargoPara(parseInt(e.target.value)) - }} - - > - - - - - - - - - - Causa Rectificacion: - - - setCausaRectificacion(e.target.value)} - style={{visibility: AduanaH === '' ? 'hidden':'visible'}} - /> - - + +
- {EncabezadoPedimento2} + Última Rectificación - 0 && !(AduanaH.length>0 && PatenteH.length>0 && PedimentoH.length>0 && FechaPagoH.length>0)) ? 'visible' : 'hidden' }}> - + + Aduana @@ -1997,7 +1965,7 @@ export default function TraficoCliente(props:IProps){ - + Pedimento @@ -3277,240 +3245,6 @@ export default function TraficoCliente(props:IProps){ - - - - - - - - - {/* - - Pedimento - - { - const { value } = values - setPedimento(value.length === 0 ? 0 : value) - }} - style={ - Depto === 'Corresponsalias' - ? { - fontSize: '18px', - backgroundColor: '#FEFDF5', - border: '2px solid #837F5D', - width: '100px', - textAlign: 'right', - borderRadius: '10px', - } - : { - fontSize: '16px', - backgroundColor: '#FEFDF5', - border: '2px solid #837F5D', - width: '100px', - textAlign: 'right', - borderRadius: '10px', - } - } - /> - - Fecha pago - - Motivo - - - */} - - = 3 ? '' : 'd-none'} - > - - - - - PDF Cuenta Mexicana - - - XML Cuenta Mexicana - - - - Total Honorarios A.A - Total Gastos Terceros - - - - - - - - - - - - - - { - const { value } = values - setTotalHonorariosAA(value) - }} - style={{ - fontSize: '18px', - backgroundColor: '#FEFDF5', - border: '2px solid #837F5D', - width: '100%', - textAlign: 'right', - borderRadius: '10px', - paddingLeft: '20px', - paddingRight: '10px', - }} - /> - - - { - const { value } = values - setTotalGastosTerceros(value) - }} - style={{ - fontSize: '18px', - backgroundColor: '#FEFDF5', - border: '2px solid #837F5D', - width: '100%', - textAlign: 'right', - borderRadius: '10px', - paddingLeft: '20px', - paddingRight: '10px', - }} - /> - - - - - - - PDF de Gastos a Terceros - - - Archivos Adicionales - - - - - - - - - - - - - - - - - - - - - - @@ -3521,7 +3255,7 @@ export default function TraficoCliente(props:IProps){ dialogClassName={ LoadComponent === 1 || LoadComponent === 2 || LoadComponent === 9 ? 'modal-90w' - : 'modal-50w' + : LoadComponent === 13 || LoadComponent === 14 ? 'modal-70w' : 'modal-50w' } > @@ -3602,6 +3336,26 @@ export default function TraficoCliente(props:IProps){ />
) : null} + {LoadComponent === 13 ? ( +
+ +
+ ) : null} + {LoadComponent === 14? ( +
+ +
+ ) : null} = (props) => { const [msg, setMsg] = useState('') const msgColor = 'primary' + const [showModal, setShowModal] = useState(false) + const [LoadComponent, setLoadComponent] = useState(0) + const [Id, setId] = useState(0) const [Aduana, setAduana] = useState(props.Aduana) const [Patente, setPatente] = useState(props.Patente) @@ -37,6 +45,7 @@ export const PedimentosConsolidados:React.FC = (props) => { const [ClavePedimento, setClavePedimento] = useState(''); const [FechaPago, setFechaPago] = useState('') + const [IdPedimentoH, setIdPedimentoH] = useState(0) const [AduanaH, setAduanaH] = useState(0) const [PatenteH, setPatenteH] = useState(0) const [PedimentoH, setPedimentoH] = useState(0) @@ -44,74 +53,8 @@ export const PedimentosConsolidados:React.FC = (props) => { const [FechaPagoH, setFechaPagoH] = useState('') const [isRectificacion, setIsRectificacion] = useState(false) const mCPedimentosConsolidados = useSelector((state:RootState) => state.CPedimentosConsolidados.PedimentosConsolidados) - const [columnDefs] = useState([ - props.Depto === 'Corresponsalias' ? - { - field: 'id', - headerName: 'Acciones', - width: 120, - sortable: true, - filter: true, - cellRenderer: (params: any) => { - return ( -
- - { - loadRow(params.data) - }} - style={{ cursor: 'pointer' }} - /> - -     - - { - Delete(params.data.id) - }} - style={{ cursor: 'pointer' }} - /> - -
- ) - } - } : { - field: 'id', - headerName: 'Acciones', - width: 110, - sortable: true, - filter: true, - }, - { field: 'patente', width: 110, sortable: true, filter: true }, - { field: 'aduana', width: 110, sortable: true, filter: true }, - { field: 'pedimento', width: 120, sortable: true, filter: true }, - { field: 'clave', width: 100, sortable: true, filter: true }, - { - field: 'fechaPago', - sortable: true, - filter: true, - cellRenderer: (params: any) => { - if (params.value) return params.value.substring(0, 10) - else return '' - }, - },props.Depto === 'Corresponsalias' ? - { - field: 'id', - headerName: '', - width: 120, - sortable: true, - filter: true, - flex: 1, //Se encarga de llenar el espacio sobrante de las columnas - cellRenderer: (params: any) => { - return ( -
- -
- ) - } - } : {} - ]) - const [Data, setData] = useState() + const mcRectificaciones = useSelector((state:RootState) => state.CRectificaciones.RectificacionesPedimentos) + const [Rectificaciones, setRectificaciones] = useState([]); const cleanForm = () => { setId(0) @@ -156,16 +99,16 @@ export const PedimentosConsolidados:React.FC = (props) => { }).then(resp => { if(Id > 0){ dispatch(updatePedimento(resp.data)) - cleanForm() setHeader('Informativo') setMsg('Datos actualizados correctamente') setShowMsg(true) - return + }else{ + dispatch(addPedimento(resp.data)) + setHeader('Informativo') + setMsg('Pedimento guardado correctamente') + setShowMsg(true) } - dispatch(addPedimento(resp.data)) - setHeader('Informativo') - setMsg('Pedimento guardado correctamente') - setShowMsg(true) + cleanForm() return }).catch((e) => { setHeader('Error') @@ -197,31 +140,13 @@ export const PedimentosConsolidados:React.FC = (props) => { return }) } - - const PrepareRectificacion = (pedimento: DTOPedimentosConsolidados) => { - setIsRectificacion(true) - setAduanaH(pedimento.aduana) - setPatenteH(pedimento.patente) - setPedimentoH(pedimento.pedimento) - setClavePedimentoH(pedimento.clave) - setFechaPagoH(pedimento.fechaPago) - } - - const CancelIsRectificacion = () => { - setIsRectificacion(false) - setAduanaH(0) - setPatenteH(0) - setPedimentoH(0) - setClavePedimentoH('') - setFechaPagoH('') - } return ( <> {props.Depto === 'Corresponsalias' ? <> - Rectificación + = (props) => { onValueChange={(values: any) => { const { value } = values if(value.length === 7 ){ - CorresponsalesTraficoServices.ValidaTraficoDuplicado(Aduana, Patente, value, props.IdTrafico).then( response => { + CTrafDataService.ValidaTraficoDuplicado(Aduana, Patente, value, props.IdTrafico).then( response => { if(response.data !== ""){ setHeader('Informativo') setMsg(`Pedimento Duplicado.\n\rLa referencia ${response.data} ya cuenta con los mismos datos de aduana, patente y pedimento`) @@ -323,86 +248,65 @@ export const PedimentosConsolidados:React.FC = (props) => { - - Original - - - - - Aduana - - - - - - Patente - - - - - - Pedimento - - - - - - Clave - - - - - - Fec. Pago - - - - - - -
: ("") } -
- +
+ + + {props.Depto === 'Corresponsalias' ? : ''} + + + {mCPedimentosConsolidados + ? mCPedimentosConsolidados.map((item, index) => { + return item.id > 0 ? + + + {props.Depto === 'Corresponsalias' ? + : '' + } + + + + + + + : '' + }) + : ''} + +
#AccionesAduanaPatentePedimentoClaveFecha de Pago
{index}
+ + { + loadRow(item) + }} + style={{ cursor: 'pointer' }} + /> + +     + + { + Delete(item.id) + }} + style={{ cursor: 'pointer' }} + /> + +
{item.aduana}{item.patente}
{item.pedimento} {item.id === 0 ? {'⭐'} : ''}
{item.clave}{item.fechaPago ? item.fechaPago.substring(0,10) : ''}
{ - setShowMsg(false) - }} - /> + show={show} + msg={msg} + header={header} + msgColor={msgColor} + closeToast={() => { + setShowMsg(false) + }} + /> + ) } \ No newline at end of file diff --git a/src/Components/Corresponsales/Rectificaciones/HistorialRectificaciones.tsx b/src/Components/Corresponsales/Rectificaciones/HistorialRectificaciones.tsx new file mode 100644 index 0000000..43061bd --- /dev/null +++ b/src/Components/Corresponsales/Rectificaciones/HistorialRectificaciones.tsx @@ -0,0 +1,85 @@ +import { useEffect, useState } from "react" +import { Alert, Card, Col, Row, Table } from "react-bootstrap" +import { useSelector } from "react-redux" +import { RootState } from "../../../store/store" +import { AgGridReact } from "ag-grid-react" +import ICorresponsalRectificacionHistorico from "../../../Interfaces/Corresponsales/ICorresponsalRectificacionHistorico" + +interface IProps{ + //pedimento: number + IdPedimentoConsolidado: string +} + +export const HistorialRectificaciones: React.FC = (props) => { + const [columnDefs] = useState([ + { field: 'patente', width: 110, sortable: true, filter: true }, + { field: 'aduana', width: 110, sortable: true, filter: true }, + { field: 'pedimento', width: 120, sortable: true, filter: true }, + { field: 'clave', width: 100, sortable: true, filter: true }, + { + field: 'fechaPago', + sortable: true, + filter: true, + cellRenderer: (params: any) => { + if (params.value) return params.value.substring(0, 10) + else return '' + }, + }, + { + field: 'fhCreacion', + sortable: true, + filter: true, + cellRenderer: (params: any) => { + if (params.value) return params.value + else return '' + }, + flex:1 + }, + ]) + const mcRectificaciones = useSelector((state:RootState) => state.CRectificaciones.RectificacionesPedimentos) + const [Rectificaciones, setRectificaciones] = useState([]); + useEffect(()=>{ + if(props.IdPedimentoConsolidado !== '#') + setRectificaciones(mcRectificaciones.filter(x => x.idPedimentoConsolidado === + props.IdPedimentoConsolidado)) + else + setRectificaciones(mcRectificaciones) + },[mcRectificaciones, props.IdPedimentoConsolidado]) + + return( +
+ + + Historial de Pedimentos Rectificados + + +
+
+ + + + + + {Rectificaciones + ? Rectificaciones.map((item, index) => { + return( + + + + + + + + + ) + }) + : ''} + +
#AduanaPatentePedimentoClaveFecha de Pago
{index + 1}{item.aduana}{item.patente}{item.pedimento}{item.clave}{item.fechaPago ? item.fechaPago.substring(0,10) : ''}
+
+
+ ) +} \ No newline at end of file diff --git a/src/Components/Corresponsales/Rectificaciones/NuevaRectificacion.tsx b/src/Components/Corresponsales/Rectificaciones/NuevaRectificacion.tsx new file mode 100644 index 0000000..bb20c81 --- /dev/null +++ b/src/Components/Corresponsales/Rectificaciones/NuevaRectificacion.tsx @@ -0,0 +1,348 @@ +import { useState } from "react"; +import { Button, Card, Col, Form, FormControl, FormLabel, Row } from "react-bootstrap" +import CurrencyFormat from "react-currency-format"; +import { IconContext } from "react-icons"; +import { FaEraser } from "react-icons/fa"; +import CTrafDataService from "../../../Services/Corresponsalias/Corresponsales.Trafico.Services" +import { useDispatch, useSelector } from "react-redux"; +import { ICatClavesPedimentos } from "../../../Interfaces/Catalogos/ICatClavesPedimentos"; +import { DTOPedimentosConsolidados } from "../../../DTO/Corresponsales/DTOPedimentosConsolidados"; +import DTORectificacionHistorico from "../../../DTO/Corresponsales/DTORectificacionHistorico"; +import { updatePedimento } from "../../../store/features/Corresponsales/CorresponsalesPedimentosConsolidadosSlice"; +import { addRectificacion } from "../../../store/features/Corresponsales/CorresponsalesPedimentosRectificacionesSlice"; +import ICorresponsalRectificacionHistorico from "../../../Interfaces/Corresponsales/ICorresponsalRectificacionHistorico"; +import { RootState } from "../../../store/store"; +import { HistorialRectificaciones } from "./HistorialRectificaciones"; +import { MsgInformativo } from "../../Utils/Toast/msgInformativo"; + +interface IProps { + IdTrafico: number + Aduana: number + Patente: number + ClavesPedimento: ICatClavesPedimentos[] + Pedimentos: DTOPedimentosConsolidados[] + Depto: string + UserId: number + onAppendRectificacion: (data: DTORectificacionHistorico) => void +} + +export const NuevaRectificacion:React.FC = (props) => { + const dispatch = useDispatch() + const [header, setHeader] = useState('') + const [show, setShowMsg] = useState(false) + const [msg, setMsg] = useState('') + const msgColor = 'primary' + + const [showHistorial, setShowHistorial] = useState(false) + + const [Id, setId] = useState(0) + const [Aduana, setAduana] = useState(props.Aduana) + const [Patente, setPatente] = useState(props.Patente) + const [Pedimento, setPedimento] = useState(0) + const [ClavePedimento, setClavePedimento] = useState(''); + const [FechaPago, setFechaPago] = useState('') + + const [IdPedimentoH, setIdPedimentoH] = useState(0) + const [AduanaH, setAduanaH] = useState(props.Aduana) + const [PatenteH, setPatenteH] = useState(props.Patente) + const [PedimentoH, setPedimentoH] = useState(0) + const [ClavePedimentoH, setClavePedimentoH] = useState('') + const [FechaPagoH, setFechaPagoH] = useState('') + + const [IdPedimentoConsolidadoSelected, setIdPedimentoConsolidadoSelected] = useState("#") + + + function setDate(fecha: string | undefined): string { + if (!fecha) return '' + else { + var dd = fecha?.substring(8, 10) + var mm = fecha?.substring(5, 7) + var yyyy = fecha?.substring(0, 4) + return yyyy + '-' + mm + '-' + dd + } + } + + const generaRectificacion = () => { + if (Aduana && Patente && Pedimento && ClavePedimento.length>0 && FechaPago) { + const data : DTORectificacionHistorico = { + IdTrafico: props.IdTrafico, + IdUsuario: props.UserId, + IdPedimento: IdPedimentoH, + Aduana: Aduana, + Patente: Patente, + Pedimento: Pedimento, + Clave: ClavePedimento, + FechaPago: FechaPago, + AduanaH: AduanaH, + PatenteH: PatenteH, + PedimentoH: PedimentoH, + ClaveH: ClavePedimentoH, + FechaPagoH: FechaPagoH + } + CTrafDataService.AppendRectificacionHistorico(data) + .then((response) => { + setHeader('Informativo') + setMsg('La rectificación se creó correctamente') + setShowMsg(true) + dispatch( + updatePedimento({ + id: data.IdPedimento, + idTrafico: data.IdTrafico, + aduana: data.Aduana, + patente: data.Patente, + pedimento: data.Pedimento, + clave: data.Clave, + fechaPago: data.FechaPago + }) + ) + dispatch( + addRectificacion({ + id: response.data.id, + usuario: response.data.usuario, + idTrafico: response.data.idTrafico, + aduana: response.data.aduana, + patente: response.data.patente, + pedimento: response.data.pedimento, + clave: response.data.clave, + fechaPago: response.data.fechaPago, + fhCreacion: response.data.fhCreacion, + activo: response.data.activo, + idPedimentoConsolidado: response.data.idPedimentoConsolidado + }) + ) + cleanForm() + props.onAppendRectificacion(data) + return + }) + .catch((e: Error) => { + setHeader('Error') + setMsg('Ocurrió un error al crear la rectificación. Favor de actualizar la página e intentarlo nuevamente.') + setShowMsg(true) + return + }) + } else { + setHeader('Error') + setMsg('Parea poder generar este proceso es necesario que los siguientes campos tengan informacion: Patente, Aduana, Pedimento, Clave, Fecha pago') + setShowMsg(true) + return + } + } + + const PrepareRectificacion = (idPedimentoConsolidado: number) => { + var dto = props.Pedimentos.filter(x => x.id === idPedimentoConsolidado)[0] + setIdPedimentoH(dto.id) + setAduanaH(dto.aduana) + setPatenteH(dto.patente) + setPedimentoH(dto.pedimento) + setClavePedimentoH(dto.clave) + setFechaPagoH(dto.fechaPago) + setShowHistorial(true) + } + + const CancelIsRectificacion = () => { + setAduanaH(0) + setPatenteH(0) + setPedimentoH(0) + setClavePedimentoH('') + setFechaPagoH('') + setIdPedimentoH(0) + } + + const cleanForm = () => { + setIdPedimentoConsolidadoSelected("#") + setIdPedimentoH(0) + setPedimentoH(0) + setClavePedimentoH('') + setFechaPagoH('') + setId(0) + setPedimento(0) + setClavePedimento('') + setFechaPago('') + } + + + return ( + + + { props.Depto === 'Corresponsalias' ? <> + + Original + + + + + Aduana + + + + + + Patente + + + + + + Pedimento + { + setIdPedimentoConsolidadoSelected(e.target.value) + PrepareRectificacion(+e.target.value) + }} + value={IdPedimentoConsolidadoSelected} + className="form-select form-select-sm" + > + + {props.Pedimentos + ? props.Pedimentos.map((p) => { + return ( + + ) + }) + : null} + + + + + + Clave + + + + + + Fec. Pago + + + + + + + + + Rectificación + { + cleanForm(); + }} + > + + + + + + + Aduana + setAduana(+e.target.value)}> + + + + + Patente + setPatente(+e.target.value)}> + + + + + Pedimento + { + const { value } = values + if(value.length === 7 ){ + CTrafDataService.ValidaTraficoDuplicado(Aduana, Patente, value, props.IdTrafico).then( response => { + if(response.data !== ""){ + setHeader('Informativo') + setMsg(`Pedimento Duplicado.\n\rLa referencia ${response.data} ya cuenta con los mismos datos de aduana, patente y pedimento`) + setShowMsg(true) + return + } + setPedimento(value.length === 0 ? 0 : value) + }) + } + }} + style={{ + fontSize: '18px', + backgroundColor: '#FEFDF5', + border: '2px solid #837F5D', + width: '100%', + textAlign: 'right', + borderRadius: '10px' + }} + /> + + + + + Clave + { + setClavePedimento(e.target.value) + }} + className="form-select form-select-sm" + value={ClavePedimento} + > + + {props.ClavesPedimento + ? props.ClavesPedimento.map((item, index) => { + return ( + + ) + }) + : ''} + + + + + + Fec. Pago + setFechaPago(e.target.value)} + /> + + + + +
: '' } + + { + setShowMsg(false) + }} + /> +
+
+ ) +} \ No newline at end of file diff --git a/src/Components/Corresponsales/TraficoCorresponsales.tsx b/src/Components/Corresponsales/TraficoCorresponsales.tsx index 4c84621..494a21e 100644 --- a/src/Components/Corresponsales/TraficoCorresponsales.tsx +++ b/src/Components/Corresponsales/TraficoCorresponsales.tsx @@ -110,7 +110,6 @@ import ICorresponsalesCatTraficoEstatus from '../../Interfaces/Corresponsales/IC import ICorresponsalCatMediosEmbarque from '../../Interfaces/Corresponsales/ICorresponsalCatMediosEmbarque' import { CuentasComplementarias } from './CuentasComplementarias/CuentasComplementarias' import DTOTraficoCompleto from '../../DTO/Corresponsales/DTOTraficoCompleto' -import DTORectificacionHistorico from '../../DTO/Corresponsales/DTORectificacionHistorico' import moment from 'moment' import ICorresponsalContenedores from '../../Interfaces/Corresponsales/ICorresponsalContenedores' import ICorresponsalFacturas from '../../Interfaces/Corresponsales/ICorresponsalFacturas' @@ -127,6 +126,9 @@ import CorresponsalesFacturasServices from '../../Services/Corresponsalias/Corre import { PedimentosConsolidados } from './PedimentosConsolidados/PedimentosConsolidados' import PedimentosConsolidadosService from '../../Services/Corresponsalias/Corresponsales.Trafico.Pedimento.Consolidados.Service' import { populatePedimentos } from '../../store/features/Corresponsales/CorresponsalesPedimentosConsolidadosSlice' +import { populateRectificaciones } from '../../store/features/Corresponsales/CorresponsalesPedimentosRectificacionesSlice' +import { NuevaRectificacion } from './Rectificaciones/NuevaRectificacion' +import DTORectificacionHistorico from '../../DTO/Corresponsales/DTORectificacionHistorico' interface IProps { IDTrafico: number @@ -261,6 +263,9 @@ export default function TraficoCorresponsales (props:IProps) { const [LblPedimentos, setLblPedimentos] = useState(() => { return Depto === 'Corresponsalias' ? 'Consolidar Pedimentos' : 'Pedimentos Consolidados' }) + const [LblRectificaciones, setLblRectificaciones] = useState(() => { + return Depto === 'Corresponsalias' ? 'Agregar Rectificaciones' : 'Ped. Rectificados' + }) const [StatusTrafico, setStatusTrafico] = useState(1) const [StatusColor, setStatusColor] = useState('#FFFFFF') const [PagosaTerceros, setPagosaTerceros] = useState(0) @@ -543,6 +548,9 @@ export default function TraficoCorresponsales (props:IProps) { } }) .catch((e: Error) => { + setTimeout(() => { + setIsDisabled(false) + }, 5000); setHeader('Error') setMsg('Ocurrio un error: ' + e) setShowMsg(true) @@ -795,14 +803,15 @@ export default function TraficoCorresponsales (props:IProps) { const loadRectificacionHistorico = () => { CTrafDataService.GetRectificacionHistorico(IDTrafico) .then((response) => { - - if (response.data.id > 0) { + dispatch(populateRectificaciones(response.data)) + if (response.data.length > 0) { + let ultimaRectificacion = response.data[response.data.length-1] setEncabezadoPedimento1("Pedimento Master Rectificado") - setAduanaH(response.data.aduana.toString()) - setPatenteH(response.data.patente.toString()) - setPedimentoH(response.data.pedimento.toString()) - setClavePedimentoH(response.data.clave) - setFechaPagoH(response.data.fechaPago) + setAduanaH(ultimaRectificacion.aduana.toString()) + setPatenteH(ultimaRectificacion.patente.toString()) + setPedimentoH(ultimaRectificacion.pedimento.toString()) + setClavePedimentoH(ultimaRectificacion.clave) + setFechaPagoH(ultimaRectificacion.fechaPago) } }) .catch((e: Error) => { @@ -1080,8 +1089,8 @@ export default function TraficoCorresponsales (props:IProps) { }, [mCAnticipos]) useEffect(() => { - let ant = mCPedimentosConsolidados.length - let label = Depto === 'Corresponsalias' ? `Consolidar Pedimentos (${ant})` : `Pedimentos Consolidados (${ant})` + let ant = mCPedimentosConsolidados.filter(x => x.id > 0) + let label = Depto === 'Corresponsalias' ? `Consolidar Pedimentos (${ant.length})` : `Pedimentos Consolidados (${ant.length})` setLblPedimentos(label) }, [mCPedimentosConsolidados]) @@ -1255,37 +1264,6 @@ export default function TraficoCorresponsales (props:IProps) { return time.getHours() > 12 ? 'text-success' : 'text-error' } - const generaRectificacion = () => { - if (Aduana && Patente && Pedimento && ClavePedimento.length>0 && FechaPago) { - const data : DTORectificacionHistorico = { - IdTrafico: IDTrafico, - IdUsuario: UserId - } - CTrafDataService.AppendRectificacionHistorico(data) - .then((response) => { - console.log(response); - if(response.data) loadRectificacionHistorico() - else{ - setHeader('Error') - setMsg('Para poder generar la rectificación asegurese de GUARDAR los datos: Patente, Aduana, Pedimento, Clave, Fecha pago') - setShowMsg(true) - return - } - }) - .catch((e: Error) => { - setHeader('Error') - setMsg('Ocurrio un error: ' + e) - setShowMsg(true) - return - }) - } else { - setHeader('Error') - setMsg('Parea poder generar este proceso es necesario que los siguientes campos tengan informacion: Patente, Aduana, Pedimento, Clave, Fecha pago') - setShowMsg(true) - return - } - } - const uploadAlenTxt = (file: File) => { const formData = new FormData() formData.append('name', file.name) @@ -1484,6 +1462,11 @@ export default function TraficoCorresponsales (props:IProps) { return }) } + + const showHistorialRectificaciones = () => { + setLoadComponent(14); + setShowModal(true); + } return (
@@ -2162,8 +2145,8 @@ export default function TraficoCorresponsales (props:IProps) {
Última Rectificación - 0 && !(AduanaH.length>0 && PatenteH.length>0 && PedimentoH.length>0 && FechaPagoH.length>0)) ? 'visible' : 'hidden' }}> - + + Aduana @@ -4206,7 +4189,7 @@ export default function TraficoCorresponsales (props:IProps) { dialogClassName={ LoadComponent === 1 || LoadComponent === 2 || LoadComponent === 9 ? 'modal-90w' - : LoadComponent === 13 ? 'modal-70w' : 'modal-50w' + : LoadComponent === 13 || LoadComponent === 14 ? 'modal-70w' : 'modal-50w' } style={{backdropFilter: 'brightness(0.5)'}} > @@ -4293,6 +4276,29 @@ export default function TraficoCorresponsales (props:IProps) {
) : null} + {LoadComponent === 14? ( +
+ +
+ ) : null} (`/Corresponsalias/Traficos/ValidateComplete/${data.id}`,data); } AppendRectificacionHistorico(data: DTORectificacionHistorico) { - return http.post(`Corresponsalias/Traficos/Rectificacion/Historico/Append`,data); + return http.post(`Corresponsalias/Traficos/Rectificacion/Historico/Append`,data); } GetRectificacionHistorico(IdTrafico: number) { - return http.get(`Corresponsalias/Traficos/Rectificacion/Historico/Get?IdTrafico=${IdTrafico}`); + return http.get(`Corresponsalias/Traficos/Rectificacion/Historico/Get?IdTrafico=${IdTrafico}`); } ValidaTraficoDuplicado(aduana: number | undefined, patente: number | undefined, pedimento:number | undefined, IdTrafico: number | undefined){ diff --git a/src/store/features/Corresponsales/CorresponsalesPedimentosRectificacionesSlice.ts b/src/store/features/Corresponsales/CorresponsalesPedimentosRectificacionesSlice.ts new file mode 100644 index 0000000..c4b16ee --- /dev/null +++ b/src/store/features/Corresponsales/CorresponsalesPedimentosRectificacionesSlice.ts @@ -0,0 +1,40 @@ +import ICorresponsalRectificacionHistorico from "../../../Interfaces/Corresponsales/ICorresponsalRectificacionHistorico"; +import { createSlice, PayloadAction } from "@reduxjs/toolkit"; + +const RectificacionesPedimentos: ICorresponsalRectificacionHistorico[] = [] + +const initialState = {RectificacionesPedimentos}; + +export const RectificacionesPedimentosSlice = createSlice({ + name: 'RectificacionesPedimentos', + initialState: initialState, + reducers: { + populateRectificaciones : (state, action: PayloadAction) => { + state.RectificacionesPedimentos = [] + state.RectificacionesPedimentos.push(... action.payload) + }, + addRectificacion : (state, action: PayloadAction) => { + var Existe = state.RectificacionesPedimentos.find(function(item) { + return item.id === action.payload.id; + }); + if (!Existe) state.RectificacionesPedimentos.push(action.payload) + }, + updateRectificacion : (state, action: PayloadAction) => { + const i = state.RectificacionesPedimentos.findIndex(_element => _element.id === action.payload.id); + if (i > -1) state.RectificacionesPedimentos[i] = action.payload; + else state.RectificacionesPedimentos.push(action.payload); + }, + deleteRectificacion : (state, action: PayloadAction) => { + const newArr = state.RectificacionesPedimentos.filter(data => data.id != action.payload); + state.RectificacionesPedimentos=newArr + }, + } +}) + + +export const { populateRectificaciones, + addRectificacion, + updateRectificacion, + deleteRectificacion, +} = RectificacionesPedimentosSlice.actions; +export default RectificacionesPedimentosSlice.reducer; \ No newline at end of file diff --git a/src/store/store.ts b/src/store/store.ts index f7458c5..188bd95 100644 --- a/src/store/store.ts +++ b/src/store/store.ts @@ -11,6 +11,7 @@ import CorresponsalesGuiasSlice from './features/Corresponsales/CorresponsalesGu import CorresponsalesPartidasSlice from './features/Corresponsales/CorresponsalesPartidasSlice' import CorresponsalesCuentasComplementariasEstatusSlice from './features/Corresponsales/CorresponsalesCuentasComplementariasEstatusSlice' import PedimentosConsolidadosSlice from './features/Corresponsales/CorresponsalesPedimentosConsolidadosSlice' +import RectificacionesPedimentosSlice from './features/Corresponsales/CorresponsalesPedimentosRectificacionesSlice' export const store = configureStore({ @@ -26,7 +27,8 @@ export const store = configureStore({ CGuias: CorresponsalesGuiasSlice, CPartidas: CorresponsalesPartidasSlice, CCueCompEstatus : CorresponsalesCuentasComplementariasEstatusSlice, - CPedimentosConsolidados: PedimentosConsolidadosSlice + CPedimentosConsolidados: PedimentosConsolidadosSlice, + CRectificaciones: RectificacionesPedimentosSlice } })