@arolariu/website / lib/actions/invoices/deleteInvoiceScan / deleteInvoiceScan
Function: deleteInvoiceScan()
deleteInvoiceScan(
input):ServerActionOutputType
Defined in: lib/actions/invoices/deleteInvoiceScan.ts:82
Deletes a scan from an existing invoice entity.
Parameters
input
ServerActionInputType
The invoice ID and scan location
Returns
ServerActionOutputType
Promise that resolves when scan is successfully deleted
Remarks
Execution Context: Server-side only (Next.js server action).
Authentication: Automatically fetches JWT from Clerk auth service.
Deletion Behavior:
- Removes scan reference from invoice entity
- Azure blob marked for cleanup (not immediately deleted)
- Fails if attempting to delete the last remaining scan
Side Effects:
- Emits OpenTelemetry spans for tracing
- Updates invoice aggregate to remove scan reference
Error Handling: Throws on validation, auth, or API failures.
Throws
When invoiceId is not a valid GUID
Throws
When attempting to delete the last scan
Throws
When authentication fails
Throws
When API returns non-OK status
Example
import {deleteInvoiceScan} from "@/lib/actions/invoices/deleteInvoiceScan";
await deleteInvoiceScan({
invoiceId: "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
scanLocation: "https://storage.blob.core.windows.net/invoices/scan.jpg"
});
See
attachInvoiceScan for adding scans