This dashboard is only available to users with a premium license. Please
contact us to get access to Lago Cloud and Lago
Self-Hosted Premium.
Our dashboard empowers you with insights into the number of invoices and their respective values across all payment statuses.
This means you can easily track the count of invoices with failed, pending, or successful payment statuses and ease your collection.
By simply clicking on any of the rows, you can gain access to a detailed list of invoices categorized by their status.
This feature proves valuable when you need to initiate a new payment intent or take specific actions related to invoice management.
To access the Invoice collection analytics dashboard:
Navigate to the “Analytics” section; and
Access the “Outstanding invoices” Dashboard.
Oustanding invoices dashboard
To access the Invoice collection analytics dashboard:
Navigate to the “Analytics” section; and
Access the “Outstanding invoices” Dashboard.
Oustanding invoices dashboard
LAGO_URL="https://api.getlago.com"API_KEY="__YOUR_API_KEY__"curl--location--request GET "$LAGO_URL/api/v1/analytics/invoice_collection?currency=USD"\--header"Authorization: Bearer $API_KEY"\--header'Content-Type: application/json'\
The generated amounts are in cents, making it compatible with different currencies.
--- Get start date of the organizationWITH organization_creation_date AS(SELECT DATE_TRUNC('month', o.created_at)AS start_monthFROM organizations oWHERE o.id ='__YOUR_ORGANIZATION_ID__')--- Generate a series of months, all_months AS(SELECT generate_series((SELECT start_month FROM organization_creation_date), DATE_TRUNC('month',CURRENT_DATE+INTERVAL'10 years'),interval'1 month')ASmonth)--- Get invoice number and value per status,invoices_per_status AS(SELECT DATE_TRUNC('month', i.issuing_date)ASmonth, i.currency,CASEWHEN i.payment_status =0THEN'pending'WHEN i.payment_status =1THEN'paid'WHEN i.payment_status =2THEN'failed'ENDAS payment_status,COALESCE(COUNT(*),0)AS number_invoices,COALESCE(SUM(i.total_amount_cents::float),0)AS amount_centsFROM invoices iWHERE i.organization_id ='__YOUR_ORGANIZATION_ID__'AND i.status=1--- ONLY FINALIZED INVOICESGROUPBY payment_status,month, currency)--- Get invoice total and amount per status per month till the current monthSELECT am.month, payment_status, currency,COALESCE(number_invoices,0)AS number_invoices,COALESCE(amount_cents,0)AS amount_centsFROM all_months amLEFTJOIN invoices_per_status ips ON ips.month= am.monthAND ips.payment_status ISNOTNULLWHERE am.month<= DATE_TRUNC('month',CURRENT_DATE)AND payment_status ISNOTNULL---AND currency = '' --- Filter by currency if neededORDERBY am.month, payment_status, currency;