From 60b80b6e48b7aa4e4deabc6c4ab4c48da8f4fdc2 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 10 Jan 2023 17:09:02 -0600 Subject: [PATCH] Se termina la primer version entregable del reporte de facturas recibidas de Amazon --- .../Amazon/Reportes/AmazonNoPartes.tsx | 145 ++++++++++++----- .../Reportes/RptAmazonPendingInvoices.tsx | 133 +++++++++++---- .../RptAmazonPendingInvoicesDetail.tsx | 154 +++++++++++------- .../Amazon/Services/Amazon.Services.ts | 10 +- 4 files changed, 302 insertions(+), 140 deletions(-) diff --git a/src/Components/Clientes/Amazon/Reportes/AmazonNoPartes.tsx b/src/Components/Clientes/Amazon/Reportes/AmazonNoPartes.tsx index caf59b7..0c2fa8d 100644 --- a/src/Components/Clientes/Amazon/Reportes/AmazonNoPartes.tsx +++ b/src/Components/Clientes/Amazon/Reportes/AmazonNoPartes.tsx @@ -38,7 +38,10 @@ export function AmazonNoPartes(props: IAmazonNoPartesProps) { const [DescripcionAgenteAduanal, setDescripcionAgenteAduanal] = useState('') const [PaisOrigen, setPaisOrigen] = useState('') const [UMF, setUMF] = useState('') - + const [Search, setSearch] = useState('') + const openLink = (item: string) => { + window.open('https://www.amazon.com/dp/' + item) + } const colsNoPartes = [ { @@ -79,7 +82,9 @@ export function AmazonNoPartes(props: IAmazonNoPartesProps) { { name: 'Parte', width: '110px', - selector: (row: I2096NoParte) => row.parte, + cell: (row: I2096NoParte) => ( +
openLink(row.parte)}>{row.parte}
+ ), sortable: true }, { @@ -138,7 +143,7 @@ export function AmazonNoPartes(props: IAmazonNoPartesProps) { const loadData = (row: I2096NoParte) => { setIDParte(row.id) setTipoOperacion(row.tipoOperacion) - setFraccion(row.fraccion.substring(0,8)) + setFraccion(row.fraccion.substring(0, 8)) setSubdivision(row.fraccion.slice(-2)) setPaisOrigen(row.paisOrigen) setDescripcionFactura(row.descripcionFactura) @@ -149,16 +154,25 @@ export function AmazonNoPartes(props: IAmazonNoPartesProps) { useEffect(() => { AmazonDS.Get$Pais$Claves() - .then((response) => { - setPaisClaves(response.data) - }) - .catch((e: Error) => { + .then((response) => { + setPaisClaves(response.data) + }) + .catch((e: Error) => { + setHeader('Error') + setMsg('Ocurrio un error: ' + e) + setShowMsg(true) + return + }) + }, []) + + const loadInfo = () => { + if (Search.length < 9) { setHeader('Error') - setMsg('Ocurrio un error: ' + e) + setMsg('Proporcione el numero de parte, para poder continuar') setShowMsg(true) return - }) - AmazonDS.NoPartesGet() + } + AmazonDS.NoPartesGet(Search) .then((response) => { dispatch(populateNoPartes(response.data)) }) @@ -168,24 +182,52 @@ export function AmazonNoPartes(props: IAmazonNoPartesProps) { setShowMsg(true) return }) - }, []) + } return (
- - 0 - })} - /> - + + + + No parte + + + setSearch(e.target.value)} + /> + + + + + + + + + 0 + })} + /> + + +
- + T. Operacion - + Descripcion factura - + - + Descripcion agente aduanal - + - Pais Origen - + Pais Origen + setPaisOrigen(e.target.value)} className="form-select form-select-sm" - > { - PaisClaves ? ( - PaisClaves.map((row) =>{ - return - }) - ) : '' - } + > + {' '} + {PaisClaves + ? PaisClaves.map((row) => { + return ( + + ) + }) + : ''} - - Unidad medida factura - + Unidad medida factura + + setUMF(e.target.value)} size="sm" /> - + - - - + + + + +
diff --git a/src/Components/Clientes/Amazon/Reportes/RptAmazonPendingInvoices.tsx b/src/Components/Clientes/Amazon/Reportes/RptAmazonPendingInvoices.tsx index a9b2f17..e3b9f6b 100644 --- a/src/Components/Clientes/Amazon/Reportes/RptAmazonPendingInvoices.tsx +++ b/src/Components/Clientes/Amazon/Reportes/RptAmazonPendingInvoices.tsx @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react' -import { Button, Card, Col, Form, Row, Table } from 'react-bootstrap' +import { Alert, Button, Card, Col, Form, FormCheck, Modal, Row, Table } from 'react-bootstrap' import { IconContext } from 'react-icons' import { BsChevronDown, BsChevronRight, BsSearch } from 'react-icons/bs' import { FaCheckCircle, FaFileExcel, FaQuestionCircle } from 'react-icons/fa' @@ -37,7 +37,9 @@ export default function RtpAmazonPendingInvoices( const [Fin, setFin] = useState(currentDate(0)) const [filtro, setFiltro] = useState('') const [header, setHeader] = useState('') + const [IDFactura, setIDFactura] = useState(0) const [show, setShowMsg] = useState(false) + const [ShowModal, setShowModal] = useState(false) const [msg, setMsg] = useState('') const msgColor = 'primary' @@ -84,7 +86,6 @@ export default function RtpAmazonPendingInvoices( }) } - const downloadExceptionsFile = (id: number) => { DSAmazon.TerminaFactura(id) .then((response) => {}) @@ -95,7 +96,10 @@ export default function RtpAmazonPendingInvoices( const url = window.URL.createObjectURL(new Blob([response.data])) const link = document.createElement('a') link.href = url - link.setAttribute('download', 'Formato de consultas (Exceptions Handling 2021).xlsx') + link.setAttribute( + 'download', + 'Formato de consultas (Exceptions Handling 2021).xlsx' + ) document.body.appendChild(link) link.click() } @@ -108,7 +112,6 @@ export default function RtpAmazonPendingInvoices( }) } - useEffect(() => { loadReport() }, []) @@ -132,13 +135,36 @@ export default function RtpAmazonPendingInvoices( .map((element) => { let newElt = Object.assign({}, element) // copies element return newElt.detail.filter( - (child) => - (child.idHeader === IDMaster) && - (child.autorizado) && - (child.destinationHTSCode.toString().replaceAll('.','') !== child.fraccionGEMCO) + (child) => child.idHeader === IDMaster && !child.autorizado ) }) - return Exceptions[0].length ? Exceptions[0].length : 0 + console.log(JSON.stringify(Exceptions[0])) + return Exceptions[0].length ? Exceptions[0].length : 0 + } + + const facturaTerminada = (row: I2096Headers) => { + DSAmazon.Se$Puede$Terminar$Factura(row.id) + .then((response) => { + if (response.data.respuesta.includes('lista')) { + setIDFactura(row.id) + setShowModal(true) + return + } else { + setIDFactura(0) + setHeader('Informativo') + setMsg(response.data.respuesta) + setShowMsg(true) + return + } + }) + .catch((e: Error) => { + setIDFactura(0) + setHeader('Error') + setMsg('Ocurrio un error') + setShowMsg(true) + return + }) + } return ( @@ -168,14 +194,10 @@ export default function RtpAmazonPendingInvoices( id + Commercial Invoice Date Invoice Number Name - {/* Trailer Number - Trailer Id - Por Of Loading - Port of entry - Payments Terms */} Incoterms HAWB Qty Unit of measure @@ -226,12 +248,15 @@ export default function RtpAmazonPendingInvoices( )} + {MasterData.id} {existsExeptions(MasterData.id) > 0 ? (
downloadExceptionsFile(MasterData.id)} - title='Archivo de excepciones' + onClick={() => + downloadExceptionsFile(MasterData.id) + } + title="Archivo de excepciones" > ) : null} + + { + facturaTerminada(MasterData) + } + } + label="" + /> + {MasterData.commercialInvoiceDate} {MasterData.invoiceNumber} - + {MasterData.name} - {/* - {MasterData.trailerNumber} - - - {MasterData.trailerId} - - - {MasterData.porOfLoading} - - - {MasterData.portOfEntry} - - - {MasterData.paymentsTerms} - */} {MasterData.incoterms} @@ -357,7 +380,7 @@ export default function RtpAmazonPendingInvoices( + { + setShowModal(false) + }} + size={'sm'} + dialogClassName={'modal-50w'} + > + +
+ + + + + La factura esta lista para terminarse, desea terminarla? + + + + + + + + + + + + +
+
+
{ window.open('https://www.amazon.com/dp/' + item) } - const target = React.useRef(null); + const target = React.useRef(null) const UpdateInfo = (Invoice: I2096Headers, Detail: I2096Detail[]) => { const updatedInvoice: I2096Headers = { @@ -141,7 +149,8 @@ export default function RtpAmazonPendingInvoivesDetail( } useEffect(() => { - if (UserChanged && EstatusSwith && !props.detail.fraccionGEMCO) autoriceItem(props.detail.id) + if (UserChanged && EstatusSwith && !props.detail.fraccionGEMCO) + autoriceItem(props.detail.id) }, [EstatusSwith, UserChanged]) const popover = ( @@ -152,7 +161,7 @@ export default function RtpAmazonPendingInvoivesDetail( right? - ); + ) return ( <> @@ -194,11 +203,12 @@ export default function RtpAmazonPendingInvoivesDetail( - {props.detail.destinationHTSCode} +   {props.detail.destinationHTSCode} @@ -378,61 +401,74 @@ export default function RtpAmazonPendingInvoivesDetail( id="switchEnabled" type="switch" disabled={ - (props.detail.fraccionGEMCO===props.detail.destinationHTSCode.replaceAll('.','')) + props.detail.fraccionGEMCO === + props.detail.destinationHTSCode.replaceAll('.', '') } - checked={EstatusSwith && props.detail.autorizado /* (props.detail.fraccionGEMCO===props.detail.destinationHTSCode.replace('.','')) */} + checked={EstatusSwith && props.detail.autorizado} onChange={() => { setEstatusSwitch(!EstatusSwith) - setUserChanged(true) + setUserChanged(true) setShowModal(!EstatusSwith) }} label="" /> - {RequerimientoNormativo}} - > - {({ ref, ...triggerHandler }) => ( - - )} - - {Comentarios}} - > - {({ ref, ...triggerHandler }) => ( - + )} + + + - - - - - - )} - + {' '} + {Comentarios}} + > + {({ ref, ...triggerHandler }) => ( + + )} + + - + { @@ -453,7 +489,7 @@ export default function RtpAmazonPendingInvoivesDetail( - Reparto normativo + Cumplimiento normativo {' '} setRequerimientoNormativo(e.target.value)} + onChange={(e) => setComentarios(e.target.value)} />   diff --git a/src/Components/Clientes/Amazon/Services/Amazon.Services.ts b/src/Components/Clientes/Amazon/Services/Amazon.Services.ts index 3ffe8d3..6b7cbde 100644 --- a/src/Components/Clientes/Amazon/Services/Amazon.Services.ts +++ b/src/Components/Clientes/Amazon/Services/Amazon.Services.ts @@ -7,6 +7,7 @@ import DTO2096Descripcion from '../DTO/DTO2096Descripcion' import I2096NoParte from '../Interfaces/I2096NoParte' import I2096PaisClave from '../Interfaces/I2096PaisClave' import DTO2096ItemAutoriza from '../DTO/DTO2096ItemAutoriza' +import DTORespuesta from '../../ZincInternacional/DTO/DTORespuesta' class AmazonDataService { GetPendingInvoice() { @@ -51,8 +52,11 @@ class AmazonDataService { console.log(error) }) } - NoPartesGet() { - return http.get(`/AmazonInvoice/NoPartesGet`) - } + NoPartesGet(Search: string) { + return http.get(`/AmazonInvoice/NoPartesGet?Search=${Search}`) + } + Se$Puede$Terminar$Factura(id: number) { + return http.get(`/AmazonInvoice/SePuedeTerminarFactura?id=${id}`) + } } export default new AmazonDataService()