pohoda_update_stock
Modify inventory item details in POHODA accounting software. Update product names, prices, units, VAT rates, and notes to maintain accurate stock records.
Instructions
Update an existing stock/inventory item in POHODA
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | Stock item ID to update | |
| code | No | Stock code to identify item (alternative to id) | |
| name | No | New name | |
| unit | No | New unit | |
| purchasingPrice | No | New purchasing price | |
| sellingPrice | No | New selling price | |
| rateVAT | No | New VAT rate | |
| note | No | New note |
Implementation Reference
- src/tools/stock.ts:95-132 (handler)Handler and registration for the 'pohoda_update_stock' tool. It constructs an XML request using 'buildImportDoc' to send an update command to the Pohoda client based on provided stock item parameters.
server.tool( "pohoda_update_stock", "Update an existing stock/inventory item in POHODA", { id: z.number().optional().describe("Stock item ID to update"), code: z.string().optional().describe("Stock code to identify item (alternative to id)"), name: z.string().optional().describe("New name"), unit: z.string().optional().describe("New unit"), purchasingPrice: z.number().optional().describe("New purchasing price"), sellingPrice: z.number().optional().describe("New selling price"), rateVAT: z.enum(["none", "low", "high"]).optional().describe("New VAT rate"), note: z.string().optional().describe("New note"), }, async (params) => { try { if (!params.id && !params.code) return err("Either id or code is required to identify the stock item."); const xml = buildImportDoc({ ico: client.ico }, (item) => { const stk = item.ele(NS.stk, "stk:stock").att("version", "2.0"); const act = stk.ele(NS.stk, "stk:actionType").ele(NS.stk, "stk:update"); const ftr = act.ele(NS.ftr, "ftr:filter"); if (params.id != null) ftr.ele(NS.ftr, "ftr:id").txt(String(params.id)); else if (params.code) ftr.ele(NS.ftr, "ftr:code").txt(params.code); const hdr = stk.ele(NS.stk, "stk:stockHeader"); if (params.name) hdr.ele(NS.stk, "stk:name").txt(params.name); if (params.unit) hdr.ele(NS.stk, "stk:unit").txt(params.unit); 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.rateVAT) hdr.ele(NS.stk, "stk:rateVAT").txt(params.rateVAT); 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 updated. ${result.message}`) : err(`Failed: ${result.message}`); } catch (e) { return err((e as Error).message); } }, );