pohoda_create_stock
Add new inventory items to POHODA accounting software by specifying code, name, pricing, VAT rates, and stock details for accurate inventory management.
Instructions
Create a new stock/inventory item in POHODA
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Unique stock code | |
| name | Yes | Stock item name | |
| stockType | No | Stock type (default: card) | |
| unit | No | Unit of measure (e.g., ks, kg, m) | |
| purchasingPrice | No | Purchasing price | |
| sellingPrice | No | Selling price without VAT | |
| sellingPriceVAT | No | Selling price with VAT | |
| rateVAT | No | VAT rate | |
| store | No | Store name | |
| note | No | Note | |
| description | No | Extended description | |
| quantity | No | Initial quantity |
Implementation Reference
- src/tools/stock.ts:49-93 (handler)The implementation of the `pohoda_create_stock` tool handler, including schema definition and XML construction logic.
server.tool( "pohoda_create_stock", "Create a new stock/inventory item in POHODA", { code: z.string().describe("Unique stock code"), name: z.string().describe("Stock item name"), stockType: z.enum(["card", "text", "service", "kit", "set"]).optional().describe("Stock type (default: card)"), unit: z.string().optional().describe("Unit of measure (e.g., ks, kg, m)"), purchasingPrice: z.number().optional().describe("Purchasing price"), sellingPrice: z.number().optional().describe("Selling price without VAT"), sellingPriceVAT: z.number().optional().describe("Selling price with VAT"), rateVAT: z.enum(["none", "low", "high"]).optional().describe("VAT rate"), store: z.string().optional().describe("Store name"), note: z.string().optional().describe("Note"), description: z.string().optional().describe("Extended description"), quantity: z.number().optional().describe("Initial quantity"), }, async (params) => { try { const xml = buildImportDoc({ ico: client.ico }, (item) => { const stk = item.ele(NS.stk, "stk:stock").att("version", "2.0"); const hdr = stk.ele(NS.stk, "stk:stockHeader"); hdr.ele(NS.stk, "stk:stockType").txt(params.stockType ?? "card"); hdr.ele(NS.stk, "stk:code").txt(params.code); hdr.ele(NS.stk, "stk:name").txt(params.name); if (params.unit) hdr.ele(NS.stk, "stk:unit").txt(params.unit); if (params.store) hdr.ele(NS.stk, "stk:storage").ele(NS.typ, "typ:ids").txt(params.store); if (params.purchasingPrice != null) hdr.ele(NS.stk, "stk:purchasingPrice").txt(String(params.purchasingPrice)); if (params.sellingPrice != null) hdr.ele(NS.stk, "stk:sellingPrice").txt(String(params.sellingPrice)); if (params.sellingPriceVAT != null) hdr.ele(NS.stk, "stk:sellingPriceVAT").txt(String(params.sellingPriceVAT)); if (params.rateVAT) hdr.ele(NS.stk, "stk:rateVAT").txt(params.rateVAT); if (params.quantity != null) hdr.ele(NS.stk, "stk:count").txt(String(params.quantity)); if (params.description) hdr.ele(NS.stk, "stk:description").txt(params.description); if (params.note) hdr.ele(NS.stk, "stk:note").txt(params.note); }); const resp = parseResponse(await client.sendXml(xml)); const result = extractImportResult(resp); return result.success ? ok(`Stock item created. ${result.message}${result.producedId ? ` ID: ${result.producedId}` : ""}`) : err(`Failed to create stock item: ${result.message}`); } catch (e) { return err((e as Error).message); } }, );