@arolariu/website / lib/actions/invoices/patchInvoice / default
Function: default()
default(
input):ServerActionOutputType
Defined in: lib/actions/invoices/patchInvoice.ts:111
Server action that performs a partial update (PATCH) on an invoice.
Parameters
input
ServerActionInputType
The invoice ID and patch payload
Returns
ServerActionOutputType
A result object containing the updated invoice or error message
Remarks
HTTP Method: PATCH
Endpoint: /rest/v1/invoices/{invoiceId}
Patch Semantics:
- Only provided fields are updated
- Null/undefined values preserve existing data
sharedWithreplaces the entire list when providedadditionalMetadatamerges with existing metadata
Error Handling:
Returns a result object with success flag instead of throwing,
making it easier to handle errors in UI components.
Example
// Update only the name
const result = await patchInvoice({
invoiceId: "abc-123",
payload: { name: "New Invoice Name" }
});
if (result.success) {
console.log("Updated:", result.invoice);
} else {
console.error("Failed:", result.error);
}
// Update sharing settings
const shareResult = await patchInvoice({
invoiceId: "abc-123",
payload: { sharedWith: ["user-guid-1", "user-guid-2"] }
});