Skip to content

Make AccountingTransfers API have the same behaviour for TB & PSQL #3134

@mkurapov

Description

@mkurapov

Context

Two-phase transfers in TigerBeetle are done by first creating a "pending" transfer, then a new, subsequent void-ing or post-ing transfer. This is different than what we do in the PSQL accounting, where we just update the state of the original PENDING transfer to either POSTED or VOIDED.

While this does not cause any differences functionally, this difference is visible in our AccountingTransfers Admin API: whenever we are looking up transfers for an account (e.g. outgoing payment) with TB as the ledger, we will get two transfers (one PENDING and one POSTED or VOIDED), but if we do the same query with PSQL as the ledger, we will just see a single POSTED transfer. (We actually filter out VOIDED transfers in our PSQL query).

We should standardize the behaviour of this query, so you get back the same results no matter which accounting ledger is used.

This requires a few changes:

Todos

  • In TigerBeetle account lookup, filter out initial PENDING transfers if a transfer was voided or posted by a corresponding transfer. (You can use pending_id flag to find transfers which POSTED or VOIDED the initial transfer)
  • Show VOIDED and EXPIRED transfers in PSQL accounting by updating the filter in transfer query in PSQL's getAccountTransfers
  • Add EXPIRED enum value to the LedgerTransferState in backend/src/accounting/service.ts, do the correct mapping to this enum for TB & PSQL transfers (EXPIRED transfers are pending transfers with an expiry date in the past)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions