pohoda_create_enquiry
Create new enquiries in POHODA accounting software by specifying enquiry type and date, with optional details like partner information, description text, and line items.
Instructions
Create a new enquiry in POHODA. Requires enquiryType and date. Optional: text, partner details, note, and line items.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| enquiryType | Yes | Enquiry type: issuedEnquiry or receivedEnquiry (required) | |
| date | Yes | Enquiry date (DD.MM.YYYY or YYYY-MM-DD) | |
| text | No | Enquiry text/description | |
| 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), optional unit |
Implementation Reference
- src/tools/enquiries.ts:62-130 (handler)Implementation of the pohoda_create_enquiry tool. It builds the XML import document for an enquiry using the provided parameters and sends it to the POHODA client.
server.tool( "pohoda_create_enquiry", "Create a new enquiry in POHODA. Requires enquiryType and date. Optional: text, partner details, note, and line items.", { enquiryType: enquiryTypeEnum.describe("Enquiry type: issuedEnquiry or receivedEnquiry (required)"), date: z.string().describe("Enquiry date (DD.MM.YYYY or YYYY-MM-DD)"), text: z.string().optional().describe("Enquiry text/description"), 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(enquiryItemSchema) .optional() .describe("Line items: text, quantity, unitPrice, rateVAT (none|low|high), optional unit"), }, async (params) => { try { const xml = buildImportDoc({ ico: client.ico }, (item) => { const enq = item.ele(NS.enq, "enq:enquiry").att("version", "2.0"); const header = enq.ele(NS.enq, "enq:enquiryHeader"); header.ele(NS.enq, "enq:enquiryType").txt(params.enquiryType); header.ele(NS.enq, "enq:date").txt(toIsoDate(params.date)); if (params.text) header.ele(NS.enq, "enq:text").txt(params.text); const hasPartner = params.partnerName ?? params.partnerStreet ?? params.partnerCity ?? params.partnerZip ?? params.partnerIco; if (hasPartner) { const identity = header.ele(NS.enq, "enq: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.enq, "enq:note").txt(params.note); if (params.items && params.items.length > 0) { const detail = enq.ele(NS.enq, "enq:enquiryDetail"); for (const it of params.items) { const enqItem = detail.ele(NS.enq, "enq:enquiryItem"); enqItem.ele(NS.enq, "enq:text").txt(it.text); enqItem.ele(NS.enq, "enq:quantity").txt(String(it.quantity)); enqItem.ele(NS.enq, "enq:rateVAT").txt(it.rateVAT); enqItem .ele(NS.enq, "enq:homeCurrency") .ele(NS.typ, "typ:unitPrice") .txt(String(it.unitPrice)); if (it.unit) enqItem.ele(NS.enq, "enq:unit").txt(it.unit); } } }); const response = await client.sendXml(xml); const result = extractImportResult(parseResponse(response)); return result.success ? ok( `Enquiry created successfully.${result.producedId != null ? ` ID: ${result.producedId}` : ""} ${result.message}` ) : err(result.message); } catch (e) { return err((e as Error).message); } } );