Table of Contents

**@arolariu/website**


@arolariu/website / lib/actions/invoices/deleteInvoice / default

Function: default()

default(input): ServerActionOutputType

Defined in: lib/actions/invoices/deleteInvoice.ts:85

Soft-deletes an invoice from the system.

Parameters

input

ServerActionInputType

The invoice deletion parameters

Returns

ServerActionOutputType

Promise that resolves when deletion is complete

Remarks

Execution Context: Server-side only (Next.js server action).

Authentication: Automatically fetches JWT from Clerk auth service.

Deletion Semantics:

  • Performs soft-delete (invoice marked as deleted, not physically removed)
  • Deleted invoices excluded from standard queries
  • Deletion is idempotent (deleting already-deleted invoice succeeds)

Side Effects:

  • Emits OpenTelemetry spans for tracing
  • Updates invoice isDeleted flag in database
  • Cascades to associated scan records

Error Handling: Throws on validation, auth, or API failures.

Throws

When invoiceId is not a valid GUID

Throws

When authentication fails

Throws

When API returns 404 (invoice not found)

Throws

When API returns 403 (not authorized to delete)

Example

import deleteInvoice from "@/lib/actions/invoices/deleteInvoice";

try {
  await deleteInvoice({
    invoiceId: "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d"
  });
  console.log("Invoice deleted successfully");
} catch (error) {
  console.error("Failed to delete invoice:", error);
}

See

fetchInvoices - Deleted invoices won't appear in list