dolfindevelopers

Expense detail

ComponentExpensesSDK + UI

The blocks of one expense, laid out by the decision: a header with the state and what it allows (Approve, Retry post, Re-code); the flag with what to do (pick an account, map the category, set up the card, accept); the approval policy that decided it and who it waits on; where it posted, with a link to the entry and the reference; the receipt or the uploaded receipts that might match, with Attach and Detach; the merchant, memo and personal switch; the coding with one-account picker, learned-coding evidence and the lines editor; the history and the raw card transaction with the spender picker. ReactNode props for a card after the posted entry, account picker extras and an aside. Fetches by expenseId; pass expense (with loading, error and the callbacks you want) to render your own data without a request.

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/expenses-expense-detail

Also installs: badge, button, card, input, label, popover, select, switch, base-theme, base-info-hint, base-money, base-page, base-states, base-timeline, expenses-status, expenses-card-transaction-detail, expenses-expense-lines, expenses-spender-select, ui-expenses-expense-detail.

Usage

screen.tsx
import { ExpenseDetail } from "@/components/dolfin/expenses/expense-detail";

// Place it anywhere inside your <DolfinProvider>.
<ExpenseDetail />

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
expenseIdstringReads the expense and everything around it, and wires every action to the SDK.
expense{ id?: string; organisationId?: string; cardConnectionId?: string; cardLast4?: null | string; cardNetwork?: null | string; cardDisplayName?:…Your expense: passing `expense`, `loading` or `error` means nothing is fetched; `null` reads as not found.
loadingboolean
errorError
onRetry() => voidShows "Try again" in the error state.
receipt{ id?: string; organisationId?: string; fileName?: null | string; contentType?: null | string; fileSizeBytes?: number | string; source?: com…With your expense: the attached receipt.
candidatesreadonly { cardTransactionId?: null | string; expenseId?: null | string; receiptId?: null | string; score?: number | string; withinAmountTol…With your expense: uploaded receipts that might belong to it.
historyreadonly { id?: string; event: string; toState?: null | string; detail?: null | string; actorUserId?: null | string; createdAt?: string; }[]With your expense: its history, newest first.
accountsreadonly ExpenseLedgerAccount[]With your expense: the synced ledger accounts (naming lines, offered by the pickers).
taxRatesreadonly { id?: string; code: string; name?: null | string; rate?: null | number | string; type?: null | string; description?: null | string…With your expense: the tax rates for the lines editor.
approversreadonly ExpenseMember[]With your expense: the people it waits on.
merchant{ aliases?: components["schemas"]["MerchantAliasResponse"][]; id?: string; displayName?: null | string; logoUrl?: null | string; mcc?: null …With your expense: the merchant with every spelling of it.
membersreadonly ExpenseMember[]With your expense: the people the spender picker offers.
canResolvePolicyViolationsbooleanWhether this person may accept a policy violation. By id it comes from the role.
backfalse | DolfinRouteWhere "Back to expenses" leads; `false` hides it. Defaults to the expenses list.
onNavigate(route: DolfinRoute) => void
onSetUpCard() => voidWhere a card's accounts are set up (a missing accounting setup); the button shows only with it.
headerActionsstring | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re…Buttons after Re-code in the header.
afterPostedstring | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re…After the posted entry: a bookkeeping card, accounting sync status.
accountPickerFooterstring | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re…Extra entries at the end of the account pickers (e.g. "Create an account" opening the host's dialog).
asidestring | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re…After the card transaction.
errorStatestring | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re…Replaces the not-found and error state.
classNamestring
onApprove() => voidShows Approve. By id the SDK's own asks first; yours replaces it, confirmation included, and runs at once.
approveDisabledReasonstringExplains why Approve is off, in an InfoHint beside the disabled button.
onRetryPost() => void
onRecode() => void
onResolveFlag() => voidAccept the flag and let the expense continue.
resolveFlagDisabledReasonstringExplains why Accept is off, in an InfoHint beside the disabled button.
onChooseAccount(input: ExpenseChooseAccountInput) => voidCode the whole expense to one account (also "Looks right" on a learned account).
onAttachReceipt(receiptId: string) => void
onDetachReceipt() => void
onUpdate(input: ExpenseUpdateInput) => voidSave the memo or the personal-spend switch.
onSpenderChange(userId: string) => voidCorrect who spent it.
onSaveLines(lines: ExpenseLineRequest[]) => voidReplace the coding lines (shows Edit lines).
pendingActionExpensePendingActionThe change running: its control shows progress and every other control waits.

Customisation

Without editing the source, you can change:

Class names
className
Messages
base.infoHint.moreAboutexpenses.accountLabelexpenses.accountsLoadingexpenses.alsoSeenAsexpenses.amountDiffersexpenses.attachexpenses.autoexpenses.candidatesIntroexpenses.cardShowsexpenses.cardTransactions.detailexpenses.chooseAccountexpenses.codingexpenses.copiedexpenses.copyexpenses.currentAccountexpenses.dateexpenses.detachexpenses.expenseexpenses.expenses.cardexpenses.expenses.flagsexpenses.expenses.spenderexpenses.expenses.unknownMemberexpenses.expenses.unknownMerchantexpenses.isPendingexpenses.loadingexpenses.manualexpenses.matchexpenses.merchantexpenses.merchantCountexpenses.merchantFallbackexpenses.noVatNumberexpenses.noneexpenses.notFoundexpenses.openexpenses.paidFromexpenses.platformIdexpenses.recognisedexpenses.referenceexpenses.referenceHintexpenses.rejectedexpenses.titleexpenses.totalexpenses.vatexpenses.vatNumberexpenses.viewMerchantexpenses.yourPlatform

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.

useDolfinLocaleuseDolfinNavigateuseExpenseuseExpenseActionsuseExpenseAuditLogsuseExpenseLedgerAccountsuseExpenseMatchCandidatesuseExpenseMembersByIduseExpenseMerchantuseExpensePermissionsuseExpenseReceiptuseMessages

Files

Written to your app by the install command:

  • components/dolfin/expenses/expense-detail.tsx 336 lines
  • components/dolfin/expenses/expense-header.tsx 215 lines
  • components/dolfin/expenses/expense-decision-cards.tsx 247 lines
  • components/dolfin/expenses/expense-receipt-card.tsx 189 lines
  • components/dolfin/expenses/expense-details-card.tsx 106 lines
  • components/dolfin/expenses/expense-coding-card.tsx 265 lines
  • components/dolfin/expenses/expense-history-card.tsx 127 lines