@arolariu/website / lib/actions/invoices/fetchInvoice / default
Function: default()
default(
input):ServerActionOutputType
Defined in: lib/actions/invoices/fetchInvoice.ts:83
Fetches a single invoice by its unique identifier.
Parameters
input
ServerActionInputType
The fetch parameters
Returns
ServerActionOutputType
Promise resolving to the complete Invoice entity
Remarks
Execution Context: Server-side only (Next.js server action).
Authentication: Automatically fetches JWT from Clerk auth service.
Data Returned:
- Full invoice aggregate including scans, products, metadata
- Merchant reference (use fetchMerchant for full merchant data)
- Analysis results if previously analyzed
Caching: Response is not cached; always fetches fresh data.
Side Effects: Emits OpenTelemetry spans for tracing.
Throws
When invoiceId is not a valid GUID
Throws
When authentication fails
Throws
When invoice not found (404)
Throws
When user not authorized to view invoice (403)
Example
import fetchInvoice from "@/lib/actions/invoices/fetchInvoice";
const invoice = await fetchInvoice({
invoiceId: "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d"
});
console.log("Total amount:", invoice.estimatedSurface?.totalAmount);
console.log("Number of items:", invoice.items?.length);
See
- Invoice for the complete data structure
- fetchMerchant for retrieving linked merchant details