Gross revenue represents the total income generated by your organization in a single month, giving you a complete overview of your financial performance.
We ensure a comprehensive approach, encompassing all types of discounts, such as credit notes, coupons, and credits, to provide you with a precise picture of your gross revenue.
In essence, it’s the amount you should expect to receive every month.
Our gross revenue calculation considers the following factors:
All finalized invoices, whether related to subscriptions or usage;
Pay in advance fees, whether they are invoiceable or not;
Invoices related to prepaid credits from wallets;
One-off invoices; and
Deducting the credit note amounts refunded to customers.
To access the Gross Revenue analytics dashboard:
Navigate to the “Analytics” section; and
Access the “Gross Revenue” Dashboard.
Gross revenue dashboard
To access the Gross Revenue analytics dashboard:
Navigate to the “Analytics” section; and
Access the “Gross Revenue” Dashboard.
Gross revenue dashboard
LAGO_URL="https://api.getlago.com"API_KEY="__YOUR_API_KEY__"curl--location--request GET "$LAGO_URL/api/v1/analytics/gross_revenue?external_customer_id=hooli_1234¤cy=USD"\--header"Authorization: Bearer $API_KEY"\--header'Content-Type: application/json'\
The generated amounts are in cents, making it compatible with different currencies.
--- Start date of the query is the organization creation dateWITH organization_creation_date AS(SELECT DATE_TRUNC('month', o.created_at)AS start_monthFROM organizations oWHERE o.id ='__YOUR_ORGANIZATION_ID__'),--- Generate a number of date series in the future 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 value for all issued invoices issued_invoices AS(SELECT i.id, i.issuing_date, i.total_amount_cents::floatAS amount_cents, i.currency,COALESCE(SUM(refund_amount_cents::float),0)AS total_refund_amount_centsFROM invoices iLEFTJOIN customers c ON i.customer_id = c.idLEFTJOIN credit_notes cn ON cn.invoice_id = i.idWHERE i.organization_id ='__YOUR_ORGANIZATION_ID__'AND i.status=1---AND c.external_id = 'hooli_1234' --- FILTER BY CUSTOMERGROUPBY i.id, i.issuing_date, i.total_amount_cents, i.currencyORDERBY i.issuing_date ASC),--- Get value for all instant charges (paid in advance but not invoiceable) instant_charges AS(SELECT f.id, f.created_at AS issuing_date, f.amount_cents AS amount_cents, f.amount_currency AS currency,0AS total_refund_amount_centsFROM fees fLEFTJOIN subscriptions s ON f.subscription_id = s.idLEFTJOIN customers c ON c.id = s.customer_idWHERE c.organization_id ='__YOUR_ORGANIZATION_ID__'AND f.invoice_id ISNULLAND f.pay_in_advance ISTRUE---AND c.external_id = 'hooli_1234' --- FILTER BY CUSTOMER),--- Combine data to get total of gross revenue combined_data AS(SELECT DATE_TRUNC('month', issuing_date)ASmonth, currency,COALESCE(SUM(amount_cents),0)AS amount_cents,COALESCE(SUM(total_refund_amount_cents),0)AS total_refund_amount_centsFROM(SELECT*FROM issued_invoicesUNIONALLSELECT*FROM instant_charges)AS gross_revenueGROUPBYmonth, currency, total_refund_amount_cents)--- Get gross revenue month over monthSELECT am.month, cd.currency,SUM(cd.amount_cents - cd.total_refund_amount_cents)AS amount_centsFROM all_months amLEFTJOIN combined_data cd ON am.month= cd.monthWHERE am.month<= DATE_TRUNC('month',CURRENT_DATE)---AND am.month >= DATE_TRUNC('month', CURRENT_DATE - INTERVAL '11 months') --- LAST 12 MONTHSAND cd.amount_cents ISNOTNULL--- AND cd.currency = 'EUR'GROUPBY am.month, cd.currencyORDERBY am.month