@get-asset/sdk

BalanceSheetReport

Headless compound that fetches a point-in-time balance sheet for a specific date — defaults to "now" if no date is provided — and exposes it as a flat list of lines with depth metadata. Subtotal rows include their nested totals; leaf rows expose the per-ledger amount.

Anatomy

Import the primitive and compose the parts you need.

<BalanceSheetReport.Root asOf={new Date()}>
<BalanceSheetReport.AsOf />
<BalanceSheetReport.Success>
<BalanceSheetReport.Sections>
<BalanceSheetReport.Lines>
<BalanceSheetReport.Line>
<BalanceSheetReport.LineName />
<BalanceSheetReport.LineAmount />
</BalanceSheetReport.Line>
</BalanceSheetReport.Lines>
</BalanceSheetReport.Sections>
</BalanceSheetReport.Success>
<BalanceSheetReport.Loading></BalanceSheetReport.Loading>
<BalanceSheetReport.Empty>No data yet.</BalanceSheetReport.Empty>
</BalanceSheetReport.Root>

Required scopes

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

  • report:read

API reference

Root props

PropTypeDefaultDescription
asOfDate | stringThe point-in-time the report is taken at. Accepts a Date or any ISO-8601 string. Defaults to "now" — the report shows the latest balance whenever it mounts.
recordsReportLine[]Override fetched data — pass the API tree as-is. Skips the API call.
state"loading" | "error" | "empty"Force a specific state for testing.
childrenrequiredReactNodeCompound parts.

Parts

Container

Always rendered. Provides data and context to its children.

PartDescription
BalanceSheetReport.RootFetches the balance sheet and provides context.
BalanceSheetReport.AsOf
asChild?, format?
Renders the resolved as-of date. Defaults to "Mon DD, YYYY". Pass format(date) to override.

Success

Renders when records are available.

PartDescription
BalanceSheetReport.SuccessState wrapper. Compose the table inside.
BalanceSheetReport.SectionsIterates each top-level section (Assets, Liabilities, Equity). Provides a section context for use inside <Lines>.
BalanceSheetReport.LinesIterates the current section's lines. Must be used inside <Sections> (throws otherwise — use the useBalanceSheetReport().lines hook for raw flat access). Group sections expand into heading → descendants → total; calc-leaf sections yield a single row. Each iteration sets the line context plus a role so <Line> emits the right data attribute.
BalanceSheetReport.Line
asChild?
Wrapper that adds data-depth, data-leaf, data-group, data-section, data-section-heading and data-section-total attributes based on the current line and (when inside Sections) its role. The same template renders headings, descendants and totals — CSS differentiates them by attribute.
BalanceSheetReport.LineName
asChild?
Renders the line name. On a section's total row this is auto-prefixed with "Total " (skipped if the section name already starts with "Total ").
BalanceSheetReport.LineAmount
asChild?, format?
Renders the line's total_amount. On group section heading rows, the rolled-up amount is hidden by default in the styled drop-in's CSS.

Loading

Renders while the fetch is in flight.

PartDescription
BalanceSheetReport.LoadingState wrapper. Render any skeleton or placeholder UI inside.

Empty

Renders when the fetch returned no records.

PartDescription
BalanceSheetReport.EmptyState wrapper. Render an empty-state message inside.

Error

Renders on fetch error.

PartDescription
BalanceSheetReport.ErrorState wrapper. Compose the error UI inside.
BalanceSheetReport.ErrorMessage
asChild?
Renders the error message string.
BalanceSheetReport.Retry
asChild?
Button that re-runs the fetch.

Download

Triggers an XLSX export of the report using the same as-of date that produced the on-screen view.

PartDescription
BalanceSheetReport.Download
asChild?
Button that calls the SDK's download action when clicked. Hits /reports/balance-sheet with end_datetime (= asOf) and saves the response as balance-sheet-{YYYY-MM-DD}.xlsx. No-op when records / state overrides are active.

Hooks

PartDescription
useBalanceSheetReport()Hook returning lines, asOf, hasData, loading, error, retry, download. download() is a Promise<void> that triggers the XLSX export.
useBalanceSheetReportLine()Hook used inside a Lines iteration; returns the current line node.
useBalanceSheetSection()Hook used inside a Sections iteration; returns the current section ({ section, descendants }).