open_invoice
Change an invoice from concept to open state by assigning its invoice number, preparing it for sending.
Instructions
Changes the state from concept to open. This will assign the actual invoice number so it's ready for sending. If the current state is not concept, this endpoint does nothing.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ID of the invoice |
Implementation Reference
- src/tools/invoices.ts:86-103 (registration)Tool registration for 'open_invoice' using server.registerTool. Defines description, annotations, and inputSchema.
server.registerTool( "open_invoice", { description: "Changes the state from concept to open.\nThis will assign the actual invoice number so it's ready for sending.\nIf the current state is not concept, this endpoint does nothing.\n", annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true }, inputSchema: { id: z.number().int().positive().describe("ID of the invoice") }, }, async ({ id }) => { try { const record = await apiPost<EduframeRecord>(`/invoices/${id}/open`, {}); void logResponse("open_invoice", { id }, record); return formatShow(record, "invoice"); } catch (error) { return formatError(error); } }, ); - src/tools/invoices.ts:94-103 (handler)Handler function for 'open_invoice'. Calls POST /invoices/{id}/open to change invoice state from concept to open, logs the response, and formats the result.
async ({ id }) => { try { const record = await apiPost<EduframeRecord>(`/invoices/${id}/open`, {}); void logResponse("open_invoice", { id }, record); return formatShow(record, "invoice"); } catch (error) { return formatError(error); } }, ); - src/tools/invoices.ts:88-92 (schema)Input schema for 'open_invoice': requires a positive integer 'id' field (the invoice ID).
{ description: "Changes the state from concept to open.\nThis will assign the actual invoice number so it's ready for sending.\nIf the current state is not concept, this endpoint does nothing.\n", annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true }, inputSchema: { id: z.number().int().positive().describe("ID of the invoice") }, - src/api.ts:163-174 (helper)The apiPost helper used by the handler to POST to /invoices/{id}/open. Sends a POST request with JSON body and returns parsed response.
export async function apiPost<T>(path: string, body: unknown): Promise<T> { const { token } = getConfig(); const url = buildUrl(path); const response = await fetch(url.toString(), { method: "POST", headers: buildHeaders(token), body: JSON.stringify(body), }); return handleResponse<T>(response); } - src/formatters.ts:68-77 (helper)The formatShow helper used by the handler to format the invoice record as a text response.
export function formatShow(record: EduframeRecord, resourceName: string): CallToolResult { return { content: [ { type: "text", text: `${resourceName}:\n\n${formatJSON(record)}${RESPONSE_LOG_HINT}`, }, ], }; }