@get-asset/sdk

Similar Transactions

Headless compound that fetches similar groups of unconfirmed transactions from GET /v0/business/{business_id}/categorization, ranked by how many look-alike transactions each group contains. It hydrates the members through the transactions list — splitting the ids filter into requests of at most 100 — and resolves their names through the external-accounts list. Each group's newest transaction is the lead row; the group count can be rendered beside it and a toggle expands its look-alike siblings. The lead row's ✓ confirms the whole group by patching its members to confirmed, while an expanded member's ✓ confirms only that transaction. The ✕ opens an inline “give a reason” form. A business_pending transaction's note goes to its both-basis journal entry and the transaction is handed back to the bookkeeper; anything else creates one categorization-agent chat and one message covering every agent-routed member in the submission. Affected rows read as reviewing with their actions disabled until the flow finishes, then both the transactions cache and group list are invalidated so groups re-rank. Confirms deliberately leave the group list alone and remove rows locally, so the list is never pulled out from under the user mid-session — only clearing the whole batch refetches it for the next one. Once the server has nothing left, the fifth, Done (“All caught up”) state persists.

Anatomy

Import the primitive and compose the parts you need.

<SimilarTransactions.Root>
<SimilarTransactions.Success>
<SimilarTransactions.Groups>
<SimilarTransactions.Group>
<SimilarTransactions.GroupPending>
<SimilarTransactions.Primary>
<SimilarTransactions.Row>
<SimilarTransactions.Date />
<SimilarTransactions.GroupLabel />
<SimilarTransactions.GroupCount />
<SimilarTransactions.Account />
<SimilarTransactions.Amount />
<SimilarTransactions.Currency />
<SimilarTransactions.GroupConfirm />
<SimilarTransactions.GroupProvideContext />
</SimilarTransactions.Row>
</SimilarTransactions.Primary>
<SimilarTransactions.GroupContext>
{/* inline "give a reason" form */}
</SimilarTransactions.GroupContext>
<SimilarTransactions.HasMore>
<SimilarTransactions.GroupToggle>
<SimilarTransactions.MoreCount /> more like this
</SimilarTransactions.GroupToggle>
</SimilarTransactions.HasMore>
<SimilarTransactions.Rest>
<SimilarTransactions.Pending>
<SimilarTransactions.Row>
<SimilarTransactions.Date />
<SimilarTransactions.Description />
<SimilarTransactions.Account />
<SimilarTransactions.Amount />
<SimilarTransactions.Currency />
<SimilarTransactions.Category />
<SimilarTransactions.Confirm />
<SimilarTransactions.ProvideContext />
</SimilarTransactions.Row>
<SimilarTransactions.Context>
{/* inline "give a reason" form */}
</SimilarTransactions.Context>
</SimilarTransactions.Pending>
</SimilarTransactions.Rest>
</SimilarTransactions.GroupPending>
</SimilarTransactions.Group>
</SimilarTransactions.Groups>
</SimilarTransactions.Success>
<SimilarTransactions.Loading>{/* skeleton table */}</SimilarTransactions.Loading>
<SimilarTransactions.Error>
<SimilarTransactions.ErrorMessage />
<SimilarTransactions.Retry>Try again</SimilarTransactions.Retry>
</SimilarTransactions.Error>
<SimilarTransactions.Empty>{/* nothing to review */}</SimilarTransactions.Empty>
<SimilarTransactions.Done>{/* all caught up */}</SimilarTransactions.Done>
</SimilarTransactions.Root>

Required scopes

The access token used by AssetProvider must include these scopes for this primitive to fetch data successfully:

  • transaction:update
  • transaction:read
  • external_account:read
  • journal_entry:read
  • journal_entry:create
  • chat:create

API reference

Root props

PropTypeDefaultDescription
limitnumber10Maximum number of count-ranked groups to show. The component considers up to 50 groups from the API.
accountIdsstring[]Only include transactions for these external account ids.
groupsSimilarTransactionGroupOverride[]Override the groups shown and skip fetching. Used by storybook/tests.
state"loading" | "error" | "empty"Force a specific state for testing.
showCurrencybooleanForce the ISO code beside each amount on or off, skipping the business fetch (storybook/tests). By default it shows only for a business that holds money in more than one currency.
onConfirmed(transactionIds: string[]) => voidCalled after transactions are confirmed, with the confirmed ids.
onContextSubmitted(transactionId: string, message: string) => voidCalled after a correction's review flow has run, with the transaction id and submitted message.

Parts

Container

Always rendered. Fetches similar groups, transaction members and external accounts, then provides the shared state and actions.

PartDescription
SimilarTransactions.RootOwns fetching, group-size ranking, confirm and correction flows, local completion state, and the inline-form state.

