Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
3 tasks
mkurapov opened this issue Nov 26, 2024 · 0 comments
Open
3 tasks

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

mkurapov opened this issue Nov 26, 2024 · 0 comments

Comments

@mkurapov
Copy link
Contributor

mkurapov commented Nov 26, 2024

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

No branches or pull requests

1 participant