dolfindevelopers

Purchase order form dialog

DialogPayablesSDK + UI

Raise or edit a purchase order in a dialog: PO number, supplier, currency, dates, external reference and lines (description, SKU, quantity, unit, unit price) with each line's net and the total. Checks the fields before saving, offers to replace the lines of an order whose PO number is taken, and refreshes order lists, bill matches and the overview afterwards. A new order can be seeded with initial values (currency, supplier, lines). Also ships NewPurchaseOrderButton and EditPurchaseOrderButton.

Dialog: a modal you open from your own screen. You control when it opens with its props. 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/ap-purchase-order-form-dialog

Also installs: button, dialog, input, base-theme, base-money, ap-purchase-order-form-parts, ui-ap-purchase-order-form-dialog.

Usage

screen.tsx
import { PurchaseOrderFormDialog } from "@/components/dolfin/ap/purchase-order-form-dialog";

// Place it anywhere inside your <DolfinProvider>.
<PurchaseOrderFormDialog open={open} onOpenChange={handleOpenChange} />

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
open requiredboolean
onOpenChange required(open: boolean) => void
purchaseOrder{ id?: string; organisationId?: string; supplierId?: null | string; externalRef?: null | string; poNumber: string; currency: string; status?…The order to edit; omit (or pass null) to raise a new one.
initialValuesPurchaseOrderFormInitialValuesSeeds a new order, e.g. `{ currency: "EUR" }` or a supplier; ignored when editing. Read when the dialog opens. Without a currency here, a new order starts in the provider's `defaultCurrency`, else GBP.
onSaved(purchaseOrder: PurchaseOrder) => voidAfter a save; the dialog has closed.
onSubmit(value: PurchaseOrderFormValue) => void | Promise<unknown>Saves the order yourself: called with the validated form instead of saving through the API. Resolve to close the dialog; reject (or set `error`) to keep it open.
submittingbooleanYour save is running.
errorErrorWhy your save failed.
supplierOptionsreadonly { id: string; name: string; }[]Suppliers to pick from (with `onSubmit`). Given, the picker fetches nothing.
titlestring | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re…
descriptionstring | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re…
classNamestring

Customisation

Without editing the source, you can change:

Class names
className
Messages
ap.orderscore.errors

Or edit the installed file directly: it is your code. See theming for colours and fonts.

Hooks

The SDK hooks this dialog uses. Use them directly from @dolfinai/react to build your own version.

useDolfinDefaultCurrencyuseMessagesusePurchaseOrderMutations

Files

Written to your app by the install command:

  • components/dolfin/ap/purchase-order-form-dialog.tsx 334 lines
  • components/dolfin/ap/purchase-order-form-saver.tsx 69 lines