orders and orders_transactions PostgreSQL tables and from Firestore office documents.
All functions accept a JSON body with a top-level data key.
sold_by_office
Returns ticket sales and revenue grouped by office name. Queries the orders PostgreSQL table and aggregates ticket counts (via json_array_length(tickets::json)) and total revenue per office.
Request parameters
Filter results to a specific event.
Start date in
YYYY-MM-DD format. Matches records where date_created >= from.End date in
YYYY-MM-DD format. Matches records where date_created <= to.Example request
Response
One entry per office that recorded sales matching the filters.
Sum of
total_sales across all offices in the result.Sum of
total_amount across all offices in the result.Example response
total_sales in the per-office array is a ticket count, not a transaction count. One order may contain multiple tickets.offices_vs_offices_active
Counts how many offices are assigned to a specific event and breaks that count down into active and inactive offices. The function reads the offices Firestore collection and checks each office’s events subcollection for the given event_id.
Request parameters
The event to check. Each office’s
events subcollection is queried for a document with id == event_id.Example request
Response
Single-element array with the office count breakdown.
Example response
An office is counted toward this event only if a document exists in
offices/{officeId}/events with id == event_id. Offices not assigned to the event are excluded entirely.sold_by_usbs
Returns sales made through USB/offline devices, broken down by office and currency. Queries the orders_transactions PostgreSQL table, grouping by event_id, office_name, event_name, and amount_currency. Uses amount_exchange (the local-currency equivalent) rather than the base amount.
Request parameters
Filter to a specific event.
Start date in
YYYY-MM-DD format.End date in
YYYY-MM-DD format.Example request
Response
One entry per office/currency combination with USB sales.
Sum of all
total_amount values where amount_currency == "USD".Sum of all
total_amount values where amount_currency == "VEF".