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 →
{
"name": "Invoice Generation Workflow",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "invoice-generate",
"responseMode": "lastNode",
"options": {}
},
"type": "n8n-nodes-base.webhook",
"typeVersion": 2.1,
"position": [
-1712,
-1120
],
"id": "929371f0-0d90-4497-a389-9e4d7379a909",
"name": "Invoice generate"
},
{
"parameters": {
"jsCode": "// Get input data\nconst input = $input.all()[0].json;\n\n// Required fields\nconst required = ['client_id', 'service_description', 'hours', 'rate'];\n\n// Check each required field\nconst missing = required.filter(field => !input[field]);\n\nif (missing.length > 0) {\n throw new Error(`Missing required fields: ${missing.join(', ')}`);\n}\n\n// Validate types\nif (typeof input.client_id !== 'number' || input.client_id <= 0) {\n throw new Error('client_id must be a positive number');\n}\n\nif (typeof input.hours !== 'number' || input.hours <= 0) {\n throw new Error('hours must be a positive number');\n}\n\nif (typeof input.rate !== 'number' || input.rate <= 0) {\n throw new Error('rate must be a positive number');\n}\n\n// Set defaults\nconst validated = {\n client_id: input.client_id,\n project_id: input.project_id || `PROJ-${Date.now()}`,\n service_description: input.service_description,\n hours: input.hours,\n rate: input.rate,\n invoice_date: input.invoice_date || new Date().toISOString().split('T')[0],\n payment_terms_days: input.payment_terms_days || 30,\n tax_rate: input.tax_rate || 0.00\n};\n\nreturn { json: validated };"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-1504,
-1120
],
"id": "afa94d39-378a-4640-9ba8-12b6bd697e8f",
"name": "Validate Input"
},
{
"parameters": {
"operation": "get",
"tableId": "clients",
"filters": {
"conditions": [
{
"keyName": "id",
"keyValue": "={{ $json.client_id }}"
}
]
}
},
"type": "n8n-nodes-base.supabase",
"typeVersion": 1,
"position": [
-1296,
-1120
],
"id": "709da4fd-fdc4-4799-b6f1-93f6f570f229",
"name": "Fetch Client Data",
"credentials": {
"supabaseApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "// Get data from previous nodes\nconst input = $('Validate Input').first().json;\nconst client = $('Fetch Client Data').first().json;\n\n// Calculate amounts\nconst subtotal = parseFloat((input.hours * input.rate).toFixed(2));\nconst tax_amount = parseFloat((subtotal * input.tax_rate).toFixed(2));\nconst total_amount = parseFloat((subtotal + tax_amount).toFixed(2));\n\n// Calculate due date\nconst invoice_date = new Date(input.invoice_date);\nconst payment_terms = client.payment_terms_days || input.payment_terms_days;\nconst due_date = new Date(invoice_date);\ndue_date.setDate(due_date.getDate() + payment_terms);\n\n// Format dates\nconst formatted_invoice_date = invoice_date.toISOString().split('T')[0];\nconst formatted_due_date = due_date.toISOString().split('T')[0];\n\n// Build line items\nconst line_items = [\n {\n description: input.service_description,\n quantity: input.hours,\n rate: input.rate,\n amount: subtotal\n }\n];\n\n// Return calculated data\nreturn {\n json: {\n client_id: input.client_id,\n project_id: input.project_id,\n service_description: input.service_description,\n invoice_date: formatted_invoice_date,\n due_date: formatted_due_date,\n subtotal: subtotal,\n tax_rate: input.tax_rate,\n tax_amount: tax_amount,\n total_amount: total_amount,\n payment_terms_days: payment_terms,\n line_items: line_items,\n client: client\n }\n};"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-1088,
-1120
],
"id": "5778bed3-a1a4-445d-9b94-fc50a704b024",
"name": "Calculate Amounts"
},
{
"parameters": {
"jsCode": "// Get current year\nconst year = new Date().getFullYear();\n\n// Generate random 6-digit number (in production, query DB for max+1)\nconst random = Math.floor(100000 + Math.random() * 900000);\n\n// Format: INV-YYYY-XXXXXX\nconst invoice_number = `INV-${year}-${random}`;\n\n// Pass through all previous data plus invoice number\nconst data = $('Calculate Amounts').first().json;\n\nreturn {\n json: {\n ...data,\n invoice_number: invoice_number\n }\n};"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-880,
-1120
],
"id": "3bd09d80-8d12-4963-acf7-80523a28585f",
"name": "Generate Invoice Number"
},
{
"parameters": {
"tableId": "invoices",
"fieldsUi": {
"fieldValues": [
{
"fieldId": "invoice_number",
"fieldValue": "={{ $json.invoice_number }}"
},
{
"fieldId": "client_id",
"fieldValue": "={{ $json.client_id }}"
},
{
"fieldId": "project_id",
"fieldValue": "={{ $json.project_id }}"
},
{
"fieldId": "service_description",
"fieldValue": "={{ $json.service_description }}"
},
{
"fieldId": "invoice_date",
"fieldValue": "={{ $json.invoice_date }}"
},
{
"fieldId": "due_date",
"fieldValue": "={{ $json.due_date }}"
},
{
"fieldId": "subtotal",
"fieldValue": "={{ $json.subtotal }}"
},
{
"fieldId": "tax_rate",
"fieldValue": "={{ $json.tax_rate }}"
},
{
"fieldId": "tax_rate",
"fieldValue": "={{ $json.tax_rate }}"
},
{
"fieldId": "tax_amount",
"fieldValue": "={{ $json.tax_amount }}"
},
{
"fieldId": "total_amount",
"fieldValue": "={{ $json.total_amount }}"
},
{
"fieldId": "status",
"fieldValue": "=SENT"
},
{
"fieldId": "sent_date",
"fieldValue": "={{ $now }}"
},
{
"fieldId": "created_by",
"fieldValue": "SYSTEM"
}
]
}
},
"type": "n8n-nodes-base.supabase",
"typeVersion": 1,
"position": [
-672,
-1120
],
"id": "f5b1eedb-0f18-43f9-ad55-b088aed2764d",
"name": "Create Invoice Record",
"credentials": {
"supabaseApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"documentTemplateId": "6292FF59-8AFE-4099-839B-A6D0CBC493DD",
"payload": "={\n \"invoice_number\": \"{{$json.invoice_number}}\",\n \"invoice_date\": \"{{$json.invoice_date}}\",\n \"due_date\": \"{{$json.due_date}}\",\n \"payment_terms_days\": \"{{Math.floor((new Date($json.due_date) - new Date($json.invoice_date)) / (1000 * 60 * 60 * 24))}}\",\n \"project_id\": \"{{$json.project_id}}\",\n \"client_name\": \"{{ $('Generate Invoice Number').item.json.client.client_name }}\",\n \"client_address\": \"{{ $('Generate Invoice Number').item.json.client.address }}\",\n \"client_city\": \"{{ $('Generate Invoice Number').item.json.client.city }}\",\n \"client_state\": \"{{ $('Generate Invoice Number').item.json.client.state }}\",\n \"client_zip\": \"{{ $('Generate Invoice Number').item.json.client.zip_code }}\",\n \"client_email\": \"{{ $('Generate Invoice Number').item.json.client.contact_email }}\",\n \"client_phone\": \"{{ $('Generate Invoice Number').item.json.client.phone }}\",\n \"line_{{ $('Generate Invoice Number').item.json.client.city }}items\": [\n {\n \"description\": \"{{$json.service_description}}\",\n \"quantity\": \"{{$json.quantity}}\",\n \"rate\": \"{{$json.rate}}\",\n \"amount\": \"{{Number($json.subtotal).toFixed(2)}}\"\n }\n ],\n \"subtotal\": \"{{Number($json.subtotal).toFixed(2)}}\",\n \"tax_rate\": \"{{ $json.tax_rate }}\",\n \"tax_amount\": \"{{Number($json.tax_amount).toFixed(2)}}\",\n \"total_amount\": \"{{Number($json.total_amount).toFixed(2)}}\"\n}",
"filename": "={{$json.invoice_number}}_Debasanta_Consulting.pdf",
"meta": "={\n \"invoice_id\": \"{{$json.id}}\",\n \"client_id\": \"{{$json.client_id}}\",\n \"status\": \"{{$json.status}}\",\n \"created_at\": \"{{$json.created_at}}\",\n \"sent_date\": \"{{$json.sent_date}}\",\n \"qb_invoice_id\": \"{{$json.qb_invoice_id}}\"\n}"
},
"type": "n8n-nodes-pdfmonkey.pdfMonkey",
"typeVersion": 1,
"position": [
-1760,
-896
],
"id": "d87aa681-5a01-4a27-a882-bce1435cfd7b",
"name": "Create PDF invoice",
"credentials": {
"pdfMonkeyApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"fromEmail": "example@email.com",
"toEmail": "={{ $('Generate Invoice Number').item.json.client.billing_email }}",
"subject": "=Invoice {{ $('Generate Invoice Number').item.json.invoice_number }} from Debasanta Consulting LLC",
"text": "=Dear {{ $('Generate Invoice Number').item.json.client.client_name }},\n\nThank you for choosing Debasanta Consulting LLC. Please find attached your invoice for services rendered.\n\nINVOICE DETAILS:\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\nInvoice Number: {{ $('Create Invoice Record').item.json.invoice_number }}\nInvoice Date: {{ $('Create Invoice Record').item.json.invoice_date }}\nDue Date: {{ $('Create Invoice Record').item.json.due_date }}\nAmount Due: ${{ $('Create Invoice Record').item.json.total_amount }}\nProject: {{ $('Create Invoice Record').item.json.service_description }} \n\nPAYMENT METHODS:\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\ud83d\udcb3 Credit Card: https://debasantaconsulting.com/pay/\n\ud83c\udfe6 Bank Transfer: \n Bank: Mercury Bank\n Account: 4589217364\n Routing: 084009519\n Reference: {{ $('Create Invoice Record').item.json.invoice_number }}\n\n\ud83d\udcb0 EARLY PAYMENT DISCOUNT:\nPay within 10 days and receive a 2% discount!\n\nIf you have any questions about this invoice, please don't hesitate to reach out.\n\nBest regards,\nDebasanta\nDebasanta Consulting LLC\nexample@email.com\n(646) 555-0198\n\n---\nThis is an automated message. Your invoice is attached as a PDF.",
"html": "=",
"additionalFields": {},
"variablesUi": {
"variablesValues": [
{
"name": "Invoice Pdf",
"value": "={{ $json.document_card.public_share_link }}"
}
]
}
},
"type": "n8n-nodes-base.mailjet",
"typeVersion": 1,
"position": [
-1584,
-896
],
"id": "440fe777-a37c-45e9-92f0-d309698d0278",
"name": "Send an email",
"credentials": {
"mailjetEmailApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"resource": "invoice",
"operation": "create",
"Line": [
{
"Amount": "={{ $('Create Invoice Record').item.json.total_amount }}",
"Description": "={{ $('Create Invoice Record').item.json.service_description }}"
}
],
"additionalFields": {
"BillEmail": "={{ $('Generate Invoice Number').item.json.client.billing_email }}",
"DueDate": "={{ $('Generate Invoice Number').item.json.due_date }}",
"TxnDate": "={{ $('Generate Invoice Number').item.json.invoice_date }}"
}
},
"type": "n8n-nodes-base.quickbooks",
"typeVersion": 1,
"position": [
-1376,
-896
],
"id": "256a9285-8817-466d-96b9-9a3d58379b29",
"name": "Sync to QuickBooks",
"credentials": {
"quickBooksOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "append",
"documentId": {
"__rl": true,
"value": "1XzKxLOfWbJYc1JZi59STPJysRXN-vY2DxG3gHpJXiJs",
"mode": "list",
"cachedResultName": "Google Sheets Dashboard Structure",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1XzKxLOfWbJYc1JZi59STPJysRXN-vY2DxG3gHpJXiJs/edit?usp=drivesdk"
},
"sheetName": {
"__rl": true,
"value": 2065419117,
"mode": "list",
"cachedResultName": "Invoices",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1XzKxLOfWbJYc1JZi59STPJysRXN-vY2DxG3gHpJXiJs/edit#gid=2065419117"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"Invoice ID": "={{ $('Create Invoice Record').item.json.id }}",
"Invoice Number": "={{ $('Create Invoice Record').item.json.invoice_number }}",
"Client Name": "={{ $('Generate Invoice Number').item.json.client.client_name }}",
"Project ID": "={{ $('Generate Invoice Number').item.json.project_id }}",
"Invoice Date": "={{ $('Generate Invoice Number').item.json.invoice_date }}",
"Due Date": "={{ $('Generate Invoice Number').item.json.due_date }}",
"Amount": "={{ $('Generate Invoice Number').item.json.total_amount }}",
"Amount Paid": "0",
"Status": "SENT"
},
"matchingColumns": [],
"schema": [
{
"id": "Invoice ID",
"displayName": "Invoice ID",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Invoice Number",
"displayName": "Invoice Number",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Client Name",
"displayName": "Client Name",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Project ID",
"displayName": "Project ID",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Invoice Date",
"displayName": "Invoice Date",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Due Date",
"displayName": "Due Date",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Days Outstanding",
"displayName": "Days Outstanding",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Days Overdue",
"displayName": "Days Overdue",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Amount",
"displayName": "Amount",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Amount Paid",
"displayName": "Amount Paid",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Balance Due",
"displayName": "Balance Due",
"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": "Reminder Stage",
"displayName": "Reminder Stage",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Last Reminder",
"displayName": "Last Reminder",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Next Reminder",
"displayName": "Next Reminder",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Payment Method",
"displayName": "Payment Method",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "QB Invoice ID",
"displayName": "QB Invoice ID",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.7,
"position": [
-1168,
-896
],
"id": "0ac0038f-edce-4d50-92fd-0546efe937f3",
"name": "Update Dashboard",
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"tableId": "payment_tracking",
"fieldsUi": {
"fieldValues": [
{
"fieldId": "status",
"fieldValue": "SENT"
},
{
"fieldId": "amount_due",
"fieldValue": "={{ $('Generate Invoice Number').item.json.total_amount }}"
},
{
"fieldId": "amount_paid",
"fieldValue": "0"
},
{
"fieldId": "balance_due",
"fieldValue": "={{ $('Generate Invoice Number').item.json.total_amount }}"
},
{
"fieldId": "next_reminder_date",
"fieldValue": "={{ $json.next_reminder_date }}"
},
{
"fieldId": "invoice_id",
"fieldValue": "={{ $('Create Invoice Record').item.json.id }}"
}
]
}
},
"type": "n8n-nodes-base.supabase",
"typeVersion": 1,
"position": [
-736,
-896
],
"id": "f61cc5f4-eb6e-4c80-9c6a-f48de8d5d465",
"name": "Create Payment Tracking",
"credentials": {
"supabaseApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "const dueDate = new Date($('Generate Invoice Number').item.json.due_date);\nconst reminderDate = new Date(dueDate);\nreminderDate.setDate(reminderDate.getDate() - 5); // 5 days before due\n\nreturn {\n json: {\n next_reminder_date: reminderDate.toISOString().split('T')[0]\n }\n};"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-944,
-896
],
"id": "df083bc4-30cd-4d0d-ba63-78a265ee5c0b",
"name": "next_reminder_date calculation"
},
{
"parameters": {
"tableId": "audit_log",
"fieldsUi": {
"fieldValues": [
{
"fieldId": "event_type",
"fieldValue": "INVOICE_CREATED"
},
{
"fieldId": "invoice_id",
"fieldValue": "={{ $('Create Invoice Record').item.json.id }}"
},
{
"fieldId": "client_id",
"fieldValue": "={{ $('Generate Invoice Number').item.json.client_id }}"
},
{
"fieldId": "user_id",
"fieldValue": "SYSTEM"
}
]
}
},
"type": "n8n-nodes-base.supabase",
"typeVersion": 1,
"position": [
-544,
-896
],
"id": "22a3761c-8865-4244-8971-e8392b428f54",
"name": "Log to Audi",
"credentials": {
"supabaseApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"content": "## Payment Tracking & Receipt Workflow\n",
"height": 624,
"width": 1616,
"color": 4
},
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-1920,
-1312
],
"id": "e8679af0-f366-47f3-80d8-e4499563fbe5",
"name": "Sticky Note"
}
],
"connections": {
"Invoice generate": {
"main": [
[
{
"node": "Validate Input",
"type": "main",
"index": 0
}
]
]
},
"Validate Input": {
"main": [
[
{
"node": "Fetch Client Data",
"type": "main",
"index": 0
}
]
]
},
"Fetch Client Data": {
"main": [
[
{
"node": "Calculate Amounts",
"type": "main",
"index": 0
}
]
]
},
"Calculate Amounts": {
"main": [
[
{
"node": "Generate Invoice Number",
"type": "main",
"index": 0
}
]
]
},
"Generate Invoice Number": {
"main": [
[
{
"node": "Create Invoice Record",
"type": "main",
"index": 0
}
]
]
},
"Create Invoice Record": {
"main": [
[
{
"node": "Create PDF invoice",
"type": "main",
"index": 0
}
]
]
},
"Create PDF invoice": {
"main": [
[
{
"node": "Send an email",
"type": "main",
"index": 0
}
]
]
},
"Send an email": {
"main": [
[
{
"node": "Sync to QuickBooks",
"type": "main",
"index": 0
}
]
]
},
"Sync to QuickBooks": {
"main": [
[]
]
},
"Update Dashboard": {
"main": [
[
{
"node": "next_reminder_date calculation",
"type": "main",
"index": 0
}
]
]
},
"Create Payment Tracking": {
"main": [
[
{
"node": "Log to Audi",
"type": "main",
"index": 0
}
]
]
},
"next_reminder_date calculation": {
"main": [
[
{
"node": "Create Payment Tracking",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "11236b13-33a1-47ab-b3a6-2b2296132bcc",
"meta": {
"templateCredsSetupCompleted": true
},
"id": "jPt7ik2imCBeKb6U",
"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.
googleSheetsOAuth2ApimailjetEmailApipdfMonkeyApiquickBooksOAuth2ApisupabaseApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Invoice Generation Workflow. Uses supabase, n8n-nodes-pdfmonkey, mailjet, quickbooks. Webhook trigger; 14 nodes.
Source: https://github.com/tabii-dev/n8n-Portfolio/blob/main/automated-invoice-system/Invoice-Generation-Workflow.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.
This workflow automates raw materials inventory management for businesses, eliminating manual stock updates, delayed material issue approvals, and missed low stock alerts. It ensures real-time stock t
BP_check. Uses googleSheets, @n-octo-n/n8n-nodes-json-database, httpRequest, itemLists. Webhook trigger; 99 nodes.
webhook - simulador PDV (fluxo). Uses supabase. Webhook trigger; 55 nodes.
2. Refresh Pipedrive tokens. Uses stopAndError, stickyNote, supabase, httpRequest. Webhook trigger; 29 nodes.
This workflow provides an OAuth 2.0 auth token refresh process for better control. Developers can utilize it as an alternative to n8n's built-in OAuth flow to achieve improved control and visibility.