From b4027b57643a660425b2e0824d90d4be650be1a9 Mon Sep 17 00:00:00 2001 From: borja Date: Mon, 4 Dec 2023 16:04:08 +0100 Subject: [PATCH] =?UTF-8?q?crea=20un=20replaceHeaders=20para=20abordar=20l?= =?UTF-8?q?a=20tabla=20buena=20de=20los=20brutos=20cambi=C3=A1ndoles=20los?= =?UTF-8?q?=20nombres=20a=20las=20columnas=20y=20hideando=20las=20que=20no?= =?UTF-8?q?=20use?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- importarexcel.js | 17 ++++++++++------- replaceHeaders.js | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 replaceHeaders.js diff --git a/importarexcel.js b/importarexcel.js index 649887c..f318975 100644 --- a/importarexcel.js +++ b/importarexcel.js @@ -6,7 +6,7 @@ /** @type { Object. } */ /** @type {Object.} */ -const codetoNameEquivalences = { +const clientCodeInfo = { "AAA": { name: "Hospital Son Espases", province: "Baleares", ccaa: "Islas Baleares", city: "Palma", }, "BBB": { name: "Hospital Sant Joan Reus", province: "Tarragona", ccaa: "Cataluña", city: "Reus", }, "CCC": { name: "Hospital Universitario Germans Trías y Pujol", province: "Barcelona", ccaa: "Cataluña", city: "Badalona", }, @@ -238,14 +238,17 @@ const cleanTable = (name) => { // Removes all rows from a table } } -const clientCodeToName = (code) => { // Normalizes names according to client Code +const ccToName = (code) => { // Normalizes info according to client code const clientCode = code.toString(); - let clientName = ""; - if (codetoNameEquivalences[clientCode]) { - clientName = codetoNameEquivalences[clientCode]; + if (clientCodeInfo[clientCode]) { + return { + name: clientCodeInfo[clientCode].name, + province: clientCodeInfo[clientCode].province, + ccaa: clientCodeInfo[clientCode].ccaa, + city: clientCodeInfo[clientCode].city + } } - return clientName; - + return "newClient"; } const removeDoubleSpace = (str) => { // Removes double spaces in string diff --git a/replaceHeaders.js b/replaceHeaders.js new file mode 100644 index 0000000..46725b4 --- /dev/null +++ b/replaceHeaders.js @@ -0,0 +1,37 @@ + +// CONSTANTS + +const ORIGIN_TABLE_NAME = "BASE DE DATOS"; +const ORIGIN_VIEW_NAME = "Default View"; + +// Activate tables and views +const originTable = base.getTableByName(ORIGIN_TABLE_NAME); +const originView = base.getViewByName(originTable, ORIGIN_VIEW_NAME); + +const replaceNames = { + "OrgVt": "ORG_VT", + "Nº doc.": "NUM_DOC", + "Factura": "FACTURA", + "Material": "MATERIAL", + "Texto breve de material": "TEXTO_BREVE_MATERIAL", + "Lote": "LOTE", + "Solic.": "CODE_SOLICITANTE", + "Agrup. Cliente": "AGRUPACION_CLIENTE", + "País Solic.": "PAIS_SOLICITANTE", + "Doc.vtas.": "DOCUMENTO_VENTAS", + "Entrega": "ENTREGA", + "Año Fact.": "ANO_FACTURA", + "Denomin.": "DENOMINACION", + "Sust.Activa": "SUSTANCIA_ACTIVA", + "Present.Concentr.": "PRESENTACION_CONCENTRACION", + "Nom.Cl.Final": "CLIENTE_FINAL", + "País CLF": "PAIS_CLIENTE_FINAL", + "Lote-prov.": "LOTE_PROVEEDOR", + "Nom.Prov.Lote": "NOM_PROVEEDOR_LOTE", + "Sector": "SECTOR", + "Dirección dest.me": "DIRECCION_DESTINO", + "N.I.F.com.": "NIF_COMUNITARIO", + "Nº Ped. Cliente cab": "NUM_PEDIDO_CLIENTE", + "Nom Dest.": "NOMBRE_DESTINATARIO", + +}