<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Kronix700 Automation]]></title><description><![CDATA[Kronix700 Automation]]></description><link>https://kronix700.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/6b03aa1bb738686ec8c059be/71e3c1da-547a-4769-a30d-c57616298486.png</url><title>Kronix700 Automation</title><link>https://kronix700.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Mon, 30 Nov 2026 22:21:25 GMT</lastBuildDate><atom:link href="https://kronix700.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How to Automate Stripe Payout & Fee Reconciliation in Google Sheets Using n8n]]></title><description><![CDATA[Reconciling Stripe bank deposits against accounting ledgers is a recurring bottleneck for bookkeepers and SaaS operators. Stripe settles funds as net…]]></description><link>https://kronix700.hashnode.dev/how-to-automate-stripe-payout-fee-reconciliation-in-google-sheets-using-n8n</link><guid isPermaLink="true">https://kronix700.hashnode.dev/how-to-automate-stripe-payout-fee-reconciliation-in-google-sheets-using-n8n</guid><category><![CDATA[n8n]]></category><category><![CDATA[stripe]]></category><category><![CDATA[automation]]></category><category><![CDATA[google sheets]]></category><dc:creator><![CDATA[Kronix700]]></dc:creator><pubDate>Mon, 23 Nov 2026 19:24:05 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b03aa1bb738686ec8c059be/ab0e5de9-5ca4-4aac-a362-26bd236538e8.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Reconciling Stripe bank deposits against accounting ledgers is a recurring bottleneck for bookkeepers and SaaS operators. Stripe settles funds as net lump-sum payouts—bundling dozens of charges, partial refunds, currency adjustments, and processing fees (<code>2.9% + $0.30</code>) into a single bank transfer. Manually matching each bank deposit back to gross revenue and fee expense accounts creates monthly close delays.</p>
<p>You can automate this entire reconciliation loop without third-party middleware fees using a deterministic 5-node <strong>n8n</strong> workflow that listens to <code>payout.paid</code> webhooks, audits every underlying balance transaction in JavaScript, and writes verified entries into <strong>Google Sheets</strong>.</p>
<img src="https://raw.githubusercontent.com/Kronix700/n8n-stripe-payout-reconciliation/main/Stripe_Nodes.jpg" alt="n8n Stripe Payout Reconciliation Workflow" style="display:block;margin:0 auto" />

<blockquote>
<p><strong>Skip the manual node setup:</strong> You can download the ready-to-import <code>.json</code> workflow, 13-column <code>.csv</code> ledger template, and deployment guide directly on <a href="https://payhip.com/b/wV3ov">Payhip</a> or inspect the architecture in the <a href="https://github.com/Kronix700/n8n-stripe-payout-reconciliation">GitHub repository</a>.</p>
</blockquote>
<hr />
<h2>Pipeline Architecture</h2>
<p>The workflow runs on real-time webhook events with zero LLM or external API costs:</p>
<ol>
<li><strong>Stripe Trigger (</strong><code>On Payout Paid</code><strong>):</strong> Subscribes to <code>payout.paid</code> events, capturing the payout ID (<code>{{ $json.data.object.id }}</code>), exact net bank deposit in cents, currency code, and bank arrival timestamp.</li>
<li><strong>HTTP Request (</strong><code>Fetch Payout Transactions</code><strong>):</strong> Queries <code>GET https://api.stripe.com/v1/balance_transactions</code> with <code>payout={{ $json.data.object.id }}</code> and <code>limit=100</code> using a restricted read-only Stripe API key.</li>
<li><strong>Split Out (</strong><code>Extract Transaction Array</code><strong>):</strong> Splits the <code>data</code> array into individual balance items (<code>charge</code>, <code>refund</code>, <code>adjustment</code>).</li>
<li><strong>Code Node (</strong><code>Payout Math Audit</code><strong>):</strong> Filters out the outbound <code>payout</code> transfer entry to prevent double-counting, converts cents into standard decimal units, aggregates totals by accounting category, and verifies the accounting identity within a <code>$0.01</code> tolerance.</li>
<li><strong>Google Sheets (</strong><code>Append Reconciled Payout</code><strong>):</strong> Maps all 13 verified columns into the <code>Payout_Ledger</code> spreadsheet tab.</li>
</ol>
<hr />
<h2>Deterministic Math Audit in JavaScript</h2>
<p>Stripe's <code>/v1/balance_transactions</code> endpoint returns all balance movements linked to a payout—including the negative <code>payout</code> transfer entry itself. The <strong>Payout Math Audit</strong> Code node strips that transfer record (<code>tx.type !== 'payout'</code>) and verifies that \(\text{Gross Sales} - \text{Refunds} - \text{Stripe Fees} + \text{Adjustments} = \text{Bank Payout Amount}\):</p>
<pre><code class="language-javascript">const payoutObj = $('On Payout Paid').first().json.data.object;
const items = $input.all().map(i =&gt; i.json);

