@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:updatetransaction:readexternal_account:readjournal_entry:readjournal_entry:createchat:create
API reference
Root props
| Prop | Type | Default | Description |
|---|---|---|---|
limit | number | 10 | Maximum number of count-ranked groups to show. The component considers up to 50 groups from the API. |
accountIds | string[] | — | Only include transactions for these external account ids. |
groups | SimilarTransactionGroupOverride[] | — | Override the groups shown and skip fetching. Used by storybook/tests. |
state | "loading" | "error" | "empty" | — | Force a specific state for testing. |
showCurrency | boolean | — | Force 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[]) => void | — | Called after transactions are confirmed, with the confirmed ids. |
onContextSubmitted | (transactionId: string, message: string) => void | — | Called 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.
| Part | Description |
|---|---|
SimilarTransactions.Root | Owns 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.
| Part | Description |
|---|---|
SimilarTransactions.Success | State wrapper. Compose the group-size-ranked table inside. |
SimilarTransactions.GroupsdefaultOpen? | Iterates groups from largest to smallest and provides per-group context. Groups are collapsed by default. |
SimilarTransactions.GroupasChild? | Wrapper for one group. Adds data-open, data-confirmed, data-confirming, and data-reviewing. |
SimilarTransactions.GroupLabelasChild? | The group's display label, normally its most common member description. |
SimilarTransactions.GroupCategoryasChild? | The suggested category shared by the group. |
SimilarTransactions.GroupCountasChild?, format? | Number of transactions in the group. |
SimilarTransactions.GroupAmountasChild?, format? | Total absolute value of the group in the business's home currency. |
SimilarTransactions.GroupCurrencyasChild? | 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.GroupToggleasChild? | Toggles the group's member rows. Adds aria-expanded, data-open, and data-collapsed. |
SimilarTransactions.GroupConfirmasChild? | Button that confirms every pending member in the group. Disabled while the group is confirmed, confirming, or reviewing. |
SimilarTransactions.GroupProvideContextasChild? | The group's ✕ action. Opens one inline correction form for every member and is disabled while reviewing. |
SimilarTransactions.GroupContext | Renders children while the group's correction form is open. |
SimilarTransactions.GroupConfirmed | Renders children once every member in the group is confirmed. |
SimilarTransactions.GroupPending | Renders children while the group still needs review. |
SimilarTransactions.HasMore | Renders children only when the group has members beyond the lead row. |
SimilarTransactions.MoreCountasChild?, format? | Number of members beyond the lead (the "7" in "7 more like this"). |
SimilarTransactions.Primary | Provides the group's newest transaction as the lead-row context. |
SimilarTransactions.Rest | Iterates every member beyond the lead while the group is expanded; renders nothing while collapsed. |
SimilarTransactions.Members | Iterates every member, including the lead, while the group is expanded; useful for a grouped layout. |
SimilarTransactions.RowasChild? | Per-transaction wrapper. Adds data-direction, data-confirmed, data-confirming, and data-reviewing. |
SimilarTransactions.DateasChild?, format? | Posting date — shows "Apr 30"; sets dateTime and a full-date title (pair with <time> via asChild). Pass format(date) to override. |
SimilarTransactions.DescriptionasChild? | The transaction's description. |
SimilarTransactions.AccountasChild? | Name of the external account the transaction belongs to. |
SimilarTransactions.AmountasChild?, format? | Signed amount (negative for money out). Adds data-direction (inflow/outflow/unknown). |
SimilarTransactions.CurrencyasChild? | The ISO 4217 code the transaction's currency. Renders nothing at all unless the business holds money in more than one currency. |
SimilarTransactions.CategoryasChild? | The member transaction's suggested category. |
SimilarTransactions.ConfirmasChild? | Button that confirms only the current transaction. Disabled while confirmed, confirming, or reviewing. |
SimilarTransactions.ProvideContextasChild? | The member's ✕ action. Opens its inline correction form and is disabled while reviewing. |
SimilarTransactions.Context | Renders children while the member's correction form is open. |
SimilarTransactions.Confirmed | Renders children once the current transaction is confirmed. |
SimilarTransactions.Pending | Renders children while the current transaction still needs review. |
Loading
Renders while the initial fetch is in flight.
| Part | Description |
|---|---|
SimilarTransactions.Loading | State wrapper. Render a skeleton table inside. |
Empty
Renders when no similar-transaction groups are available.
| Part | Description |
|---|---|
SimilarTransactions.Empty | State 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.
| Part | Description |
|---|---|
SimilarTransactions.Done | State wrapper. Render the finished "All caught up" message inside. |
Error
Renders on a group, hydration, or external-accounts fetch error.
| Part | Description |
|---|---|
SimilarTransactions.Error | State wrapper. Compose the error UI inside. |
SimilarTransactions.ErrorMessageasChild?, format? | Renders the error message string. |
SimilarTransactions.RetryasChild? | Button that re-runs the group, hydration, and account fetches. |
Hooks
| Part | Description |
|---|---|
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>. |