The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"id": "doz1sAclV184MnnH",
"createdAt": "2023-07-14T04:39:03.303Z",
"updatedAt": "2024-01-18T15:45:44.375Z",
"name": "[Oscar] GetInvoicesFromFapro",
"active": false,
"nodes": [
{
"parameters": {
"method": "POST",
"url": "https://cumplo.fapro.app/api/v1.0/login",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "email",
"value": "api@cumplo.com"
},
{
"name": "password",
"value": "TKB6Thdmt2WacP3B8z9h"
}
]
},
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "Accept",
"value": "application/json"
}
]
},
"options": {}
},
"id": "f3498d29-d0fa-4087-92fa-2f08f47f0ab4",
"name": "LogginFapro",
"type": "n8n-nodes-base.httpRequest",
"position": [
-1260,
680
],
"typeVersion": 3
},
{
"parameters": {
"url": "https://cumplo.fapro.app/api/v1.0/company/connected",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "authorization",
"value": "=Bearer {{ $json[\"data\"][\"accessToken\"] }}"
},
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "Accept",
"value": "application/json"
}
]
},
"options": {}
},
"id": "bb5c2fd8-2e24-4699-a8e5-9745fd00423e",
"name": "GetBusinessLogged",
"type": "n8n-nodes-base.httpRequest",
"position": [
-1040,
680
],
"typeVersion": 3
},
{
"parameters": {
"jsCode": "// Loop over input items and add a new field\n// called 'myNewField' to the JSON of each one\n//input all, el input es uno solo, el input all trae todo los inputs de ese nodo, en este caso es uno. s epuede tener varios items.\n\nvar data = []\nfor (const item of $input.all()) {\n \n data = item.json.data.companies.map(\n (account) => {\n return {\n empresa:{\n rut: account.rut.substring(0, account.rut.length -2),\n dv: account.rut.substring(account.rut.length,account.rut.length-1 ),\n rutdv:account.rut.substring(0, account.rut.length -2)+account.rut.substring(account.rut.length,account.rut.length-1 ),\n rznSocial: account.razon_social.toUpperCase()\n }\n }\n })\n}\n\nreturn data;"
},
"id": "551a861c-21ec-4611-a684-83d7265a044a",
"name": "Code",
"type": "n8n-nodes-base.code",
"position": [
-820,
680
],
"typeVersion": 1
},
{
"parameters": {
"keepOnlySet": true,
"values": {
"number": [
{
"name": "rut",
"value": "={{ parseInt($json[\"empresa\"][\"rut\"]) }}"
}
],
"string": [
{
"name": "RznSocial",
"value": "={{ $json[\"empresa\"][\"rznSocial\"] }}"
},
{
"name": "dv",
"value": "={{ $json[\"empresa\"][\"dv\"] }}"
},
{
"name": "rutdv",
"value": "={{ $json[\"empresa\"][\"rutdv\"] }}"
}
]
},
"options": {}
},
"id": "19ec2997-cbb1-43f1-aa42-e42b1f011d49",
"name": "BussinessActive",
"type": "n8n-nodes-base.set",
"position": [
-580,
680
],
"typeVersion": 1
},
{
"parameters": {
"jsCode": "const registeredBusiness = $('RegisteredBusiness').all()\nconst moment = require('moment')\n data = []\n\nfor(var i = 0 ; i < registeredBusiness.length;i ++){ \n const empresas= registeredBusiness[i]\n const empresa = empresas.json.Rut \n \n let caca = {\n empresa:{\n rut: empresa.toString(),\n init_date: moment().format('YYYY-MM-DD'),\n end_date: '2023-12-31'}}\n data.push(caca)\n\n \n }\nreturn data\n\n"
},
"id": "40e582a1-7a7e-4310-b150-fa2b3803ac38",
"name": "Code4",
"type": "n8n-nodes-base.code",
"position": [
-120,
680
],
"typeVersion": 1
},
{
"parameters": {
"keepOnlySet": true,
"values": {
"number": [
{
"name": "Rut",
"value": "={{ $json[\"rut\"] }}"
}
]
},
"options": {}
},
"id": "39db6f6c-7d27-49e0-9755-d0eebbe51d6d",
"name": "RegisteredBusiness",
"type": "n8n-nodes-base.set",
"position": [
-340,
680
],
"typeVersion": 1
},
{
"parameters": {
"url": "https://cumplo.fapro.app/api/v1.0/company/list-docs-sales",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "=Bearer {{ $node[\"LogginFapro\"].json[\"data\"][\"accessToken\"] }}"
}
]
},
"sendBody": true,
"contentType": "raw",
"rawContentType": "application/json",
"body": "={{ $json[\"empresa\"] }}",
"options": {}
},
"id": "fbdc3121-3a06-479e-a86b-70fc5b616991",
"name": "GetInvoices1",
"type": "n8n-nodes-base.httpRequest",
"position": [
460,
460
],
"typeVersion": 3
},
{
"parameters": {
"conditions": {
"number": [
{
"operation": "notEqual",
"value2": "={{ $json[\"data\"][\"total_sales\"].length }}"
}
]
}
},
"id": "7846aa0a-b938-432a-989a-682603c3f498",
"name": "IF1",
"type": "n8n-nodes-base.if",
"position": [
820,
700
],
"typeVersion": 1
},
{
"parameters": {
"jsCode": "\nconst rut = $('Split In Batches').first()\n\nconst rutCliente = rut.json.empresa.rut\n\nvar current = new Date().toLocaleString()\nconsole.log('prueba', rutCliente)\n\nlet data = []\nfor (const item of $input.all()) {\n \n data = item.json.data.total_sales.map(\n (account) => {\n return {\n identifier: \n `${rutCliente}_${account.rut_receptor}_${account.folio}_${account.tipo_documento}`,\n clientIdentifier: `${rutCliente}`,\n payerIdentifier: account.rut_receptor,\n payerName: account.nombre_empresa_receptora,\n folio:account.folio,\n invoiceAmount: account.monto_total_factura,\n documentType: account.tipo_documento,\n invoiceDate: account.fecha_factura,\n invoiceReceptionDate: account.fecha_recepcion_sii,\n cesionStatus: account.estado_cesion,\n hasCreditNote: account.notas_credito_asociadas.length, \n eventoReceptor: account.evento_receptor,\n createdAt: `${current}`\n }\n })\n}\n\nreturn data;"
},
"id": "c4f07310-1e13-42e1-ae5c-f8076573b9eb",
"name": "Code5",
"type": "n8n-nodes-base.code",
"position": [
1080,
680
],
"typeVersion": 1
},
{
"parameters": {
"table": {
"__rl": true,
"mode": "list",
"value": "Invoices",
"cachedResultName": "Invoices"
},
"columns": "identifier,clientIdentifier,payerIdentifier,payerName,folio,invoiceAmount,documentType,invoiceDate,invoiceReceptionDate,cesionStatus,hasCreditNote,eventoReceptor,createdAt",
"options": {
"ignore": true
}
},
"id": "5df06a93-8af7-40e1-a20d-5f068b3700fe",
"name": "MySQL1",
"type": "n8n-nodes-base.mySql",
"position": [
1600,
680
],
"typeVersion": 1,
"credentials": {
"mySql": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"options": {}
},
"id": "43968818-89b7-4bb4-8d53-5358d558c2e6",
"name": "Set1",
"type": "n8n-nodes-base.set",
"position": [
1300,
680
],
"typeVersion": 1
},
{
"parameters": {
"rule": {
"interval": [
{
"field": "hours"
}
]
}
},
"id": "8522c2ea-98f9-4919-839d-0a30c28afb83",
"name": "Schedule Trigger",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-1560,
800
],
"typeVersion": 1
},
{
"parameters": {
"unit": "seconds"
},
"id": "656427db-28be-4d79-8cad-92df47bc880b",
"name": "Wait",
"type": "n8n-nodes-base.wait",
"position": [
1160,
960
],
"typeVersion": 1
},
{
"parameters": {
"batchSize": 1,
"options": {
"reset": "="
}
},
"id": "0d75bb00-5077-4caf-a22b-d201cbc102ca",
"name": "Split In Batches",
"type": "n8n-nodes-base.splitInBatches",
"position": [
100,
680
],
"typeVersion": 1
}
],
"connections": {
"IF1": {
"main": [
[
{
"node": "Code5",
"type": "main",
"index": 0
}
],
[
{
"node": "Wait",
"type": "main",
"index": 0
}
]
]
},
"Code": {
"main": [
[
{
"node": "BussinessActive",
"type": "main",
"index": 0
}
]
]
},
"Set1": {
"main": [
[
{
"node": "MySQL1",
"type": "main",
"index": 0
}
]
]
},
"Wait": {
"main": [
[
{
"node": "Split In Batches",
"type": "main",
"index": 0
}
]
]
},
"Code4": {
"main": [
[
{
"node": "Split In Batches",
"type": "main",
"index": 0
}
]
]
},
"Code5": {
"main": [
[
{
"node": "Set1",
"type": "main",
"index": 0
}
]
]
},
"MySQL1": {
"main": [
[
{
"node": "Split In Batches",
"type": "main",
"index": 0
}
]
]
},
"LogginFapro": {
"main": [
[
{
"node": "GetBusinessLogged",
"type": "main",
"index": 0
}
]
]
},
"GetInvoices1": {
"main": [
[
{
"node": "IF1",
"type": "main",
"index": 0
}
]
]
},
"BussinessActive": {
"main": [
[
{
"node": "RegisteredBusiness",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "LogginFapro",
"type": "main",
"index": 0
}
]
]
},
"Split In Batches": {
"main": [
[
{
"node": "GetInvoices1",
"type": "main",
"index": 0
}
]
]
},
"GetBusinessLogged": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
},
"RegisteredBusiness": {
"main": [
[
{
"node": "Code4",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1",
"saveDataErrorExecution": "none",
"saveDataSuccessExecution": "none",
"saveExecutionProgress": false,
"saveManualExecutions": false,
"callerPolicy": "workflowsFromSameOwner"
},
"staticData": {
"node:Schedule Trigger": {
"recurrencyRules": []
}
},
"versionId": "4809a0a0-f0bd-4b44-87a4-e31c5b2df9bb",
"triggerCount": 1,
"tags": []
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
mySql
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
[Oscar] GetInvoicesFromFapro. Uses httpRequest, mySql. Scheduled trigger; 14 nodes.
Source: https://github.com/abdopcnet/nodemation-backups/blob/main/[oscar]-getinvoicesfromfapro-doz1sAclV184MnnH.json — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
[eliminado] HS Factura. Uses httpRequest, itemLists, mySql. Scheduled trigger; 15 nodes.
[Oscar] addNewBusinessLogged. Uses httpRequest, mySql. Scheduled trigger; 8 nodes.
MainWorkflow. Uses httpRequest, mySql, emailSend. Scheduled trigger; 8 nodes.
Sincronização entre Bancos de Dados. Uses mySql, httpRequest. Scheduled trigger; 5 nodes.