const movements = items.filter(tx =&gt; tx.type !== 'payout');

let grossSalesCents = 0;
let refundsCents = 0;
let feesCents = 0;
let adjustmentsCents = 0;
let computedNetCents = 0;

for (const tx of movements) {
  feesCents += Number(tx.fee || 0);
  computedNetCents += Number(tx.net || 0);

  if (tx.type === 'charge' || tx.type === 'payment') {
    grossSalesCents += Number(tx.amount || 0);
  } else if (tx.type === 'refund' || tx.type === 'payment_refund') {
    refundsCents += Math.abs(Number(tx.amount || 0));
  } else {
    adjustmentsCents += Number(tx.amount || 0);
  }
}

const expectedPayout = Number(payoutObj.amount || 0) / 100;
const computedNet = computedNetCents / 100;
const variance = Math.abs(computedNet - expectedPayout);

return [{
  json: {
    reconciled_at: new Date().toISOString(),
    payout_id: payoutObj.id,
    arrival_date: new Date(payoutObj.arrival_date * 1000).toISOString().split('T')[0],
    currency: (payoutObj.currency || 'usd').toUpperCase(),
    transaction_count: movements.length,
    gross_sales: Number((grossSalesCents / 100).toFixed(2)),
    refunds: Number((refundsCents / 100).toFixed(2)),
    stripe_fees: Number((feesCents / 100).toFixed(2)),
    adjustments: Number((adjustmentsCents / 100).toFixed(2)),
    net_computed: Number(computedNet.toFixed(2)),
    bank_payout_amount: Number(expectedPayout.toFixed(2)),
    audit_status: variance &lt;= 0.01 ? 'RECONCILED' : 'PAYOUT_VARIANCE',
    variance: Number(variance.toFixed(2))
  }
}];
</code></pre>
<p>When <code>net_computed</code> matches <code>bank_payout_amount</code>, <code>audit_status</code> outputs <code>RECONCILED</code> with <code>variance: 0</code>. If a multi-currency conversion rounding difference or high-volume pagination (&gt;100 items per payout) occurs, <code>audit_status</code> flags <code>PAYOUT_VARIANCE</code> with the exact discrepancy amount.</p>
<img src="https://raw.githubusercontent.com/Kronix700/n8n-stripe-payout-reconciliation/main/Stripe_Reconciled.jpg" alt="Payout Math Audit Output" style="display:block;margin:0 auto" />

<hr />
<h2>Turnkey Deployment Kit</h2>
<p>To deploy this workflow immediately in n8n Cloud or Self-Hosted without configuring webhooks, expressions, and spreadsheet schemas manually, download the complete package:</p>
<ul>
<li><a href="https://payhip.com/b/wV3ov"><strong>Download the n8n Stripe Payout &amp; Fee Reconciliation Kit ($34 USD)</strong></a> — Includes <code>stripe-payout-reconciliation-n8n.json</code>, <code>Stripe_Payout_Ledger_Template.csv</code>, and <code>Stripe_Setup_Guide.pdf</code>.</li>
<li><a href="https://payhip.com/b/dgcwr">Get the 2-in-1 Accounting Automation Bundle ($49 USD — Save 22%)</a> — Includes both the <strong>Invoice OCR &amp; Math Audit Kit (v1.1)</strong> and the <strong>Stripe Payout &amp; Fee Reconciliation Kit (v1.0)</strong>.</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[How to Automate PDF Invoice OCR and Math Reconciliation in Google Sheets Using n8n and GPT-4o-mini]]></title><description><![CDATA[Manual invoice data entry is slow, and relying solely on Large Language Models (LLMs) to extract financial figures introduces a hidden risk: arithmetic…]]></description><link>https://kronix700.hashnode.dev/how-to-automate-pdf-invoice-ocr-and-math-reconciliation-in-google-sheets-using-n8n-and-gpt-4o-mini</link><guid isPermaLink="true">https://kronix700.hashnode.dev/how-to-automate-pdf-invoice-ocr-and-math-reconciliation-in-google-sheets-using-n8n-and-gpt-4o-mini</guid><category><![CDATA[n8n]]></category><category><![CDATA[automation]]></category><category><![CDATA[openai]]></category><category><![CDATA[google sheets]]></category><dc:creator><![CDATA[Kronix700]]></dc:creator><pubDate>Mon, 23 Nov 2026 03:08:17 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b03aa1bb738686ec8c059be/c6122796-8b3e-48a8-a0ae-faa2f69bc498.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Manual invoice data entry is slow, and relying solely on Large Language Models (LLMs) to extract financial figures introduces a hidden risk: arithmetic hallucinations. While models like GPT-4o-mini excel at unstructured text extraction, they predict tokens rather than execute deterministic math—occasionally misreading a decimal point or mismatching subtotal and tax lines.</p>
<p>To eliminate both manual entry and silent accounting discrepancies, you can build a 6-node <strong>n8n</strong> pipeline that extracts PDF invoice data using OpenAI's <code>strict json_schema</code> mode, validates the arithmetic in JavaScript, guards against scanned PDFs without a text layer, and logs verified rows into <strong>Google Sheets</strong>.</p>
<blockquote>
<p><strong>Skip the manual node setup:</strong> You can download the ready-to-import <code>.json</code> workflow (<code>v1.1</code>), pre-formatted <code>.csv</code> ledger template, and deployment guide directly on <a href="https://payhip.com/b/tzei5">Payhip</a> or inspect the architecture in the <a href="https://github.com/Kronix700/n8n-invoice-ocr-accounting-audit">GitHub repository</a>.</p>
</blockquote>
<h2>Pipeline Architecture</h2>
<img src="https://raw.githubusercontent.com/Kronix700/n8n-invoice-ocr-accounting-audit/main/Nodes.jpg" alt="n8n Workflow Architecture" style="display:block;margin:0 auto" />

<p>The workflow operates asynchronously across six sequential nodes:</p>
<ol>
<li><strong>Google Drive Trigger (Watch Invoices Folder):</strong> Polls a designated folder for newly uploaded PDF invoices.</li>
<li><strong>Google Drive (Download PDF Invoice):</strong> Fetches the binary file using the incoming file ID (<code>{{ $json.id }}</code>).</li>
<li><strong>Extract from File (Extract PDF Text):</strong> Parses raw text directly from digital PDFs without third-party OCR API fees.</li>
<li><strong>HTTP Request (AI Structured Extraction):</strong> Sends the extracted text to OpenAI's <code>gpt-4o-mini</code> endpoint with <code>strict json_schema</code> enforcement and <code>temperature: 0</code> (~$0.0005 USD per invoice).</li>
<li><strong>Code Node (Accounting Audit Check):</strong> Runs a deterministic JavaScript reconciliation check and empty-text guard on the extracted numbers.</li>
<li><strong>Google Sheets (Append to Ledger):</strong> Maps all 13 verified fields into a structured accounting sheet.</li>
</ol>
<h2>Enforcing Strict JSON Extraction</h2>
<p>To prevent conversational filler or missing fields from breaking downstream nodes, configure the OpenAI <strong>HTTP Request</strong> body with <code>strict json_schema</code> enabled:</p>
<pre><code class="language-json">{
  "model": "gpt-4o-mini",
  "temperature": 0,
  "response_format": {
    "type": "json_schema",
    "json_schema": {
      "name": "invoice_extraction",
      "strict": true,
      "schema": {
        "type": "object",
        "properties": {
          "vendor_name": { "type": "string" },
          "tax_id": { "type": ["string", "null"] },
          "invoice_number": { "type": "string" },
          "invoice_date": { "type": "string" },
          "currency": { "type": "string" },
          "subtotal": { "type": "number" },
          "tax_amount": { "type": "number" },
          "total_amount": { "type": "number" },
          "expense_category": {
            "type": "string",
            "enum": ["Materials", "Subcontractors", "Software", "Fuel", "Office", "Utilities", "Other"]
          }
        },
        "required": [
          "vendor_name",
          "tax_id",
          "invoice_number",
          "invoice_date",
          "currency",
          "subtotal",
          "tax_amount",
          "total_amount",
          "expense_category"
        ],
        "additionalProperties": false
      }
    }
  },
  "messages": [
    {
      "role": "system",
      "content": "Extract accounting fields from the invoice text. Use YYYY-MM-DD for invoice_date and 3-letter ISO codes for currency."
    },
    {
      "role": "user",
      "content": {{ JSON.stringify($json.text) }}
    }
  ]
}
</code></pre>
<p>Setting <code>temperature: 0</code> eliminates sampling randomness, while <code>strict json_schema</code> guarantees type-safe JSON matching all 9 accounting keys on every execution.</p>
<h2>Deterministic Math Reconciliation in JavaScript</h2>
<p>Before appending data to your ledger, the <strong>Accounting Audit Check</strong> Code node verifies whether <code>subtotal + tax_amount</code> equals <code>total_amount</code> within a <code>$0.01</code> rounding tolerance and blocks image-only PDFs with empty text layers:</p>
<pre><code class="language-javascript">const rawPdfText = ($('Extract PDF Text').first().json.text || '').trim();
const aiRaw = $input.first().json.choices[0].message.content;
const data = JSON.parse(aiRaw);

