Expense detail
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
Ready to connect to Dolfin. Loads data through SDK hooks, with appearance and behaviour you can customise. Requires DolfinProvider.
Installation
Needs the Dolfin registry token. The CLI copies the source into your app.
bunx --bun shadcn@4.23.0 add @dolfin/expenses-expense-detailAlso 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
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
| Prop | Type | Description |
|---|---|---|
expenseId | string | Reads 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. |
loading | boolean | |
error | Error | |
onRetry | () => void | Shows "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. |
candidates | readonly { cardTransactionId?: null | string; expenseId?: null | string; receiptId?: null | string; score?: number | string; withinAmountTol… | With your expense: uploaded receipts that might belong to it. |
history | readonly { id?: string; event: string; toState?: null | string; detail?: null | string; actorUserId?: null | string; createdAt?: string; }[] | With your expense: its history, newest first. |
accounts | readonly ExpenseLedgerAccount[] | With your expense: the synced ledger accounts (naming lines, offered by the pickers). |
taxRates | readonly { 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. |
approvers | readonly 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. |
members | readonly ExpenseMember[] | With your expense: the people the spender picker offers. |
canResolvePolicyViolations | boolean | Whether this person may accept a policy violation. By id it comes from the role. |
back | false | DolfinRoute | Where "Back to expenses" leads; `false` hides it. Defaults to the expenses list. |
onNavigate | (route: DolfinRoute) => void | |
onSetUpCard | () => void | Where a card's accounts are set up (a missing accounting setup); the button shows only with it. |
headerActions | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | Buttons after Re-code in the header. |
afterPosted | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | After the posted entry: a bookkeeping card, accounting sync status. |
accountPickerFooter | string | 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). |
aside | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | After the card transaction. |
errorState | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | Replaces the not-found and error state. |
className | string | |
onApprove | () => void | Shows Approve. By id the SDK's own asks first; yours replaces it, confirmation included, and runs at once. |
approveDisabledReason | string | Explains why Approve is off, in an InfoHint beside the disabled button. |
onRetryPost | () => void | |
onRecode | () => void | |
onResolveFlag | () => void | Accept the flag and let the expense continue. |
resolveFlagDisabledReason | string | Explains why Accept is off, in an InfoHint beside the disabled button. |
onChooseAccount | (input: ExpenseChooseAccountInput) => void | Code the whole expense to one account (also "Looks right" on a learned account). |
onAttachReceipt | (receiptId: string) => void | |
onDetachReceipt | () => void | |
onUpdate | (input: ExpenseUpdateInput) => void | Save the memo or the personal-spend switch. |
onSpenderChange | (userId: string) => void | Correct who spent it. |
onSaveLines | (lines: ExpenseLineRequest[]) => void | Replace the coding lines (shows Edit lines). |
pendingAction | ExpensePendingAction | The 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.
useDolfinLocaleuseDolfinNavigateuseExpenseuseExpenseActionsuseExpenseAuditLogsuseExpenseLedgerAccountsuseExpenseMatchCandidatesuseExpenseMembersByIduseExpenseMerchantuseExpensePermissionsuseExpenseReceiptuseMessagesFiles
Written to your app by the install command:
components/dolfin/expenses/expense-detail.tsx336 linescomponents/dolfin/expenses/expense-header.tsx215 linescomponents/dolfin/expenses/expense-decision-cards.tsx247 linescomponents/dolfin/expenses/expense-receipt-card.tsx189 linescomponents/dolfin/expenses/expense-details-card.tsx106 linescomponents/dolfin/expenses/expense-coding-card.tsx265 linescomponents/dolfin/expenses/expense-history-card.tsx127 lines