pohoda_create_voucher
Create cash vouchers (receipts or expenses) in POHODA accounting software. Specify voucher type, date, and optional details like cash register, partner information, and line items.
Instructions
Create a cash voucher (receipt or expense) in POHODA. Requires voucherType and date. Optional: cashRegister, text, symbols, partner details, note, and line items.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| voucherType | Yes | Voucher type: receipt or expense (required) | |
| cashRegister | No | Cash register identifier | |
| date | Yes | Document date (DD.MM.YYYY or YYYY-MM-DD) | |
| text | No | Document text/description | |
| symVar | No | Variable symbol | |
| symConst | No | Constant symbol | |
| partnerName | No | Partner company name | |
| partnerStreet | No | Partner street | |
| partnerCity | No | Partner city | |
| partnerZip | No | Partner ZIP code | |
| partnerIco | No | Partner IČO | |
| note | No | Note | |
| items | No | Line items: text, quantity, unitPrice, rateVAT (none|low|high) |
Implementation Reference
- src/tools/vouchers.ts:71-120 (handler)The handler function that creates the voucher by building the XML request and parsing the result.
async (params) => { try { const xml = buildImportDoc({ ico: client.ico }, (item) => { const vch = item.ele(NS.vch, "vch:voucher").att("version", "2.0"); const header = vch.ele(NS.vch, "vch:voucherHeader"); header.ele(NS.vch, "vch:voucherType").txt(params.voucherType); if (params.cashRegister) { header.ele(NS.vch, "vch:cashRegister").ele(NS.typ, "typ:ids").txt(params.cashRegister); } header.ele(NS.vch, "vch:date").txt(toIsoDate(params.date)); if (params.text) header.ele(NS.vch, "vch:text").txt(params.text); if (params.symVar) header.ele(NS.vch, "vch:symVar").txt(params.symVar); if (params.symConst) header.ele(NS.vch, "vch:symConst").txt(params.symConst); const hasPartner = params.partnerName ?? params.partnerStreet ?? params.partnerCity ?? params.partnerZip ?? params.partnerIco; if (hasPartner) { const identity = header.ele(NS.vch, "vch:partnerIdentity"); const typAddr = identity.ele(NS.typ, "typ:address"); if (params.partnerName) typAddr.ele(NS.typ, "typ:name").txt(params.partnerName); if (params.partnerStreet) typAddr.ele(NS.typ, "typ:street").txt(params.partnerStreet); if (params.partnerCity) typAddr.ele(NS.typ, "typ:city").txt(params.partnerCity); if (params.partnerZip) typAddr.ele(NS.typ, "typ:zip").txt(params.partnerZip); if (params.partnerIco) typAddr.ele(NS.typ, "typ:ico").txt(params.partnerIco); } if (params.note) header.ele(NS.vch, "vch:note").txt(params.note); if (params.items && params.items.length > 0) { const detail = vch.ele(NS.vch, "vch:voucherDetail"); for (const it of params.items) { const vchItem = detail.ele(NS.vch, "vch:voucherItem"); vchItem.ele(NS.vch, "vch:text").txt(it.text); vchItem.ele(NS.vch, "vch:quantity").txt(String(it.quantity)); vchItem.ele(NS.vch, "vch:rateVAT").txt(it.rateVAT); vchItem .ele(NS.vch, "vch:homeCurrency") .ele(NS.typ, "typ:unitPrice") .txt(String(it.unitPrice)); } } }); const response = await client.sendXml(xml); const result = extractImportResult(parseResponse(response)); return result.success ? ok( `Voucher created successfully.${result.producedId != null ? ` ID: ${result.producedId}` : ""} ${result.message}` ) : err(result.message); - src/tools/vouchers.ts:53-70 (schema)The input validation schema for the 'pohoda_create_voucher' tool.
{ voucherType: voucherTypeEnum.describe("Voucher type: receipt or expense (required)"), cashRegister: z.string().optional().describe("Cash register identifier"), date: z.string().describe("Document date (DD.MM.YYYY or YYYY-MM-DD)"), text: z.string().optional().describe("Document text/description"), symVar: z.string().optional().describe("Variable symbol"), symConst: z.string().optional().describe("Constant symbol"), partnerName: z.string().optional().describe("Partner company name"), partnerStreet: z.string().optional().describe("Partner street"), partnerCity: z.string().optional().describe("Partner city"), partnerZip: z.string().optional().describe("Partner ZIP code"), partnerIco: z.string().optional().describe("Partner IČO"), note: z.string().optional().describe("Note"), items: z .array(voucherItemSchema) .optional() .describe("Line items: text, quantity, unitPrice, rateVAT (none|low|high)"), }, - src/tools/vouchers.ts:50-121 (registration)The registration of the 'pohoda_create_voucher' tool within the server.
server.tool( "pohoda_create_voucher", "Create a cash voucher (receipt or expense) in POHODA. Requires voucherType and date. Optional: cashRegister, text, symbols, partner details, note, and line items.", { voucherType: voucherTypeEnum.describe("Voucher type: receipt or expense (required)"), cashRegister: z.string().optional().describe("Cash register identifier"), date: z.string().describe("Document date (DD.MM.YYYY or YYYY-MM-DD)"), text: z.string().optional().describe("Document text/description"), symVar: z.string().optional().describe("Variable symbol"), symConst: z.string().optional().describe("Constant symbol"), partnerName: z.string().optional().describe("Partner company name"), partnerStreet: z.string().optional().describe("Partner street"), partnerCity: z.string().optional().describe("Partner city"), partnerZip: z.string().optional().describe("Partner ZIP code"), partnerIco: z.string().optional().describe("Partner IČO"), note: z.string().optional().describe("Note"), items: z .array(voucherItemSchema) .optional() .describe("Line items: text, quantity, unitPrice, rateVAT (none|low|high)"), }, async (params) => { try { const xml = buildImportDoc({ ico: client.ico }, (item) => { const vch = item.ele(NS.vch, "vch:voucher").att("version", "2.0"); const header = vch.ele(NS.vch, "vch:voucherHeader"); header.ele(NS.vch, "vch:voucherType").txt(params.voucherType); if (params.cashRegister) { header.ele(NS.vch, "vch:cashRegister").ele(NS.typ, "typ:ids").txt(params.cashRegister); } header.ele(NS.vch, "vch:date").txt(toIsoDate(params.date)); if (params.text) header.ele(NS.vch, "vch:text").txt(params.text); if (params.symVar) header.ele(NS.vch, "vch:symVar").txt(params.symVar); if (params.symConst) header.ele(NS.vch, "vch:symConst").txt(params.symConst); const hasPartner = params.partnerName ?? params.partnerStreet ?? params.partnerCity ?? params.partnerZip ?? params.partnerIco; if (hasPartner) { const identity = header.ele(NS.vch, "vch:partnerIdentity"); const typAddr = identity.ele(NS.typ, "typ:address"); if (params.partnerName) typAddr.ele(NS.typ, "typ:name").txt(params.partnerName); if (params.partnerStreet) typAddr.ele(NS.typ, "typ:street").txt(params.partnerStreet); if (params.partnerCity) typAddr.ele(NS.typ, "typ:city").txt(params.partnerCity); if (params.partnerZip) typAddr.ele(NS.typ, "typ:zip").txt(params.partnerZip); if (params.partnerIco) typAddr.ele(NS.typ, "typ:ico").txt(params.partnerIco); } if (params.note) header.ele(NS.vch, "vch:note").txt(params.note); if (params.items && params.items.length > 0) { const detail = vch.ele(NS.vch, "vch:voucherDetail"); for (const it of params.items) { const vchItem = detail.ele(NS.vch, "vch:voucherItem"); vchItem.ele(NS.vch, "vch:text").txt(it.text); vchItem.ele(NS.vch, "vch:quantity").txt(String(it.quantity)); vchItem.ele(NS.vch, "vch:rateVAT").txt(it.rateVAT); vchItem .ele(NS.vch, "vch:homeCurrency") .ele(NS.typ, "typ:unitPrice") .txt(String(it.unitPrice)); } } }); const response = await client.sendXml(xml); const result = extractImportResult(parseResponse(response)); return result.success ? ok( `Voucher created successfully.${result.producedId != null ? ` ID: ${result.producedId}` : ""} ${result.message}` ) : err(result.message); } catch (e) {