const subtotal = Number(data.subtotal) || 0;
const tax = Number(data.tax_amount) || 0;
const total = Number(data.total_amount) || 0;
const invoiceNumber = (data.invoice_number || '').toString().trim();

const diff = Math.abs((subtotal + tax) - total);

// Guard against image-only/scanned PDFs without a text layer (0 + 0 = 0 false positive)
const hasReadableText = rawPdfText.length &gt;= 15;
const hasValidCoreFields = total &gt; 0 &amp;&amp; invoiceNumber.length &gt; 0;

let auditStatus = 'VERIFIED';
if (!hasReadableText || !hasValidCoreFields) {
  auditStatus = 'NEEDS_REVIEW';
} else if (diff &gt; 0.01) {
  auditStatus = 'MATH_DISCREPANCY';
}

return [{
  json: {
    processed_at: new Date().toISOString(),
    file_name: $('Watch Invoices Folder').first().json.name,
    vendor_name: data.vendor_name || 'UNKNOWN',
    tax_id: data.tax_id || '',
    invoice_number: invoiceNumber || 'N/A',
    invoice_date: data.invoice_date || '',
    currency: data.currency || 'USD',
    subtotal: subtotal,
    tax_amount: tax,
    total_amount: total,
    expense_category: data.expense_category || 'Other',
    audit_status: auditStatus,
    variance: Number(diff.toFixed(2))
  }
}];
</code></pre>
<p>If an invoice contains a surcharge not captured in the tax line or an OCR misread occurs, <code>audit_status</code> outputs <code>MATH_DISCREPANCY</code> alongside the exact <code>variance</code> amount, while image-only or scanned PDFs without a readable text layer (<code>&lt; 15</code> characters or <code>total_amount &lt;= 0</code>) are automatically flagged as <code>NEEDS_REVIEW</code> instead of passing as <code>0 + 0 = 0</code> false positives.</p>
<img src="https://raw.githubusercontent.com/Kronix700/n8n-invoice-ocr-accounting-audit/main/Verified.jpg" alt="Accounting Audit Check Output" style="display:block;margin:0 auto" />

<h2>Turnkey Deployment Kit</h2>
<p>If you want to deploy this workflow immediately in n8n Cloud or Self-Hosted without wiring each node and expression from scratch, the complete package is available here:</p>
<ul>
<li><a href="https://payhip.com/b/tzei5">Download the n8n Invoice OCR &amp; Math Audit Kit v1.1 ($29 USD)</a> — Includes <code>invoice-ocr-math-audit-n8n-v1.1.json</code>, <code>Ledger_Template.csv</code>, and <code>Setup_Guide.pdf</code>.</li>
<li><a href="https://github.com/Kronix700/n8n-invoice-ocr-accounting-audit">Inspect the Architecture &amp; Schema on GitHub</a></li>
<li><a href="https://payhip.com/b/dgcwr">Get the 2-in-1 Accounting Automation Bundle ($49 USD — Save 22%)</a> — Includes both the <strong>Invoice OCR &amp; Math Audit Kit (v1.1)</strong> and the <strong>Stripe Payout &amp; Fee Reconciliation Kit (v1.0)</strong>.</li>
</ul>
]]></content:encoded></item></channel></rss>