@get-asset/react

Snapshot Card

Styled card showing the period's revenue and expense side by side with the resulting net profit and its change versus the prior period. The reporting range follows the AssetProvider's DatePicker-driven range — a month, quarter, or year compares against the one before it, and a custom range against the same number of days immediately before it. Pass dateFrom / dateTo to pin a fixed range instead.

Preview

Loading preview…

Required scopes

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

  • report:read
  • business:read

API reference

Root props

PropTypeDefaultDescription
dateFromCalendarDateStringInclusive start (YYYY-MM-DD) of a fixed reporting range. Setting it detaches the card from the provider's shared range entirely; must be paired with dateTo (one without the other throws). Use periodDateRange to derive the pair from a month, quarter, or year.
dateToCalendarDateStringInclusive end (YYYY-MM-DD) of a fixed reporting range. Must be paired with dateFrom. Omit both to follow the provider's DatePicker-driven range.
revenuenumberOverride fetched revenue. Skips the API call.
expensenumberOverride fetched expense.
previousNetProfitnumberOverride fetched prior-period net profit (used for the change tone).
state"loading" | "error" | "empty"Force a specific state for testing.
lockedbooleanGate the report for a viewer who isn't entitled to it. Activates the SDK's Locked state: the summary renders blurred and inert as a teaser behind a lock and the upgrade CTA. No live fetch runs while locked — the teaser shows built-in placeholder data (a `revenue`/`expense` override still wins).
upsell{ title?, description?, ctaLabel?, onUpgrade? }Customize the locked state's copy and action. `ctaLabel` and `onUpgrade` are the tenant's upgrade wording and handler; `title` / `description` default per report.
onViewDetails(ctx: { range, period, basis }) => voidCallback fired when the viewer asks to see more details (e.g. to navigate to the full report). Receives the card's resolved range, the exact period it represents (or null for a custom range) and the accounting basis, so the report can open on the same window the card shows.
basis"accrual" | "modified_cash"Report on a specific accounting basis. Omit to inherit the AssetProvider's basis, which itself falls back to the Business's country — Canadian Businesses report on Accrual, everyone else on Cash (see Accounting basis).
basisTogglebooleanShow the Cash/Accrual select in the card header. Off by default. Flipping it moves every component that inherits the provider's basis, so it can't leave a screen half cash and half accrual (see Accounting basis).
classNamestringForwarded to the outer card element.

States

Loading

Loading preview…

Success

Loading preview…

EmptyNo revenue or expenses recorded.

Loading preview…

Error

Loading preview…

View detailsPass `onViewDetails` to handle a request for more details (e.g. navigate to the full report). The callback receives the card's own range, period and basis — here it logs them to the console.

Loading preview…

LockedViewer isn't entitled to the report — a built-in placeholder teaser renders blurred behind the upgrade prompt. Pass `upsell` to customize the copy and wire `onUpgrade`.

Loading preview…

Accounting basis

AssetSnapshotCard reports on one of two accounting bases: Accrual (accrual on the wire), which counts invoices and bills when they are issued, or Cash (modified_cash), which counts them when the money moves. Cashflow components take no basis — cashflow is a cash concept.

The basis is resolved per component, first match winning:

  • the card's own basis prop;
  • the provider's basis — defaultBasis on AssetProvider, or whatever the toggle was last flipped to;
  • the Business's country — Canadian Businesses report on Accrual, everyone else on Cash.

Only the last step costs a request — a Business read, which is why every basis-aware component's scopes includes business:read — and it is serial: the card holds its own fetch until the Business answers. One request is shared across every basis-aware component on the screen, but pass defaultBasis on AssetProvider when you already know the basis and skip it entirely. If the lookup fails the card falls back to Cash and stays there — the Retry button re-runs the report, not the basis lookup.

basisToggle is off by default: no control renders in the header and the card reports on its resolved basis. Turn it on and flipping the control moves every basis-aware component under the provider with it, so the toggle can never leave a screen half cash and half accrual. A component pinned with its own basis prop is the exception — it keeps the basis you gave it and renders no toggle of its own, which is how you show both bases side by side on purpose.