diff --git a/src/Components/Clientes/Amazon/Components/ComboSelect/ComboFraccion.tsx b/src/Components/Clientes/Amazon/Components/ComboSelect/ComboFraccion.tsx index f00f0fe..d7a8085 100644 --- a/src/Components/Clientes/Amazon/Components/ComboSelect/ComboFraccion.tsx +++ b/src/Components/Clientes/Amazon/Components/ComboSelect/ComboFraccion.tsx @@ -75,7 +75,7 @@ export function ComboFraccion(props: IComboFraccionProps) { o.detail = o.detail.filter(s => (s.idHeader === props.IDInvoice) && (s.id!=props.IDDetail)); }); */ -const newObj = mInvoices.map(function(o) { +/* const newObj = mInvoices.map(function(o) { const newDetail = {...o.detail} if (newDetail[0].id===props.IDDetail) { newDetail[0].fraccionGEMCO=Fraccion @@ -83,7 +83,7 @@ const newObj = mInvoices.map(function(o) { return newDetail }); -console.log(newObj) +console.log(newObj) */ //dispatch(updateInvoice(newObj)) diff --git a/src/Components/Clientes/Amazon/Reportes/RptAmazonPendingInvoices.tsx b/src/Components/Clientes/Amazon/Reportes/RptAmazonPendingInvoices.tsx index 1cfba52..8e2f6c4 100644 --- a/src/Components/Clientes/Amazon/Reportes/RptAmazonPendingInvoices.tsx +++ b/src/Components/Clientes/Amazon/Reportes/RptAmazonPendingInvoices.tsx @@ -61,200 +61,27 @@ export default function RtpAmazonPendingInvoices( } const downloadExcel = (id: number) => { -/* DSAmazon.TerminaFactura(id) - .then((response) => {}) - .catch((e: Error) => { - alert('Ocurrio un error' + e.message.toString()) - }) */ - let Invoice: I2096Headers[] = mInvoices.filter((row) => row.id === id) - let Details: I2096Detail[] = Invoice[0].detail - let Consecutivo = 1 - let excelReadyArray: DTO2096PrevioExcel[] = Details.map(function (element) { - return { - Consecutivo: (Consecutivo++).toString(), - ClaveCliente: '2096', - Parte: element.itemId, - ClaveProveedor: '10', - TipoOperacion: '1', - Fraccion: element.fraccionGEMCO, - SubDivisión: element.fraccionGEMCO.slice(-2), - DescripcionTIGIE: ' ', - DescripcionFactura: element.itemDescription, - DescripcionAgenteAduanal: element.descripcionGEMCO, - UMFactura: ' ', - UMComercial: ' ', - UMTarifa: ' ', - PrecioUnitario: ' ', - PaisOrigenDestino: ' ', - PaisCompradorVendedor: ' ', - CodigoBarras: ' ', - CodigoControlInterno: ' ', - FamiliaProducto: ' ', - Vinculacion: '1', - CodigoPreferencial: ' ', - MetodoValoración: '1', - AplicaTLC: '0', - MontoDesgravacion: '0,000', - TipoArancel: '1', - TasaArancelEspecifico: '0,00000', - TasaMaximaAdvalorem: '0,00000', - UM: ' ', - ES: ' ', - Peso: ' ', - Observaciones: ' ', - ValorMinimo: ' ', - UMCove: ' ', - ClaveModificacion: ' ', - DescripcionCertificado: ' ', - TipoUsoMercancia: ' ', - Exotico: ' ', - Registro: ' ', - TipoRegistro: ' ', - FechaEmision: ' ', - FechaVencimiento: ' ', - Producto: ' ', - UMCFDI: ' ', - UMEmbalaje: ' ', - IdParte99Update: ' ' - } + DSAmazon.TerminaFactura(id) + .then((response) => {}) + .catch((e: Error) => { + }) + DSAmazon.GetExcel(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() + } + }) + .catch((e: Error) => { + setHeader('Error') + setMsg('Ocurrio un error') + setShowMsg(true) + return }) - exportExcel(id, excelReadyArray, 'Plantilla de partes') - } - - function exportExcel( - id: number, - jsonData: DTO2096PrevioExcel[], - fileName: string - ): void { - let Heading = [ - [ - 'Consecutivo', - 'ClaveCliente', - 'Parte', - 'ClaveProveedor', - 'TipoOperacion', - 'Fraccion', - 'SubDivisión', - 'DescripcionTIGIE', - 'DescripcionFactura', - 'DescripcionAgenteAduanal', - 'UMFactura', - 'UMComercial', - 'UMTarifa', - 'PrecioUnitario', - 'PaisOrigenDestino', - 'PaisCompradorVendedor', - 'CodigoBarras', - 'CodigoControlInterno', - 'FamiliaProducto', - 'Vinculacion', - 'CodigoPreferencial', - 'MetodoValoración', - 'AplicaTLC', - 'MontoDesgravacion', - 'TipoArancel', - 'TasaArancelEspecifico', - 'TasaMaximaAdvalorem', - 'UM', - 'ES', - 'Peso', - 'Observaciones', - 'ValorMinimo', - 'UMCove', - 'ClaveModificacion', - 'DescripcionCertificado', - 'TipoUsoMercancia', - 'Exotico', - 'Registro', - 'TipoRegistro', - 'FechaEmision', - 'FechaVencimiento', - 'Producto', - 'UMCFDI', - 'UMEmbalaje', - 'IdParte99Update' - ] - ] - let clientesHeading = [ - [ - 'ConsecutivoPartes', - 'ClaveCliente', - - ] - ] - let identificadoresHeading = [ - [ - 'Consecutivo', - 'TipoIdentificador', - 'ClaveIdentificador', - 'Art', - 'Complemento1', - 'Complemento2', - 'Complemento3', - 'ClaveCliente', - 'Parte', - 'ClaveProveedor', - 'TipoOperacion', - 'FirmaDescargo', - 'NumeroPermiso', - 'IdParte99Update' - ] - ] - let impuestosPartesHeading = [ - [ - 'Impuesto', - 'ValorTasa', - 'FormaPago', - 'ClaveCliente', - 'Parte', - 'ClaveProveedor', - 'TipoOperacion' - ] - ] - let submodelosHeading = [ - [ - 'ConsecutivoPartePadre', - 'ConsecutivoParteHijo' - ] - ] - const wb = XLSX.utils.book_new() - const ws: XLSX.WorkSheet = XLSX.utils.json_to_sheet([]) - const ws2: XLSX.WorkSheet = XLSX.utils.json_to_sheet([]) - const ws3: XLSX.WorkSheet = XLSX.utils.json_to_sheet([]) - const ws4: XLSX.WorkSheet = XLSX.utils.json_to_sheet([]) - const ws5: XLSX.WorkSheet = XLSX.utils.json_to_sheet([]) - const ws6: XLSX.WorkSheet = XLSX.utils.json_to_sheet([]) - XLSX.utils.sheet_add_aoa(ws, Heading) - XLSX.utils.sheet_add_json(ws, jsonData, { origin: 'A2', skipHeader: true }) - XLSX.utils.book_append_sheet(wb, ws, 'Partes') - - - XLSX.utils.sheet_add_aoa(ws2, clientesHeading) - XLSX.utils.sheet_add_json(ws2, [{}], { origin: 'A2', skipHeader: true }) - XLSX.utils.book_append_sheet(wb, ws2, 'Clientes') - - XLSX.utils.sheet_add_aoa(ws3, identificadoresHeading) - XLSX.utils.sheet_add_json(ws3, [{}], { origin: 'A2', skipHeader: true }) - XLSX.utils.book_append_sheet(wb, ws3, 'Identificadores') - - XLSX.utils.sheet_add_aoa(ws4, impuestosPartesHeading) - XLSX.utils.sheet_add_json(ws4, [{}], { origin: 'A2', skipHeader: true }) - XLSX.utils.book_append_sheet(wb, ws4, 'ImpuestosPartes') - - XLSX.utils.sheet_add_aoa(ws5, submodelosHeading) - XLSX.utils.sheet_add_json(ws5, [{}], { origin: 'A2', skipHeader: true }) - XLSX.utils.book_append_sheet(wb, ws5, 'Submodelos') - - XLSX.utils.sheet_add_aoa(ws6, [ [] ]) - XLSX.utils.sheet_add_json(ws6, [{}], { origin: 'A2', skipHeader: true }) - XLSX.utils.book_append_sheet(wb, ws6, 'Diccionario') - XLSX.writeFile(wb, fileName + '.xlsx') - var range = XLSX.utils.decode_range(ws['!ref?']) - /* for (var C = range.s.c; C <= range.e.c; ++C) { - var address = XLSX.utils.encode_col(C) + '1' // <-- first row, column number C - if (!ws[address]) continue - ws[address].v = ws[address].v.toUpperCase() - } */ } useEffect(() => { @@ -320,7 +147,7 @@ export default function RtpAmazonPendingInvoices( onChange={(e) => setFin(e.target.value)} size="sm" /> */} - + {/*