INVOICE PROCESSING

Build a BigQuery FX gain/loss ledger from normalized invoice payments

When an invoice is marked paid, it compares the posting-date rate to the payment-date rate, computes the realized FX gain or loss.

CategoryInvoice Processing
Enginesim
Difficultyadvanced
Triggerwebhook
Steps5
Setup~25 min

How it runs

The automated pipeline, trigger to output.

  • TriggerInvoice-paid webhook receivedHTTP webhook
  • ActionLoad posting-date rate and amount from PostgresPostgreSQLPostgres
  • ActionFetch FX rate on payment dateHTTP webhook
  • LogicCompute realized FX gain or loss
  • OutputAppend entry to BigQuery FX ledgerGoogle BigQueryBigQuery

What it does

This workflow closes the loop on FX accounting. The moment a foreign invoice is settled, it captures the realized currency gain or loss between when the invoice was booked and when it was paid, then records a structured entry in BigQuery for analytics and month-end close.

When to use it

Use it when finance needs an auditable realized-FX trail rather than ad hoc spreadsheets, or when analysts want to query gains and losses by vendor, currency, or period. It pairs naturally with a normalizer that already stored the posting-date rate.

How it works

  1. 1A webhook fires when an invoice status changes to paid, carrying the invoice id and payment date.
  2. 2A Postgres action loads the original amount, currency, and posting-date rate for that invoice.
  3. 3An HTTP action fetches the FX rate on the payment date.
  4. 4A logic step computes the realized gain or loss and classifies it as gain, loss, or flat.
  5. 5A BigQuery output appends the attributed ledger row for reporting.

Set it up

What you configure once, before turning it on.

  1. 1
    Connect HTTP webhookTrigger any URL on agent actions.
  2. 2
    Connect PostgresAny Postgres URL — query, write, migrate.
  3. 3
    Connect BigQueryDatasets, queries, schemas.
  4. 4
    Set each agent's modelWe leave models unset so you pick the tier — fast + cheap, or top-quality.
  5. 5
    Tune it to your dataEdit the prompts, filters, and field mappings so it matches how your team works.
  6. 6
    Test, then turn it onRun once against a sample, confirm the output, then enable the trigger.

Run this workflow in your colony.

14-day trial. No DevOps. No Sales call. Provisioned in under a minute.