siigo_update_invoice
Modify existing invoice records in Siigo accounting software by providing the invoice ID and updated data to correct errors or reflect changes.
Instructions
Update an existing invoice
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Invoice ID | |
| invoice | Yes | Invoice data to update |
Implementation Reference
- src/index.ts:926-936 (handler)MCP tool handler that invokes SiigoClient.updateInvoice with args.id and args.invoice, formats the result as JSON text content.private async handleUpdateInvoice(args: any) { const result = await this.siigoClient.updateInvoice(args.id, args.invoice); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
- src/siigo-client.ts:112-114 (handler)Core implementation that performs a PUT request to Siigo API endpoint /v1/invoices/{id} to update the invoice.async updateInvoice(id: string, invoice: Partial<SiigoInvoice>): Promise<SiigoApiResponse<SiigoInvoice>> { return this.makeRequest<SiigoInvoice>('PUT', `/v1/invoices/${id}`, invoice); }
- src/index.ts:397-408 (registration)Tool registration in getTools() array, including name, description, and input schema.{ name: 'siigo_update_invoice', description: 'Update an existing invoice', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'Invoice ID' }, invoice: { type: 'object', description: 'Invoice data to update' }, }, required: ['id', 'invoice'], }, },
- src/types.ts:94-143 (schema)Type definition for SiigoInvoice used in updateInvoice parameters.export interface SiigoInvoice { id?: string; document: { id: number; number?: number; }; date: string; customer: { person_type?: string; id_type?: string; identification: string; branch_office?: number; name?: string[]; address?: any; phones?: any[]; contacts?: any[]; }; cost_center?: number; currency?: { code: string; exchange_rate: number; }; seller: number; observations?: string; items: Array<{ code: string; description?: string; quantity: number; price: number; discount?: number; taxes?: Array<{ id: number }>; }>; payments: Array<{ id: number; value: number; due_date?: string; }>; stamp?: { send: boolean; }; mail?: { send: boolean; }; global_discounts?: Array<{ id: number; percentage?: number; value?: number; }>; additional_fields?: any; }
- src/siigo-client.ts:41-59 (helper)Shared helper method that handles authentication, makes HTTP requests to Siigo API, and processes responses/errors.private async makeRequest<T>(method: string, endpoint: string, data?: any, params?: any): Promise<SiigoApiResponse<T>> { await this.authenticate(); try { const response: AxiosResponse<SiigoApiResponse<T>> = await this.httpClient.request({ method, url: endpoint, data, params, }); return response.data; } catch (error: any) { if (error.response?.data) { return error.response.data; } throw new Error(`API request failed: ${error.message}`); } }