Success

Renders while at least one group still needs review.

PartDescription
SimilarTransactions.SuccessState wrapper. Compose the group-size-ranked table inside.
SimilarTransactions.Groups
defaultOpen?
Iterates groups from largest to smallest and provides per-group context. Groups are collapsed by default.
SimilarTransactions.Group
asChild?
Wrapper for one group. Adds data-open, data-confirmed, data-confirming, and data-reviewing.
SimilarTransactions.GroupLabel
asChild?
The group's display label, normally its most common member description.
SimilarTransactions.GroupCategory
asChild?
The suggested category shared by the group.
SimilarTransactions.GroupCount
asChild?, format?
Number of transactions in the group.
SimilarTransactions.GroupAmount
asChild?, format?
Total absolute value of the group in the business's home currency.
SimilarTransactions.GroupCurrency
asChild?
The ISO 4217 code of the business's home currency. Renders nothing at all unless the business holds money in more than one currency.
SimilarTransactions.GroupToggle
asChild?
Toggles the group's member rows. Adds aria-expanded, data-open, and data-collapsed.
SimilarTransactions.GroupConfirm
asChild?
Button that confirms every pending member in the group. Disabled while the group is confirmed, confirming, or reviewing.
SimilarTransactions.GroupProvideContext
asChild?
The group's ✕ action. Opens one inline correction form for every member and is disabled while reviewing.
SimilarTransactions.GroupContextRenders children while the group's correction form is open.
SimilarTransactions.GroupConfirmedRenders children once every member in the group is confirmed.
SimilarTransactions.GroupPendingRenders children while the group still needs review.
SimilarTransactions.HasMoreRenders children only when the group has members beyond the lead row.
SimilarTransactions.MoreCount
asChild?, format?
Number of members beyond the lead (the "7" in "7 more like this").
SimilarTransactions.PrimaryProvides the group's newest transaction as the lead-row context.
SimilarTransactions.RestIterates every member beyond the lead while the group is expanded; renders nothing while collapsed.
SimilarTransactions.MembersIterates every member, including the lead, while the group is expanded; useful for a grouped layout.
SimilarTransactions.Row
asChild?
Per-transaction wrapper. Adds data-direction, data-confirmed, data-confirming, and data-reviewing.
SimilarTransactions.Date
asChild?, format?
Posting date — shows "Apr 30"; sets dateTime and a full-date title (pair with <time> via asChild). Pass format(date) to override.
SimilarTransactions.Description
asChild?
The transaction's description.
SimilarTransactions.Account
asChild?
Name of the external account the transaction belongs to.
SimilarTransactions.Amount
asChild?, format?
Signed amount (negative for money out). Adds data-direction (inflow/outflow/unknown).
SimilarTransactions.Currency
asChild?
The ISO 4217 code the transaction's currency. Renders nothing at all unless the business holds money in more than one currency.
SimilarTransactions.Category
asChild?
The member transaction's suggested category.
SimilarTransactions.Confirm
asChild?
Button that confirms only the current transaction. Disabled while confirmed, confirming, or reviewing.
SimilarTransactions.ProvideContext
asChild?
The member's ✕ action. Opens its inline correction form and is disabled while reviewing.
SimilarTransactions.ContextRenders children while the member's correction form is open.
SimilarTransactions.ConfirmedRenders children once the current transaction is confirmed.
SimilarTransactions.PendingRenders children while the current transaction still needs review.

Loading

Renders while the initial fetch is in flight.

PartDescription
SimilarTransactions.LoadingState wrapper. Render a skeleton table inside.

Empty

Renders when no similar-transaction groups are available.

PartDescription
SimilarTransactions.EmptyState wrapper. Render the empty all-caught-up message inside.

Done

Renders once every fetched group is confirmed; the list then refetches for the next batch, and the done state persists only when nothing is left.

PartDescription
SimilarTransactions.DoneState wrapper. Render the finished "All caught up" message inside.

Error

Renders on a group, hydration, or external-accounts fetch error.

PartDescription
SimilarTransactions.ErrorState wrapper. Compose the error UI inside.
SimilarTransactions.ErrorMessage
asChild?, format?
Renders the error message string.
SimilarTransactions.Retry
asChild?
Button that re-runs the group, hydration, and account fetches.

Hooks

PartDescription
useSimilarTransactions()Hook returning the full root context: ranked groups, loading/error/completion state, confirm state, correction state, and the confirm/context actions.
useSimilarTransactionsGroup()Hook returning the current group and its open/toggle state inside <Groups>.
useSimilarTransaction()Hook returning the current transaction inside <Primary>, <Rest>, or <Members>.