From 83a72b0809c179e2423e1cb6d8a41d8cfcdaab7b Mon Sep 17 00:00:00 2001 From: Felix Morales Date: Tue, 26 Sep 2023 17:41:24 -0500 Subject: [PATCH] Creacion del catalogo de centros de costos de clientes. Agregar campo para mostrar cc al crear un trafico. Validar que se tenga capturado el cc y la descripcion de la mercancia. Agregar el cc y la descripcion al txt de facturacion --- .../CatCentroCostos/CatCentroCostos.tsx | 107 +++++++++++ .../Corresponsales/TraficoCorresponsales.tsx | 180 +++++++++++------- src/DTO/DTOCatCentrosCostos.ts | 6 + src/Interfaces/Catalogos/ICatCentroCostos.ts | 5 + .../Catalogos/CentrosCostos.Service.ts | 20 ++ src/index.tsx | 2 + 6 files changed, 253 insertions(+), 67 deletions(-) create mode 100644 src/Components/Catalogos/CatCentroCostos/CatCentroCostos.tsx create mode 100644 src/DTO/DTOCatCentrosCostos.ts create mode 100644 src/Interfaces/Catalogos/ICatCentroCostos.ts create mode 100644 src/Services/Catalogos/CentrosCostos.Service.ts diff --git a/src/Components/Catalogos/CatCentroCostos/CatCentroCostos.tsx b/src/Components/Catalogos/CatCentroCostos/CatCentroCostos.tsx new file mode 100644 index 0000000..8198e32 --- /dev/null +++ b/src/Components/Catalogos/CatCentroCostos/CatCentroCostos.tsx @@ -0,0 +1,107 @@ +import React, { FC, useEffect, useState } from "react"; +import { Button, Card, Col, Row, Table } from "react-bootstrap"; +import CurrencyFormat from "react-currency-format"; +import { ICatCentroCostos } from "../../../Interfaces/Catalogos/ICatCentroCostos"; +import CentrosCostosService from "../../../Services/Catalogos/CentrosCostos.Service"; +import DTOCatCentrosCostos from "../../../DTO/DTOCatCentrosCostos"; +import { MsgInformativo } from "../../Utils/Toast/msgInformativo"; +import { error } from "console"; + +export const CatCentroConstos: FC = () => { + + const [CentrosCostos, setCentrosCostos] = useState([]); + const centros:ICatCentroCostos[] = []; + const [header, setHeader] = useState('') + const [show, setShowMsg] = useState(false) + const [msg, setMsg] = useState('') + const msgColor = 'primary' + useEffect(()=>{ + CentrosCostosService.getAllCentrosCostos().then(response => setCentrosCostos(response.data)) + },[]) + + const saveCentroCosto = (centroCostos: ICatCentroCostos, index: number) => { + CentrosCostosService.append(centroCostos).then(response => { + setCentrosCostos(response.data) + setHeader('Informativo') + setMsg('Centro de costos actualizado con exito') + setShowMsg(true) + return + }).catch(error => { + setHeader('Error') + setMsg('Ocurrio un error al guardar el centro de costos. Intentelo de nuevo') + setShowMsg(true) + return + }); + } + return ( + + + + +

Centro de Costos

+ +
+ + + + + + + + + { + CentrosCostos.map((centroCosto, index) => + + + + + + + ) + } + +
ClaveClienteCentro Costos
{centroCosto.idCliente}{centroCosto.nombreCliente}{ + { + const {formattedValue, value, floatValue} = values; + centroCosto.centroCostos = formattedValue; + }} + /> + }
+
+
+
+ + + { + setShowMsg(false) + }} + /> +
+ ) +} \ No newline at end of file diff --git a/src/Components/Corresponsales/TraficoCorresponsales.tsx b/src/Components/Corresponsales/TraficoCorresponsales.tsx index 97c849f..25eb335 100644 --- a/src/Components/Corresponsales/TraficoCorresponsales.tsx +++ b/src/Components/Corresponsales/TraficoCorresponsales.tsx @@ -114,6 +114,7 @@ import ICorresponsalFacturas from '../../Interfaces/Corresponsales/ICorresponsal import { ITiposMercancias } from '../../Interfaces/Catalogos/ICatTiposMercancias' import axios from 'axios' import { TargetURL } from '../../Constants/TargetURL' +import CentrosCostosService from '../../Services/Catalogos/CentrosCostos.Service' interface IProps { IDTrafico: number @@ -308,6 +309,7 @@ export default function TraficoCorresponsales (props:IProps) { const [CausaRectificacion, setCausaRectificacion] = useState(''); const [EncabezadoPedimento1, setEncabezadoPedimento1] = useState("Pedimento"); const [EncabezadoPedimento2, setEncabezadoPedimento2] = useState("."); + const [CentroCostos, setCentroCostos] = useState(''); const FechaRegistro = currentDate() const msgColor = 'primary' @@ -370,7 +372,7 @@ export default function TraficoCorresponsales (props:IProps) { setMsg('Para continuar seleccion el corresponsal') setShowMsg(true) return - } + } let data = new CCorresponsalesTrafico().getEmptyObject() data.id = IDTrafico data.idUsuario = UserId @@ -668,6 +670,7 @@ export default function TraficoCorresponsales (props:IProps) { setFolioTrafico(response.data.folioGemco) setProceso(response.data.proceso) setIDCliente(response.data.idCliente) + getCentroCostos(response.data.idCliente); setIDTabulador(response.data.idTabulador) setTipoOperacion(response.data.tipoOperacion) setOpEntrada(response.data.opEntrada) @@ -863,7 +866,9 @@ export default function TraficoCorresponsales (props:IProps) { FechaDesaduanamiento !== null && NoCuenta !== null && TieneArchivoZIPGEMCO && - TieneArchivoZIPCorresponsal + TieneArchivoZIPCorresponsal && + DescripcionMercancia !== '' && DescripcionMercancia !== undefined && + CentroCostos !== '' ) { let tmp = Pedimento?.toString() if (tmp?.length === 7) { @@ -888,7 +893,9 @@ export default function TraficoCorresponsales (props:IProps) { FechaDesaduanamiento, NoCuenta, TieneArchivoZIPGEMCO, - TieneArchivoZIPCorresponsal + TieneArchivoZIPCorresponsal, + DescripcionMercancia, + CentroCostos ]) useEffect(() => { @@ -1286,7 +1293,7 @@ export default function TraficoCorresponsales (props:IProps) { // 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"}"|`; + 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; @@ -1300,7 +1307,7 @@ export default function TraficoCorresponsales (props:IProps) { // 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-${IDCliente}"`; + 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(); @@ -1335,9 +1342,30 @@ export default function TraficoCorresponsales (props:IProps) { return pedidos; } + const getCentroCostos = (idCliente: number) => { + if(idCliente > 0){ + CentrosCostosService.get(idCliente) + .then(response => { + if(response.status === 204){ + setHeader('Informativo') + setMsg('Centro de costos no asignado. Solicitar a servicios administrativos la asignacion del centro de costos del cliente.') + setShowMsg(true) + return + } + setCentroCostos(response.data) + }) + .catch((e: Error) => { + setHeader('Error') + setMsg('Ocurrio un error: ' + e) + setShowMsg(true) + return + }); + } + } + return (
- + @@ -1431,74 +1459,91 @@ export default function TraficoCorresponsales (props:IProps) { - - Cliente - - { - setIDCliente(parseInt(e.target.value)) - }} - value={IDCliente} - className="form-select form-select-sm" - > - - {Clientes - ? Clientes.map((c) => { - return ( - - ) - }) - : null} - + + Cliente + { + setIDCliente(parseInt(e.target.value)) + getCentroCostos(+e.target.value); + }} + value={IDCliente} + className="form-select form-select-sm" + > + + {Clientes + ? Clientes.map((c) => { + return ( + + ) + }) + : null} + + - - { - return (Depto === 'Corresponsalias' || Depto === 'Sistemas') - ? showModalBox(10) - : '' - }} - style={{ cursor: 'pointer' }} - > - - - -  Precuenta + + Centro de Costos + - - { - setIDTabulador(parseInt(e.target.value)) - }} - value={IDTabulador} - className="form-select form-select-sm" - > - - {Tabuladores - ? Tabuladores.map((t) => { - return ( - - ) - }) - : null} - + + + + { + return (Depto === 'Corresponsalias' || Depto === 'Sistemas') + ? 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} + + @@ -1653,6 +1698,7 @@ export default function TraficoCorresponsales (props:IProps) { defaultActiveKey="InformacionGeneral" id="uncontrolled-tab-example" className="mb-3" + style={{visibility: IDTrafico !== 0 ? 'visible' : 'hidden'}} > setClavePedimento(e.target.value)} + onChange={(e) => {if(e.target.value.length <= 2) setClavePedimento(e.target.value)}} /> diff --git a/src/DTO/DTOCatCentrosCostos.ts b/src/DTO/DTOCatCentrosCostos.ts new file mode 100644 index 0000000..e5b038f --- /dev/null +++ b/src/DTO/DTOCatCentrosCostos.ts @@ -0,0 +1,6 @@ +export default interface DTOCatCentrosCostos{ + id:number; + idCliente: number; + nombreCliente: string; + centroCostos: string; +} \ No newline at end of file diff --git a/src/Interfaces/Catalogos/ICatCentroCostos.ts b/src/Interfaces/Catalogos/ICatCentroCostos.ts new file mode 100644 index 0000000..08d1d77 --- /dev/null +++ b/src/Interfaces/Catalogos/ICatCentroCostos.ts @@ -0,0 +1,5 @@ +export interface ICatCentroCostos{ + id:number; + idCliente: number; + centroCostos: string; +} \ No newline at end of file diff --git a/src/Services/Catalogos/CentrosCostos.Service.ts b/src/Services/Catalogos/CentrosCostos.Service.ts new file mode 100644 index 0000000..8c5ae25 --- /dev/null +++ b/src/Services/Catalogos/CentrosCostos.Service.ts @@ -0,0 +1,20 @@ +import http from "../common/http-common"; +import { ICatCentroCostos } from "../../Interfaces/Catalogos/ICatCentroCostos"; +import DTOCatCentrosCostos from "../../DTO/DTOCatCentrosCostos"; + +class CentrosCostosService{ + getAllCentrosCostos(){ + return http.get('/Catalogos/CatCentrosCostos/GetAll'); + } + + append(centroCostos: ICatCentroCostos){ + console.log('Guardando ',centroCostos) + return http.post('/Catalogos/CatCentrosCostos/Append', centroCostos); + } + + get(idCliente: number){ + return http.get(`/Catalogos/CatCentrosCostos?idCliente=${idCliente}`); + } +} + +export default new CentrosCostosService(); \ No newline at end of file diff --git a/src/index.tsx b/src/index.tsx index 8709572..9d3ea43 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -22,6 +22,7 @@ import UserControl from './Components/UserControl/UserControl' import ResetCredentials from './Components/Login/ResetCredentials' import { ReporteSemanalNewell } from './Components/ReportesClientes/ReporteSemanalNewel' import { ReporteMensualNewell } from './Components/ReportesClientes/ReporteMensualNewell' +import { CatCentroConstos } from './Components/Catalogos/CatCentroCostos/CatCentroCostos' require (`./css/${process.env.REACT_APP_ENVIRONMENT}-home.css`) function PageNotFound() { @@ -75,6 +76,7 @@ root.render( } /> }/> }/> + }/>