AutomationFlowsData & Sheets › [oscar] Getinvoicesfromfapro Copy

[oscar] Getinvoicesfromfapro Copy

[Oscar] GetInvoicesFromFapro copy. Uses httpRequest, mySql. Event-driven trigger; 14 nodes.

Event trigger★★★★☆ complexity14 nodesHTTP RequestMySQL
Data & Sheets Trigger: Event Nodes: 14 Complexity: ★★★★☆ Added:

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 →

Download .json
{
  "id": "MY9HLBmBovMjqUml",
  "createdAt": "2023-07-14T04:39:38.637Z",
  "updatedAt": "2023-07-14T04:40:17.198Z",
  "name": "[Oscar] GetInvoicesFromFapro copy",
  "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": "d6e6f22a-f8bd-4ab2-b67f-26e3d6396c60",
      "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": "6d6ab342-aa3e-4510-8c1e-011ad548a342",
      "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": "aadadd81-47a6-4ae8-a38f-bcc3d678c20f",
      "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": "0e936414-0c59-43f2-8fd5-8a9573dbbbe8",
      "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: '2023-07-01',\n        end_date: '2023-12-31'}}\n  data.push(caca)\n\n    \n  }\nreturn data\n\n"
      },
      "id": "9630ab7e-7ea7-4975-91f5-cc3250657d85",
      "name": "Code4",
      "type": "n8n-nodes-base.code",
      "position": [
        -120,
        680
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "number": [
            {
              "name": "Rut",
              "value": "={{ $json[\"rut\"] }}"
            }
          ]
        },
        "options": {}
      },
      "id": "4fe16384-0b0c-4cf2-92cb-1c93ac7d2761",
      "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": "e0aa7baf-f201-40b1-a692-5cb2cd11d56c",
      "name": "GetInvoices1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        460,
        460
      ],
      "typeVersion": 3
    },
    {
      "parameters": {
        "conditions": {
          "number": [
            {
              "operation": "notEqual",
              "value2": "={{ $json[\"data\"][\"total_sales\"].length }}"
            }
          ]
        }
      },
      "id": "a685cc02-67f6-4596-8e8e-3977ebec8a18",
      "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": "9f43556e-21cb-4f62-a0fd-9bdfcf1ee120",
      "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": "3a770614-8aa5-4787-9f7c-03bd13d7166a",
      "name": "MySQL1",
      "type": "n8n-nodes-base.mySql",
      "position": [
        1600,
        680
      ],
      "typeVersion": 1,
      "credentials": {
        "mySql": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "f0d792f1-ac8f-4862-8225-60e5e6d7a168",
      "name": "Set1",
      "type": "n8n-nodes-base.set",
      "position": [
        1300,
        680
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "unit": "seconds"
      },
      "id": "f6e88459-c1b8-48ed-b476-fcc8651c682c",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        1160,
        960
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "batchSize": 1,
        "options": {
          "reset": "="
        }
      },
      "id": "d9f2161e-dcf0-4e30-aef7-4b9a4e5f7a85",
      "name": "Split In Batches",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        100,
        680
      ],
      "typeVersion": 1
    },
    {
      "parameters": {},
      "id": "296de0ca-2865-415b-b31d-8aca90929eb3",
      "name": "When clicking \"Execute Workflow\"",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -1620,
        680
      ]
    }
  ],
  "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
          }
        ]
      ]
    },
    "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
          }
        ]
      ]
    },
    "When clicking \"Execute Workflow\"": {
      "main": [
        [
          {
            "node": "LogginFapro",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "saveDataErrorExecution": "none",
    "saveDataSuccessExecution": "none",
    "saveExecutionProgress": false,
    "saveManualExecutions": false,
    "callerPolicy": "workflowsFromSameOwner"
  },
  "staticData": {
    "node:Schedule Trigger": {
      "recurrencyRules": []
    }
  },
  "versionId": "f708c327-d81e-495b-863a-a75cd1ba5e09",
  "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.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

[Oscar] GetInvoicesFromFapro copy. Uses httpRequest, mySql. Event-driven trigger; 14 nodes.

Source: https://github.com/abdopcnet/nodemation-backups/blob/main/[oscar]-getinvoicesfromfapro-copy-MY9HLBmBovMjqUml.json — original creator credit. Request a take-down →

More Data & Sheets workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Data & Sheets

This template demonstrates how to build a low-code, AI-powered data analysis workflow in n8n. It enables you to connect to various data sources (such as MySQL, Google Sheets, or local files), process

MySQL, Google Sheets, Read Write File +2
Data & Sheets

[eliminado] HS Owners. Uses httpRequest, itemLists, mySql. Event-driven trigger; 14 nodes.

HTTP Request, Item Lists, MySQL
Data & Sheets

[backup] HS Companies. Uses httpRequest, itemLists, mySql. Event-driven trigger; 10 nodes.

HTTP Request, Item Lists, MySQL
Data & Sheets

Финансовый Бот Telegram - Полный Функционал. Uses telegramTrigger, agent, telegram, httpRequest. Event-driven trigger; 53 nodes.

Telegram Trigger, Agent, Telegram +4
Data & Sheets

aula-00-mapa-do-n8n. Uses emailReadImap, stopAndError, httpRequest, graphql. Event-driven trigger; 46 nodes.

Email Read Imap, Stop And Error, HTTP Request +14