From d6be08190bc9338733b6ea52e21791bf4e045c77 Mon Sep 17 00:00:00 2001 From: Felix Morales Date: Thu, 21 Sep 2023 16:21:24 -0500 Subject: [PATCH] feature creacion del reporte mensual de newell --- .../Corresponsales/CCorresponsalesTrafico.ts | 14 +- .../Corresponsales/TraficoCorresponsales.tsx | 564 +++++++++--------- .../ReportesClientes/ReporteMensualNewell.tsx | 174 ++++++ .../ReportesClientes/ReporteSemanalNewel.tsx | 6 +- .../Utils/FileManager/FileManager.tsx | 4 +- .../Corresponsales/ICorresponsalTrafico.ts | 4 +- ...Newell.ts => IReporteOperacionesNewell.ts} | 2 +- .../Corresponsales.Trafico.Services.ts | 4 +- .../Reportes/reportesNewell.services.ts | 10 + src/Services/Utils/FileManager.Services.ts | 4 + src/css/generic01.css | 5 +- src/index.tsx | 2 + .../CorresponsalesTraficoSlice.ts | 4 +- 13 files changed, 502 insertions(+), 295 deletions(-) create mode 100644 src/Components/ReportesClientes/ReporteMensualNewell.tsx rename src/Interfaces/ReportesClientes/{IReporteSemanalNewell.ts => IReporteOperacionesNewell.ts} (89%) create mode 100644 src/Services/Reportes/reportesNewell.services.ts diff --git a/src/Classes/Corresponsales/CCorresponsalesTrafico.ts b/src/Classes/Corresponsales/CCorresponsalesTrafico.ts index b179c47..133ee8d 100644 --- a/src/Classes/Corresponsales/CCorresponsalesTrafico.ts +++ b/src/Classes/Corresponsales/CCorresponsalesTrafico.ts @@ -42,7 +42,9 @@ export default class CCorresponsalesTrafico implements ICorresponsalTrafico { noRecti: number; estatusCode: number; activo?: number; - idTipoMercancia: number | null; + idTipoMercancia: number | null; + cargoA: number; + causaRectificacion: string; constructor() { this.id=0 @@ -87,6 +89,8 @@ export default class CCorresponsalesTrafico implements ICorresponsalTrafico { this.estatusCode=0; this.activo=1 this.idTipoMercancia=null; + this.cargoA = 0; + this.causaRectificacion = '' } public getEmptyObject(): ICorresponsalTrafico { @@ -132,7 +136,9 @@ export default class CCorresponsalesTrafico implements ICorresponsalTrafico { noRecti:0, estatusCode:0, activo :1 , - idTipoMercancia: null + idTipoMercancia: null, + cargoA: 0, + causaRectificacion: '' } } @@ -179,7 +185,9 @@ export default class CCorresponsalesTrafico implements ICorresponsalTrafico { noRecti: data.noRecti, estatusCode: data.estatusCode, activo : data.activo, - idTipoMercancia: data.idTipoMercancia, + idTipoMercancia: data.idTipoMercancia, + cargoA: data.cargoA, + causaRectificacion: data.causaRectificacion } } } \ No newline at end of file diff --git a/src/Components/Corresponsales/TraficoCorresponsales.tsx b/src/Components/Corresponsales/TraficoCorresponsales.tsx index 39fff85..97c849f 100644 --- a/src/Components/Corresponsales/TraficoCorresponsales.tsx +++ b/src/Components/Corresponsales/TraficoCorresponsales.tsx @@ -136,6 +136,7 @@ interface IAduanas { export default function TraficoCorresponsales (props:IProps) { const URL = new TargetURL() + const token = localStorage.getItem('token'); const dispatch = useDispatch() const [UserId, setUserId] = useState(() => { const stickyValue = window.localStorage.getItem('UserId') @@ -303,6 +304,10 @@ export default function TraficoCorresponsales (props:IProps) { const [showNextStepModal, setShowNexStepModal] = useState(false); const [nextStepModalHeader, setNextStepModalHeader] = useState(""); const [nextStepModalBody, setNextStepModalBody] = useState(""); + const [CargoPara, setCargoPara] = useState(0); + const [CausaRectificacion, setCausaRectificacion] = useState(''); + const [EncabezadoPedimento1, setEncabezadoPedimento1] = useState("Pedimento"); + const [EncabezadoPedimento2, setEncabezadoPedimento2] = useState("."); const FechaRegistro = currentDate() const msgColor = 'primary' @@ -400,6 +405,8 @@ export default function TraficoCorresponsales (props:IProps) { data.fechaCuenta = FechaCuenta data.idTabulador = IDTabulador data.idTipoMercancia = IDTipoMercancia + data.cargoA = CargoPara + data.causaRectificacion = CausaRectificacion CTrafDataService.Append(data) .then((response) => { if (response.data.estatusCode === 0) { @@ -689,6 +696,8 @@ export default function TraficoCorresponsales (props:IProps) { setNoCuenta(response.data.noCuenta) setFechaCuenta(setDate(response.data.fechaCuenta)) setIDTipoMercancia(response.data.idTipoMercancia); + setCargoPara(response.data.cargoA) + setCausaRectificacion(response.data.causaRectificacion) }) .catch((e: Error) => { setHeader('Error') @@ -723,7 +732,10 @@ export default function TraficoCorresponsales (props:IProps) { const loadRectificacionHistorico = () => { CTrafDataService.GetRectificacionHistorico(IDTrafico) .then((response) => { + if (response.data.id > 0) { + setEncabezadoPedimento1("Pedimento Rectificado") + setEncabezadoPedimento2("Pedimento Original") setAduanaH(response.data.aduana.toString()) setPatenteH(response.data.patente.toString()) setPedimentoH(response.data.pedimento.toString()) @@ -1296,7 +1308,11 @@ export default function TraficoCorresponsales (props:IProps) { await axios.post( URL.get() + `/FileManager/AppendFileByProcess?IdUsuario=${UserId}&Proceso=${31}&Tags=${IDTrafico}&crud=1`, - formData + formData, { + headers:{ + 'Authorization': 'Bearer ' + token + } + } ); /*const url = URL.createObjectURL(blob); const link = document.createElement("a"); @@ -1522,6 +1538,7 @@ export default function TraficoCorresponsales (props:IProps) { + @@ -1538,6 +1555,7 @@ export default function TraficoCorresponsales (props:IProps) { + @@ -1765,126 +1783,113 @@ export default function TraficoCorresponsales (props:IProps) { - + - - - Trafico - +
+ {EncabezadoPedimento1} + - { - setTrafico(e.target.value) - }} - /> - - - Aduana + + Trafico + { + setTrafico(e.target.value) + }} + /> + - - - - Patente + + Aduana + + - + + Patente + + - - - - - - { - openSOIA() - }} - style={{ cursor: 'pointer' }} - > - Pedimento + + + { + openSOIA() + }} + style={{ cursor: 'pointer' }} + > + Pedimento + + { + const { value } = values + setPedimento(value.length === 0 ? 0 : value) + if(value.length === 7 ){ + CTrafDataService.ValidaTraficoDuplicado(Aduana, Patente, value).then( response => { + if(response.data !== ""){ + setHeader('Informativo') + setMsg(`Ya existe un registro con los mismos datos de aduana, patente y pedimento con el folio: ${response.data}`) + setShowMsg(true) + } + }) + } + }} + style={{ + fontSize: '18px', + backgroundColor: '#FEFDF5', + border: '2px solid #837F5D', + width: '100%', + textAlign: 'right', + borderRadius: '10px' + }} + /> - - { - const { value } = values - setPedimento(value.length === 0 ? 0 : value) - if(value.length === 7 ){ - CTrafDataService.ValidaTraficoDuplicado(Aduana, Patente, value).then( response => { - if(response.data !== ""){ - setHeader('Informativo') - setMsg(`Ya existe un registro con los mismos datos de aduana, patente y pedimento con el folio: ${response.data}`) - setShowMsg(true) - } - }) + + + + + Clave + - - - Clave - - - setClavePedimento(e.target.value)} - /> - - - Fec. Pago + onChange={(e) => setClavePedimento(e.target.value)} + /> + - + Fec. Pago + setFechaPago(e.target.value)} + /> + + + + + Cargo A + { + setCargoPara(parseInt(e.target.value)) + }} + + > + + + + + + + + + + Causa Rectificacion: + + + setCausaRectificacion(e.target.value)} + style={{visibility: AduanaH === '' ? 'hidden':'visible'}} /> +
-
- - +
+ {EncabezadoPedimento2} + 0 && !(AduanaH.length>0 && PatenteH.length>0 && PedimentoH.length>0 && FechaPagoH.length>0)) ? 'visible' : 'hidden' }}> - - + + - Aduana + Aduana @@ -1927,89 +1973,94 @@ export default function TraficoCorresponsales (props:IProps) { Patente - + - - - - - - Pedimento - + + + + Pedimento + - - + + - Clave + Clave - - + + - Fec. Pago + Fec. Pago - + +
@@ -2024,35 +2075,23 @@ export default function TraficoCorresponsales (props:IProps) { { const { value } = values setTipoCambio(value) }} - style={ - Depto === 'Corresponsalias' - ? { - fontSize: '18px', - backgroundColor: '#F5FFED', - border: '2px solid #25D05B', - width: '100%', - textAlign: 'right', - borderRadius: '10px' - } - : { - fontSize: '18px', - backgroundColor: '#F5FFED', - border: '2px solid #25D05B', - width: '100%', - textAlign: 'right', - borderRadius: '10px', - paddingRight: '5px', - paddingLeft: '5px' - } - } + style={{ + fontSize: '18px', + backgroundColor: '#F5FFED', + border: '2px solid #25D05B', + width: '100%', + textAlign: 'right', + borderRadius: '10px', + paddingRight: '10px', + paddingLeft: '10px' + }} /> @@ -2064,35 +2103,23 @@ export default function TraficoCorresponsales (props:IProps) { { const { value } = values setValorAduanaMN(value) }} - style={ - Depto === 'Corresponsalias' - ? { - fontSize: '18px', - backgroundColor: '#F5FFED', - border: '2px solid #25D05B', - width: '100%', - textAlign: 'right', - borderRadius: '10px' - } - : { - fontSize: '18px', - backgroundColor: '#F5FFED', - border: '2px solid #25D05B', - width: '100%', - textAlign: 'right', - borderRadius: '10px', - paddingRight: '5px', - paddingLeft: '5px' - } - } + style={{ + fontSize: '18px', + backgroundColor: '#F5FFED', + border: '2px solid #25D05B', + width: '100%', + textAlign: 'right', + borderRadius: '10px', + paddingRight: '10px', + paddingLeft: '10px' + }} /> @@ -2108,35 +2135,23 @@ export default function TraficoCorresponsales (props:IProps) { { const { value } = values setTotalPagado(value) }} - style={ - Depto === 'Corresponsalias' - ? { - fontSize: '18px', - backgroundColor: '#F5FFED', - border: '2px solid #25D05B', - width: '100%', - textAlign: 'right', - borderRadius: '10px' - } - : { - fontSize: '18px', - backgroundColor: '#F5FFED', - border: '2px solid #25D05B', - width: '100%', - textAlign: 'right', - borderRadius: '10px', - paddingRight: '5px', - paddingLeft: '5px' - } - } + style={{ + fontSize: '18px', + backgroundColor: '#F5FFED', + border: '2px solid #25D05B', + width: '100%', + textAlign: 'right', + borderRadius: '10px', + paddingRight: '10px', + paddingLeft: '10px' + }} /> @@ -2253,27 +2268,16 @@ export default function TraficoCorresponsales (props:IProps) { setValorFacturasDls(value) }} readOnly={true} - style={ - Depto === 'Corresponsalias' - ? { - fontSize: '18px', - backgroundColor: '#F5FFED', - border: '2px solid #25D05B', - width: '100%', - textAlign: 'right', - borderRadius: '10px' - } - : { - fontSize: '18px', - backgroundColor: '#F5FFED', - border: '2px solid #25D05B', - width: '100%', - textAlign: 'right', - borderRadius: '10px', - paddingRight: '5px', - paddingLeft: '5px' - } - } + style={{ + fontSize: '18px', + backgroundColor: '#F5FFED', + border: '2px solid #25D05B', + width: '100%', + textAlign: 'right', + borderRadius: '10px', + paddingRight: '10px', + paddingLeft: '10px' + }} />
diff --git a/src/Components/ReportesClientes/ReporteMensualNewell.tsx b/src/Components/ReportesClientes/ReporteMensualNewell.tsx new file mode 100644 index 0000000..dcfd80b --- /dev/null +++ b/src/Components/ReportesClientes/ReporteMensualNewell.tsx @@ -0,0 +1,174 @@ +import { useEffect, useRef, useState } from "react"; +import { Row, Col, Card, Button, Form } from "react-bootstrap"; +import { FaRegFileExcel } from "react-icons/fa"; +import { MdCloudUpload, MdDeleteForever, MdCloudDownload } from "react-icons/md"; +import { MsgInformativo } from "../Utils/Toast/msgInformativo"; +import reportesNewellServices from "../../Services/Reportes/reportesNewell.services"; +import axios from "axios"; +import { TargetURL } from "../../Constants/TargetURL"; +import FileManager from "../Utils/FileManager/FileManager"; +import FileManagerServices from "../../Services/Utils/FileManager.Services"; + +export const ReporteMensualNewell: React.FC<{}> = () => { + const [Mes, setMes] = useState('Septiembre') + const [show, setShowMsg] = useState(false) + const [header, setHeader] = useState('') + const [msg, setMsg] = useState('') + const [msgColor, setMsgColor] = useState('primary') + const [UserId, setUserId] = useState(() => { + const stickyValue = window.localStorage.getItem('UserId') + return stickyValue !== null ? JSON.parse(stickyValue) : 0 + }); + const [IdTrailasFile, setIdTrailasFile] = useState(0); + const [IdOpCdAcunaFile, setIdOpCdAcunaFile] = useState(0); + const [IdOpMyMFile, setIdOpMyMFile] = useState(0); + + const GenerarReporteMensualNewell = async () => { + if (IdTrailasFile === 0 || IdOpCdAcunaFile === 0 || IdOpMyMFile === 0){ + setHeader('Error') + setMsg('Asegurese de cargar todos los archivos para continuar.') + setShowMsg(true) + return; + } + reportesNewellServices.getReporteMensual(IdTrailasFile, IdOpCdAcunaFile, IdOpMyMFile) + .then((response) => { + const url = window.URL.createObjectURL(new Blob([response.data])); + const link = document.createElement('a'); + link.href = url; + link.setAttribute('download', `ReporteMensual_${Mes}.xlsx`); + document.body.appendChild(link); + link.click(); + }).catch(error => { + console.log(error); + }); + } + + const convertFile = (fileId: number, process: number) => { + FileManagerServices.ConvertFile(fileId, process).then((resp: any) => console.log(resp)); + } + + return ( + <> + + + + + +

Reporte Mensual Newell

+ + + + + Mes + setMes(e.target.value)} + value={Mes} + className="form-select form-select-sm" + > + + + + + + + + + + + + + + + + +
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ + + +
+ + +
+ { + setShowMsg(false) + }} + /> + + ) +} \ No newline at end of file diff --git a/src/Components/ReportesClientes/ReporteSemanalNewel.tsx b/src/Components/ReportesClientes/ReporteSemanalNewel.tsx index 2f0b722..f5d57de 100644 --- a/src/Components/ReportesClientes/ReporteSemanalNewel.tsx +++ b/src/Components/ReportesClientes/ReporteSemanalNewel.tsx @@ -5,7 +5,7 @@ import * as XLSX from 'xlsx' import CTrafDataService from '../../Services/Corresponsalias/Corresponsales.Trafico.Services' import { MsgInformativo } from "../Utils/Toast/msgInformativo"; import { FaRegFileExcel } from "react-icons/fa"; -import IReporteSemanalNewell from "../../Interfaces/ReportesClientes/IReporteSemanalNewell"; +import IReporteOperacionesNewell from "../../Interfaces/ReportesClientes/IReporteOperacionesNewell"; export const ReporteSemanalNewell: React.FC<{}> = () => { @@ -56,14 +56,14 @@ export const ReporteSemanalNewell: React.FC<{}> = () => { const oldWorkSheetName = oldWorkBook.SheetNames[0]//se toma el nombre de la primer hoja del archivo const oldWorkSheet = oldWorkBook.Sheets[oldWorkSheetName]//Se crea una referencia a la misma hoja XLSX.utils.sheet_add_aoa(oldWorkSheet,encabezadosTemp,{origin:'A1'});//Se cambian los encabezados originales por los temporales para que las columnas coincidan con las propiedades del dto IReporteSemanalNewell - const rows = XLSX.utils.sheet_to_json(oldWorkSheet)//aqui es donde los renglones pasan a ser un array de objetos + const rows = XLSX.utils.sheet_to_json(oldWorkSheet)//aqui es donde los renglones pasan a ser un array de objetos //Se obtienen los datos faltantes del reporte let newWorkBookData = await getDataByPedimento(rows); await exportReporteSemanal(newWorkBookData); } } - const getDataByPedimento = async (rows: IReporteSemanalNewell[]) => { + const getDataByPedimento = async (rows: IReporteOperacionesNewell[]) => { let data = [...rows]; data=[]; await Promise.all( diff --git a/src/Components/Utils/FileManager/FileManager.tsx b/src/Components/Utils/FileManager/FileManager.tsx index 63dfd91..25c8f58 100644 --- a/src/Components/Utils/FileManager/FileManager.tsx +++ b/src/Components/Utils/FileManager/FileManager.tsx @@ -19,7 +19,7 @@ interface IProps { Leyenda: string canDelete: boolean FileType: string[] - width: number + width: number | string height: number onDelete?: (val: boolean) => void setBackgroundColor?: number @@ -206,7 +206,7 @@ export const FileManager: FC = (props) => { {Archivo?.nombreArchivo ? ( - + {props.Prefijo ? props.Prefijo : 'Archivo'} :   diff --git a/src/Interfaces/Corresponsales/ICorresponsalTrafico.ts b/src/Interfaces/Corresponsales/ICorresponsalTrafico.ts index fb61474..14e45cf 100644 --- a/src/Interfaces/Corresponsales/ICorresponsalTrafico.ts +++ b/src/Interfaces/Corresponsales/ICorresponsalTrafico.ts @@ -40,5 +40,7 @@ export default interface ICorresponsalTrafico { noRecti: number, estatusCode: number, activo?: number, - idTipoMercancia: number | null + idTipoMercancia: number | null, + cargoA: number, + causaRectificacion: string, } diff --git a/src/Interfaces/ReportesClientes/IReporteSemanalNewell.ts b/src/Interfaces/ReportesClientes/IReporteOperacionesNewell.ts similarity index 89% rename from src/Interfaces/ReportesClientes/IReporteSemanalNewell.ts rename to src/Interfaces/ReportesClientes/IReporteOperacionesNewell.ts index 485eb62..788d337 100644 --- a/src/Interfaces/ReportesClientes/IReporteSemanalNewell.ts +++ b/src/Interfaces/ReportesClientes/IReporteOperacionesNewell.ts @@ -1,4 +1,4 @@ -export default interface IReporteSemanalNewell{ +export default interface IReporteOperacionesNewell{ aduana: number; patente: number; pedimento: number; fechaDeEntrada: string|Date; fechaDePago: string|Date; valorComercialMxn: number; valorComercialDlls: number; valorAduana: number; clave: string; iva: number; dta: number; prv: number; lgi: number; factura: string; tc: number; proveedor: string; taxId: number; producto: string; diff --git a/src/Services/Corresponsalias/Corresponsales.Trafico.Services.ts b/src/Services/Corresponsalias/Corresponsales.Trafico.Services.ts index f217a7a..9560206 100644 --- a/src/Services/Corresponsalias/Corresponsales.Trafico.Services.ts +++ b/src/Services/Corresponsalias/Corresponsales.Trafico.Services.ts @@ -6,7 +6,7 @@ import DTOTraficoCompleto from "../../DTO/Corresponsales/DTOTraficoCompleto"; import IRespuesta from "../../Interfaces/IRespuesta"; import ICorresponsalRectificacionHistorico from "../../Interfaces/Corresponsales/ICorresponsalRectificacionHistorico"; import DTORectificacionHistorico from "../../DTO/Corresponsales/DTORectificacionHistorico"; -import IReporteSemanalNewell from "../../Interfaces/ReportesClientes/IReporteSemanalNewell"; +import IReporteOperacionesNewell from "../../Interfaces/ReportesClientes/IReporteOperacionesNewell"; class Corresponsales_Trafico_DataService { GetAll(id: number) { @@ -14,7 +14,7 @@ class Corresponsales_Trafico_DataService { } GetByPedimento(pedimento: number) { - return http.get(`/Corresponsalias/Traficos/GetByPedimento?pedimento=${pedimento}`); + return http.get(`/Corresponsalias/Traficos/GetByPedimento?pedimento=${pedimento}`); } Append(data: ICorresponsalTrafico) { diff --git a/src/Services/Reportes/reportesNewell.services.ts b/src/Services/Reportes/reportesNewell.services.ts new file mode 100644 index 0000000..eab6ca0 --- /dev/null +++ b/src/Services/Reportes/reportesNewell.services.ts @@ -0,0 +1,10 @@ +import http from "../common/http-common"; + +class ReportesNewellService{ + + getReporteMensual(IdTrailasFile: number, IdOpCdAcunaFile: number, IdOpMyMFile: number){ + return http.get(`reportesNewell/ReporteMensual?idTrailasFile=${IdTrailasFile}&idRptCdAcunaFile=${IdOpCdAcunaFile}&idRptLazaroCardenasFile=${IdOpMyMFile}`, {responseType: 'blob'}); + } +} + +export default new ReportesNewellService(); \ No newline at end of file diff --git a/src/Services/Utils/FileManager.Services.ts b/src/Services/Utils/FileManager.Services.ts index f857d66..faddf06 100644 --- a/src/Services/Utils/FileManager.Services.ts +++ b/src/Services/Utils/FileManager.Services.ts @@ -23,5 +23,9 @@ class FileManagerDataService { return http.delete(`/FileManager/DeleteById/${id}`); } + ConvertFile(fileId: number, process: number){ + return http.get(`/FileManager/ConvertExcel2New?id=${fileId}&Proceso=${process}`); + } + } export default new FileManagerDataService(); \ No newline at end of file diff --git a/src/css/generic01.css b/src/css/generic01.css index 9a41035..608aa2c 100644 --- a/src/css/generic01.css +++ b/src/css/generic01.css @@ -65,9 +65,10 @@ tr:nth-child(odd) { background-color: #f5f5f5; } .hideDiv { - visibility: 'hidden'; + display: none; + /*visibility: 'hidden'; height: '0px'; - width: '0px'; + width: '0px';*/ } .hideRow { diff --git a/src/index.tsx b/src/index.tsx index b2fd4bb..8709572 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -21,6 +21,7 @@ import PIN from './Components/Login/PIN' import UserControl from './Components/UserControl/UserControl' import ResetCredentials from './Components/Login/ResetCredentials' import { ReporteSemanalNewell } from './Components/ReportesClientes/ReporteSemanalNewel' +import { ReporteMensualNewell } from './Components/ReportesClientes/ReporteMensualNewell' require (`./css/${process.env.REACT_APP_ENVIRONMENT}-home.css`) function PageNotFound() { @@ -73,6 +74,7 @@ root.render( } /> } /> }/> + }/> diff --git a/src/store/features/Corresponsales/CorresponsalesTraficoSlice.ts b/src/store/features/Corresponsales/CorresponsalesTraficoSlice.ts index f6019a1..a13492e 100644 --- a/src/store/features/Corresponsales/CorresponsalesTraficoSlice.ts +++ b/src/store/features/Corresponsales/CorresponsalesTraficoSlice.ts @@ -42,7 +42,9 @@ const CorresponsalesTrafico: ICorresponsalTrafico[] = [{ noRecti:0, estatusCode:0, activo: 0, - idTipoMercancia:0 + idTipoMercancia:0, + cargoA: 0, + causaRectificacion: '' }] const initialState = { CorresponsalesTrafico }