Bill lines editor
Add, remove, reorder and edit a bill's lines (description, SKU, quantity, unit, unit price, tax, category, spend class and tags) with AI suggestions one click away, each line's gross and a check that the lines add up to the bill total. Driven by useBillDraft. Also ships the unit, currency and category comboboxes and the tag input.
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/ap-bill-lines-editorAlso installs: badge, button, card, command, field, input, popover, select, base-theme, base-info-hint, base-money, base-states, ui-ap-bill-lines-editor.
Usage
import { BillLinesEditor } from "@/components/dolfin/ap/bill-lines-editor";
// Place it anywhere inside your <DolfinProvider>.
<BillLinesEditor values={values} onChange={handleChange} />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 |
|---|---|---|
values required | BillDraft | The draft to edit, e.g. `useBillDraft(billId).draft`. A controlled form: every change goes to `onChange`. |
onChange required | (next: BillDraft) => void | |
errors | Partial<Record<BillDraftPath, string>> | Messages by path (`lines.0.description`, ...). |
dirtyFields | readonly string[] | Paths changed since the bill was read, ringed (`useBillDraft(billId).dirtyFields`). |
bill | { id?: string; organisationId?: string; state?: components["schemas"]["BillState"]; source?: components["schemas"]["BillSource"]; eInvoiceId… | The bill the draft came from: its currency and the extraction's category suggestions. |
categories | readonly { key: string; displayName: string; defaultSpendClass: null | components["schemas"]["SpendClass"]; source: string; }[] | Spend categories to pick from. Given, nothing is fetched. |
emptyState | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | Replaces the note shown when the bill has no lines. |
renderLineExtra | (line: BillDraftLine, index: number) => ReactNode | Extra fields under a line (for example where it posts in your accounting system). |
className | string |
Customisation
Without editing the source, you can change:
- Class names
className- Messages
ap.billDraftbase.infoHint.moreAboutbase.statescore.errors
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.
useBillCategoriesuseBillCurrenciesuseMessagesFiles
Written to your app by the install command:
components/dolfin/ap/bill-lines-editor.tsx312 linescomponents/dolfin/ap/bill-draft-pickers.tsx136 lines