Credit notes table
Credit notes raised against your invoices: number and reason, net, tax with its rate, amount (money off once issued), status and created date. A customer filter, cursor pagination, rows that open the credit note and an Issue row action on drafts. Takes columns, rowActions and initial filters (customer, invoice).
Component: A piece you place inside your own screens: a table, a form, a card or a dialog. You decide the layout around it. Pages vs components
Ready to connect to Dolfin. Loads data through SDK hooks, with appearance and behaviour you can customise. Requires DolfinProvider.
Installation
Needs the Dolfin registry token. The CLI copies the source into your app.
bunx --bun shadcn@4.23.0 add @dolfin/ar-credit-notes-tableAlso installs: button, select, ar-credit-note-parts, base-data-table, base-money, base-states, ui-ar-credit-notes-table.
Usage
import { CreditNotesTable } from "@/components/dolfin/ar/credit-notes-table";
// Place it anywhere inside your <DolfinProvider>.
<CreditNotesTable />Renders inside DolfinProvider (set it up once). By default it loads its own data through the SDK. Supplied-data examples show how to override that behavior.
API reference
| Prop | Type | Description |
|---|---|---|
filters | CreditNoteListFilters | Initial filters for the list it loads: a customer, an invoice. A changed value re-applies. |
pageSize | number | |
creditNotes | readonly { id?: string; organisationId?: string; invoiceId?: string; documentNumber?: null | string; amount?: number | string; netAmount?: n… | Your own rows: the table then shows them and makes no request (and no customer filter). |
loading | boolean | |
error | Error | |
onRetry | () => void | |
page | number | 1-based page number, for your own rows. |
hasNextPage | boolean | |
onPageChange | (page: number) => void | Shows the pager for your own rows. |
onIssue | (note: CreditNote) => void | Adds Issue to drafts' row menus (with your own rows). |
forCustomer | boolean | The empty state reads "for this customer". |
onCustomerFilterChange | (customerId: string | null) => void | |
hideCustomerFilter | boolean | Hide the customer filter (a list already scoped to one customer or invoice). |
toolbarActions | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | Extra controls beside the customer filter. |
columns | CreditNoteColumnsProp | |
columnOrder | readonly string[] | |
columnVisibility | Readonly<Record<string, boolean>> | |
rowActions | CreditNoteRowActionsProp | Pass `[]` for none. |
getRowRoute | (note: CreditNote) => DolfinRoute | null | Where a row links to; the credit note by default (return its invoice when you have no credit note page). |
onRowClick | (note: CreditNote) => void | Called when a row is clicked; given, it replaces the row's link. |
emptyState | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | Replaces the default empty state. |
emptyAction | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | In the default empty state (e.g. "Show all customers" while filtered). |
className | string | |
variant | DataTableVariant | |
classNames | DataTableClassNames | |
pager | boolean | Show the built-in previous / next pager when there is more than one page. Default true; pass false when you draw your own pager from the list's pagination (the table still dims while a page loads). |
onRowHover | (row: { id?: string; organisationId?: string; invoiceId?: string; documentNumber?: null | string; amount?: number | string; netAmount?: numb… | Called with the row the pointer moves onto, and with `null` when the pointer leaves the rows (e.g. to highlight the row's point in a chart next to the table). Moving between rows reports the new row without a `null` first. |
Customisation
Without editing the source, you can change:
- Class names
classNameclassNames.frameclassNames.headerclassNames.headerCellclassNames.rowclassNames.cellclassNames.pager- Messages
ar.creditNotes
Or edit the installed file directly: it is your code. See theming for colours and fonts.
Hooks
The SDK hooks this component uses. Use them directly from @dolfinai/react to build your own version.
useCreditNoteMutationsuseCreditNotesuseCustomerOptionsuseDolfinLocaleuseMessagesFiles
Written to your app by the install command:
components/dolfin/ar/credit-notes-table.tsx350 linescomponents/dolfin/ar/credit-note-columns.tsx93 lines