diff --git a/src/Classes/Corresponsales/CCorresponsalesTrafico.ts b/src/Classes/Corresponsales/CCorresponsalesTrafico.ts index 0f94005..2be4c30 100644 --- a/src/Classes/Corresponsales/CCorresponsalesTrafico.ts +++ b/src/Classes/Corresponsales/CCorresponsalesTrafico.ts @@ -41,7 +41,8 @@ export default class CCorresponsalesTrafico implements ICorresponsalTrafico { idTabulador: number; noRecti: number; estatusCode: number; - activo?: number + activo?: number; + idTipoMercancia: number; constructor() { this.id=0 @@ -85,6 +86,7 @@ export default class CCorresponsalesTrafico implements ICorresponsalTrafico { this.noRecti=0; this.estatusCode=0; this.activo=1 + this.idTipoMercancia=0; } public getEmptyObject(): ICorresponsalTrafico { @@ -129,7 +131,8 @@ export default class CCorresponsalesTrafico implements ICorresponsalTrafico { idTabulador:0, noRecti:0, estatusCode:0, - activo :1 + activo :1 , + idTipoMercancia: 0 } } @@ -175,7 +178,8 @@ export default class CCorresponsalesTrafico implements ICorresponsalTrafico { idTabulador: data.idTabulador, noRecti: data.noRecti, estatusCode: data.estatusCode, - activo : data.activo + activo : data.activo, + idTipoMercancia: data.idTipoMercancia, } } } \ No newline at end of file diff --git a/src/Components/Corresponsales/TraficoCorresponsales.tsx b/src/Components/Corresponsales/TraficoCorresponsales.tsx index 479d572..99c81c2 100644 --- a/src/Components/Corresponsales/TraficoCorresponsales.tsx +++ b/src/Components/Corresponsales/TraficoCorresponsales.tsx @@ -80,7 +80,7 @@ import CPedimentoService from '../../Services/Corresponsalias/Corresponsales.Tra import DashboardService from '../../Services/Dashboard/Dashboard.Corresponsales.Services' import CCueCompService from '../../Services/Corresponsalias/Corresponsales.CuentasComplementarias.Services' import FileManService from '../../Services/Utils/FileManager.Services' - +import TiposMercanciaService from '../../Services/Catalogos/TiposMercancia.Services' // Componentes import CurrencyFormat from 'react-currency-format' import MaskedInput from 'react-text-mask' @@ -111,6 +111,7 @@ import DTORectificacionHistorico from '../../DTO/Corresponsales/DTORectificacion import moment from 'moment' import ICorresponsalContenedores from '../../Interfaces/Corresponsales/ICorresponsalContenedores' import ICorresponsalFacturas from '../../Interfaces/Corresponsales/ICorresponsalFacturas' +import { ITiposMercancias } from '../../Interfaces/Catalogos/ICatTiposMercancias' interface IProps { IDTrafico: number @@ -246,6 +247,8 @@ export default function TraficoCorresponsales (props:IProps) { const [DataCatEstatus, setDataCatEstatus] = useState< ICorresponsalesCatTraficoEstatus[] >([]) + const [TiposMercancia, setTiposMercancia] = useState([]) + const [IDTipoMercancia, setIDTipoMercancia] = useState(0) const [Aduanas, setAduanas] = useState([ { id: 440, descripcion: 'CD. ACUNA, COAH.' }, { id: 810, descripcion: 'ALTAMIRA, TAMPS.' } @@ -387,6 +390,7 @@ export default function TraficoCorresponsales (props:IProps) { data.noCuenta = NoCuenta data.fechaCuenta = FechaCuenta data.idTabulador = IDTabulador + data.idTipoMercancia = IDTipoMercancia CTrafDataService.Append(data) .then((response) => { if (response.data.estatusCode === 0) { @@ -520,6 +524,17 @@ export default function TraficoCorresponsales (props:IProps) { setShowMsg(true) return }) + + TiposMercanciaService.GetAll() + .then((response) => { + setTiposMercancia(response.data); + }) + .catch((e: Error) => { + setHeader('Error') + setMsg('Ocurrio un error: ' + e) + setShowMsg(true) + return + }); CFacDataService.getAll(IDTrafico) .then((response) => { @@ -664,6 +679,7 @@ export default function TraficoCorresponsales (props:IProps) { setSemaforoFiscal(response.data.semaforoFiscal) setNoCuenta(response.data.noCuenta) setFechaCuenta(setDate(response.data.fechaCuenta)) + setIDTipoMercancia(response.data.idTipoMercancia); }) .catch((e: Error) => { setHeader('Error') @@ -1102,7 +1118,7 @@ export default function TraficoCorresponsales (props:IProps) { idTrafico: IDTrafico, statusProceso: 0, fechaRegistro: '', - razonRechazo: arrStatus[0].estatus, + razonRechazo: arrStatus[0]?.estatus ? arrStatus[0]?.estatus : "", tipo: 0 } rejectCurrentStep(data) @@ -1233,6 +1249,51 @@ export default function TraficoCorresponsales (props:IProps) { }); } + const generateFacturacionTxt = () => { + 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 fileData = `"${FolioTrafico}"|${IDCliente}|${Patente}|${Pedimento}|${TipoCambio}|${FechaPago}|0|0|0|0|0|0|0.00|"${Aduana}"|"${ClavePedimento}"|${TipoOperacion}|`; + // + fileData += `"C"|${ValorFacturasDls}|${ValorFacturasDls! * TipoCambio!}|${ValorAduanaMN}|"${Descripcion}"|${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(",")}"|0|"${nombreProveedor}"|"${concatFacturasPedidos(facturas)}"|`; + }else + fileData += `0|""|0|""|""|`; + // + fileData += `${Bultos}|${0}|${0}|${moment(FechaDesaduanamiento).format('MM/DD/YYYY')}|0|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|"${cliente!.sRazonSocial.split('|')[0].trim()}"|${cliente!.sRFC}|""|""|""|""|""|""|""|"${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|""|"1-9999"`; + const blob = new Blob([fileData], { type: "text/plain" }); + 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) => { + if(factura.pedido !== ''){ + if(index <= facturas.length){ + pedidos += `${factura.pedido},`; + }else{ + pedidos += factura.pedido; + } + } + }); + return pedidos; + } + return (
@@ -1561,118 +1622,119 @@ export default function TraficoCorresponsales (props:IProps) { - - - + + + - - - - - - Bultos - - - { - const { value } = values - setBultos(value) - }} - style={ - Depto === 'Corresponsalias' - ? { - fontSize: '15px', - backgroundColor: '#FFFFFF', - border: '1px solid #000000', - width: '70px', - borderRadius: '3px' - } - : { - fontSize: '15px', - backgroundColor: '#FFFFFF', - paddingLeft: '20px', - paddingRight: '5px', - border: '1px solid #000000', - width: '70px', - borderRadius: '3px' - } - } - /> - - - Kilos + + + Bultos + { + const { value } = values + setBultos(value) + }} + style={{ + fontSize: '15px', + backgroundColor: '#FFFFFF', + border: '1px solid #000000', + width: '100%', + borderRadius: '3px', + textAlign: 'end', + padding: '0 5px' + }} + /> + - - { - const { value } = values - setKilos(value) - }} - style={ - Depto === 'Corresponsalias' - ? { - fontSize: '15px', - backgroundColor: '#FFFFFF', - border: '1px solid #000000', - width: '100%', - borderRadius: '3px' - } - : { - fontSize: '15px', - backgroundColor: '#FFFFFF', - paddingLeft: '20px', - paddingRight: '5px', - border: '1px solid #000000', - width: '100%', - borderRadius: '3px' - } - } - /> + + + Kilos + { + const { value } = values + setKilos(value) + }} + style={{ + fontSize: '15px', + backgroundColor: '#FFFFFF', + border: '1px solid #000000', + width: '100%', + borderRadius: '3px', + textAlign: 'end', + padding: '0 5px' + }} + /> + - + - - - - Estatus + + + + + Tipo de Mercancia + { + setIDTipoMercancia(parseInt(e.target.value)) + }} + > + + {TiposMercancia + ? TiposMercancia.map((t) => { + return ( + + ) + }) + : null} + + - - { - setEstatus(parseInt(e.target.value)) - }} - > - - {DataCatEstatus - ? DataCatEstatus.map((c) => { - return ( - - ) - }) - : null} - + + + Estatus + { + setEstatus(parseInt(e.target.value)) + }} + > + + {DataCatEstatus + ? DataCatEstatus.map((c) => { + return ( + + ) + }) + : null} + + @@ -2588,6 +2650,23 @@ export default function TraficoCorresponsales (props:IProps) { )} + + + + + Trafico Corresponsales: Rechazo(s) diff --git a/src/Interfaces/Catalogos/ICatTiposMercancias.ts b/src/Interfaces/Catalogos/ICatTiposMercancias.ts new file mode 100644 index 0000000..e9eb6b9 --- /dev/null +++ b/src/Interfaces/Catalogos/ICatTiposMercancias.ts @@ -0,0 +1,5 @@ +export interface ITiposMercancias{ + id: number, + clave: string; + descripcion: string; +} \ No newline at end of file diff --git a/src/Interfaces/Catalogos/IClientes.ts b/src/Interfaces/Catalogos/IClientes.ts index abc33d1..ce4d55f 100644 --- a/src/Interfaces/Catalogos/IClientes.ts +++ b/src/Interfaces/Catalogos/IClientes.ts @@ -2,4 +2,5 @@ export default interface IClientes { sClave: number; agrupado: number; sRazonSocial : string; + sRFC : string; } \ No newline at end of file diff --git a/src/Interfaces/Corresponsales/ICorresponsalTrafico.ts b/src/Interfaces/Corresponsales/ICorresponsalTrafico.ts index d070beb..c29099a 100644 --- a/src/Interfaces/Corresponsales/ICorresponsalTrafico.ts +++ b/src/Interfaces/Corresponsales/ICorresponsalTrafico.ts @@ -39,5 +39,6 @@ export default interface ICorresponsalTrafico { idTabulador: number, noRecti: number, estatusCode: number, - activo?: number + activo?: number, + idTipoMercancia: number } diff --git a/src/Services/Catalogos/TiposMercancia.Services.ts b/src/Services/Catalogos/TiposMercancia.Services.ts new file mode 100644 index 0000000..bd8ca8c --- /dev/null +++ b/src/Services/Catalogos/TiposMercancia.Services.ts @@ -0,0 +1,9 @@ +import http from "../common/http-common"; + +class CorresponsalesTiposMercanciaService{ + GetAll() { + return http.get(`/Catalogos/TiposMercancia`); + } +} + +export default new CorresponsalesTiposMercanciaService(); \ No newline at end of file diff --git a/src/store/features/Corresponsales/CorresponsalesTraficoSlice.ts b/src/store/features/Corresponsales/CorresponsalesTraficoSlice.ts index 0b5fd6a..f6019a1 100644 --- a/src/store/features/Corresponsales/CorresponsalesTraficoSlice.ts +++ b/src/store/features/Corresponsales/CorresponsalesTraficoSlice.ts @@ -42,6 +42,7 @@ const CorresponsalesTrafico: ICorresponsalTrafico[] = [{ noRecti:0, estatusCode:0, activo: 0, + idTipoMercancia:0 }] const initialState = { CorresponsalesTrafico }