🧾 Sync AWS billing invoices with FreeAgent and PostgreSQL tracking

14 views · 🧾 Invoice Processing

Description

Automatically retrieve AWS invoices and create corresponding bills in FreeAgent, marking them as paid. This workflow eliminates manual data entry for AWS billing.

What It Does

  1. Fetches invoices from AWS Invoicing API for the previous month
  2. Filters invoices by issue date to ensure only new ones are processed
  3. Checks PostgreSQL database for previously processed invoices
  4. Creates a bill in FreeAgent with correct dates and amounts
  5. Marks the bill as paid with a bank transaction explanation
  6. Records the invoice in the database to prevent future duplication

Prerequisites

Quick Setup Checklist

Configuration Required

This template has placeholders that you need to replace:

In Code Nodes

Credentials to Add

Use Cases

Database Schema

The workflow uses a PostgreSQL table to track processed invoices - To initially create the table you need to run :

CREATE TABLE aws_invoices_processed (
    id SERIAL PRIMARY KEY,
    aws_invoice_id VARCHAR(255) UNIQUE NOT NULL,
    freeagent_invoice_url TEXT NOT NULL,
    billing_period VARCHAR(7) NOT NULL,
    amount DECIMAL(10, 2) NOT NULL,
    currency VARCHAR(3) NOT NULL,
    processed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Customization

Notes

🔗 Nodes Used

HTTP Request, Postgres, Schedule Trigger

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup