Skip to main content
The reconciliation process involves loading transaction data from both the TMT platform and the bank, running the matching algorithm, and handling records that could not be matched automatically.

Workflow

1

Load TMT transactions

Call conciliation_transaction_load_tmt or for_conciliation to populate conc_conciliado_c with platform-side transaction records from orders_transactions.
2

Load bank records

Import bank statement entries into conc_conciliado_b. Use conciliation_load_bank_manual for individual entries when automated import is not available.
3

Run the matching engine

Call conciliation_process. It reads all unprocessed records from both tables (procesado = false), compares no_docu (last 8 characters), tipo_doc, and monto, then writes matched pairs to conc_conciliacion and unmatched records to conc_noconciliado_c / conc_noconciliado_b.
4

Review non-reconciled records

Use noconciliation_data_cia and noconciliation_data_b to retrieve records that did not match automatically.
5

Apply adjustments

Use conciliation_ajustes to manually pair a non-reconciled CIA record with one or more bank records, forcing them into conc_conciliacion.

conciliation_process

Runs the core matching algorithm. Reads all records from conc_conciliado_c and conc_conciliado_b where procesado = false, attempts to match them by document number and amount, and distributes matched records to the appropriate output tables. When a NC (credit note) match is found, the function also calculates payout distributions and creates orders_payout entries in Firestore and PostgreSQL.
This function does not currently accept from/to date parameters via the request body — the date filter variables are declared but set to null at runtime. The effective filter is procesado = false.
Matching rules:
Document typeMatch condition
NC (credit note)Last 8 chars of no_docu match and compara_c.monto.toFixed(2) == compara_b.monto
ND (debit note)Last 8 chars of no_docu match and compara_c.monto == compara_b.monto (exact)
POST /conciliation_process
{}
Response
{
  "message": "Conciliacion Procesada ",
  "status": 200,
  "data": {
    "message": "Conciliacion Procesada "
  }
}

conciliation_transaction_load_tmt

Loads unprocessed TMT transactions into conc_conciliado_c for reconciliation. Reads from orders_transactions where payment_data->>'reference_number' is not null and inserts records with procedencia = 'W' (wire/automated source).
Like conciliation_process, the from/to date parameters are declared but currently default to null. All transactions with a reference_number are loaded.
POST /conciliation_transaction_load_tmt
{}
Response
{
  "message": "Carga data Conciliacion TMT Procesada ",
  "status": 200,
  "data": {
    "message": "Carga data Conciliacion TMT Procesada"
  }
}

conciliation_data_banco

Retrieves bank-side records from conc_conciliado_b for a given custody account, optionally filtered by date range.
POST /conciliation_data_banco
Request
{
  "data": {
    "num_cta": "001-123456-78",
    "from": "2024-01-01",
    "to": "2024-01-31"
  }
}
data.num_cta
string
required
The bank account number (no_cta) to filter records by. This is the primary filter; from/to narrow the result further.
data.from
string
Start date filter applied to the fecha column. ISO 8601 date string (e.g., "2024-01-01").
data.to
string
End date filter applied to the fecha column. ISO 8601 date string.
Response — records found
{
  "message": "Conciliacion Encontrada",
  "status": 200,
  "data": {
    "valido": true,
    "response": [
      {
        "id": 42,
        "no_cia": "1",
        "no_cta": "001-123456-78",
        "procedencia": "W",
        "tipo_doc": "NC",
        "no_docu": "REF00012345",
        "fecha": "2024-01-15T00:00:00.000Z",
        "monto": 150.00,
        "no_fisico": "REF00012345",
        "serie_fisico": "REF00012345",
        "procesado": false
      }
    ]
  }
}
Response — no records
{
  "message": "Conciliacion no Encontrada",
  "status": 400,
  "data": { "valido": false }
}
data.valido
boolean
true when at least one record was found, false otherwise.
data.response
array
Array of records from conc_conciliado_b. Present only when valido is true.

conciliation_data_cia

Retrieves company/platform-side records from conc_conciliado_c for a given custody account, optionally filtered by date range.
POST /conciliation_data_cia
Request
{
  "data": {
    "num_cta": "001-123456-78",
    "from": "2024-01-01",
    "to": "2024-01-31"
  }
}
data.num_cta
string
required
The custody account number (no_cta) to filter by.
data.from
string
Start date filter on the fecha column.
data.to
string
End date filter on the fecha column.
Response — records found
{
  "message": "Conciliacion Encontrada",
  "status": 200,
  "data": {
    "valido": true,
    "response": [
      {
        "id": 18,
        "no_cia": "1",
        "no_cta": "001-123456-78",
        "procedencia": "W",
        "tipo_doc": "NC",
        "no_docu": "REF00012345",
        "fecha": "2024-01-15T00:00:00.000Z",
        "monto": 150.00,
        "no_fisico": "REF00012345",
        "serie_fisico": "REF00012345",
        "tipo_cambio": 1.0,
        "event_id": "evt_abc123",
        "event_name": "Festival 2024",
        "procesado": false
      }
    ]
  }
}
Response — no records
{
  "message": "Conciliacion no Encontrada",
  "status": 400,
  "data": { "valido": false }
}

