@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
| Prop | Type | Default | Description |
|---|---|---|---|
asOf | Date | string | — | The 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. |
records | ReportLine[] | — | Override fetched data — pass the API tree as-is. Skips the API call. |
state | "loading" | "error" | "empty" | — | Force a specific state for testing. |
childrenrequired | ReactNode | — | Compound parts. |
Parts
Container
Always rendered. Provides data and context to its children.
| Part | Description |
|---|---|
BalanceSheetReport.Root | Fetches the balance sheet and provides context. |
BalanceSheetReport.AsOfasChild?, format? | Renders the resolved as-of date. Defaults to "Mon DD, YYYY". Pass format(date) to override. |
Success
Renders when records are available.
| Part | Description |
|---|---|
BalanceSheetReport.Success | State wrapper. Compose the table inside. |
BalanceSheetReport.Sections | Iterates each top-level section (Assets, Liabilities, Equity). Provides a section context for use inside <Lines>. |
BalanceSheetReport.Lines | Iterates 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.LineasChild? | 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.LineNameasChild? | 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.LineAmountasChild?, 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.
| Part | Description |
|---|---|
BalanceSheetReport.Loading | State wrapper. Render any skeleton or placeholder UI inside. |
Empty
Renders when the fetch returned no records.
| Part | Description |
|---|---|
BalanceSheetReport.Empty | State wrapper. Render an empty-state message inside. |
Error
Renders on fetch error.
| Part | Description |
|---|---|
BalanceSheetReport.Error | State wrapper. Compose the error UI inside. |
BalanceSheetReport.ErrorMessageasChild? | Renders the error message string. |
BalanceSheetReport.RetryasChild? | 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.
| Part | Description |
|---|---|
BalanceSheetReport.DownloadasChild? | 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
| Part | Description |
|---|---|
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 }). |