@get-asset/react

Expenses Card

Drop-in styled card for the period's expenses and the change versus the prior period. A decrease reads as a positive tone; an increase as negative. The reporting range defaults to the AssetProvider's shared range (driven by the DatePicker), and the comparison mirrors it — the previous month, quarter, or year for a period-shaped range, or the same number of days immediately before a custom one.

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. Detaches the card from the AssetProvider's shared range entirely — pass it together with dateTo; one without the other throws. Use periodDateRange to derive the pair from a month, quarter, or year. Omit both and the card follows the provider's range, which the DatePicker drives.
dateToCalendarDateStringInclusive end (YYYY-MM-DD) of the fixed reporting range. Must be paired with dateFrom. The prior-period comparison mirrors whatever range resolves — the previous month, quarter, or year for a period-shaped range, or the same number of days immediately before a custom one.
expensesnumberOverride fetched expenses. Skips the API call.
previousExpensesnumberOverride fetched prior-period expenses.
state"loading" | "error"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 metric 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 (an `expenses` 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…

SuccessYear-over-year decrease (positive tone).

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

AssetExpensesCard 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.