crea un replaceHeaders para abordar la tabla buena de los brutos cambiándoles los nombres a las columnas y hideando las que no use

main
borja 1 year ago
parent 4f9aabbd9c
commit b4027b5764

@ -6,7 +6,7 @@
/** @type { Object.<string, Client> } */ /** @type { Object.<string, Client> } */
/** @type {Object.<string,{ name: string, province: string, ccaa: string, city: string}>} */ /** @type {Object.<string,{ name: string, province: string, ccaa: string, city: string}>} */
const codetoNameEquivalences = { const clientCodeInfo = {
"AAA": { name: "Hospital Son Espases", province: "Baleares", ccaa: "Islas Baleares", city: "Palma", }, "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", }, "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", }, "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(); const clientCode = code.toString();
let clientName = ""; if (clientCodeInfo[clientCode]) {
if (codetoNameEquivalences[clientCode]) { return {
clientName = codetoNameEquivalences[clientCode]; 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 const removeDoubleSpace = (str) => { // Removes double spaces in string

@ -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",
}
Loading…
Cancel
Save