dolfindevelopers

Invoice discounts and totals

ComponentReceivablesSDK + UI

Discount controls (none, percentage or fixed amount) for a line or the whole invoice, the early payment discount (amount and last day to pay at it), and the invoice editor's summary card: invoice discount, live subtotal, discount, tax, total and the early payment price, worked out as the server will. A controlled card that fetches nothing: values and onChange (the whole draft), errors and dirtyFields.

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

Works with Dolfin’s SDK context, 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-discount

Also installs: card, field, input, select, base-theme, base-info-hint, base-money, ui-ar-invoice-discount.

Usage

screen.tsx
import { InvoiceDiscountFields } from "@/components/dolfin/ar/invoice-discount";

// Place it anywhere inside your <DolfinProvider>.
<InvoiceDiscountFields type={type} value={value} onTypeChange={handleTypeChange} onValueChange={handleValueChange} currency={currency} label={label} />

Renders inside DolfinProvider (set it up once). It renders the data you pass as props.

API reference

PropTypeDescription
type required"Fixed" | "None" | "Percentage"
value requirednumber
onTypeChange required(type: DiscountType) => void
onValueChange required(value: number) => void
currency requiredstringThe invoice currency, shown on a fixed amount.
label requiredstring
errorstringMessage for the value, from the draft's errors.
compactbooleanSmaller labels, for a line.
dirtyClassNamestring | falseRing for a changed field.
classNamestring

Customisation

Without editing the source, you can change:

Class names
dirtyClassNameclassName
Messages
ar.invoiceDraftbase.infoHint.moreAbout

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.

useDolfinLocaleuseMessages

Files

Written to your app by the install command:

  • components/dolfin/ar/invoice-discount.tsx 132 lines
  • components/dolfin/ar/invoice-draft-summary.tsx 177 lines