order_process
Firestore trigger — fires on every new document created in the orders collection.
order_created writes a new document.
What it does
- Reads the new order document from the
orders/{id}path. - If
data.statusistrue, iterates each transaction and builds aTransactionDataobject. - For each ticket where
statusisfalse, updates the corresponding ticket document insideevents/{event_id}/tickets/{ticket_id}with attendee fields:customer_email,customer_id,customer_name,customer_phone,customer_address,customer_country, anddate.updated. - Batch-updates those same fields in the PostgreSQL
ticketstable. - Calls the
order_usercallable function to create or link the end-user account. - Reads
events/{event_id}/setup/financialto determine fixed and variable cost splits, then writes one or moreorders_payoutdocuments per transaction. - Calls
transactions_generateto finalize the transaction records. - If
point_sale_tmtistrueon a transaction, routes tofor_conciliationinstead of creating payout records directly.
Payout split logic
| Condition | Payout created |
|---|---|
| Fixed cost balance not fully collected | Pago Costo Fijo entry for TMT |
| Variable cost percentage > 0 | Pago Costo Variable entry for TMT |
| Variable cost percentage > 0 | Pago Costo Variable entry for Cliente |
order_update
This function is an internal alias used within the order pipeline. It does not expose an independent HTTP endpoint.
order_user
u_users Firestore document for the ticket purchaser if one does not already exist, then attaches the order to the user’s orders subcollection.
Request body
Attendee email. Used to look up existing user accounts.
Attendee full name.
Attendee national ID (cédula).
Attendee phone number.
Attendee address. Defaults to
"".Country object
{ code, name, key }. Defaults to { code: "ve", name: "Venezuela", key: 0 }.ID document type prefix. Defaults to
"V".The Firestore order document ID to attach to the user.
The full order data object written to the user’s
orders subcollection.What it does
- Queries
u_userswhereemail == customer_email. - New user: creates a Firebase Auth account with a random password, writes a
u_users/{uid}document, attaches the order tou_users/{uid}/orders/{order_id}, and stores the generated password inu_users/{uid}/security. - Existing user: attaches the order to the existing user’s
orderssubcollection.
Response
"procesado "200 on success, 400 if user creation fails.true when the operation succeeded.Example
invoice_payout_status
payout_status = true) for a given event and date range, by currency.
Request body
Filter payouts by event.
Start date filter (
date_created >= from). ISO 8601 date string.End date filter (
date_created <= to). ISO 8601 date string.If
true, marks all VEF-currency payout records as paid.If
true, marks all USD-currency payout records as paid.The bank transfer or payment reference number to record against each updated row.
Example
process_order_billing
order_process. It resolves the purchaser’s full profile from u_users, fetches client data from u_clients, generates a sequential invoice number, and calls the billing core.
Request body
Firestore order document ID.
Full order data object (same shape as the
orders Firestore document).Event document ID.
Event display name.
Box office document ID.
Box office display name.
VEF/USD exchange rate to use for invoice line items.
What it does
- Resolves the purchaser’s full profile by looking up
order_data.purchaser_info.emailinu_users. - Fetches client (tercero) details from
u_clients/{client_id}. - Calls
getNextInvoiceNumber()for a sequential, unique invoice number. - Calls
generateBillingDataFromOrder()and thenemitirFacturaCore(). - On success, updates the
orders/{order_id}document withbilling_info: { billed: true, billing_date, billing_result }.
Response
"Facturación completada exitosamente" on success, "Error en facturación" on billing failure.200 on success, 400 on billing error, 500 on critical error.true when billing succeeded.The order ID that was billed.
The raw billing result object returned by the billing core.
Example
split_queries
Request body
Event document ID. Used to filter payouts and to load the event’s financial setup.
Start datetime filter (
date_created >= from).End datetime filter (
date_created <= to).Response
Total fixed cost collected by TMT (USD).
Total variable cost collected by TMT (USD).
Total variable cost allocated to the Client (USD).
Array of fixed cost line items from the event’s financial setup, each with:
name, amaount, entity, percentage.Array of variable cost line items, each with:
name, amaount, entity, percentage.