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", + +}