dolfindevelopers

Apply supplier credit dialog

DialogPayablesSDK + UI

Nets a credit note's available credit against bills you owe the same supplier: the open bills that can take it (or a bill id typed by hand), an amount filled in up to what the bill owes and the credit left, and more bills to split the credit across. Limits are checked as you type.

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-apply-supplier-credit-dialog

Also installs: button, dialog, input, label, select, base-money, ui-ap-apply-supplier-credit-dialog.

Usage

screen.tsx
import { ApplySupplierCreditDialog } from "@/components/dolfin/ap/apply-supplier-credit-dialog";

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

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
creditNote required{ id?: string; organisationId?: string; supplierId?: string; documentNumber?: null | string; amount?: number | string; netAmount?: number | …The issued note whose available credit is applied.
onApplied(result: ApplySupplierCreditResult) => voidCalled after every allocation went through, once the dialog has closed.
openBillsreadonly { id?: string; organisationId?: string; state?: components["schemas"]["BillState"]; source?: components["schemas"]["BillSource"]; e…The supplier's open bills to apply the credit to. Given, the list is not fetched.
onSubmit(allocations: { billId: string; amount: number; }[]) => void | Promise<unknown>Applies the allocations yourself instead of through the API. Resolve to close the dialog; reject (or set `error`) to keep it open.
errorErrorWhy your apply failed (a `DolfinError` reads as the API's message).
classNamestring

Customisation

Without editing the source, you can change:

Class names
className
Messages
ap.supplierCreditNotes.applyDialogcore.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.

useApplySupplierCredituseMessages

Files

Written to your app by the install command:

  • components/dolfin/ap/apply-supplier-credit-dialog.tsx 228 lines