get_sale
Retrieve detailed information about a specific sale transaction by providing its unique ID. This tool helps track sales data for consignment and retail business operations.
Instructions
Get details of a specific sale
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Sale ID |
Implementation Reference
- src/client.ts:155-158 (handler)Primary handler that fetches sale by ID from API /sales/{id} and converts response to store currency format.async getSale(id: string): Promise<Sale> { const response = await this.client.get(`/sales/${id}`); return this.convertSaleResponse(response.data); }
- src/server.ts:114-124 (registration)Registers the 'get_sale' MCP tool with input schema requiring sale ID.{ name: 'get_sale', description: 'Get details of a specific sale', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'Sale ID' }, }, required: ['id'], }, },
- src/server.ts:453-454 (handler)MCP server dispatch case that calls client.getSale and returns JSON-formatted result.case 'get_sale': return { content: [{ type: 'text', text: JSON.stringify(await client.getSale((args as any).id), null, 2) }] };
- src/types.ts:22-33 (schema)TypeScript interface defining the Sale response structure.export interface Sale { id: string; created: string; total: number; // converted to store currency subtotal: number; // converted to store currency tax: number; // converted to store currency customer: string | null; location: string | null; items: any[]; payments: any[]; status: 'completed' | 'voided' | 'returned'; }
- src/client.ts:411-427 (helper)Helper function converting API cents-based sale data to store currency values.private convertSaleResponse(sale: any): Sale { return { ...sale, total: this.convertFromApiCents(sale.total), subtotal: this.convertFromApiCents(sale.subtotal), tax: this.convertFromApiCents(sale.tax), items: sale.items?.map((item: any) => ({ ...item, tag_price: item.tag_price ? this.convertFromApiCents(item.tag_price) : undefined, total: item.total ? this.convertFromApiCents(item.total) : undefined, })), payments: sale.payments?.map((payment: any) => ({ ...payment, amount: payment.amount ? this.convertFromApiCents(payment.amount) : undefined, })), }; }