Workflow
Load TMT transactions
Call
conciliation_transaction_load_tmt or for_conciliation to populate conc_conciliado_c with platform-side transaction records from orders_transactions.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.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.Review non-reconciled records
Use
noconciliation_data_cia and noconciliation_data_b to retrieve records that did not match automatically.conciliation_process
Runs the core matching algorithm. Reads all records fromconc_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.| Document type | Match 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) |
conciliation_transaction_load_tmt
Loads unprocessed TMT transactions intoconc_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.conciliation_data_banco
Retrieves bank-side records fromconc_conciliado_b for a given custody account, optionally filtered by date range.
The bank account number (
no_cta) to filter records by. This is the primary filter; from/to narrow the result further.Start date filter applied to the
fecha column. ISO 8601 date string (e.g., "2024-01-01").End date filter applied to the
fecha column. ISO 8601 date string.true when at least one record was found, false otherwise.Array of records from
conc_conciliado_b. Present only when valido is true.conciliation_data_cia
Retrieves company/platform-side records fromconc_conciliado_c for a given custody account, optionally filtered by date range.
The custody account number (
no_cta) to filter by.Start date filter on the
fecha column.End date filter on the
fecha column.noconciliation_data_cia
Retrieves company-side records that were not matched during the last reconciliation run. These records exist inconc_noconciliado_c.
The custody account number (
no_cta) to filter by.Start date filter on the
fecha column.End date filter on the
fecha column.noconciliation_data_b
Retrieves bank-side records that were not matched during the last reconciliation run. These records exist inconc_noconciliado_b.
conciliation_data
Retrieves matched/reconciled records fromconc_conciliacion for a given custody account, optionally filtered by registration date range. This table contains records that have already been paired successfully.
The custody account number (
no_cta) to filter by.Start date filter applied to the
fecha_reg (registration date) column.End date filter applied to the
fecha_reg column.conciliation_load_cia_manual
Manually inserts a single company-side record intoconc_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.
Custody account number.
Document type. Use
NC for credit notes or ND for debit notes.Document/reference number. This value is also used as both
no_fisico and serie_fisico.Transaction date. ISO 8601 date string.
Transaction amount.
Firestore event document ID.
Human-readable event name.
conciliation_load_bank_manual
Manually inserts a single bank-side record intoconc_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.
Bank account number.
Document type. Use
NC for credit notes or ND for debit notes.Document/reference number from the bank statement. Used as both
no_fisico and serie_fisico.Transaction date from the bank statement. ISO 8601 date string.
Transaction amount as reported by the bank.
conciliation_ajustes
Manually reconciles a CIA document against one or more bank documents when automatic matching failed. Inserts the pairs intoconc_conciliacion and removes them from conc_noconciliado_c and conc_noconciliado_b.
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.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.for_conciliation
Marks an individual platform transaction as ready for reconciliation by inserting it directly intoconc_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.
The payout record associated with this transaction. Stored as a JSON blob in
conc_conciliado_c.order_payout.The transaction record. The following fields are extracted:
custody_account.account_number→no_ctapayment_data.reference_number→no_docu,no_fisico,serie_fisicodate.created→fechaamount_exchange→montoamount_exchange_rate→tipo_cambio