e-conomic Invoices
Booked sales invoices with customer, amounts in invoice currency, open remainder and payment status.
What it answers
- Which invoices are open or overdue?
- How much was invoiced to a customer?
The dataset is named after the company, such as "Acme ApS Invoices", and reads the company's e-conomic data.
How to add it
Gatlas adds it for a company when the company connects e-conomic, and it fills in after the first sync. For a company that connected earlier, ask your agent, connected with a Read/write key:
Add the e-conomic Invoices dataset for Acme ApS.
Your agent creates it from the ready-made dataset economic/invoices, after checking that the company's data has every column the dataset reads.
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
The company'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, the name Tables shows beside the company. To adapt the dataset, copy the SQL, put the schema in its place and change what your company needs.
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