---
title: "e-conomic Invoices"
description: "Booked sales invoices with customer, amounts in invoice currency, open remainder and payment status."
url: https://www.gatlas.ai/docs/datasets/catalog/economic/invoices
markdown_url: https://www.gatlas.ai/docs/datasets/catalog/economic/invoices.md
---

# e-conomic Invoices

Booked sales invoices with customer, amounts in invoice currency, open remainder and payment status.

Template id: economic/invoices. Added for a company when it connects e-conomic. The dataset is named "{Company} Invoices".

## Questions it answers
- Which invoices are open or overdue?
- How much was invoiced to a customer?

## Columns
- invoice_number: Booked invoice number.
- date: Invoice date.
- due_date: Due date.
- customer_number: e-conomic customer number.
- customer_name: Customer name from the customer master.
- recipient_name: Name on the invoice.
- recipient_country: Country on the invoice.
- currency: Invoice currency.
- net_amount: Net amount, invoice currency.
- vat_amount: VAT, invoice currency.
- gross_amount: Gross amount, invoice currency.
- remainder: Open amount, invoice currency.
- remainder_base: Open amount in base currency.
- payment_status: paid, open or partial.
- days_overdue: Days past due on an unpaid invoice; null otherwise.
- connection_label: The e-conomic agreement the row comes from.
- data_as_of: When this row was last synced.

## AI context

__ENTITY__'s booked sales invoices from e-conomic, one row per invoice.
net_amount, vat_amount, gross_amount and remainder are in the invoice's own currency; remainder_base is the open amount in base currency, the one to sum for receivables across currencies.
payment_status is paid, open or partial from the remainder. days_overdue is set only on an unpaid invoice past its due date, as of the day the dataset was built.
Draft invoices are not here; the ledger postings of a booked invoice are in the Ledger dataset (entry_type customerInvoice).

## SQL

__SCHEMA__ stands for the company's schema (schema_name in list_companies), and __ENTITY__ for its name.

```sql
SELECT
  ib."bookedInvoiceNumber" AS invoice_number,
  ib."date"::date AS date,
  ib."dueDate"::date AS due_date,
  (NULLIF(ib."customer"::text, '')::jsonb ->> 'customerNumber')::bigint AS customer_number,
  c."name" AS customer_name,
  NULLIF(ib."recipient"::text, '')::jsonb ->> 'name' AS recipient_name,
  NULLIF(ib."recipient"::text, '')::jsonb ->> 'country' AS recipient_country,
  ib."currency" AS currency,
  ib."netAmount" AS net_amount,
  ib."vatAmount" AS vat_amount,
  ib."grossAmount" AS gross_amount,
  ib."remainder" AS remainder,
  ib."remainderInBaseCurrency" AS remainder_base,
  CASE
    WHEN ABS(COALESCE(ib."remainder", 0)) < 0.01 THEN 'paid'
    WHEN ABS(ib."remainder" - ib."grossAmount") < 0.01 THEN 'open'
    ELSE 'partial'
  END AS payment_status,
  CASE
    WHEN ABS(COALESCE(ib."remainder", 0)) < 0.01 OR ib."dueDate" IS NULL THEN NULL::int
    WHEN ib."dueDate"::date < CURRENT_DATE THEN (CURRENT_DATE - ib."dueDate"::date)::int
  END AS days_overdue,
  ib."_gatlas_connection_label" AS connection_label,
  ib."_gatlas_synced_at" AS data_as_of
FROM __SCHEMA__.economic_invoices_booked ib
LEFT JOIN __SCHEMA__.economic_customers c
  ON c."customerNumber" = (NULLIF(ib."customer"::text, '')::jsonb ->> 'customerNumber')::bigint
 AND COALESCE(c."_gatlas_connection_label", '') = COALESCE(ib."_gatlas_connection_label", '')
ORDER BY ib."date" DESC, ib."bookedInvoiceNumber" DESC
```

Link: https://www.gatlas.ai/docs/datasets/catalog/economic/invoices.md
