dolfindevelopers

Invoice lines editor

ComponentReceivablesSDK + UI

Add, remove, reorder (drag or buttons) and edit an invoice's lines: a product picker scoped to the invoice currency (with an optional New Product entry), tax rate, quantity, unit price (starts at the product's price) and a line discount, with each line's total. A controlled editor: values and onChange (the whole draft), errors, dirtyFields; pass the products and tax rates to pick from and it makes no request, leave one out and its picker reads it once opened. Also ships the line pickers on their own: InvoiceProductPicker (searches the catalogue, or takes your products) and InvoiceTaxRatePicker (reads the rates, or takes yours), and the type-to-search combobox the invoice form uses.

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

Choose your integration

Ready to connect to Dolfin. Loads data through SDK hooks, with appearance and behaviour you can customise. Requires DolfinProvider.

Loading preview…

Installation

Needs the Dolfin registry token. The CLI copies the source into your app.

Terminal
bunx --bun shadcn@4.23.0 add @dolfin/ar-invoice-lines-editor

Also installs: button, card, command, field, input, popover, select, base-theme, base-info-hint, base-money, base-states, ar-invoice-discount, ui-ar-invoice-lines-editor.

Usage

screen.tsx
import { InvoiceLinesEditor } from "@/components/dolfin/ar/invoice-lines-editor";

// Place it anywhere inside your <DolfinProvider>.
<InvoiceLinesEditor values={values} />

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

PropTypeDescription
values requiredInvoiceDraftThe invoice being edited (`useInvoiceDraft().draft`, or your own): its lines, priced in its currency.
onChange(values: InvoiceDraft) => voidCalled with the whole invoice after each edit (`useInvoiceDraft().setValues`, or your own state).
errorsReadonly<Partial<Record<string, string>>>A message per field path (`lines`, `lines.0.quantity`), as `useInvoiceDraft().errors` holds them.
dirtyFieldsreadonly string[]Field paths to ring as changed since the invoice was saved (`useInvoiceDraft().dirtyFields`).
productsreadonly ProductOption[]The products to pick from, in the invoice currency. Given (`[]` included), the picker makes no request; left out, it searches them once it opens. The same for `taxRates`.
productsLoadingboolean
productsErrorError
onProductsRetry() => void
onProductSearch(query: string) => voidCalled with the product search as the user types (debounced 400ms).
taxRatesreadonly TaxRateOption[]The tax rates a line can carry.
taxRatesLoadingboolean
taxRatesErrorError
onTaxRatesRetry() => void
onCreateProduct(lineKey: string) => voidOffers "New Product" in the product picker; open your create-product dialog for this line.
emptyStatestring | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re…Replaces the note shown when there are no lines.
renderLineExtra(line: InvoiceDraftLine, index: number) => ReactNodeExtra fields under a line (for example an income account).
classNamestring

Customisation

Without editing the source, you can change:

Class names
className
Messages
ar.invoiceDraft.linesbase.states.loadingbase.states.retry

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.

useMessagesuseProductOptionsuseTaxRateOptions

Files

Written to your app by the install command:

  • components/dolfin/ar/invoice-lines-editor.tsx 320 lines
  • components/dolfin/ar/invoice-product-picker.tsx 150 lines
  • components/dolfin/ar/invoice-tax-rate-picker.tsx 102 lines
  • components/dolfin/ar/invoice-draft-combobox.tsx 100 lines