noconciliation_data_cia

Retrieves company-side records that were not matched during the last reconciliation run. These records exist in conc_noconciliado_c.
POST /noconciliation_data_cia
Request
{
  "data": {
    "num_cta": "001-123456-78",
    "from": "2024-01-01",
    "to": "2024-01-31"
  }
}
data.num_cta
string
required
The custody account number (no_cta) to filter by.
data.from
string
Start date filter on the fecha column.
data.to
string
End date filter on the fecha column.
Response — records found
{
  "message": "Consulta Encontrada",
  "status": 200,
  "data": {
    "valido": true,
    "response": [
      {
        "no_cia": "1",
        "no_cta": "001-123456-78",
        "procedencia": "W",
        "tipo_doc": "NC",
        "no_docu": "REF00099999",
        "beneficiario": "",
        "monto": 75.00,
        "mensaje": "",
        "monto_bco": 0,
        "difere": 0,
        "no_fisico": "REF00099999",
        "serie_fisico": "REF00099999",
        "fecha_reg": "2024-01-20T00:00:00.000Z",
        "order_payout": {},
        "transaction": {},
        "fecha": "2024-01-20T00:00:00.000Z"
      }
    ]
  }
}
Response — no records
{
  "message": "Sin Datos",
  "status": 400,
  "data": { "valido": false }
}

noconciliation_data_b

Retrieves bank-side records that were not matched during the last reconciliation run. These records exist in conc_noconciliado_b.
This endpoint currently ignores from, to, and num_cta request parameters — those variables are hardcoded to null/'-' in the current implementation. All records in conc_noconciliado_b for the default account are returned.
POST /noconciliation_data_b
{}
Response — records found
{
  "message": "Consulta Encontrada",
  "status": 200,
  "data": {
    "valido": true,
    "response": [
      {
        "no_cia": "1",
        "no_cta": "-",
        "procedencia": "W",
        "tipo_doc": "NC",
        "no_docu": "BANKREF88888",
        "beneficiario": "",
        "monto": 200.00,
        "mensaje": "",
        "monto_bco": 0,
        "difere": 0,
        "no_fisico": "BANKREF88888",
        "serie_fisico": "BANKREF88888",
        "fecha_reg": "2024-01-22T00:00:00.000Z",
        "fecha": "2024-01-22T00:00:00.000Z"
      }
    ]
  }
}
Response — no records
{
  "message": "Sin Datos",
  "status": 400,
  "data": { "valido": false }
}

conciliation_data

Retrieves matched/reconciled records from conc_conciliacion for a given custody account, optionally filtered by registration date range. This table contains records that have already been paired successfully.
POST /conciliation_data
Request
{
  "data": {
    "num_cta": "001-123456-78",
    "from": "2024-01-01",
    "to": "2024-01-31"
  }
}
data.num_cta
string
required
The custody account number (no_cta) to filter by.
data.from
string
Start date filter applied to the fecha_reg (registration date) column.
data.to
string
End date filter applied to the fecha_reg column.
Response — records found
{
  "message": "Consulta Encontrada",
  "status": 200,
  "data": {
    "valido": true,
    "response": [
      {
        "no_cia": "1",
        "no_cta": "001-123456-78",
        "proce": "W",
        "tipo_doc": "NC",
        "no_docu": "REF00012345",
        "no_fisico": "REF00012345",
        "serie_fisico": "REF00012345",
        "monto": 150.00,
        "ano": "2024",
        "mes": "01",
        "no_fisico_b": "REF00012345",
        "serie_fisico_b": "REF00012345",
        "monto_b": 150.00,
        "procedencia_b": "W",
        "tipo_doc_b": "NC",
        "no_docu_b": "REF00012345",
        "fecha_reg": "2024-01-15T12:00:00.000Z"
      }
    ]
  }
}
Response — no records
{
  "message": "Sin Datos",
  "status": 400,
  "data": { "valido": false }
}

conciliation_load_cia_manual

Manually inserts a single company-side record into conc_noconciliado_c for reconciliation. The record is stored with procedencia = 'M' (manual entry). Use this when a transaction exists on the platform but was not captured automatically.
POST /conciliation_load_cia_manual
Request
{
  "data": {
    "no_cta": "001-123456-78",
    "tipo_doc": "NC",
    "no_docu": "REF00077777",
    "fecha": "2024-01-18",
    "monto": 300.00,
    "event_id": "evt_abc123",
    "event_name": "Festival 2024"
  }
}
data.no_cta
string
required
Custody account number.
data.tipo_doc
string
required
Document type. Use NC for credit notes or ND for debit notes.
data.no_docu
string
required
Document/reference number. This value is also used as both no_fisico and serie_fisico.
data.fecha
string
required
Transaction date. ISO 8601 date string.
data.monto
number
required
Transaction amount.
data.event_id
string
required
Firestore event document ID.
data.event_name
string
required
Human-readable event name.
Response
{
  "message": "Carga data Conciliacion manual TMT Procesada ",
  "status": 200,
  "data": {
    "message": "Carga data Conciliacion manual TMT Procesada"
  }
}

