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

feature/ConsolidarPedimentos_20231229
Felix Morales 1 year ago
parent d6be08190b
commit 83a72b0809
  1. 107
      src/Components/Catalogos/CatCentroCostos/CatCentroCostos.tsx
  2. 180
      src/Components/Corresponsales/TraficoCorresponsales.tsx
  3. 6
      src/DTO/DTOCatCentrosCostos.ts
  4. 5
      src/Interfaces/Catalogos/ICatCentroCostos.ts
  5. 20
      src/Services/Catalogos/CentrosCostos.Service.ts
  6. 2
      src/index.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<DTOCatCentrosCostos[]>([]);
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 (
<Row style={{paddingTop:'3rem'}}>
<Col lg={1} xl={2}></Col>
<Col xs={12} lg={10} xl={8}>
<Card style={{width:'100%'}}>
<Card.Header><h4>Centro de Costos</h4></Card.Header>
<Card.Body style={{
height: '35rem'
}}>
<div style={{
height: '100%',
overflowY:'scroll'
}}>
<Table responsive>
<thead>
<th>Clave</th>
<th>Cliente</th>
<th>Centro Costos</th>
<th></th>
</thead>
<tbody>
{
CentrosCostos.map((centroCosto, index) =>
<tr>
<td>{centroCosto.idCliente}</td>
<td>{centroCosto.nombreCliente}</td>
<td>{
<CurrencyFormat
value={centroCosto.centroCostos}
disabled={false}
displayType={'input'}
format={'#-####'}
style={{
fontSize: '18px',
backgroundColor: '#F1EEF9',
border: '2px solid #5923F6',
color: '#5923F6',
width: '100%',
textAlign: 'right',
borderRadius: '10px',
paddingRight: '10px',
paddingLeft: '10px',
}}
onValueChange={(values: any) => {
const {formattedValue, value, floatValue} = values;
centroCosto.centroCostos = formattedValue;
}}
/>
}</td>
<td><Button variant="primary" onClick={() => saveCentroCosto(centroCosto, index)}>Guardar</Button></td>
</tr>
)
}
</tbody>
</Table>
</div>
</Card.Body>
</Card>
</Col>
<Col lg={1} xl={2}></Col>
<MsgInformativo
show={show}
msg={msg}
header={header}
msgColor={msgColor}
closeToast={() => {
setShowMsg(false)
}}
/>
</Row>
)
}

