From 82b77d1e6ec5a9ed35f8df068bd36af2d948d542 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 31 Jan 2023 17:56:50 -0600 Subject: [PATCH] Se le hacen mejoras al catalogo de numero de partes --- .../ComboSelect/ComboDescripcion.tsx | 6 +- .../Components/ComboSelect/ComboFraccion.tsx | 5 +- .../Clientes/Amazon/DTO/DTO2096Estatus.ts | 5 + .../Clientes/Amazon/DTO/DTO2096NoParte.ts | 7 + .../Amazon/Interfaces/I2096NoParte.ts | 5 +- .../Amazon/Reportes/AmazonNoPartes.tsx | 113 +++++++++- ...RptAmazonFinishedClasificationInvoices.tsx | 95 ++++---- ...zonFinishedClasificationInvoicesDetail.tsx | 1 + .../Pending/ClasificatorAssign.tsx | 1 - .../RptAmazonPendingClasificationInvoices.tsx | 209 +++++++++++------- ...azonPendingClasificationInvoicesDetail.tsx | 118 +++++++--- .../RptPendingAnswerFromAmazon.tsx | 137 +++++++----- .../RptPendingAnswerFromAmazonDetail.tsx | 36 ++- .../Linking/RptAmazonLinkInvoice2Traffic.tsx | 4 +- .../RptAmazonLinkInvoice2TrafficDetail.tsx | 1 + .../Amazon/Services/Amazon.Services.ts | 14 +- 16 files changed, 512 insertions(+), 245 deletions(-) create mode 100644 src/Components/Clientes/Amazon/DTO/DTO2096Estatus.ts create mode 100644 src/Components/Clientes/Amazon/DTO/DTO2096NoParte.ts diff --git a/src/Components/Clientes/Amazon/Components/ComboSelect/ComboDescripcion.tsx b/src/Components/Clientes/Amazon/Components/ComboSelect/ComboDescripcion.tsx index 6d57045..96d353f 100644 --- a/src/Components/Clientes/Amazon/Components/ComboSelect/ComboDescripcion.tsx +++ b/src/Components/Clientes/Amazon/Components/ComboSelect/ComboDescripcion.tsx @@ -21,6 +21,7 @@ export interface IComboDescripcionProps { DescripcionOriginal: string Deshabilitado: boolean ConfirmaDescripcion: number + Detail: I2096Detail } export function ComboDescripcion(props: IComboDescripcionProps) { @@ -150,9 +151,10 @@ export function ComboDescripcion(props: IComboDescripcionProps) { onChange={(e) => changeValidacion(parseInt(e.target.value))} value={Validacion} > - - + {props.Detail.validaFraccionOriginal===0 ? : '' } + {props.Detail.validaFraccionOriginal===0 ? : ''} + {props.Detail.validaFraccionOriginal===3 ? : ''} changeValidacion(parseInt(e.target.value))} value={Validacion} > - - + {props.Detail.validaFraccionOriginal===0 ? : '' } + {props.Detail.validaFraccionOriginal===0 ? : ''} + {props.Detail.validaFraccionOriginal===3 ? : ''} state.AmazonNoPartes.NoPartes ) + const [UserId, setUserId] = useState(() => { + const stickyValue = window.localStorage.getItem('UserId') + return stickyValue !== null ? JSON.parse(stickyValue) : 0 + }) const [PaisClaves, setPaisClaves] = useState([]) + const [Data, setData] = useState([]) const [ShowModal, setShowModal] = useState(false) const [header, setHeader] = useState('') const [msgColor, setMsgColor] = useState('primary') @@ -29,6 +37,7 @@ export function AmazonNoPartes(props: IAmazonNoPartesProps) { const [msg, setMsg] = useState('') const [MsgTime, setMsgTime] = useState(3000) const [IDParte, setIDParte] = useState(0) + const [Parte, setParte] = useState('') const [TipoOperacion, setTipoOperacion] = useState(0) const [Fraccion, setFraccion] = useState('') const [Subdivision, setSubdivision] = useState('') @@ -37,6 +46,9 @@ export function AmazonNoPartes(props: IAmazonNoPartesProps) { const [PaisOrigen, setPaisOrigen] = useState('') const [UMF, setUMF] = useState('') const [Search, setSearch] = useState('') + const [FechaInsercion, setFechaInsercion] = useState('') + const [Clasificador, setClasificador] = useState('') + const openLink = (item: string) => { window.open('https://www.amazon.com/dp/' + item) } @@ -81,7 +93,9 @@ export function AmazonNoPartes(props: IAmazonNoPartesProps) { name: 'Parte', width: '110px', cell: (row: I2096NoParte) => ( -
openLink(row.parte)}>{row.parte}
+
openLink(row.parte)}> + {row.parte} +
), sortable: true }, @@ -135,22 +149,59 @@ export function AmazonNoPartes(props: IAmazonNoPartesProps) { selector: (row: I2096NoParte) => row.descripcionAgenteAduanal, wrap: true, sortable: true + }, + { + name: 'Fecha / Hora', + width: '200px', + selector: (row: I2096NoParte) => row.fechaConfirmacion, + wrap: true, + sortable: true + }, + { + name: 'Usuario', + width: '300px', + selector: (row: I2096NoParte) => getUser(row.usuarioActualizacion), + wrap: true, + sortable: true } ] + const getUser = (Id: number) => { + const NoAsignado = 'NO ASIGNADO' + if (Id === 0) return NoAsignado + else if (Data.length) { + const Usuario = Data.filter((item) => item.idUsuario === Id) + return Usuario ? Usuario[0].nombre : NoAsignado + } + return NoAsignado + } + + const loadProfiles = () => { + DSAmazon.PerfilesParecidosGet('_') + .then((response) => { + setData(response.data) + }) + .catch((e: Error) => { + alert('Ocurrio un error' + e.message.toString()) + }) + } + const loadData = (row: I2096NoParte) => { setIDParte(row.id) + setParte(row.parte) setTipoOperacion(row.tipoOperacion) setFraccion(row.fraccion.substring(0, 8)) - setSubdivision(row.fraccion.slice(-2)) + setSubdivision(row.subdivision) setPaisOrigen(row.paisOrigen) setDescripcionFactura(row.descripcionFactura) setDescripcionAgenteAduanal(row.descripcionAgenteAduanal) setUMF(row.unidadMedidaFactura) + setFechaInsercion(row.FHActualizacion) + setClasificador(getUser(row.usuarioActualizacion)) setShowModal(true) } - useEffect(() => { + const loadPaisesClaves = () => { AmazonDS.PaisClavesGET() .then((response) => { setPaisClaves(response.data) @@ -161,6 +212,11 @@ export function AmazonNoPartes(props: IAmazonNoPartesProps) { setShowMsg(true) return }) + } + + useEffect(() => { + loadPaisesClaves() + loadProfiles() }, []) const loadInfo = () => { @@ -172,6 +228,7 @@ export function AmazonNoPartes(props: IAmazonNoPartesProps) { } AmazonDS.NoPartesGet(Search) .then((response) => { + //console.log(JSON.stringify(response.data)) dispatch(populateNoPartes(response.data)) }) .catch((e: Error) => { @@ -182,6 +239,26 @@ export function AmazonNoPartes(props: IAmazonNoPartesProps) { }) } + const saveInfo = () => { + const data: DTO2096NoParte = { + id: IDParte, + fraccionGEMCO: Fraccion, + subdivisionGEMCO: Subdivision, + descripcionAgenteAduanal: DescripcionAgenteAduanal, + usuario: UserId + } + AmazonDS.NoPartesUpdate(data) + .then((response) => { + dispatch(updateNoPartes(response.data)) + }) + .catch((e: Error) => { + setHeader('Error') + setMsg('Ocurrio un error: ' + e) + setShowMsg(true) + return + }) + } + return (
@@ -235,12 +312,18 @@ export function AmazonNoPartes(props: IAmazonNoPartesProps) { size={'sm'} dialogClassName={'modal-50w'} > + + + No Parte: {Parte} ................ insertado : [ {FechaInsercion} ] + +
T. Operacion setTipoOperacion(parseInt(e.target.value))} className="form-select form-select-sm" @@ -277,6 +360,7 @@ export function AmazonNoPartes(props: IAmazonNoPartesProps) { + setDescripcionAgenteAduanal(e.target.value) + } /> @@ -304,6 +391,7 @@ export function AmazonNoPartes(props: IAmazonNoPartesProps) { setPaisOrigen(e.target.value)} className="form-select form-select-sm" > @@ -320,6 +408,7 @@ export function AmazonNoPartes(props: IAmazonNoPartesProps) { Unidad medida factura - + Clasificador + + + + - +
diff --git a/src/Components/Clientes/Amazon/Reportes/Clasification/Finished/RptAmazonFinishedClasificationInvoices.tsx b/src/Components/Clientes/Amazon/Reportes/Clasification/Finished/RptAmazonFinishedClasificationInvoices.tsx index 9d95cb3..d4cc772 100644 --- a/src/Components/Clientes/Amazon/Reportes/Clasification/Finished/RptAmazonFinishedClasificationInvoices.tsx +++ b/src/Components/Clientes/Amazon/Reportes/Clasification/Finished/RptAmazonFinishedClasificationInvoices.tsx @@ -11,21 +11,9 @@ import { } from 'react-bootstrap' import { IconContext } from 'react-icons' import { BsChevronDown, BsChevronRight, BsSearch } from 'react-icons/bs' -import { - FaAmazon, - FaCheckCircle, - FaFileExcel, - FaQuestionCircle -} from 'react-icons/fa' -import { ImCross } from 'react-icons/im' -import { ComboDescripcion } from '../../../Components/ComboSelect/ComboDescripcion' -import { ComboFraccion } from '../../../Components/ComboSelect/ComboFraccion' -import { TextBoxFraccion } from '../../../Components/TextBox/TextBoxFraccion' -import I2096Detail from '../../../Interfaces/I2096Detail' +import { FaAmazon, FaFileExcel } from 'react-icons/fa' import I2096Headers from '../../../Interfaces/I2096Header' import DSAmazon from '../../../Services/Amazon.Services' -import * as XLSX from 'xlsx' -import DTO2096PrevioExcel from '../../../DTO/DTO2096PrevioExcel' import { MsgInformativo } from '../../../../../Utils/Toast/msgInformativo' import { RootState } from '../../../../../../store/store' import { @@ -37,7 +25,7 @@ import RtpAmazonFinishedClasificationInvoicesDetail from './RptAmazonFinishedCla // Redux import { useDispatch, useSelector } from 'react-redux' import DTO2096PerfilesParecidos from '../../../DTO/DTO2096PerfilesParecidos' -import { SelectEstatus } from '../../../../../Corresponsales/CuentasComplementarias/SelectEstatus/SelectEstatus' +import loadingImg from '../../../../../../images/ajaxloader.gif' export interface IRptAmazonFinishedClasificationInvoicesProps {} @@ -49,10 +37,6 @@ export default function RptAmazonFinishedClasificationInvoices( (state: RootState) => state.AmazonInvoices.Invoice ) const [Data, setData] = useState([]) - /* const [Inicio, setInicio] = useState(currentDate(0)) - const [Fin, setFin] = useState(currentDate(0)) - const [filtro, setFiltro] = useState('') - */ const [Accion, setAccion] = useState(0) const [Estatus, setEstatus] = useState(0) const [IDInvoice, setIDInvoice] = useState(0) @@ -62,17 +46,10 @@ export default function RptAmazonFinishedClasificationInvoices( const [header, setHeader] = useState('') const [show, setShowMsg] = useState(false) const [msg, setMsg] = useState('') + const [WaitingDialog, setWaitingDialog] = useState(false) + const [WaitingMessage, setWaitingMessage] = useState('Plantilla de Partes') const msgColor = 'primary' -/* function currentDate(days: number): string { - var today = new Date() - today.setDate(today.getDate() + days) - var dd = String(today.getDate()).padStart(2, '0') - var mm = String(today.getMonth() + 1).padStart(2, '0') - var yyyy = today.getFullYear() - return yyyy + '-' + mm + '-' + dd - } */ - const loadReport = () => { DSAmazon.AmazonFinishedClasificationInvoiceGET() .then((response) => { @@ -85,9 +62,7 @@ export default function RptAmazonFinishedClasificationInvoices( } const downloadExcel = (id: number) => { - DSAmazon.SePuedeTerminardeClasificarFactura(id) - .then((response) => {}) - .catch((e: Error) => {}) + setWaitingDialog(true) DSAmazon.NoPartesAmazon2SIRGET(id) .then((response: any) => { if (response.status === 200) { @@ -97,11 +72,7 @@ export default function RptAmazonFinishedClasificationInvoices( link.setAttribute('download', 'Plantilla de partes.xlsx') document.body.appendChild(link) link.click() - DSAmazon.TerminaClasificarFactura(id) - .then((response) => {}) - .catch((e: Error) => { - alert('Ocurrio un error' + e.message.toString()) - }) + setWaitingDialog(false) } }) .catch((e: Error) => { @@ -112,8 +83,7 @@ export default function RptAmazonFinishedClasificationInvoices( }) } - useEffect(() => { - loadReport() + const loadProfiles = () => { DSAmazon.PerfilesParecidosGet('Clasificador') .then((response) => { setData(response.data) @@ -121,10 +91,15 @@ export default function RptAmazonFinishedClasificationInvoices( .catch((e: Error) => { alert('Ocurrio un error' + e.message.toString()) }) + } + + useEffect(() => { + loadReport() + loadProfiles() }, []) const getUser = (Id: number) => { - const NoAsignado = ' - NO ASIGNADO -' + const NoAsignado = 'NO ASIGNADO' if (Id === 0) return NoAsignado else if (Data.length) { const Usuario = Data.filter((item) => item.idUsuario === Id) @@ -134,9 +109,9 @@ export default function RptAmazonFinishedClasificationInvoices( } useEffect(() => { - if (ShowModal) { + if (ShowModal) { setClasificador(getUser(IDClasificador)) - } + } }, [ShowModal]) const changeToggle = (row: I2096Headers) => { @@ -148,17 +123,13 @@ export default function RptAmazonFinishedClasificationInvoices( const returnTO = () => { DSAmazon.InvoiceReturnState(IDInvoice, 0) - .then((response) => { - loadReport() - setShowModal(false) - }) - .catch((e: Error) => { - alert('Ocurrio un error' + e.message.toString()) - }) - } - - const openLink = (item: string) => { - window.open('https://www.amazon.com/dp/' + item) + .then((response) => { + loadReport() + setShowModal(false) + }) + .catch((e: Error) => { + alert('Ocurrio un error' + e.message.toString()) + }) } return ( @@ -204,6 +175,7 @@ export default function RptAmazonFinishedClasificationInvoices( Tot currency ISO code Tot Monetary amount Tot partidas + Clasificador @@ -305,6 +277,7 @@ export default function RptAmazonFinishedClasificationInvoices( return row.detail.length })} + {getUser(MasterData.clasificador)}
+ { + setWaitingDialog(false) + }} + backdrop="static" + keyboard={false} + size="sm" + dialogClassName={'modal-50w'} + centered + > + + + + + proccessing + Generando {WaitingMessage}... + + + { - DSAmazon.TerminaClasificarFactura(id) - .then((response) => { - DSAmazon.NoPartesAmazon2SIRGET(id) - .then((response: any) => { - if (response.status === 200) { - const url = window.URL.createObjectURL(new Blob([response.data])) - const link = document.createElement('a') - link.href = url - link.setAttribute('download', 'Plantilla de partes.xlsx') - document.body.appendChild(link) - link.click() - setShowModal(false) - loadReport() - } - }) - .catch((e: Error) => { - setHeader('Error') - setMsg('Ocurrio un error') - setShowMsg(true) - return - }) - }) - .catch((e: Error) => {}) - } - useEffect(() => { loadReport() }, []) @@ -109,67 +86,104 @@ export default function RtpAmazonPendingInvoices( (child) => child.idHeader === IDMaster && child.destinationHTSCode.replaceAll('.', '').trim() !== - child.fraccionGEMCO + child.fraccionGEMCO && + child.validaFraccionOriginal !== 3 ) }) return Exceptions && Exceptions.length ? Exceptions[0].length : 0 } - const facturaTerminada = (row: I2096Headers) => { - if (!existsExeptions(row.id)) { - DSAmazon.SePuedeTerminardeClasificarFactura(row.id) - .then((response) => { - if (response.data.respuesta.includes('lista')) { - setIDFactura(row.id) - setShowModal(true) - return - } else { - setIDFactura(0) + const descargaArchivoExcepciones = () => { + setShowModalW(false) + setWaitingMessage('Archivo de excepciones') + setWaitingDialog(true) + DSAmazon.ExceptionsFileAmazonGET(IDFactura) + .then((response: any) => { + if (response.status === 200) { + const url = window.URL.createObjectURL(new Blob([response.data])) + const link = document.createElement('a') + link.href = url + link.setAttribute('download', 'Archivo de excepciones.xlsx') + document.body.appendChild(link) + link.click() + DSAmazon.EnviaEsperaRespuestaAmazon(IDFactura) + .then((response) => { + loadReport() + setWaitingDialog(false) + }) + .catch((e: Error) => { + setHeader('Error') + setMsg( + 'Ocurrio un error, no se pudo actualizar informacion' + + e.message.toString() + ) + setShowMsg(true) + return + }) + + } + }) + .catch((e: Error) => { setHeader('Error') - setMsg(response.data.respuesta) + setMsg('Ocurrio un error') setShowMsg(true) return - } - }) - .catch((e: Error) => { - setIDFactura(0) - setHeader('Error') - setMsg('Ocurrio un error') - setShowMsg(true) - return - }) - } else { - DSAmazon.SePuedeTerminardeClasificarFacturaEsperandoRespuesta(row.id) - .then((response) => { - if (response.data.respuesta.includes('lista')) { - setIDFactura(row.id) - setShowModalW(true) - return - } else { - setIDFactura(0) + }) + } + + const descargaPantillaPartes = () => { + setShowModal(false) + setWaitingMessage('Plantilla de partes') + setWaitingDialog(true) + DSAmazon.NoPartesAmazon2SIRGET(IDFactura) + .then((response: any) => { + if (response.status === 200) { + const url = window.URL.createObjectURL(new Blob([response.data])) + const link = document.createElement('a') + link.href = url + link.setAttribute('download', 'Plantilla de partes.xlsx') + document.body.appendChild(link) + link.click() + DSAmazon.TerminaClasificarFactura(IDFactura) + .then((response) => { + loadReport() + setWaitingDialog(false) + }) + .catch((e: Error) => { + setHeader('Error') + setMsg( + 'Ocurrio un error, no se pudo actualizar informacion' + + e.message.toString() + ) + setShowMsg(true) + return + }) + } + }) + .catch((e: Error) => { setHeader('Error') - setMsg(response.data.respuesta) + setMsg('Ocurrio un error') setShowMsg(true) return - } - }) - .catch((e: Error) => { - setIDFactura(0) - setHeader('Error') - setMsg('Ocurrio un error') - setShowMsg(true) - return - }) - } + }) } - - const send2WaitingProcess = (id: number) => { - DSAmazon.EnviaEsperaRespuestaAmazon(id) - .then((response) => { - setShowModalW(false) - loadReport() - }) - .catch((e: Error) => {}) + + const facturaTerminada = (row: I2096Headers) => { + DSAmazon.SePuedeTerminardeClasificarFactura(row.id).then((response) => { + if (response.data.estatus === 0) { + setIDFactura(0) + setHeader('Error') + setMsg(response.data.respuesta) + setShowMsg(true) + return + } else if (response.data.estatus === 1) { + setIDFactura(row.id) + setShowModalW(true) + } else if (response.data.estatus === 2) { + setIDFactura(row.id) + setShowModal(true) + } + }) } return ( @@ -228,7 +242,13 @@ export default function RtpAmazonPendingInvoices( Perfil !== 'Clasificador lider' ) { return a - } else if ( ["Clasificador lider", "Administrador"].includes(Perfil)) {return a} + } else if ( + ['Clasificador lider', 'Administrador'].includes( + Perfil + ) + ) { + return a + } }) .map((MasterData) => { return ( @@ -332,9 +352,6 @@ export default function RtpAmazonPendingInvoices( })} - {' '} - {/* Componente: Asigna clasificador */} - {/* {Perfil==='Clasificador lider' ? 'Modifica' : 'NO MODIFICA'} */} - Confirme fraccion + Confirme +   fraccion   - La factura esta lista para terminarse y pasarse al siguiente proceso? + ¿La factura esta lista para terminarse y pasarse al siguiente + proceso? @@ -646,7 +665,7 @@ export default function RtpAmazonPendingInvoices(
+ { + setWaitingDialog(false) + }} + backdrop='static' + keyboard={false} + size='sm' + dialogClassName={'modal-50w'} + centered + > + + + + + proccessing + Generando {WaitingMessage}... + + + state.AmazonInvoices.Invoice ) - const [ShowModal, setShowModal] = useState(false) - const [Checked, setChecked] = useState(props.detail.checked) + const [ShowModal, setShowModal] = useState(false) + const [Checked, setChecked] = useState(props.detail.checked) const [EstatusSwith, setEstatusSwitch] = useState(props.detail.autorizado) const [UserChanged, setUserChanged] = useState(false) const [header, setHeader] = useState('') @@ -64,7 +64,10 @@ export default function RtpAmazonPendingInvoivesDetail( } const target = React.useRef(null) - const UpdateInvoiceDetail = (Invoice: I2096Headers, Detail: I2096Detail[]) => { + const UpdateInvoiceDetail = ( + Invoice: I2096Headers, + Detail: I2096Detail[] + ) => { const updatedInvoice: I2096Headers = { id: props.IDMaster, referencia: Invoice.referencia, @@ -137,11 +140,35 @@ export default function RtpAmazonPendingInvoivesDetail( const checkDetail = () => { DSAmazon.CheckDetail(props.detail.id) - .then((response) => { - setChecked(!Checked) - editInvoice(props.detail.id,!Checked) - }) - .catch((e: Error) => {}) + .then((response) => { + setChecked(!Checked) + editInvoice(props.detail.id, !Checked) + }) + .catch((e: Error) => {}) + } + + const ColorSET = (value: number, mode: number) => { + switch(mode) { + case 1: { + // Background color + if (value === 1) return '#FFFAF2' + else if (value === 2) return '#E5F7B6' + else if (value === 3) return '#E9F3FC' + break + } case 2: { + // Border color + if (value === 1) return '2px solid #F9A721' + else if (value === 2) return '2px solid green' + else if (value === 3) return '2px solid blue' + break + } case 3: { + // Color + if (value === 1) return '#5923F6' + if (value === 2) return '#000000' + if (value === 3) return 'blue' + break + } + } } return ( @@ -149,7 +176,7 @@ export default function RtpAmazonPendingInvoivesDetail( @@ -171,7 +198,7 @@ export default function RtpAmazonPendingInvoivesDetail( textAlign: 'right', backgroundColor: props.detail.checked ? '#E6EEF5' : '#ffffff' }} - className="DetailData" + className="DetailData" > {props.detail.itemDescription} @@ -217,6 +244,15 @@ export default function RtpAmazonPendingInvoivesDetail( > + ) : props.detail.validaFraccionOriginal === 3 ? ( + + + ) : ( {props.detail.totalUnitValueMonetaryAmount} -{/* */} {({ ref, ...triggerHandler }) => ( -