order_payout
Firestore trigger — fires on every new document created in the orders_payout collection.
order_process writes a new orders_payout document.
What it does
If the newly created payout document haspayout_type set to any value other than "Manual", the function immediately writes a payment_reference object back to the same document:
| Field | Value |
|---|---|
payment_reference.amount | The payout amount from the document |
payment_reference.date | Firestore Timestamp.now() |
payment_reference.document | "" (empty, to be filled later) |
payment_reference.reference | "ref ref ref" (placeholder) |
date.updated | Firestore Timestamp.now() |
payout_type = "Manual" (the default for non-TMT-POS orders) are left for manual reconciliation and are not updated by this trigger.
Payout document shape
Theorders_payout collection stores documents with the following fields:
| Field | Type | Description |
|---|---|---|
amount | number | Payout amount in base currency |
amount_currency | string | "USD" or "VEF" |
amount_exchange | number | Amount in local currency equivalent |
amount_exchange_rate | number | Exchange rate applied |
client_id | string | Client account ID |
client_name | string | Client display name |
custody_account.id | string | Custody account ID |
custody_account.name | string | Custody account name |
custody_account.account_number | string | Bank account number |
date.created | Timestamp | Creation time |
date.payout | string | Payout execution time (filled on settlement) |
description | string | "Pago Costo Fijo" or "Pago Costo Variable" |
entity | string | "TMT" or "Cliente" |
event_id | string | Associated event ID |
event_name | string | Associated event name |
order_id | string | Parent order document ID |
payment_data | object | Raw payment gateway data |
payment_id | string | Payment method identifier |
payment_name | string | Payment method name |
payout_status | boolean | false = pending, true = paid |
payout_type | string | "Manual" or "Automatic" |
split_payout
Request body
Event document ID. Used both to filter
orders_payout rows and to load the event’s setup/financial document.Start datetime filter applied to
date_created in PostgreSQL.End datetime filter applied to
date_created in PostgreSQL.Response
USD totals
Total fixed cost (TMT) in USD across all statuses.
Total variable cost (TMT) in USD across all statuses.
Total variable cost (Client) in USD across all statuses.
Fixed cost (TMT) USD — paid only.
Variable cost (TMT) USD — paid only.
Variable cost (Client) USD — paid only.
Fixed cost (TMT) USD — pending only.
Variable cost (TMT) USD — pending only.
Variable cost (Client) USD — pending only.
VEF totals
Total fixed cost (TMT) in VEF across all statuses.
Total variable cost (TMT) in VEF across all statuses.
Total variable cost (Client) in VEF across all statuses.
Fixed cost (TMT) VEF — paid only.
Variable cost (TMT) VEF — paid only.
Variable cost (Client) VEF — paid only.
Fixed cost (TMT) VEF — pending only.
Variable cost (TMT) VEF — pending only.
Variable cost (Client) VEF — pending only.
Cost line items
Per-cost-item fixed cost allocations. Each item contains:
name, entity ("TMT"), percentage, amaount, amaount_pagado, amaount_nopagado, amaount_VEF, amaount_pagado_VEF, amaount_nopagado_VEF.Per-cost-item variable cost allocations. Each item contains:
name, entity ("TMT" or "Cliente"), percentage, amaount, amaount_pagado, amaount_nopagado, amaount_VEF, amaount_pagado_VEF, amaount_nopagado_VEF.