diff --git a/src/Components/Catalogos/CatTabulador/CatTabulador.tsx b/src/Components/Catalogos/CatTabulador/CatTabulador.tsx index 003fb5d..f868833 100644 --- a/src/Components/Catalogos/CatTabulador/CatTabulador.tsx +++ b/src/Components/Catalogos/CatTabulador/CatTabulador.tsx @@ -17,7 +17,9 @@ import 'react-data-table-component-extensions/dist/index.css' import { BsPlusSquareFill } from 'react-icons/bs' import IClientes from '../../../Interfaces/Catalogos/IClientes' import { FcTimeline } from 'react-icons/fc' -import { FaEraser, FaTimesCircle } from 'react-icons/fa' +import { FaEraser, FaPencilAlt, FaSave, FaTimesCircle } from 'react-icons/fa' +import CorresponsalesServices from '../../../Services/Catalogos/Corresponsales.Services' +import ICatCorresponsales from '../../../Interfaces/Catalogos/ICatCorresponsales' interface IProps {} @@ -47,27 +49,38 @@ export default function CatTabuladores (props: IProps) { const [show, setShowMsg] = useState(false) const [msg, setMsg] = useState('') const [DialogTabs, setDialogTabs] = useState(false) + const [Corresponsal, setCorresponsal] = useState(0) + const [Corresponsales, setCorresponsales] = useState([]) const columnsConcepts = [ - { - name: 'id', - selector: (row: ITabuladorConceptos) => row.id, - sortable: true, - }, { name: 'Concepto', - width: '70%', + width: '85%', selector: (row: ITabuladorConceptos) => row.concepto, sortable: true, }, { - name: 'Costo', + name: 'Costo Cliente', + width: '15%', cell: (row: ITabuladorConceptos) => ( { - postCost(id, value) + postCost(id, value, row.costoCorresponsal) + }} + /> + ), + }, + { + name: 'Costo Corresponsal', + width: '15%', + cell: (row: ITabuladorConceptos) => ( + { + postCost(id, row.costo, value) }} /> ), @@ -76,25 +89,32 @@ export default function CatTabuladores (props: IProps) { const columnsTabs = [ { - name: 'id', - selector: (row: ITabulador) => row.id, + name: 'Nombre', + width: '70%', + cell: (row: ITabulador) => ( +
+ {row.nombre} +
+ ), sortable: true, }, { - name: 'Nombre', - width: '70%', + name: 'Editar', + width: '10%', cell: (row: ITabulador) => (
{ setTabulador(row.id) setNombreTabulador(row.nombre) + setCorresponsal(row.idCorresponsal!) }} > - {row.nombre} + + +
), - sortable: true, }, { name: 'Elimina', @@ -115,14 +135,15 @@ export default function CatTabuladores (props: IProps) { }, ] - const postCost = (id: number, Cost: number) => { + const postCost = (id: number, costoCliente: number, costoCorresponsal: number) => { const data: ITabuladorConceptos = { id: id, idTabulador: Tabulador, idConcepto: Concepto, concepto: '', - costo: Cost, + costo: costoCliente, activo: 1, + costoCorresponsal: costoCorresponsal } CTabDetDataService.Append(data) .then((response) => { @@ -130,6 +151,7 @@ export default function CatTabuladores (props: IProps) { setHeader('Confirmacion') setMsg('La informacion se guardo corrctamente') setShowMsg(true) + setConcepto(0) }) .catch((e: Error) => { setHeader('Error') @@ -181,9 +203,19 @@ export default function CatTabuladores (props: IProps) { setShowMsg(true) return }) + CorresponsalesServices.getAll() + .then((response) => { + setCorresponsales(response.data) + }) + .catch((e: Error) => { + setHeader('Error') + setMsg('Ocurrio un error: ' + e) + setShowMsg(true) + return + }) }, []) - useEffect(() => { + useEffect(() => {//Consulta los conceptos del tabulador CTabDetDataService.GetDetailByIdTab(Tabulador) .then((response) => { setDetalleConceptos(response.data) @@ -197,12 +229,12 @@ export default function CatTabuladores (props: IProps) { console.log(Tabulador) }, [Tabulador]) - useEffect(() => { + useEffect(() => {//Consulta los tabuladores de un cliente if (Cliente > 0) { setNombreTabulador('') setTabuladores([]) setDetalleConceptos([]) - CTabDataService.GetByCustomer(Cliente) + CTabDataService.GetByCustomer(Cliente, null) .then((response) => { setTabuladores(response.data) }) @@ -228,12 +260,14 @@ export default function CatTabuladores (props: IProps) { } const saveForm = () => { - const data: ITabulador = { - id: Tabulador, - idCliente: Cliente, - nombre: NombreTabulador, - } - CTabDataService.Append(data) + if(NombreTabulador){ + const data: ITabulador = { + id: Tabulador, + idCliente: Cliente, + nombre: NombreTabulador, + idCorresponsal:Corresponsal + } + CTabDataService.Append(data) .then((response) => { if (response.status === 200) { setHeader('Informativo') @@ -260,6 +294,13 @@ export default function CatTabuladores (props: IProps) { setShowMsg(true) return }) + }else{ + setHeader('Error') + setMsg('Favor de capturar el nombre del tabulador') + setShowMsg(true) + setCorresponsal(0) + return + } } const addConcept = () => { @@ -275,7 +316,14 @@ export default function CatTabuladores (props: IProps) { setShowMsg(true) return } - postCost(0, 0) + postCost(0, 0, 0) + } + + const clearForm = () => { + setTabulador(0) + setNombreTabulador('') + setCorresponsal(0) + setConcepto(0) } return ( @@ -283,7 +331,7 @@ export default function CatTabuladores (props: IProps) { - Tabuladores + Tabuladores Clientes @@ -314,48 +362,6 @@ export default function CatTabuladores (props: IProps) { - { - setTabulador(0) - setNombreTabulador('') - }} - > - - - - - -
-
Tabulador
-
- - -

- { - setNombreTabulador(e.target.value) - }} - placeholder='Nombre del tabulador' - style={{ fontSize: '18px' }} - /> -

- - - -
@@ -364,18 +370,39 @@ export default function CatTabuladores (props: IProps) { - - Tabulador + {clearForm()}} + > + + + - - { - filtraTabulador(e) - }} - /> + +
+
Tabulador
+
+ + +

+ { + setNombreTabulador(e.target.value) + }} + placeholder='Ingrese el nombre del tabulador...' + style={{ fontSize: '18px' }} + /> +

+ + + + saveForm()} style={{ cursor: 'pointer' }}/> +
@@ -395,16 +422,45 @@ export default function CatTabuladores (props: IProps) { + + Corresponsal: + + { + setCorresponsal(parseInt(e.target.value)) + }} + className='form-select form-select-sm' + style={{ fontSize: '18px' }} + value={Corresponsal} + > + + {Corresponsales + ? Corresponsales.map((c) => { + return ( + + ) + }) + : null} + + + +
Conceptos setConcepto(parseInt(e.target.value))} className='form-select form-select-sm' style={{ fontSize: '17px' }} + value={Concepto} > {CatConceptos diff --git a/src/Components/Clientes/Traficos/TraficoCliente.tsx b/src/Components/Clientes/Traficos/TraficoCliente.tsx index 8958523..3342484 100644 --- a/src/Components/Clientes/Traficos/TraficoCliente.tsx +++ b/src/Components/Clientes/Traficos/TraficoCliente.tsx @@ -957,18 +957,6 @@ export default function TraficoCliente(props:IProps){ }*/ useEffect(() => { - if (IDCliente > 0) { - CTabDataService.GetByCustomer(IDCliente) - .then((response) => { - setTabuladores(response.data) - }) - .catch((e: Error) => { - setHeader('Error') - setMsg('Ocurrio un error: ' + e) - setShowMsg(true) - return - }) - } if (Clientes) { let tmpArray: ItemList[] = [] Clientes.forEach((element) => { @@ -3275,6 +3263,7 @@ export default function TraficoCliente(props:IProps){ IDTrafico={IDTrafico} IDTabulador={IDTabulador} NombreCliente={NombreCliente} + IDCorresponsal={null} closeTabulador={function (arg: boolean): void { setShowModal(arg) }} diff --git a/src/Components/Corresponsales/Tabulador/Tabulador.tsx b/src/Components/Corresponsales/Tabulador/Tabulador.tsx index 3f04379..5951167 100644 --- a/src/Components/Corresponsales/Tabulador/Tabulador.tsx +++ b/src/Components/Corresponsales/Tabulador/Tabulador.tsx @@ -15,6 +15,7 @@ interface IProps { IDCliente: number IDTabulador: number IDTrafico: number + IDCorresponsal: number | null NombreCliente: string closeTabulador: (arg: boolean) => void cambiaPrecuenta: (IDPrecuenta: number) => void @@ -41,20 +42,14 @@ export const Tabulador: FC = (props) => { const [msg, setMsg] = useState('') const columnsConcepts = [ - { - name: 'id', - width: '10%', - selector: (row: ITabuladorConceptos) => row.id, - sortable: true, - }, { name: 'Concepto', - width: '65%', + width: '60%', selector: (row: ITabuladorConceptos) => row.concepto, sortable: true, }, { - name: 'Costo', + name: 'Costo Cte', width: '15%', cell: (row: ITabuladorConceptos) => { return {}} /> @@ -65,6 +60,18 @@ export const Tabulador: FC = (props) => { )*/ }, }, + { + name: 'Costo Corresp', + width: '15%', + cell: (row: ITabuladorConceptos) => { + return {}} /> + /*return row.activo === 1 ? ( + {}} /> + ) : ( + {}} /> + )*/ + }, + }, { name: 'Activo', width: '10%', @@ -134,7 +141,7 @@ export const Tabulador: FC = (props) => { // const postCost = (id: number, Cost: number) => {} const GetAllTabs = () => { - CTabDataService.GetByCustomer(props.IDCliente) + CTabDataService.GetByCustomer(props.IDCliente, props.IDCorresponsal) .then((response) => { setTabuladores(response.data) }) diff --git a/src/Components/Corresponsales/TraficoCorresponsales.tsx b/src/Components/Corresponsales/TraficoCorresponsales.tsx index 10bf725..ba21804 100644 --- a/src/Components/Corresponsales/TraficoCorresponsales.tsx +++ b/src/Components/Corresponsales/TraficoCorresponsales.tsx @@ -1112,7 +1112,7 @@ export default function TraficoCorresponsales (props:IProps) { useEffect(() => { if (IDCliente > 0) { - CTabDataService.GetByCustomer(IDCliente) + CTabDataService.GetByCustomer(IDCliente, IDCorresponsal) .then((response) => { setTabuladores(response.data) }) @@ -1734,7 +1734,7 @@ export default function TraficoCorresponsales (props:IProps) { - {showModalBox(10, 'modal-50w', false)}} + {showModalBox(10, 'modal-70w', false)}} style={{ cursor: 'pointer' }}>  Precuenta @@ -4338,11 +4338,12 @@ export default function TraficoCorresponsales (props:IProps) { ) : null} {LoadComponent === 10 ? ( -
+
(`/Catalogos/Tabulador/getAll?id=0&IdCliente=0`); } - GetByCustomer(IdCliente: number) { - return http.get(`/Catalogos/Tabulador/getAll?IdCliente=${IdCliente}`); + GetByCustomer(IdCliente: number, IdCorresponsal: number | null) { + return http.get(`/Catalogos/Tabulador/getAll?IdCliente=${IdCliente}&IdCorresponsal=${IdCorresponsal}`); } Append(data: ITabulador) { return http.post("/Catalogos/Tabulador/Append", data);