conciliation_load_bank_manual

Manually inserts a single bank-side record into conc_noconciliado_b for reconciliation. The record is stored with procedencia = 'M' (manual entry). Use this when a bank statement entry needs to be added individually.
POST /conciliation_load_bank_manual
Request
{
  "data": {
    "no_cta": "001-123456-78",
    "tipo_doc": "NC",
    "no_docu": "BANKREF00055",
    "fecha": "2024-01-18",
    "monto": 300.00
  }
}
data.no_cta
string
required
Bank account number.
data.tipo_doc
string
required
Document type. Use NC for credit notes or ND for debit notes.
data.no_docu
string
required
Document/reference number from the bank statement. Used as both no_fisico and serie_fisico.
data.fecha
string
required
Transaction date from the bank statement. ISO 8601 date string.
data.monto
number
required
Transaction amount as reported by the bank.
Response
{
  "message": "Carga data Conciliacion manual Banco Procesada ",
  "status": 200,
  "data": {
    "message": "Carga data Conciliacion manual Banco Procesada"
  }
}

conciliation_ajustes

Manually reconciles a CIA document against one or more bank documents when automatic matching failed. Inserts the pairs into conc_conciliacion and removes them from conc_noconciliado_c and conc_noconciliado_b.
Use this endpoint after reviewing non-reconciled records from noconciliation_data_cia and noconciliation_data_b. Select the CIA document and the matching bank rows, then submit them as the adjustment payload.
POST /conciliation_ajustes
Request
{
  "data": {
    "datos_ajustes": {
      "selected_document": {
        "no_cia": "1",
        "no_cta": "001-123456-78",
        "procedencia": "W",
        "tipo_doc": "NC",
        "no_docu": "REF00099999",
        "no_fisico": "REF00099999",
        "serie_fisico": "REF00099999",
        "monto": 75.00
      },
      "selected_rows": [
        {
          "no_docu": "BANKREF77777",
          "no_fisico": "BANKREF77777",
          "serie_fisico": "BANKREF77777",
          "monto": 75.00,
          "procedencia": "W",
          "tipo_doc": "NC"
        }
      ]
    }
  }
}
data.datos_ajustes.selected_document
object
required
The CIA-side non-reconciled document to match. Must include no_cia, no_cta, procedencia, tipo_doc, no_docu, no_fisico, serie_fisico, and monto.
data.datos_ajustes.selected_rows
array
required
Array of bank-side documents to pair with selected_document. Each entry must include no_docu, no_fisico, serie_fisico, monto, procedencia, and tipo_doc.
Response
{
  "message": "Ajustes Procesados ",
  "status": 200,
  "data": {
    "message": "Ajustes Procesados "
  }
}

for_conciliation

Marks an individual platform transaction as ready for reconciliation by inserting it directly into conc_conciliado_c. Unlike conciliation_transaction_load_tmt (which does a bulk load), this endpoint processes one transaction at a time and accepts both the order_payout and transaction objects directly.
This is typically called when a specific payout transaction has been confirmed and should enter the reconciliation queue immediately, rather than waiting for the next bulk load.
POST /for_conciliation
Request
{
  "data": {
    "order_payout": {
      "event_id": "evt_abc123",
      "event_name": "Festival 2024",
      "order_id": "order_xyz789",
      "payment_id": "pay_001",
      "payment_name": "Stripe",
      "client_id": "client_001",
      "client_name": "Acme Corp",
      "amount_exchange": 150.00,
      "amount_currency": "USD",
      "amount_exchange_rate": 1.0,
      "payment_data": {}
    },
    "transaction": {
      "custody_account": {
        "account_number": "001-123456-78",
        "id": "cust_001",
        "name": "Main Account"
      },
      "payment_data": {
        "reference_number": "REF00012345"
      },
      "date": {
        "created": "2024-01-15T10:00:00.000Z"
      },
      "amount_exchange": 150.00,
      "amount_exchange_rate": 1.0
    }
  }
}
data.order_payout
object
required
The payout record associated with this transaction. Stored as a JSON blob in conc_conciliado_c.order_payout.
data.transaction
object
required
The transaction record. The following fields are extracted:
  • custody_account.account_numberno_cta
  • payment_data.reference_numberno_docu, no_fisico, serie_fisico
  • date.createdfecha
  • amount_exchangemonto
  • amount_exchange_ratetipo_cambio
Response
{
  "message": "Carga data Conciliacion TMT Procesada ",
  "status": 200,
  "data": {
    "message": "Carga data Conciliacion TMT Procesada"
  }
}

Build docs developers (and LLMs) love