Se le agrega el poder descargar el archivo de Excel excepciones

AmazonRelease1.1
unknown 2 years ago
parent c60d53e638
commit bc7e4eefe3
  1. 1
      src/Components/Clientes/Amazon/Components/ComboSelect/ComboDescripcion.tsx
  2. 1
      src/Components/Clientes/Amazon/Components/ComboSelect/ComboFraccion.tsx
  3. 1
      src/Components/Clientes/Amazon/Interfaces/I2096Header.ts
  4. 111
      src/Components/Clientes/Amazon/Reportes/RptAmazonPendingInvoices.tsx
  5. 6
      src/Components/Clientes/Amazon/Reportes/RptAmazonPendingInvoicesDetail.tsx
  6. 9
      src/Components/Clientes/Amazon/Services/Amazon.Services.ts

@ -67,6 +67,7 @@ export function ComboDescripcion(props: IComboDescripcionProps) {
id: props.IDInvoice,
commercialInvoiceDate: Invoice.commercialInvoiceDate,
invoiceNumber: Invoice.invoiceNumber,
name: Invoice.name,
trailerNumber: Invoice.trailerNumber,
trailerId: Invoice.trailerId,
porOfLoading: Invoice.porOfLoading,

@ -45,6 +45,7 @@ export function ComboFraccion(props: IComboFraccionProps) {
id: props.IDInvoice,
commercialInvoiceDate: Invoice.commercialInvoiceDate,
invoiceNumber: Invoice.invoiceNumber,
name: Invoice.name,
trailerNumber: Invoice.trailerNumber,
trailerId: Invoice.trailerId,
porOfLoading: Invoice.porOfLoading,

@ -4,6 +4,7 @@ export default interface I2096Headers {
id: number
commercialInvoiceDate: string
invoiceNumber: string
name: string
trailerNumber: string
trailerId: string
porOfLoading: string

@ -22,7 +22,8 @@ import {
} from '../../../../store/features/Clientes/2096/AmazonInvoices'
// Redux
import { useDispatch, useSelector } from 'react-redux'
import RtpAmazonPendingInvoicesDetail from './RptAmazonPendingInvoicesDetail'
import RtpAmazonPendingInvoicesDetail from './RptAmazonPendingInvoicesDetail'
import { AiTwotoneFileExcel } from 'react-icons/ai'
export interface IRtpAmazonPendingInvoicesProps {}
export default function RtpAmazonPendingInvoices(
@ -62,12 +63,11 @@ export default function RtpAmazonPendingInvoices(
const downloadExcel = (id: number) => {
DSAmazon.TerminaFactura(id)
.then((response) => {})
.catch((e: Error) => {
})
.then((response) => {})
.catch((e: Error) => {})
DSAmazon.GetNoPartesAmazon2SIR(id)
.then((response: any) => {
if (response.status === 200) {
.then((response: any) => {
if (response.status === 200) {
const url = window.URL.createObjectURL(new Blob([response.data]))
const link = document.createElement('a')
link.href = url
@ -75,15 +75,40 @@ export default function RtpAmazonPendingInvoices(
document.body.appendChild(link)
link.click()
}
})
.catch((e: Error) => {
setHeader('Error')
setMsg('Ocurrio un error')
setShowMsg(true)
return
})
})
.catch((e: Error) => {
setHeader('Error')
setMsg('Ocurrio un error')
setShowMsg(true)
return
})
}
const downloadExceptionsFile = (id: number) => {
DSAmazon.TerminaFactura(id)
.then((response) => {})
.catch((e: Error) => {})
DSAmazon.Get$ExceptionsFile$Amazon(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', 'Formato de consultas (Exceptions Handling 2021).xlsx')
document.body.appendChild(link)
link.click()
}
})
.catch((e: Error) => {
setHeader('Error')
setMsg('Ocurrio un error')
setShowMsg(true)
return
})
}
useEffect(() => {
loadReport()
}, [])
@ -99,6 +124,23 @@ export default function RtpAmazonPendingInvoices(
window.open('https://www.amazon.com/dp/' + item)
}
const existsExeptions = (IDMaster: number) => {
const Exceptions = mInvoices
.filter((element) =>
element.detail.some((sub) => sub.idHeader === IDMaster)
)
.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)
)
})
return Exceptions[0].length ? Exceptions[0].length : 0
}
return (
<div>
<Card>
@ -125,13 +167,15 @@ export default function RtpAmazonPendingInvoices(
<th></th>
<th style={{ width: '50px' }}>id</th>
<th style={{ width: '50px' }}></th>
<th style={{ width: '50px' }}></th>
<th style={{ width: '80px' }}>Commercial Invoice Date</th>
<th style={{ width: '300px' }}>Invoice Number</th>
<th>Trailer Number</th>
<th style={{ width: '150px' }}>Invoice Number</th>
<th style={{ width: '50px' }}>Name</th>
{/* <th>Trailer Number</th>
<th>Trailer Id</th>
<th>Por Of Loading</th>
<th>Port of entry</th>
<th>Payments Terms</th>
<th>Payments Terms</th> */}
<th style={{ width: '100px' }}>Incoterms</th>
<th style={{ textAlign: 'center' }}>HAWB</th>
<th>Qty Unit of measure</th>
@ -183,6 +227,20 @@ export default function RtpAmazonPendingInvoices(
)}
</td>
<td>{MasterData.id}</td>
<td>
{existsExeptions(MasterData.id) > 0 ? (
<div
onClick={() => downloadExceptionsFile(MasterData.id)}
title='Archivo de excepciones'
>
<IconContext.Provider
value={{ color: 'orange', size: '20px' }}
>
<FaFileExcel />
</IconContext.Provider>
</div>
) : null}
</td>
<td>
{MasterData.estatus === 1 ? (
<div
@ -191,7 +249,7 @@ export default function RtpAmazonPendingInvoices(
<IconContext.Provider
value={{ color: 'green', size: '20px' }}
>
<FaFileExcel />
<AiTwotoneFileExcel />
</IconContext.Provider>
</div>
) : null}
@ -199,10 +257,13 @@ export default function RtpAmazonPendingInvoices(
<td style={{ width: '80px', textAlign: 'center' }}>
{MasterData.commercialInvoiceDate}
</td>
<td style={{ width: '300px' }}>
<td style={{ width: '150px' }}>
{MasterData.invoiceNumber}
</td>
<td style={{ textAlign: 'center' }}>
<td style={{ width: '50px', textAlign:'center' }}>
{MasterData.name}
</td>
{/* <td style={{ textAlign: 'center' }}>
{MasterData.trailerNumber}
</td>
<td style={{ textAlign: 'center' }}>
@ -216,7 +277,7 @@ export default function RtpAmazonPendingInvoices(
</td>
<td style={{ textAlign: 'center' }}>
{MasterData.paymentsTerms}
</td>
</td> */}
<td style={{ width: '100px', textAlign: 'center' }}>
{MasterData.incoterms}
</td>
@ -476,7 +537,15 @@ export default function RtpAmazonPendingInvoices(
detail.idHeader
)
.map((detail) => {
return <RtpAmazonPendingInvoicesDetail IDMaster={MasterData.id} detail={detail} Habilitado={MasterData.estatus<=1}/>
return (
<RtpAmazonPendingInvoicesDetail
IDMaster={MasterData.id}
detail={detail}
Habilitado={
MasterData.estatus <= 1
}
/>
)
})}
</>
)

@ -70,6 +70,7 @@ export default function RtpAmazonPendingInvoivesDetail(
id: props.IDMaster,
commercialInvoiceDate: Invoice.commercialInvoiceDate,
invoiceNumber: Invoice.invoiceNumber,
name: Invoice.name,
trailerNumber: Invoice.trailerNumber,
trailerId: Invoice.trailerId,
porOfLoading: Invoice.porOfLoading,
@ -373,12 +374,11 @@ export default function RtpAmazonPendingInvoivesDetail(
className="DetailData"
>
<FormCheck
className="form-check form-switch form-check-lg"
className="form-check form-switch form-control-lg"
id="switchEnabled"
type="switch"
disabled={
((/* !props.detail.autorizado && */
!props.detail.fraccionGEMCO)/* || (!props.detail.autorizado) */ /* || (props.detail.validaFraccionOriginal===1 && props.detail.autorizado===true) */)
(props.detail.fraccionGEMCO===props.detail.destinationHTSCode.replaceAll('.',''))
}
checked={EstatusSwith && props.detail.autorizado /* (props.detail.fraccionGEMCO===props.detail.destinationHTSCode.replace('.','')) */}
onChange={() => {

@ -42,6 +42,15 @@ class AmazonDataService {
console.log(error)
})
}
Get$ExceptionsFile$Amazon(id: number) {
return http.get<ArrayBuffer>(`/AmazonInvoice/GetArchivoExcepcionesAmazon?id=${id}`, {responseType: 'arraybuffer'})
.then(function (response) {
return response
})
.catch(function (error) {
console.log(error)
})
}
NoPartesGet() {
return http.get<I2096NoParte[]>(`/AmazonInvoice/NoPartesGet`)
}

Loading…
Cancel
Save