Skip to main content
TMT Platform tracks the official Banco Central de Venezuela (BCV) exchange rate in Firestore at data/exchange_rates. This rate is used throughout the platform for multi-currency order amounts, transaction records, and billing calculations.

Rate document structure

The data/exchange_rates Firestore document contains:
{
  "last_update_type": "automatico",
  "rates": {
    "bs": 1,
    "usd": 48.50,
    "eur": 52.30
  },
  "date": {
    "last_update": "<Firestore Timestamp>"
  }
}
A history of all rate updates is stored in the subcollection data/exchange_rates/history.

exchange_rates (automatic)

Scrapes the current USD and EUR exchange rates from the BCV website (http://www.bcv.org.ve) and stores them in Firestore.

Endpoint

POST https://{region}-{project}.cloudfunctions.net/exchange_rates

Request

{}
No body required. The function fetches rates directly from BCV.

What it does

  1. Fetches and parses the BCV website HTML
  2. Extracts USD and EUR rates from the page content
  3. Sets bs: 1 as the bolivar baseline
  4. Writes to data/exchange_rates (overwrites current rate)
  5. Appends a history entry to data/exchange_rates/history with last_update_type: "automatico"

Response

{ "result": "Actualizado . Ingresado " }
This function uses @extractus/article-extractor to parse the BCV site and disables TLS certificate validation (NODE_TLS_REJECT_UNAUTHORIZED=0) for compatibility with the BCV server. Schedule this function via Cloud Scheduler to run daily.

exchange_rates_manual

Manually sets the USD and EUR exchange rates in Firestore. Use this when the BCV site is unavailable or rates need to be overridden.

Endpoint

POST https://{region}-{project}.cloudfunctions.net/exchange_rates_manual

Request

This function reads from req.body.params (not req.body.data) — the request body uses a params key at the top level.
params.usd
number
required
USD to bolivar exchange rate (bolivares per 1 USD).
params.eur
number
required
EUR to bolivar exchange rate (bolivares per 1 EUR).
{
  "params": {
    "usd": 48.50,
    "eur": 52.30
  }
}

What it does

  1. Sets bs: 1, and uses the provided usd and eur values
  2. Writes to data/exchange_rates with last_update_type: "manual"
  3. Appends a history entry to data/exchange_rates/history

Response

{
  "result": "act con el ID: undefined . Ingresado con el ID: <history_doc_id> ."
}
Schedule exchange_rates to run automatically each morning. Use exchange_rates_manual when the BCV website is down or rates are delayed.

Usage in the platform

All order transactions reference the current exchange rate at the time of purchase:
{
  "amount_exchange_rate": 48.50,
  "amount_currency": "USD",
  "amount_exchange": 3637.50
}
The billing module also reads data/exchange_rates to calculate IVA and IGTF taxes in bolivar-equivalent amounts.

Build docs developers (and LLMs) love