From c5326ad634a21141d129976d4e68ebef3287be31 Mon Sep 17 00:00:00 2001 From: Duvan Andres Date: Mon, 23 Jun 2025 16:09:34 -0500 Subject: [PATCH] add n8n flows for upload + register company --- Ingresar_Empresa_2_v2_1_PROD.json | 1225 +++++++++++++++++++++++++++++ UploadTemplates.json | 320 ++++++++ 2 files changed, 1545 insertions(+) create mode 100644 Ingresar_Empresa_2_v2_1_PROD.json create mode 100644 UploadTemplates.json diff --git a/Ingresar_Empresa_2_v2_1_PROD.json b/Ingresar_Empresa_2_v2_1_PROD.json new file mode 100644 index 0000000..ae4ea1f --- /dev/null +++ b/Ingresar_Empresa_2_v2_1_PROD.json @@ -0,0 +1,1225 @@ +{ + "name": "Ingresar_Empresa_2_v2_1_PROD", + "nodes": [ + { + "parameters": { + "assignments": { + "assignments": [ + { + "id": "e8cc1c5d-1939-4fee-99b2-e2daa048bf18", + "name": "ambiente", + "value": "={{ $json.Ambiente === 'Prueba' ? '00' : '01' }}", + "type": "string" + }, + { + "id": "9bc2e37a-e2d6-4776-a6de-fb68d4d2c756", + "name": "codigoActividad", + "value": "={{ $json['Código de Actividad'] }}", + "type": "string" + }, + { + "id": "f96461cc-b92a-4305-bd13-d1697bfbfbe6", + "name": "descActividad", + "value": "={{ $json['Descripción Actividad'] }}", + "type": "string" + }, + { + "id": "ceb4e3ad-82ed-4f4e-9c3c-9705b88da02a", + "name": "configuracionSmtp", + "value": "= {\n \"host\": \"smtp.gmail.com\",\n \"port\": 465,\n \"secure\": true,\n \"auth\": {\n \"user\": \"factura_electronica@consiti.com\",\n \"pass\": \"kbrjcrbimzbuqbnx\"\n }\n }", + "type": "object" + }, + { + "id": "f2eba619-b4dd-4300-a0e8-010fe48397cf", + "name": "contrasena", + "value": "={{ $json['Contraseña'] }}", + "type": "string" + }, + { + "id": "fe6a444e-12f5-4133-90db-fe148ebae5d9", + "name": "correoEmpresa", + "value": "={{ $json['Correo de Empresa'] }}", + "type": "string" + }, + { + "id": "375cd3b9-122d-44a9-bb75-e5de07490d10", + "name": "direccion", + "value": "={\n \"complemento\": \"{{ $json.Complemento }}\",\n \"departamento\": \"{{ $json.Departamento }}\",\n \"municipio\": \"{{ $json.Municipio }}\"\n }\n", + "type": "object" + }, + { + "id": "499fb554-a61c-4467-a73f-b90fd4fbc4f7", + "name": "llaves", + "value": "={\n \"publica\":\"{{ $json['Clave Publica'] }}\", \n \"api\":\"{{ $json.API }}\", \n \"privada\":\"{{ $json['Clave Privada'] }}\"\n}", + "type": "object" + }, + { + "id": "70be6afc-cc87-42e6-a372-674061125339", + "name": "nit", + "value": "={{ $json.NIT.replace(/-/g, '') }}", + "type": "string" + }, + { + "id": "e9e2b141-e709-4699-a22a-8749b481215e", + "name": "nombreComercial", + "value": "={{ $json['Nombre Comercial'] }}", + "type": "string" + }, + { + "id": "1258f448-b08e-474d-9b65-387e08a3d338", + "name": "nombreEmpresa", + "value": "={{ $json['Nombre de Empresa'] }}", + "type": "string" + }, + { + "id": "6501fac1-ff08-4d90-acb6-91fff12d4f3a", + "name": "nombreUsuario", + "value": "={{ $json['Nombre de Usuario'] }}", + "type": "string" + }, + { + "id": "d63ff888-de9b-401a-afb6-97352a339661", + "name": "nrc", + "value": "={{ $json.NRC.replace(/-/g, '') }}", + "type": "string" + }, + { + "id": "d66c1a99-f636-4e48-93ff-64815b7e095f", + "name": "telefono", + "value": "={{ $json['Teléfono'] }}", + "type": "string" + }, + { + "id": "817eb2d3-62ff-434b-bbde-f6fa7879c492", + "name": "roles", + "value": "[\"admin\", \"user\"]", + "type": "array" + }, + { + "id": "bb7c3815-4eed-4660-8f89-8e42f265ba64", + "name": "isActive", + "value": true, + "type": "boolean" + }, + { + "id": "4065050b-46ab-44b1-94e0-b84b405fed81", + "name": "tipoMoneda", + "value": "\"USD\"", + "type": "string" + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + -780, + 80 + ], + "id": "b99efae7-0ba5-4c28-b512-1ba2ad4b2e8c", + "name": "Edit Fields" + }, + { + "parameters": { + "method": "POST", + "url": "https://cbii.grupoconsiti.com/api/v1/companies", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "Authorization", + "value": "=Bearer {{ $json.jwt }}" + } + ] + }, + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={{ $('Edit Fields').item.json }}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.2, + "position": [ + -340, + 80 + ], + "id": "bd70834a-e792-4c81-bdfa-95a56499e020", + "name": "HTTP Request", + "onError": "continueErrorOutput" + }, + { + "parameters": { + "authentication": "serviceAccount", + "operation": "append", + "documentId": { + "__rl": true, + "value": "1QJ6G63KV1kzvlEgnGrB3c4lgAefI-PsxCtDaoO3_3AE", + "mode": "list", + "cachedResultName": "Clientes a producción", + "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1QJ6G63KV1kzvlEgnGrB3c4lgAefI-PsxCtDaoO3_3AE/edit?usp=drivesdk" + }, + "sheetName": { + "__rl": true, + "value": 1404948049, + "mode": "list", + "cachedResultName": "Incorrectos", + "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1QJ6G63KV1kzvlEgnGrB3c4lgAefI-PsxCtDaoO3_3AE/edit#gid=1404948049" + }, + "columns": { + "mappingMode": "defineBelow", + "value": { + "ambiente": "={{ $json.ambiente }}", + "codigoActividad": "={{ $json.codigoActividad }}", + "descActividad": "={{ $json.descActividad }}", + "correoEmpresa": "={{ $json.correoEmpresa }}", + "complemento": "={{ $json.complemento }}", + "departamento": "={{ $json.departamento }}", + "municipio": "={{ $json.municipio }}", + "publica": "={{ $json.publica }}", + "api": "={{ $json.api }}", + "privada": "={{ $json.privada }}", + "nit": "={{ $json.nit }}", + "nombreComercial": "={{ $json.nombreComercial }}", + "nombreEmpresa": "={{ $json.nombreEmpresa }}", + "nombreUsuario": "={{ $json.nombreUsuario }}", + "contrasena": "={{ $json.contrasena }}", + "nrc": "={{ $json.nrc }}", + "telefono": "={{ $json.telefono }}", + "status": "={{ $json.status }}", + "message": "={{ $json.message }}" + }, + "matchingColumns": [], + "schema": [ + { + "id": "ambiente", + "displayName": "ambiente", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "codigoActividad", + "displayName": "codigoActividad", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "descActividad", + "displayName": "descActividad", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "correoEmpresa", + "displayName": "correoEmpresa", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "complemento", + "displayName": "complemento", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "departamento", + "displayName": "departamento", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "municipio", + "displayName": "municipio", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "publica", + "displayName": "publica", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "api", + "displayName": "api", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "privada", + "displayName": "privada", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "nit", + "displayName": "nit", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "nombreComercial", + "displayName": "nombreComercial", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "nombreEmpresa", + "displayName": "nombreEmpresa", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "nombreUsuario", + "displayName": "nombreUsuario", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "contrasena", + "displayName": "contrasena", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "nrc", + "displayName": "nrc", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "telefono", + "displayName": "telefono", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "status", + "displayName": "status", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "message", + "displayName": "message", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + } + ], + "attemptToConvertTypes": false, + "convertFieldsToString": false + }, + "options": {} + }, + "type": "n8n-nodes-base.googleSheets", + "typeVersion": 4.5, + "position": [ + 380, + 220 + ], + "id": "11c658bb-7739-4bdf-9bc1-f06d2f074276", + "name": "Registro Incorrectos", + "credentials": { + "googleApi": { + "id": "KKWZLgqngkZOibTW", + "name": "Google Sheets SA - felsv-consiti-cbii-sheet" + } + } + }, + { + "parameters": { + "assignments": { + "assignments": [ + { + "id": "afa36e7c-032e-4750-91ee-23a12244a0b9", + "name": "ambiente", + "value": "={{ $('Edit Fields').item.json.ambiente }}", + "type": "string" + }, + { + "id": "1a696360-1c65-4913-be2c-cf891871eadc", + "name": "codigoActividad", + "value": "={{ $('Edit Fields').item.json.codigoActividad }}", + "type": "string" + }, + { + "id": "1b568f74-974f-42f0-8a66-e55d79e3a67e", + "name": "descActividad", + "value": "={{ $('Edit Fields').item.json.descActividad }}", + "type": "string" + }, + { + "id": "a126267e-60dc-4985-a7e2-a1a8e6da35d7", + "name": "correoEmpresa", + "value": "={{ $('Edit Fields').item.json.correoEmpresa }}", + "type": "string" + }, + { + "id": "bd148168-23de-4b2d-aeef-63e3cfc23911", + "name": "complemento", + "value": "={{ $('Edit Fields').item.json.direccion.complemento }}", + "type": "string" + }, + { + "id": "b0fb2dca-11e0-4b03-8f97-441c6b56e912", + "name": "departamento", + "value": "={{ $('Edit Fields').item.json.direccion.departamento }}", + "type": "string" + }, + { + "id": "b4dfe982-1d59-4099-88a1-b3a92671e810", + "name": "municipio", + "value": "={{ $('Edit Fields').item.json.direccion.municipio }}", + "type": "string" + }, + { + "id": "13bb4038-32db-45ab-8dbb-9c059b19471e", + "name": "publica", + "value": "={{ $('Edit Fields').item.json.llaves.publica }}", + "type": "string" + }, + { + "id": "54ef03df-7733-4fee-8b4b-66ecbe8020bc", + "name": "api", + "value": "={{ $('Edit Fields').item.json.llaves.api }}", + "type": "string" + }, + { + "id": "9acf95af-1fbd-462a-a6d5-978748936855", + "name": "privada", + "value": "={{ $('Edit Fields').item.json.llaves.privada }}", + "type": "string" + }, + { + "id": "9cc47a3c-30ef-4122-8e99-ec0993df6636", + "name": "nit", + "value": "={{ $('Google Sheets').item.json.NIT }}", + "type": "string" + }, + { + "id": "5728fbd9-7769-4d12-8894-9bb51cb7ac0b", + "name": "nombreComercial", + "value": "={{ $('Edit Fields').item.json.nombreComercial }}", + "type": "string" + }, + { + "id": "bec4eab9-31af-430d-a450-865fb499ca89", + "name": "nombreEmpresa", + "value": "={{ $('Edit Fields').item.json.nombreEmpresa }}", + "type": "string" + }, + { + "id": "e1de2a25-d488-4d7b-9a9b-81c163309424", + "name": "nombreUsuario", + "value": "={{ $('Edit Fields').item.json.nombreUsuario }}", + "type": "string" + }, + { + "id": "4bfb6bb7-a0dc-4e19-84cf-c9ef7b7aa79e", + "name": "contrasena", + "value": "={{ $('Edit Fields').item.json.contrasena }}", + "type": "string" + }, + { + "id": "4b221481-3f5b-4989-95de-c708592d8d92", + "name": "nrc", + "value": "={{ $('Edit Fields').item.json.nrc }}", + "type": "string" + }, + { + "id": "83900f71-fb41-4ac7-b341-6700a31099d5", + "name": "telefono", + "value": "={{ $('Edit Fields').item.json.telefono }}", + "type": "string" + }, + { + "id": "e864c17e-e53a-47ad-98bb-38482a96fbf2", + "name": "status", + "value": "={{ $json.error.status }}", + "type": "number" + }, + { + "id": "d003cdf0-c00b-45fa-b433-94bc49b40d45", + "name": "message", + "value": "={{ $json.error.message }}", + "type": "string" + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + 20, + 220 + ], + "id": "f6c7248f-a643-42c2-aa37-fb21371743e3", + "name": "Formato incorrecto" + }, + { + "parameters": { + "authentication": "serviceAccount", + "operation": "append", + "documentId": { + "__rl": true, + "value": "1QJ6G63KV1kzvlEgnGrB3c4lgAefI-PsxCtDaoO3_3AE", + "mode": "list", + "cachedResultName": "Clientes a producción", + "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1QJ6G63KV1kzvlEgnGrB3c4lgAefI-PsxCtDaoO3_3AE/edit?usp=drivesdk" + }, + "sheetName": { + "__rl": true, + "value": "gid=0", + "mode": "list", + "cachedResultName": "Entrada", + "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1QJ6G63KV1kzvlEgnGrB3c4lgAefI-PsxCtDaoO3_3AE/edit#gid=0" + }, + "columns": { + "mappingMode": "defineBelow", + "value": { + "Ambiente": "={{ $json.body.ambient === 'Prueba' ? '00' : '01' }}", + "Código de Actividad": "={{ $json.body.occupation.split(' - ')[0] }}", + "Descripción Actividad": "={{ $json.body.occupation.split(' - ')[1] }}", + "Correo de Empresa": "={{ $json.body.email }}", + "Complemento": "={{ $json.body.complement }}", + "Departamento": "={{ $json.body.department }}", + "Municipio": "={{ $json.body.municipality }}", + "Clave Publica": "={{ $json.body.public_key }}", + "API": "={{ $json.body.api_key }}", + "Clave Privada": "={{ $json.body.private_key }}", + "NIT": "={{ $json.body.nit }}", + "Nombre Comercial": "={{ $json.body.trade_name }}", + "Nombre de Empresa": "={{ $json.body.company_name }}", + "Nombre de Usuario": "={{ $json.body.username }}", + "Contraseña": "={{ $json.body.password }}", + "NRC": "={{ $json.body.nrc }}", + "Teléfono": "={{ $json.body.phone }}", + "Marca temporal": "={{$now}}", + "Nombre DB": "={{ $json.body.db_name }}" + }, + "matchingColumns": [], + "schema": [ + { + "id": "Marca temporal", + "displayName": "Marca temporal", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "Ambiente", + "displayName": "Ambiente", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "Código de Actividad", + "displayName": "Código de Actividad", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "Descripción Actividad", + "displayName": "Descripción Actividad", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "Correo de Empresa", + "displayName": "Correo de Empresa", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "Complemento", + "displayName": "Complemento", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "Departamento", + "displayName": "Departamento", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "Municipio", + "displayName": "Municipio", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "Clave Publica", + "displayName": "Clave Publica", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "API", + "displayName": "API", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "Clave Privada", + "displayName": "Clave Privada", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "NIT", + "displayName": "NIT", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "Nombre Comercial", + "displayName": "Nombre Comercial", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "Nombre de Empresa", + "displayName": "Nombre de Empresa", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "Nombre de Usuario", + "displayName": "Nombre de Usuario", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "Contraseña", + "displayName": "Contraseña", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "NRC", + "displayName": "NRC", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "Teléfono", + "displayName": "Teléfono", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "Nombre DB", + "displayName": "Nombre DB", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": false + } + ], + "attemptToConvertTypes": false, + "convertFieldsToString": false + }, + "options": {} + }, + "type": "n8n-nodes-base.googleSheets", + "typeVersion": 4.5, + "position": [ + -1000, + 80 + ], + "id": "d075302e-284f-47af-9b86-4972ef6fed03", + "name": "Google Sheets", + "credentials": { + "googleApi": { + "id": "KKWZLgqngkZOibTW", + "name": "Google Sheets SA - felsv-consiti-cbii-sheet" + } + } + }, + { + "parameters": { + "operation": "xls", + "binaryPropertyName": "=data", + "options": { + "fileName": "=FELSV_PARAMETER_{{ $('Edit Fields').item.json.nombreEmpresa }}.xls" + } + }, + "type": "n8n-nodes-base.convertToFile", + "typeVersion": 1.1, + "position": [ + 480, + 0 + ], + "id": "44b1c4da-e08a-40af-8466-77794864c52d", + "name": "Convert to File1" + }, + { + "parameters": { + "jsCode": "return [\n { json: { Clave: \"version\", Valor: \"1\", Nit: $input.first().json.nit } },\n { json: { Clave: \"ambiente\", Valor: $input.first().json.ambiente, Nit: $input.first().json.nit } },\n { json: { Clave: \"resumen.tipo_documento\", Valor: \"01\" , Nit: $input.first().json.nit} },\n { json: { Clave: \"codEstableMH\", Valor: \"M001\", Nit: $input.first().json.nit} },\n { json: { Clave: \"codPuntoVenta\", Valor: \"2355\", Nit: $input.first().json.nit} },\n { json: { Clave: \"tipoDte\", Valor: \"01\", Nit: $input.first().json.nit } },\n { json: { Clave: \"tipoModelo\", Valor: \"1\", Nit: $input.first().json.nit } },\n { json: { Clave: \"tipoOperacion\", Valor: \"1\", Nit: $input.first().json.nit } },\n { json: { Clave: \"codPuntoVentaMH\", Valor: \"P001\", Nit: $input.first().json.nit} },\n { json: { Clave: \"receptor.nrc\", Valor: \"0\", Nit: $input.first().json.nit } },\n { json: { Clave: \"emisor.nombre\", Valor: $input.first().json.nombreEmpresa, Nit: $input.first().json.nit } },\n { json: { Clave: \"emisor.codActividad\", Valor: $input.first().json.codigoActividad, Nit: $input.first().json.nit} },\n { json: { Clave: \"emisor.descActividad\", Valor: $input.first().json.descActividad, Nit: $input.first().json.nit} },\n { json: { Clave: \"emisor.nombreComercial\", Valor: $input.first().json.nombreComercial, Nit: $input.first().json.nit} },\n { json: { Clave: \"emisor.tipoEstablecimiento\", Valor: \"01\", Nit: $input.first().json.nit} },\n { json: { Clave: \"emisor.direccion.departamento\", Valor: $input.first().json.departamento, Nit: $input.first().json.nit} },\n { json: { Clave: \"emisor.direccion.municipio\", Valor: $input.first().json.municipio, Nit: $input.first().json.nit} },\n { json: { Clave: \"emisor.direccion.complemento\", Valor: $input.first().json.complemento, Nit: $input.first().json.nit} },\n { json: { Clave: \"emisor.telefono\", Valor: $input.first().json.telefono, Nit: $input.first().json.nit} },\n { json: { Clave: \"emisor.correo\", Valor: $input.first().json.correoEmpresa.toLowerCase() , Nit: $input.first().json.nit} },\n { json: { Clave: \"codEstable\", Valor: \"ABC1\", Nit: $input.first().json.nit} },\n { json: { Clave: \"user_nest\", Valor: $input.first().json.nombreUsuario, Nit: $input.first().json.nit} },\n { json: { Clave: \"pwd_nest\", Valor: $input.first().json.contrasena, Nit: $input.first().json.nit} },\n { json: { Clave: \"emisor.nrc\", Valor: $input.first().json.nrc, Nit: $input.first().json.nit} },\n { json: { Clave: \"url_nest\", Valor: \"https://cbii.grupoconsiti.com/api/v1/\", Nit: $input.first().json.nit} }\n];\n" + }, + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + 260, + 0 + ], + "id": "005242b4-5dc8-4e50-9d3e-40955eb2a061", + "name": "Code" + }, + { + "parameters": { + "authentication": "serviceAccount", + "driveId": { + "__rl": true, + "mode": "list", + "value": "My Drive" + }, + "folderId": { + "__rl": true, + "value": "1PxKilsD0NnTpDmf6jDibLgACkhwvSwBW", + "mode": "list", + "cachedResultName": "PARAMETROS PRODUCCION", + "cachedResultUrl": "https://drive.google.com/drive/folders/1PxKilsD0NnTpDmf6jDibLgACkhwvSwBW" + }, + "options": {} + }, + "type": "n8n-nodes-base.googleDrive", + "typeVersion": 3, + "position": [ + 680, + 0 + ], + "id": "031292d5-9dfa-4a04-950e-94477556b7df", + "name": "Google Drive", + "credentials": { + "googleApi": { + "id": "KKWZLgqngkZOibTW", + "name": "Google Sheets SA - felsv-consiti-cbii-sheet" + } + } + }, + { + "parameters": { + "assignments": { + "assignments": [ + { + "id": "afa36e7c-032e-4750-91ee-23a12244a0b9", + "name": "ambiente", + "value": "={{ $json.ambiente === 'Prueba' ? '00' : '01' }}", + "type": "string" + }, + { + "id": "1a696360-1c65-4913-be2c-cf891871eadc", + "name": "codigoActividad", + "value": "={{ $json.codigoActividad }}", + "type": "string" + }, + { + "id": "e864c17e-e53a-47ad-98bb-38482a96fbf2", + "name": "descActividad", + "value": "={{ $('Edit Fields').item.json.descActividad }}", + "type": "string" + }, + { + "id": "a126267e-60dc-4985-a7e2-a1a8e6da35d7", + "name": "correoEmpresa", + "value": "={{ $json.correoEmpresa }}", + "type": "string" + }, + { + "id": "bd148168-23de-4b2d-aeef-63e3cfc23911", + "name": "complemento", + "value": "={{ $json.direccion.complemento }}", + "type": "string" + }, + { + "id": "b0fb2dca-11e0-4b03-8f97-441c6b56e912", + "name": "departamento", + "value": "={{ $json.direccion.departamento }}", + "type": "string" + }, + { + "id": "b4dfe982-1d59-4099-88a1-b3a92671e810", + "name": "municipio", + "value": "={{ $json.direccion.municipio }}", + "type": "string" + }, + { + "id": "13bb4038-32db-45ab-8dbb-9c059b19471e", + "name": "publica", + "value": "={{ $json.llaves.publica }}", + "type": "string" + }, + { + "id": "54ef03df-7733-4fee-8b4b-66ecbe8020bc", + "name": "api", + "value": "={{ $json.llaves.api }}", + "type": "string" + }, + { + "id": "9acf95af-1fbd-462a-a6d5-978748936855", + "name": "privada", + "value": "={{ $json.llaves.privada }}", + "type": "string" + }, + { + "id": "9cc47a3c-30ef-4122-8e99-ec0993df6636", + "name": "nit", + "value": "={{ $('Google Sheets').item.json.NIT }}", + "type": "string" + }, + { + "id": "5728fbd9-7769-4d12-8894-9bb51cb7ac0b", + "name": "nombreComercial", + "value": "={{ $json.nombreComercial }}", + "type": "string" + }, + { + "id": "bec4eab9-31af-430d-a450-865fb499ca89", + "name": "nombreEmpresa", + "value": "={{ $json.nombreEmpresa }}", + "type": "string" + }, + { + "id": "e1de2a25-d488-4d7b-9a9b-81c163309424", + "name": "nombreUsuario", + "value": "={{ $json.nombreUsuario }}", + "type": "string" + }, + { + "id": "4bfb6bb7-a0dc-4e19-84cf-c9ef7b7aa79e", + "name": "contrasena", + "value": "={{ $('Edit Fields').item.json.contrasena }}", + "type": "string" + }, + { + "id": "4b221481-3f5b-4989-95de-c708592d8d92", + "name": "nrc", + "value": "={{ $json.nrc.replace(/-/g, '') }}", + "type": "string" + }, + { + "id": "83900f71-fb41-4ac7-b341-6700a31099d5", + "name": "telefono", + "value": "={{ $json.telefono }}", + "type": "string" + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + 0, + 0 + ], + "id": "eb6f6233-3021-412c-bcf2-4874d334e2a5", + "name": "Formato Correcto1" + }, + { + "parameters": { + "httpMethod": "POST", + "path": "produccion-cbii", + "authentication": "jwtAuth", + "options": {} + }, + "type": "n8n-nodes-base.webhook", + "typeVersion": 2, + "position": [ + -1220, + 80 + ], + "id": "6510169c-7912-4090-830d-52f612e5d428", + "name": "Webhook", + "webhookId": "771ed3da-e3aa-49ed-b61a-10e7c1fb3dc9", + "credentials": { + "jwtAuth": { + "id": "mwX21CUZHhQOdLS1", + "name": "JWT Auth account 2" + } + } + }, + { + "parameters": { + "method": "POST", + "url": "https://demo.odoofactura.com/web/database/restore", + "sendBody": true, + "contentType": "multipart-form-data", + "bodyParameters": { + "parameters": [ + { + "name": "master_pwd", + "value": "BQCFA3ATaurp748gYBKv" + }, + { + "name": "copy", + "value": "false" + }, + { + "name": "name", + "value": "={{ $json['Nombre DB'] }}" + }, + { + "parameterType": "formBinaryData", + "name": "backup_file", + "inputDataFieldName": "data" + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.2, + "position": [ + -560, + 340 + ], + "id": "930d3aa7-8634-4947-a6fa-4ee4117ad147", + "name": "Restaurar en ODOO", + "alwaysOutputData": false + }, + { + "parameters": { + "url": "https://grupo-consiti.sfo3.digitaloceanspaces.com/odoo-backups-bd/PrecargadasOdoo13/BD_PRECARGADA_LATEST.zip", + "options": { + "response": { + "response": { + "responseFormat": "file" + } + } + } + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.2, + "position": [ + -780, + 340 + ], + "id": "fd3b1eb3-12b9-48bf-9dce-9f3d307c0000", + "name": "Descargando BD Precargada", + "executeOnce": true + }, + { + "parameters": {}, + "type": "n8n-nodes-base.noOp", + "typeVersion": 1, + "position": [ + -340, + 340 + ], + "id": "a935fe0f-daff-43bf-9d32-905c006828e2", + "name": "No Operation, do nothing" + }, + { + "parameters": { + "method": "POST", + "url": "https://cbii.grupoconsiti.com/api/v1/signin", + "sendBody": true, + "specifyBody": "json", + "jsonBody": "{\n \"email\":\"owner@consiti.com\",\n \"password\":\"1234567_\",\n \"nit\":\"06142009131109\"\n}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.2, + "position": [ + -560, + 80 + ], + "id": "095c9916-ad4f-42ca-86cc-6d00fc1983e1", + "name": "Signin CBII | Prod" + } + ], + "pinData": {}, + "connections": { + "Edit Fields": { + "main": [ + [ + { + "node": "Signin CBII | Prod", + "type": "main", + "index": 0 + } + ] + ] + }, + "HTTP Request": { + "main": [ + [ + { + "node": "Formato Correcto1", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Formato incorrecto", + "type": "main", + "index": 0 + } + ] + ] + }, + "Formato incorrecto": { + "main": [ + [ + { + "node": "Registro Incorrectos", + "type": "main", + "index": 0 + } + ] + ] + }, + "Google Sheets": { + "main": [ + [ + { + "node": "Edit Fields", + "type": "main", + "index": 0 + }, + { + "node": "Descargando BD Precargada", + "type": "main", + "index": 0 + } + ] + ] + }, + "Convert to File1": { + "main": [ + [ + { + "node": "Google Drive", + "type": "main", + "index": 0 + } + ] + ] + }, + "Code": { + "main": [ + [ + { + "node": "Convert to File1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Formato Correcto1": { + "main": [ + [ + { + "node": "Code", + "type": "main", + "index": 0 + } + ] + ] + }, + "Webhook": { + "main": [ + [ + { + "node": "Google Sheets", + "type": "main", + "index": 0 + } + ] + ] + }, + "Descargando BD Precargada": { + "main": [ + [ + { + "node": "Restaurar en ODOO", + "type": "main", + "index": 0 + } + ] + ] + }, + "Restaurar en ODOO": { + "main": [ + [ + { + "node": "No Operation, do nothing", + "type": "main", + "index": 0 + } + ] + ] + }, + "Signin CBII | Prod": { + "main": [ + [ + { + "node": "HTTP Request", + "type": "main", + "index": 0 + } + ] + ] + } + }, + "active": true, + "settings": { + "executionOrder": "v1" + }, + "versionId": "88c9dde8-6128-40a6-8a62-e126e8740392", + "meta": { + "templateCredsSetupCompleted": true, + "instanceId": "3f00f827e6d66efc9f97c59f1ab5be760cb897b12d5d15eaf36385f8951cde88" + }, + "id": "pQ9PeVju77ILQoOw", + "tags": [ + { + "createdAt": "2025-06-09T17:50:11.663Z", + "updatedAt": "2025-06-09T17:50:11.663Z", + "id": "PvALG7zPjVxZerb5", + "name": "Prod" + }, + { + "createdAt": "2025-04-25T00:57:09.664Z", + "updatedAt": "2025-04-25T00:57:09.664Z", + "id": "THhD0Na8eJLk6pA9", + "name": "CBII" + } + ] +} \ No newline at end of file diff --git a/UploadTemplates.json b/UploadTemplates.json new file mode 100644 index 0000000..f7842ab --- /dev/null +++ b/UploadTemplates.json @@ -0,0 +1,320 @@ +{ + "name": "UploadTemplates", + "nodes": [ + { + "parameters": { + "authentication": "basicAuth", + "formTitle": "Upload Files", + "formFields": { + "values": [ + { + "fieldLabel": "Certificado", + "fieldType": "file", + "multipleFiles": false, + "acceptFileTypes": ".crt", + "requiredField": true + }, + { + "fieldLabel": "PDF", + "fieldType": "file", + "acceptFileTypes": ".zip", + "requiredField": true + }, + { + "fieldLabel": "Email", + "fieldType": "file", + "acceptFileTypes": ".hbs", + "requiredField": true + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.formTrigger", + "typeVersion": 2.2, + "position": [ + 40, + 60 + ], + "id": "734d1d55-0ed3-48f3-abdd-3dbccff1fce4", + "name": "Upload Forms", + "webhookId": "b3c8c05e-a3e2-4f2b-a287-640ac09abf84", + "credentials": { + "httpBasicAuth": { + "id": "RGZpTg5V9GRShcjv", + "name": "Credential Form" + } + } + }, + { + "parameters": { + "authentication": "privateKey", + "resource": "file", + "binaryPropertyName": "Certificado", + "path": "/root/tst-services/felsv/certificates", + "options": { + "fileName": "=" + } + }, + "type": "n8n-nodes-base.ssh", + "typeVersion": 1, + "position": [ + -1060, + 40 + ], + "id": "b5d3b989-9fff-4106-9dc1-dfe77a875a71", + "name": "Upload Certificado", + "credentials": { + "sshPrivateKey": { + "id": "yfQgIOpHFSYSqrHI", + "name": "SSH Server TST" + } + } + }, + { + "parameters": { + "authentication": "privateKey", + "resource": "file", + "binaryPropertyName": "=PDF", + "path": "/tmp/", + "options": { + "fileName": "pdf.zip" + } + }, + "type": "n8n-nodes-base.ssh", + "typeVersion": 1, + "position": [ + -1060, + -140 + ], + "id": "9fee6de7-4bdf-406f-88a8-ee07a2209a7d", + "name": "Upload PDF", + "executeOnce": true, + "credentials": { + "sshPrivateKey": { + "id": "yfQgIOpHFSYSqrHI", + "name": "SSH Server TST" + } + } + }, + { + "parameters": { + "authentication": "privateKey", + "resource": "file", + "binaryPropertyName": "Email", + "path": "=/root/tst-services/felsv/templates/email/{{ $json.Certificado.filename.split(\".\")[0] }}", + "options": { + "fileName": "" + } + }, + "type": "n8n-nodes-base.ssh", + "typeVersion": 1, + "position": [ + -1060, + -380 + ], + "id": "0ec2d026-5d29-45ef-80d5-bbb68244de27", + "name": "Upload Email", + "credentials": { + "sshPrivateKey": { + "id": "yfQgIOpHFSYSqrHI", + "name": "SSH Server TST" + } + } + }, + { + "parameters": { + "authentication": "privateKey", + "command": "=unzip -o /tmp/pdf.zip -d /root/tst-services/felsv/templates/pdf/", + "cwd": "/tmp/" + }, + "type": "n8n-nodes-base.ssh", + "typeVersion": 1, + "position": [ + -900, + -140 + ], + "id": "65b93163-2540-4470-98e5-2c6733c2232c", + "name": "Descomprimir", + "credentials": { + "sshPrivateKey": { + "id": "yfQgIOpHFSYSqrHI", + "name": "SSH Server TST" + } + } + }, + { + "parameters": { + "resource": "object", + "operation": "create", + "bucketName": "cbii_templates_certificates", + "objectName": "={{ $json.Certificado.filename.split(\".\")[0] }}/{{ $json.Certificado.filename }}", + "createBinaryPropertyName": "Certificado", + "createData": {}, + "createQuery": {}, + "encryptionHeaders": {}, + "requestOptions": {} + }, + "type": "n8n-nodes-base.googleCloudStorage", + "typeVersion": 1, + "position": [ + -400, + -380 + ], + "id": "7df95548-d225-4466-a782-2449e8f77d62", + "name": "Upload Certificado to Bucket", + "credentials": { + "googleCloudStorageOAuth2Api": { + "id": "yRGr81Qzz10qzc4z", + "name": "Client OAuth - Consiti CBII " + } + }, + "disabled": true + }, + { + "parameters": { + "resource": "object", + "operation": "create", + "bucketName": "cbii_templates_certificates", + "objectName": "={{ $json.Certificado.filename.split(\".\")[0] }}/{{ $json.PDF[0].filename }}", + "createBinaryPropertyName": "PDF", + "createData": {}, + "createQuery": {}, + "encryptionHeaders": {}, + "requestOptions": {} + }, + "type": "n8n-nodes-base.googleCloudStorage", + "typeVersion": 1, + "position": [ + -400, + -160 + ], + "id": "4f63879e-189b-4c4a-a70f-a5f73c565f9b", + "name": "Upload Templates to Bucket", + "credentials": { + "googleCloudStorageOAuth2Api": { + "id": "yRGr81Qzz10qzc4z", + "name": "Client OAuth - Consiti CBII " + } + }, + "disabled": true + }, + { + "parameters": { + "resource": "object", + "operation": "create", + "bucketName": "cbii_templates_certificates", + "objectName": "={{ $json.Certificado.filename.split(\".\")[0] }}/{{ $json.Email[0].filename }}", + "createBinaryPropertyName": "Email", + "createData": {}, + "createQuery": {}, + "encryptionHeaders": {}, + "requestOptions": {} + }, + "type": "n8n-nodes-base.googleCloudStorage", + "typeVersion": 1, + "position": [ + -400, + 80 + ], + "id": "9adae919-4ac7-4a53-8ccb-fb2d4079eb55", + "name": "Upload Email to Bucket", + "credentials": { + "googleCloudStorageOAuth2Api": { + "id": "yRGr81Qzz10qzc4z", + "name": "Client OAuth - Consiti CBII " + } + }, + "disabled": true + } + ], + "pinData": {}, + "connections": { + "Upload Forms": { + "main": [ + [ + { + "node": "Upload Certificado", + "type": "main", + "index": 0 + }, + { + "node": "Upload Email", + "type": "main", + "index": 0 + }, + { + "node": "Upload PDF", + "type": "main", + "index": 0 + }, + { + "node": "Upload Certificado to Bucket", + "type": "main", + "index": 0 + }, + { + "node": "Upload Templates to Bucket", + "type": "main", + "index": 0 + }, + { + "node": "Upload Email to Bucket", + "type": "main", + "index": 0 + } + ] + ] + }, + "Upload PDF": { + "main": [ + [ + { + "node": "Descomprimir", + "type": "main", + "index": 0 + } + ] + ] + }, + "Upload Email": { + "main": [ + [] + ] + }, + "Upload Certificado": { + "main": [ + [] + ] + }, + "Descomprimir": { + "main": [ + [] + ] + } + }, + "active": true, + "settings": { + "executionOrder": "v1" + }, + "versionId": "99d219be-9778-4dd6-9d97-831baf099b52", + "meta": { + "templateCredsSetupCompleted": true, + "instanceId": "3f00f827e6d66efc9f97c59f1ab5be760cb897b12d5d15eaf36385f8951cde88" + }, + "id": "ZQEGXSpgxkbplRpX", + "tags": [ + { + "createdAt": "2025-06-06T20:26:36.314Z", + "updatedAt": "2025-06-06T20:26:36.314Z", + "id": "pvSaQz86UM7L4TXW", + "name": "test" + }, + { + "createdAt": "2025-06-06T20:26:44.764Z", + "updatedAt": "2025-06-06T20:26:44.764Z", + "id": "wiMFPYvsdx1YRorp", + "name": "felsv" + } + ] +} \ No newline at end of file