@ -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<string>('');
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 (
<div>
<Card className="labelSize13px">
<Card className="labelSize13px" style={{borderStyle:'none', height:'40rem', overflowY:'scroll'}}>
<Card.Body className={StatusColor}>
<Card>
<Card.Header>
@ -1431,74 +1459,91 @@ export default function TraficoCorresponsales (props:IProps) {
<Row style={{padding: "5px 0"}}>
<Col sm={12} md={6} lg={5}>
<Row>
<Col sm={3} md={2} lg={1}>
<Form.Label>Cliente</Form.Label>
</Col>
<Col sm={9} md={10} lg={11}>
<Form.Control
as="select"
id="CmbCliente"
disabled={(Depto !== 'Corresponsalias' && Depto !== 'Sistemas')}
onChange={(e) => {
setIDCliente(parseInt(e.target.value))
}}
value={IDCliente}
className="form-select form-select-sm"
>
<option value="0">-SELECCIONE-</option>
{Clientes
? Clientes.map((c) => {
return (
<option key={c.sClave} value={c.sClave}>
{c.sRazonSocial}
</option>
)
})
: null}
</Form.Control>
<Form.Label>
Cliente
<Form.Control
as="select"
id="CmbCliente"
disabled={(Depto !== 'Corresponsalias' && Depto !== 'Sistemas')}
onChange={(e) => {
setIDCliente(parseInt(e.target.value))
getCentroCostos(+e.target.value);
}}
value={IDCliente}
className="form-select form-select-sm"
>
<option value="0">-SELECCIONE-</option>
{Clientes
? Clientes.map((c) => {
return (
<option key={c.sClave} value={c.sClave}>
{c.sRazonSocial}
</option>
)
})
: null}
</Form.Control>
</Form.Label>
</Col>
</Row>
</Col>
<Col sm={12} md={6} lg={6}>
<Row>
<Col sm={3} md={4} lg={2}>
<Form.Label
onClick={() => {
return (Depto === 'Corresponsalias' || Depto === 'Sistemas')
? showModalBox(10)
: ''
}}
style={{ cursor: 'pointer' }}
>
<IconContext.Provider
value={{ color: 'blue', size: '15px' }}
>
<FcTimeline />
</IconContext.Provider>
&nbsp;Precuenta
<Col sm={6} md={6} lg={3}>
<Form.Label> Centro de Costos
<CurrencyFormat
value={CentroCostos}
disabled={true}
displayType={'input'}
format={'#-####'}
style={{
fontSize: '18px',
backgroundColor: '#F1EEF9',
border: '2px solid #5923F6',
color: '#5923F6',
width: '100%',
textAlign: 'right',
borderRadius: '10px',
paddingRight: '10px',
paddingLeft: '10px'
}}
/>
</Form.Label>
</Col>
<Col sm={9} md={8} lg={6}>
<Form.Control
as="select"
disabled={true}
onChange={(e) => {
setIDTabulador(parseInt(e.target.value))
}}
value={IDTabulador}
className="form-select form-select-sm"
>
<option value="0">-SELECCIONE-</option>
{Tabuladores
? Tabuladores.map((t) => {
return (
<option key={t.id} value={t.id}>
{t.nombre}
</option>
)
})
: null}
</Form.Control>
<Col sm={6} md={6} lg={5}>
<Form.Label style={{ width:'100%' }}>
<IconContext.Provider value={{ color: 'blue', size: '15px' }}>
<span onClick={() => {
return (Depto === 'Corresponsalias' || Depto === 'Sistemas')
? showModalBox(10)
: ''
}}
style={{ cursor: 'pointer' }}>
<FcTimeline />&nbsp;Precuenta
</span>
</IconContext.Provider>
<Form.Control
as="select"
disabled={true}
onChange={(e) => {
setIDTabulador(parseInt(e.target.value))
}}
value={IDTabulador}
className="form-select form-select-sm"
>
<option value="0">-SELECCIONE-</option>
{Tabuladores
? Tabuladores.map((t) => {
return (
<option key={t.id} value={t.id}>
{t.nombre}
</option>
)
})
: null}
</Form.Control>
</Form.Label>
</Col>
</Row>
</Col>
@ -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'}}
>
<Tab
eventKey="InformacionGeneral"
@ -1882,7 +1928,7 @@ export default function TraficoCorresponsales (props:IProps) {
disabled={
Depto !== 'Corresponsalias' ? true : false
}
onChange={(e) => setClavePedimento(e.target.value)}
onChange={(e) => {if(e.target.value.length <= 2) setClavePedimento(e.target.value)}}
/>
</Form.Label>
</Col>

@ -0,0 +1,6 @@
export default interface DTOCatCentrosCostos{
id:number;
idCliente: number;
nombreCliente: string;
centroCostos: string;
}

@ -0,0 +1,5 @@
export interface ICatCentroCostos{
id:number;
idCliente: number;
centroCostos: string;
}

@ -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<DTOCatCentrosCostos[]>('/Catalogos/CatCentrosCostos/GetAll');
}
append(centroCostos: ICatCentroCostos){
console.log('Guardando ',centroCostos)
return http.post<DTOCatCentrosCostos[]>('/Catalogos/CatCentrosCostos/Append', centroCostos);
}
get(idCliente: number){
return http.get<string>(`/Catalogos/CatCentrosCostos?idCliente=${idCliente}`);
}
}
export default new CentrosCostosService();

@ -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(
<Route path="*" element={<PageNotFound />} />
<Route path='newellSemanal' element={<ReporteSemanalNewell/>}/>
<Route path='newellMensual' element={<ReporteMensualNewell/>}/>
<Route path='CentroCostos' element={<CatCentroConstos/>}/>
</Route>
</Routes>
</HashRouter>

Loading…
Cancel
Save