@get-asset/react

Operating Expenses Card

Styled card showing the largest expense categories for a period with proportional bars and amounts. The reporting range defaults to the AssetProvider's shared range, which the DatePicker drives. Pass insights(shown in the preview) to render the AI insights panel to the left of the categories — it answers the listed questions from the profit & loss insights endpoint automatically, for the range on screen.

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. Categories — and the insights panel — are scoped to whatever range resolves.
limitnumber5Max number of categories to display.
categoriesOperatingExpenseCategoryOverride[]Override fetched data. Each entry: { name, amount }. Skips the API call.
state"loading" | "error" | "empty"Force a specific state for testing.
insightsboolean | { questions?, ask? }Show the AI insights panel to the left of the categories (12-col grid: insights 4, categories 8). Pass `true` and it fetches answers from the profit & loss insights endpoint automatically for the range on screen. Alongside the starter questions, an “Ask something else” input lets people type their own — same endpoint, same structured answer. Optionally override the starter `questions`, or inject `ask` to mock answers in docs / tests (this preview uses it).
lockedbooleanGate the report for a viewer who isn't entitled to it. Activates the SDK's Locked state: the categories render blurred and inert as a teaser behind a lock and the upgrade CTA; the insights panel is omitted. No live fetch runs while locked — the teaser shows built-in placeholder data (a `categories` 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.
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 categorized expenses for the range.

Loading preview…

Error

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

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