From d25724ea4642cfbaae6f7389cd51eab4ea5786a5 Mon Sep 17 00:00:00 2001 From: Felix Morales Date: Thu, 21 Dec 2023 10:27:44 -0600 Subject: [PATCH 1/4] Reporte listo, avance para relacionar facturas y contenedores --- .../Clientes/Traficos/TraficoCliente.tsx | 134 ------------------ .../Contenedores/FacturasContenedor.tsx | 76 ++++++++++ .../Contenedores/SelectContainer.tsx | 39 +++++ .../ControlledInput/ControlledInput.tsx | 5 + .../ProveedorFactura/ProveedorFactura.tsx | 63 +++++++- .../Corresponsales/TraficoCorresponsales.tsx | 117 +++++++-------- .../Reportes/RptCorresponsalesTraficos.tsx | 7 +- .../Alen/RelacionFacturas.tsx | 64 +++++++++ .../Corresponsales/ICorresponsalFacturas.ts | 5 + .../Corresponsales.Facturas.Services.ts | 3 + .../Corresponsales.Trafico.Services.ts | 3 + src/Services/Reportes/ReportesAlen.Service.ts | 10 ++ src/index.tsx | 4 + .../CorresponsalesFacturasSlice.ts | 15 ++ 14 files changed, 340 insertions(+), 205 deletions(-) create mode 100644 src/Components/Corresponsales/Contenedores/FacturasContenedor.tsx create mode 100644 src/Components/ReportesClientes/Alen/RelacionFacturas.tsx create mode 100644 src/Services/Reportes/ReportesAlen.Service.ts diff --git a/src/Components/Clientes/Traficos/TraficoCliente.tsx b/src/Components/Clientes/Traficos/TraficoCliente.tsx index c53490c..b133788 100644 --- a/src/Components/Clientes/Traficos/TraficoCliente.tsx +++ b/src/Components/Clientes/Traficos/TraficoCliente.tsx @@ -1151,7 +1151,6 @@ export default function TraficoCliente(props:IProps){ comentarios: arrStatus[0].estatus } await saveFinalStep(data).then(async (r) => { - if(Proceso === 2) await generateFacturacionTxt(); }); }else{ let data: ICorresponsalesTraficoContabilidad = { @@ -1218,123 +1217,6 @@ export default function TraficoCliente(props:IProps){ } } - const readFile = (event: any) => { - const fileUploaded = event.target.files[0]; - if(!fileUploaded) return; - const fileReader = new FileReader(); - fileReader.readAsText(fileUploaded); - - fileReader.onload = async () => { - let Gcs = fileReader.result?.toString().split("\r\n") - let facturas: Array> = [] - Gcs?.forEach(Gc => { - facturas.push(Gc.split("|")) - }) - console.log(facturas) - if(hiddenFileInputRef.current !== null ) hiddenFileInputRef.current.value = ""; - patchForm(facturas[0]) - await saveTxtContenedores(facturas) - await saveFacturasTxt(facturas) - setTimeout(()=> {dispatch(addTxtContenedores(txtContenedores));dispatch(addTxtFacturas(txtFacturas))}, 2000) - }; - - fileReader.onerror = () => {} - }; - - const patchForm = (factura: string[]) => { - setPedimento(+factura[6]); - setFechaPago(setDate(factura[7])); - setClavePedimento(factura[8]) - setTipoCambio(+factura[15]) - setCantidadFracciones(+factura[21]) - setDescripcionMercancia(factura[14]) - setObservaciones(factura[48]) - } - - const saveTxtContenedores = async (facturas: string[][]) => { - facturas.forEach(async (factura) => { - await CContDataService.Append( - {id: 0, contenedor: factura[32], idTrafico: IDTrafico , fSemaforo: factura[22], semaforo: factura[45] === 'VERDE' ? 2 : 1,} - ) - .then((response) => { - if (response.status === 200) { - txtContenedores.push(response.data) - } - }) - .catch((e: Error) => { - return - }) - }) - } - - const saveFacturasTxt = async(facturas: string[][]) => { - facturas.forEach(async (factura) => { - let proveedor = mCProveedores.filter(x => x.nombre === factura[10])[0] - await CFacDataService.Append({ - id: 0, - factura: factura[13], - idTrafico: IDTrafico, - valorFacturaDls: +factura[16], - proveedor: proveedor.id, - corresponsal: IDCorresponsal, - pedido: factura[29], - code: 0, - folioGEMCO: '' - }).then((response) => { - if (response.status === 200) { - txtFacturas.push(response.data) - } - }) - .catch((e: Error) => { - return - }) - }); - } - - const generateFacturacionTxt = async () => { - let cliente = Clientes?.filter(x => x.sClave === IDCliente)[0]; - let tipoMercancia = TiposMercancia.filter(x => x.id === IDTipoMercancia)[0]; - let facturas = mCFacturas.filter(factura => factura.id > 0); - let nombreProveedor = ""; - let descripcionMercancia = DescripcionMercancia!.replace(/(\r\n|\n|\r)/gm, ""); - // - let fileData = `"${FolioTrafico}"|${ClaveClienteFacturacion === IDCliente || ClaveClienteFacturacion === 0? IDCliente : ClaveClienteFacturacion}|${Patente}|${Pedimento}|${TipoCambio}|${FechaPago}|0|0|0|0|0|0|0.00|"${Aduana}"|"${ClavePedimento}"|${TipoOperacion}|`; - // - fileData += `"C"|${ValorFacturasDls}|${ValorFacturasDls! * TipoCambio!}|${ValorAduanaMN}|"${descripcionMercancia}"|${Kilos}|${Kilos! * 2.20462}|${CantidadFracciones}|"${SemafoFiscal === 0 ? "R" : "V"}"|`; - // - if(facturas.length > 0){ - nombreProveedor = mCProveedores.filter(p => p.id === facturas[0].proveedor)[0].nombre; - fileData += `${facturas.length}|"${facturas.map(factura => {return factura.factura}).join(",").substring(0, 25)}"|0|"${nombreProveedor}"|"${concatFacturasPedidos(facturas)}"|`; - }else - fileData += `0|""|0|""|""|`; - // - fileData += `${Bultos}|${0}|${0}|${moment(FechaDesaduanamiento).format('MM/DD/YYYY')}|${mCContenedores.length-1}|0|""|${moment(FechaDesaduanamiento).format('MM/DD/YYYY')}|${tipoMercancia?.clave ? tipoMercancia?.clave : '""'}|0|0|""|""|""|""|/ /|F|F|F|F|0|0|F|0.00|F|0|""|""|`; - // - fileData += `${FechaPagoH !== "" ? FechaPagoH : FechaPago}|""|""|0|"${ClaveClienteFacturacion === IDCliente || ClaveClienteFacturacion === 0? cliente!.sRazonSocial.split('|')[0].trim() : NombreClienteFacturacion}"|${ClaveClienteFacturacion === IDCliente || ClaveClienteFacturacion === 0? cliente!.sRFC : RfcClienteFacturacion}|""|""|""|""|""|""|""|"${nombreProveedor}"|`; - // - fileData += `0|""|""|""|""|""|""|""|""|${ValorFacturasDls}|""|""|336|""|/ / : :|${moment().format("MM/DD/YYYY hh:mm:ss")}|${moment().format("MM/DD/YYYY hh:mm:ss")}|`; - // - fileData += `0|""|""|""|0|0|0|F|""|0|""|""|0|0|0|0|""|"${CentroCostos}"`; - //const blob = new Blob([fileData], { type: "text/plain" }); - const file = new File([fileData], `${FolioTrafico}_${Date.now()}.txt`, {type: "text/plain"}); - let formData = new FormData(); - formData.append('file', file); - await axios.post( - URL.get() + - `/FileManager/AppendFileByProcess?IdUsuario=${UserId}&Proceso=${31}&Tags=${IDTrafico}&crud=1`, - formData, { - headers:{ - 'Authorization': 'Bearer ' + token - } - } - ); - /*const url = URL.createObjectURL(blob); - const link = document.createElement("a"); - link.download = `${FolioTrafico}_${Date.now()}.txt`; - link.href = url; - link.click();*/ - } - const concatFacturasPedidos = (facturas: ICorresponsalFacturas[]) => { let pedidos = ""; facturas.forEach((factura, index) => { @@ -1743,22 +1625,6 @@ export default function TraficoCliente(props:IProps){ - {IDTrafico > 0 && IDCliente === 1896? ( - <> - - - - ) : ( - '' - )} = (props) => { + const mCFacturas = useSelector( + (state: RootState) => state.CFData.CorresponsalesFacturas + ) + + const AppendContenedor = (idFactura: number) => { + CorresponsalesFacturasServices.AppendContenedor(+idFactura, props.IdContenedor) + .then((resp:any) => { + + }) + } + + const QuitContenedor = (idFactura: number) => { + CorresponsalesFacturasServices.AppendContenedor(+idFactura, props.IdContenedor) + .then((resp:any) => { + + }) + } + return ( + + + + Agregar facturas al contenedor {props.Contenedor} + + +
+ + + + + + {mCFacturas + ? mCFacturas.map((item, index) => { + return item.idTrafico === props.IDTrafico ? ( + + + + + ) : ( + '' + ) + }) + : ''} + +
Factura
+ { + if(event.currentTarget.checked) + AppendContenedor(event.target.value) + else + QuitContenedor(event.target.value) + }} value={item.id} + /> + + {item.factura} +
+
+
+ ) +} \ No newline at end of file diff --git a/src/Components/Corresponsales/Contenedores/SelectContainer.tsx b/src/Components/Corresponsales/Contenedores/SelectContainer.tsx index cdbe1a4..7d1b8a2 100644 --- a/src/Components/Corresponsales/Contenedores/SelectContainer.tsx +++ b/src/Components/Corresponsales/Contenedores/SelectContainer.tsx @@ -15,6 +15,8 @@ import 'react-datepicker/dist/react-datepicker.css' //Images import caret from '../../../images/caret.png'; import clean from '../../../images/Clean.png'; +import { FaFile } from 'react-icons/fa' +import { FacturasContenedor } from './FacturasContenedor' interface IProps { IDTrafico: number @@ -36,6 +38,7 @@ export const SelectContainer: FC = (props) => { const [DialogAddDate, setDialogAddDate] = useState(false) const [FSemaforo, setFSemaforo] = useState() const [Semaforo, setSemaforo] = useState(0) + const [ShowFacturasDialog, setShowFacturasDialog] = useState(false) useEffect(() => { setPlaceholder('(' + mCContenedores.filter((item) => item.id > 0).length + ') Contenedores') @@ -218,6 +221,11 @@ export const SelectContainer: FC = (props) => { + + + setShowFacturasDialog(true)}/> + + {item.contenedor} { @@ -251,6 +259,7 @@ export const SelectContainer: FC = (props) => { + ) : ( @@ -377,6 +386,36 @@ export const SelectContainer: FC = (props) => { + + setShowFacturasDialog(false)} + centered + dialogClassName='modal-20w' + > + +
+ +
+
+ + + + + +
) } diff --git a/src/Components/Corresponsales/ProveedorFactura/ControlledInput/ControlledInput.tsx b/src/Components/Corresponsales/ProveedorFactura/ControlledInput/ControlledInput.tsx index 0c5a0c6..4acf09c 100644 --- a/src/Components/Corresponsales/ProveedorFactura/ControlledInput/ControlledInput.tsx +++ b/src/Components/Corresponsales/ProveedorFactura/ControlledInput/ControlledInput.tsx @@ -63,6 +63,11 @@ export const ControlledInput: FC = (props) => { pedido: Pedido, code: 0, folioGEMCO: '', + uuid: '', + fechaFactura: '', + cove: '', + entrega: '', + transporte: '' }; CorFacDataService.Append(data) .then((response) => { diff --git a/src/Components/Corresponsales/ProveedorFactura/ProveedorFactura.tsx b/src/Components/Corresponsales/ProveedorFactura/ProveedorFactura.tsx index 2741d55..e20e851 100644 --- a/src/Components/Corresponsales/ProveedorFactura/ProveedorFactura.tsx +++ b/src/Components/Corresponsales/ProveedorFactura/ProveedorFactura.tsx @@ -47,7 +47,11 @@ export const ProveedorFactura: FC = (props) => { const MsgTime = 2000; const msgColor = 'primary'; const ClasificacionProveedor = 2; - + const [Uuid, setUuid] = useState(); + const [FechaFactura, setFechaFactura] = useState(); + const [Cove, setCove] = useState(); + const [Entrega, setEntrega] = useState(); + const [Transporte, setTransporte] = useState(); const TblHeader: React.FC = () => ( = (props) => { pedido: Pedido, code: 0, folioGEMCO: '', + uuid: Uuid, + fechaFactura: FechaFactura, + cove: Cove, + entrega: Entrega, + transporte: Transporte }; FacDataService.Append(data) .then((response) => { @@ -337,6 +346,58 @@ export const ProveedorFactura: FC = (props) => {   + + + setUuid(e.target.value)} + /> + + + setFechaFactura(e.target.value)} + /> + + + setCove(e.target.value)} + /> + + + setEntrega(e.target.value)} + /> + + + setTransporte(e.target.value)} + /> + + { - const fileUploaded = event.target.files[0]; - if(!fileUploaded) return; - const fileReader = new FileReader(); - fileReader.readAsText(fileUploaded); - - fileReader.onload = async () => { - let Gcs = fileReader.result?.toString().split("\r\n") - let facturas: Array> = [] - Gcs?.forEach(Gc => { - facturas.push(Gc.split("|")) - }) - console.log(facturas) + const uploadAlenTxt = (file: File) => { + const formData = new FormData() + formData.append('name', file.name) + formData.append('file', file) + axios.post( + URL.get() + `/FileManager/AppendFileByProcess?IdUsuario=${UserId}&Proceso=${43}&Tags=${IDTrafico}&crud=1`, + formData, { + headers:{ + 'Authorization': 'Bearer ' + token + } + } + ).then((res) => { if(hiddenFileInputRef.current !== null ) hiddenFileInputRef.current.value = ""; - patchForm(facturas[0]) - await saveTxtContenedores(facturas) - await saveFacturasTxt(facturas) - setTimeout(()=> {dispatch(addTxtContenedores(txtContenedores));dispatch(addTxtFacturas(txtFacturas))}, 2000) - }; - - fileReader.onerror = () => {} - }; - - const patchForm = (factura: string[]) => { - setPedimento(+factura[6]); - setFechaPago(setDate(factura[7])); - setClavePedimento(factura[8]) - setTipoCambio(+factura[15]) - setCantidadFracciones(+factura[21]) - setDescripcionMercancia(factura[14]) - setObservaciones(factura[48]) - } - - const saveTxtContenedores = async (facturas: string[][]) => { - facturas.forEach(async (factura) => { - await CContDataService.Append( - {id: 0, contenedor: factura[32], idTrafico: IDTrafico , fSemaforo: factura[22], semaforo: factura[45] === 'VERDE' ? 2 : 1,} - ) - .then((response) => { - if (response.status === 200) { - txtContenedores.push(response.data) + if (res.data.id > 0) { + CTrafDataService.AppendFacturasContenedoresAlen(IDTrafico, res.data.id) + .then(resp => { + setPedimento(resp.data.trafico.pedimento); + setFechaPago(resp.data.trafico.fechaPago); + setClavePedimento(resp.data.trafico.clave) + setTipoCambio(resp.data.trafico.tipoCambio) + setCantidadFracciones(resp.data.trafico.cantidadFracciones) + setDescripcionMercancia(resp.data.trafico.descripcionMercancia) + setObservaciones(resp.data.trafico.observaciones) + dispatch(addTxtContenedores(resp.data.contenedores)); + dispatch(addTxtFacturas(resp.data.facturas)); + setHeader('Informativo') + setMsg('Layout cargado exitosamente.'); + setShowMsg(true) + return + }).catch(() => { + setHeader('Error') + setMsg('Ocurrió un error cargar el layout. Por favor, intentelo de nuevo.') + setShowMsg(true) + return + }) + } else { + setHeader('Error') + setMsg('Ocurrió un error cargar el layout. Por favor, intentelo de nuevo.') + setShowMsg(true) + return } - }) - .catch((e: Error) => { - return - }) + }).catch((err) => { + if(hiddenFileInputRef.current !== null ) hiddenFileInputRef.current.value = ""; + setHeader('Error') + setMsg('Ocurrió un error cargar el layout. Por favor, intentelo de nuevo.') + setShowMsg(true) + return }) } - - const saveFacturasTxt = async(facturas: string[][]) => { - facturas.forEach(async (factura) => { - let proveedor = mCProveedores.filter(x => x.nombre === factura[10])[0] - await CFacDataService.Append({ - id: 0, - factura: factura[13], - idTrafico: IDTrafico, - valorFacturaDls: +factura[16], - proveedor: proveedor.id, - corresponsal: IDCorresponsal, - pedido: factura[29], - code: 0, - folioGEMCO: '' - }).then((response) => { - if (response.status === 200) { - txtFacturas.push(response.data) - } - }) - .catch((e: Error) => { - return - }) - }); - } const generateFacturacionTxt = async () => { let cliente = Clientes?.filter(x => x.sClave === IDCliente)[0]; @@ -1803,7 +1782,7 @@ export default function TraficoCorresponsales (props:IProps) { > {IDTrafico > 0 && IDCliente === 1896? ( <> - + {uploadAlenTxt(e.target.files[0]);}} ref={hiddenFileInputRef}/> + +

Relación de Facturas

+ + + setReferencia(e.target.value)} + /> + + + + + +
+ + + + { + setShowMsg(false) + }} + /> + + ) +} \ No newline at end of file diff --git a/src/Interfaces/Corresponsales/ICorresponsalFacturas.ts b/src/Interfaces/Corresponsales/ICorresponsalFacturas.ts index 7e51e4e..e23eeca 100644 --- a/src/Interfaces/Corresponsales/ICorresponsalFacturas.ts +++ b/src/Interfaces/Corresponsales/ICorresponsalFacturas.ts @@ -9,4 +9,9 @@ export default interface ICorresponsalFacturas { activo?: boolean; code: number; folioGEMCO: string; + fechaFactura?: string; + uuid?: string; + cove?: string; + entrega?: string; + transporte?: string; } diff --git a/src/Services/Corresponsalias/Corresponsales.Facturas.Services.ts b/src/Services/Corresponsalias/Corresponsales.Facturas.Services.ts index d05251d..1eb575a 100644 --- a/src/Services/Corresponsalias/Corresponsales.Facturas.Services.ts +++ b/src/Services/Corresponsalias/Corresponsales.Facturas.Services.ts @@ -15,5 +15,8 @@ class Corresponsales_Facturas_DataService { GetExcel(idTrafico: number){ return http.get(`/Corresponsalias/Facturas/GetExcel?idTrafico=${idTrafico}`, {responseType:'blob'}) } + AppendContenedor(idFactura: number, idContenedor: number){ + return http.post(`/Corresponsalias/Facturas/AppendContenedor`, {IdFactura: idFactura, IdContenedor: idContenedor}) + } } export default new Corresponsales_Facturas_DataService(); \ No newline at end of file diff --git a/src/Services/Corresponsalias/Corresponsales.Trafico.Services.ts b/src/Services/Corresponsalias/Corresponsales.Trafico.Services.ts index 35d5a7d..b309a67 100644 --- a/src/Services/Corresponsalias/Corresponsales.Trafico.Services.ts +++ b/src/Services/Corresponsalias/Corresponsales.Trafico.Services.ts @@ -42,5 +42,8 @@ class Corresponsales_Trafico_DataService { ValidaTraficoDuplicado(aduana: number | undefined, patente: number | undefined, pedimento:number | undefined, IdTrafico: number | undefined){ return http.get(`Corresponsalias/Traficos/Duplicado?aduana=${aduana}&patente=${patente}&pedimento=${pedimento}&idTrafico=${IdTrafico}`) } + AppendFacturasContenedoresAlen(idTrafico:number, fileId:number){ + return http.post(`/Corresponsalias/Traficos/Append/LayoutAlen?idTrafico=${idTrafico}&fileId=${fileId}`); + } } export default new Corresponsales_Trafico_DataService(); \ No newline at end of file diff --git a/src/Services/Reportes/ReportesAlen.Service.ts b/src/Services/Reportes/ReportesAlen.Service.ts new file mode 100644 index 0000000..526793e --- /dev/null +++ b/src/Services/Reportes/ReportesAlen.Service.ts @@ -0,0 +1,10 @@ +import http from '../common/http-common'; + +class ReportesAlenService{ + + getRelacionFacturas(referencia: string){ + return http.get(`ReportesAlen/RelacionFacturas?referencia=${referencia}`, {responseType: 'blob'}); + } +} + +export default new ReportesAlenService(); \ No newline at end of file diff --git a/src/index.tsx b/src/index.tsx index 4a0c358..d404845 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -27,6 +27,7 @@ import { ReportesEmbarques } from './Components/ReportesClientes/Embarques/Repor import { ClientesExternos } from './Components/Clientes/Clientes' import { ReporteGC50 } from './Components/ReportesClientes/GC50/ReporteGC50' import RptClientesTraficos from './Components/Clientes/Traficos/RptClientesTraficos' +import { RelacionFacturas } from './Components/ReportesClientes/Alen/RelacionFacturas' require (`./css/${process.env.REACT_APP_ENVIRONMENT}-home.css`) function PageNotFound() { @@ -84,6 +85,9 @@ root.render( }/> }/> }/> + }> + }/> + }>{/*Aqui van todas las rutas relacionadas a los clientes */} }>{/*Aqui van todas las rutas relacionadas a los reportes de los clientes*/} diff --git a/src/store/features/Corresponsales/CorresponsalesFacturasSlice.ts b/src/store/features/Corresponsales/CorresponsalesFacturasSlice.ts index 61ad566..042a5e7 100644 --- a/src/store/features/Corresponsales/CorresponsalesFacturasSlice.ts +++ b/src/store/features/Corresponsales/CorresponsalesFacturasSlice.ts @@ -10,6 +10,11 @@ const CorresponsalesFacturas: ICorresponsalFacturas[] = [ pedido: '', code: 0, folioGEMCO: '', + uuid: '', + fechaFactura: '', + cove: '', + entrega: '', + transporte: '' }, ]; const initialState = { CorresponsalesFacturas }; @@ -32,6 +37,11 @@ export const CorresponsalesFacturasSlice = createSlice({ pedido: '', code: 0, folioGEMCO: '', + uuid: '', + fechaFactura: '', + cove: '', + entrega: '', + transporte: '' }, ]; state.CorresponsalesFacturas.push(...action.payload); @@ -73,6 +83,11 @@ export const CorresponsalesFacturasSlice = createSlice({ pedido: '', code: 0, folioGEMCO: '', + uuid: '', + fechaFactura: '', + cove: '', + entrega: '', + transporte: '' }, ]; }, From df552e5e75ca2eedbac24313b87d6dc64a5e64ea Mon Sep 17 00:00:00 2001 From: Felix Morales Date: Thu, 21 Dec 2023 14:51:31 -0600 Subject: [PATCH 2/4] creacion de componente para relacionar facturas y contenedores --- .../Contenedores/FacturasContenedor.tsx | 76 ++++++++++++++----- .../ControlledInput/ControlledInput.tsx | 3 +- .../ProveedorFactura/ProveedorFactura.tsx | 3 +- .../Reportes/RptCorresponsalesTraficos.tsx | 3 +- .../Corresponsales/ICorresponsalFacturas.ts | 1 + .../CorresponsalesFacturasSlice.ts | 9 ++- 6 files changed, 72 insertions(+), 23 deletions(-) diff --git a/src/Components/Corresponsales/Contenedores/FacturasContenedor.tsx b/src/Components/Corresponsales/Contenedores/FacturasContenedor.tsx index 70796e3..f732b4d 100644 --- a/src/Components/Corresponsales/Contenedores/FacturasContenedor.tsx +++ b/src/Components/Corresponsales/Contenedores/FacturasContenedor.tsx @@ -1,9 +1,12 @@ import { Alert, Col, FormControl, Row, Table } from "react-bootstrap" -import { useSelector } from "react-redux" +import { useDispatch, useSelector } from "react-redux" import { RootState } from "../../../store/store" -import { useEffect } from "react" +import { useEffect, useState } from "react" import FormCheckInput from "react-bootstrap/esm/FormCheckInput" import CorresponsalesFacturasServices from "../../../Services/Corresponsalias/Corresponsales.Facturas.Services" +import ICorresponsalFacturas from "../../../Interfaces/Corresponsales/ICorresponsalFacturas" +import { updateCorresponsalesFacturas } from "../../../store/features/Corresponsales/CorresponsalesFacturasSlice" +import { MsgInformativo } from "../../Utils/Toast/msgInformativo" interface IProps{ IDTrafico: number @@ -14,21 +17,49 @@ export const FacturasContenedor: React.FC = (props) => { const mCFacturas = useSelector( (state: RootState) => state.CFData.CorresponsalesFacturas ) + const dispatch = useDispatch() + const [header, setHeader] = useState('') + const [msg, setMsg] = useState('') + const [show, setShowMsg] = useState(false) + const [msgColor, setMsgColor] = useState('primary') - const AppendContenedor = (idFactura: number) => { - CorresponsalesFacturasServices.AppendContenedor(+idFactura, props.IdContenedor) + const AppendContenedor = (e: any) => { + var data = mCFacturas.filter(x => x.id === +e.target.value)[0] + var factura: ICorresponsalFacturas = { + id: data.id, + factura: data.factura, + idTrafico: data.idTrafico, + valorFacturaDls: data.valorFacturaDls, + proveedor: data.proveedor, + pedido: data.pedido, + code: data.code, + folioGEMCO: data.folioGEMCO, + corresponsal: data.corresponsal, + activo: data.activo, + fechaFactura: data.fechaFactura, + uuid: data.uuid, + cove: data.cove, + entrega: data.entrega, + transporte: data.transporte, + idContenedor: e.currentTarget.checked ? props.IdContenedor : 0 + } + CorresponsalesFacturasServices.Append(factura) .then((resp:any) => { - + dispatch(updateCorresponsalesFacturas(factura)); + setHeader('Informativo') + setMsg('Factura asignada correctamente') + setShowMsg(true) + return }) - } - - const QuitContenedor = (idFactura: number) => { - CorresponsalesFacturasServices.AppendContenedor(+idFactura, props.IdContenedor) - .then((resp:any) => { - + .catch(() => { + setHeader('Error') + setMsg('Ocurrio un error: ' + e) + setShowMsg(true) + return }) } return ( + <> @@ -51,12 +82,13 @@ export const FacturasContenedor: React.FC = (props) => { return item.idTrafico === props.IDTrafico ? (
- { - if(event.currentTarget.checked) - AppendContenedor(event.target.value) - else - QuitContenedor(event.target.value) - }} value={item.id} + { + AppendContenedor(event) + }} + value={item.id} + disabled = {item.idContenedor !== 0 && item.idContenedor !== props.IdContenedor} + defaultChecked = {item.idContenedor === props.IdContenedor} /> @@ -72,5 +104,15 @@ export const FacturasContenedor: React.FC = (props) => {
+ { + setShowMsg(false) + }} + /> + ) } \ No newline at end of file diff --git a/src/Components/Corresponsales/ProveedorFactura/ControlledInput/ControlledInput.tsx b/src/Components/Corresponsales/ProveedorFactura/ControlledInput/ControlledInput.tsx index 4acf09c..a6cee33 100644 --- a/src/Components/Corresponsales/ProveedorFactura/ControlledInput/ControlledInput.tsx +++ b/src/Components/Corresponsales/ProveedorFactura/ControlledInput/ControlledInput.tsx @@ -67,7 +67,8 @@ export const ControlledInput: FC = (props) => { fechaFactura: '', cove: '', entrega: '', - transporte: '' + transporte: '', + idContenedor: 0, }; CorFacDataService.Append(data) .then((response) => { diff --git a/src/Components/Corresponsales/ProveedorFactura/ProveedorFactura.tsx b/src/Components/Corresponsales/ProveedorFactura/ProveedorFactura.tsx index e20e851..c1e85ef 100644 --- a/src/Components/Corresponsales/ProveedorFactura/ProveedorFactura.tsx +++ b/src/Components/Corresponsales/ProveedorFactura/ProveedorFactura.tsx @@ -170,7 +170,8 @@ export const ProveedorFactura: FC = (props) => { fechaFactura: FechaFactura, cove: Cove, entrega: Entrega, - transporte: Transporte + transporte: Transporte, + idContenedor: 0, }; FacDataService.Append(data) .then((response) => { diff --git a/src/Components/Reportes/RptCorresponsalesTraficos.tsx b/src/Components/Reportes/RptCorresponsalesTraficos.tsx index e3b8396..0313db5 100644 --- a/src/Components/Reportes/RptCorresponsalesTraficos.tsx +++ b/src/Components/Reportes/RptCorresponsalesTraficos.tsx @@ -465,7 +465,8 @@ export default function RptCorresponsalesTraficos(props: IProps) { fechaFactura: '', cove: '', entrega: '', - transporte: '' + transporte: '', + idContenedor: 0, }).catch((e: Error) => { setHeader('Error') setMsg('Ocurrio un error al guardar la factura: ' + element[13]) diff --git a/src/Interfaces/Corresponsales/ICorresponsalFacturas.ts b/src/Interfaces/Corresponsales/ICorresponsalFacturas.ts index e23eeca..1577c38 100644 --- a/src/Interfaces/Corresponsales/ICorresponsalFacturas.ts +++ b/src/Interfaces/Corresponsales/ICorresponsalFacturas.ts @@ -14,4 +14,5 @@ export default interface ICorresponsalFacturas { cove?: string; entrega?: string; transporte?: string; + idContenedor?: number; } diff --git a/src/store/features/Corresponsales/CorresponsalesFacturasSlice.ts b/src/store/features/Corresponsales/CorresponsalesFacturasSlice.ts index 042a5e7..d2b1745 100644 --- a/src/store/features/Corresponsales/CorresponsalesFacturasSlice.ts +++ b/src/store/features/Corresponsales/CorresponsalesFacturasSlice.ts @@ -14,7 +14,8 @@ const CorresponsalesFacturas: ICorresponsalFacturas[] = [ fechaFactura: '', cove: '', entrega: '', - transporte: '' + transporte: '', + idContenedor: 0, }, ]; const initialState = { CorresponsalesFacturas }; @@ -41,7 +42,8 @@ export const CorresponsalesFacturasSlice = createSlice({ fechaFactura: '', cove: '', entrega: '', - transporte: '' + transporte: '', + idContenedor: 0, }, ]; state.CorresponsalesFacturas.push(...action.payload); @@ -87,7 +89,8 @@ export const CorresponsalesFacturasSlice = createSlice({ fechaFactura: '', cove: '', entrega: '', - transporte: '' + transporte: '', + idContenedor: 0, }, ]; }, From 6510e6a876e1445f3ed37e0a9673c6d682ee70ab Mon Sep 17 00:00:00 2001 From: Felix Morales Date: Fri, 29 Dec 2023 15:56:37 -0600 Subject: [PATCH 3/4] Agregar campos faltantes al componente ControlledInput --- .../ControlledInput/ControlledInput.tsx | 59 +++++++++++++++++-- 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/src/Components/Corresponsales/ProveedorFactura/ControlledInput/ControlledInput.tsx b/src/Components/Corresponsales/ProveedorFactura/ControlledInput/ControlledInput.tsx index a6cee33..3c6e158 100644 --- a/src/Components/Corresponsales/ProveedorFactura/ControlledInput/ControlledInput.tsx +++ b/src/Components/Corresponsales/ProveedorFactura/ControlledInput/ControlledInput.tsx @@ -30,6 +30,12 @@ export const ControlledInput: FC = (props) => { const [show, setShowMsg] = useState(false); const [msg, setMsg] = useState(''); const [ClasificacionProveedor, setClasificacionProveedor] = useState(2); + const [Uuid, setUuid] = useState(props.record.uuid); + const [FechaFactura, setFechaFactura] = useState(props.record.fechaFactura); + const [Cove, setCove] = useState(props.record.cove); + const [Entrega, setEntrega] = useState(props.record.entrega); + const [Transporte, setTransporte] = useState(props.record.transporte); + const [IdContenedor, setIdContenedor] = useState(props.record.idContenedor); const onChangeFac = (event: any) => { setValue(event.target.value); @@ -63,12 +69,12 @@ export const ControlledInput: FC = (props) => { pedido: Pedido, code: 0, folioGEMCO: '', - uuid: '', - fechaFactura: '', - cove: '', - entrega: '', - transporte: '', - idContenedor: 0, + uuid: Uuid, + fechaFactura: FechaFactura, + cove: Cove, + entrega: Entrega, + transporte: Transporte, + idContenedor: IdContenedor, }; CorFacDataService.Append(data) .then((response) => { @@ -140,6 +146,47 @@ export const ControlledInput: FC = (props) => { }) : null}
+ setUuid(e.target.value)} + disabled={false} + onKeyDown={(e) => handleKeyDown(e, 2)} + style={{ width: '20%', textAlign: 'right' }} + /> +       + setFechaFactura(e.target.value)} + /> +       + setCove(e.target.value)} + disabled={false} + onKeyDown={(e) => handleKeyDown(e, 2)} + style={{ width: '20%', textAlign: 'right' }} + /> +       + setEntrega(e.target.value)} + disabled={false} + onKeyDown={(e) => handleKeyDown(e, 2)} + style={{ width: '20%', textAlign: 'right' }} + /> +       + setTransporte(e.target.value)} + disabled={false} + onKeyDown={(e) => handleKeyDown(e, 2)} + style={{ width: '20%', textAlign: 'right' }} + /> +       Date: Tue, 2 Jan 2024 11:04:50 -0600 Subject: [PATCH 4/4] Agregar columnas faltantes al DataTable del componente de facturas --- .../ProveedorFactura/ProveedorFactura.tsx | 89 +++++++++++++++++-- 1 file changed, 81 insertions(+), 8 deletions(-) diff --git a/src/Components/Corresponsales/ProveedorFactura/ProveedorFactura.tsx b/src/Components/Corresponsales/ProveedorFactura/ProveedorFactura.tsx index c1e85ef..6495e99 100644 --- a/src/Components/Corresponsales/ProveedorFactura/ProveedorFactura.tsx +++ b/src/Components/Corresponsales/ProveedorFactura/ProveedorFactura.tsx @@ -47,11 +47,11 @@ export const ProveedorFactura: FC = (props) => { const MsgTime = 2000; const msgColor = 'primary'; const ClasificacionProveedor = 2; - const [Uuid, setUuid] = useState(); - const [FechaFactura, setFechaFactura] = useState(); - const [Cove, setCove] = useState(); - const [Entrega, setEntrega] = useState(); - const [Transporte, setTransporte] = useState(); + const [Uuid, setUuid] = useState(''); + const [FechaFactura, setFechaFactura] = useState(''); + const [Cove, setCove] = useState(''); + const [Entrega, setEntrega] = useState(''); + const [Transporte, setTransporte] = useState(''); const TblHeader: React.FC = () => ( = (props) => { + + + + +
Proveedor + UUID + + Fecha Factura + + COVE + + Entrega + + Transporte +
); const columnsFacturas = [ { - name: 'id', - width: '10%', + name: 'Id', + width: '65px', selector: (row: ICorresponsalFacturas) => row.id, sortable: true, }, { + name: 'Factura', + width:'150px', + selector: (row: ICorresponsalFacturas) => row.factura, + sortable: true, + }, + { + name: 'Valor Dls', + width:'100px', + selector: (row: ICorresponsalFacturas) => '$ ' + row.valorFacturaDls, + sortable: true, + }, + { + name: 'Pedido', + width:'130px', + selector: (row: ICorresponsalFacturas) => row.pedido, + sortable: true, + }, + { + name: 'Proveedor', + width:'150px', + selector: (row: ICorresponsalFacturas) => mProveedores.filter(x => x.id === row.proveedor)[0].nombre, + sortable: true, + center:true, + wrap: true + }, + { + name: 'UUID', + width:'160px', + selector: (row: ICorresponsalFacturas) => row.uuid ? row.uuid : '', + sortable: true, + center:true, + wrap: true + }, + { + name: 'Fecha Factura', + width: '125px', + selector: (row: ICorresponsalFacturas) => row.fechaFactura? row.fechaFactura!.substring(0,11) : '', + sortable: true, + }, + { + name: 'COVE', + selector: (row: ICorresponsalFacturas) => row.cove ? row.cove : '', + sortable: true, + allowOverflow: true + }, + { + name: 'Entrega', + selector: (row: ICorresponsalFacturas) => row.entrega ? row.entrega : '', + sortable: true, + }, + { + name: 'Transporte', + selector: (row: ICorresponsalFacturas) => row.transporte ? row.transporte : '', + sortable: true, + }, + /* { name: , width: '75%', cell: (row: ICorresponsalFacturas) => { return ; }, - }, + }, */ { name: 'Elimina', + width: '80px', cell: (row: ICorresponsalFacturas) => (
= (props) => { useEffect(() => { FacDataService.getAll(props.IDTrafico) .then((response) => { + console.log(response.data); dispatch(populateCorresponsalesFacturas(response.data)); }) .catch((e: Error) => {