Skip to main content
Glama

ERP: Record a sale (write-off, invoice, payment)

erp_record_sale
Destructive

Record a SALE that already happened — in the shop, by hand, from stock — in ONE confirmation card: the sales order, the stock written off for each item, an invoice linked to it and the payment. Use it for «відміть / зафіксуй продаж», «продав …», «отметь продажу», «я продал …», a list of items with prices and a buyer. NOT invoice_create (that only bills, it does not write stock off) and NOT erp_stock_batch (that only moves stock). One call with EVERY line. 'client' = the buyer's name as said (found among leads / clients; nobody of that name → a NEW client, the card says so); several matches are refused with candidates — ask, then pass lead_id / organization_id. Each line: 'item' as the person wrote it (name words, number or barcode; «B12(G&G)» is fine), 'quantity' (default 1), 'price' = what ONE unit was sold for, after the discount («1060-%=980» → price 980, list_price 1060); without 'price' the catalog price is used. 'total' = the total the person stated, if any (checked against the lines). 'payment': paid (paid in full — «оплатила», «оплачено»), partial (+ paid_amount) or unpaid (will pay later); 'method' cash / card / transfer if said; 'date' YYYY-MM-DD only if not today. Items not in the catalog, several matches or not enough stock refuse the proposal with the reason — tell the person, never write stock off blindly. A sale already recorded with the same buyer, items and prices is refused (no duplicates): when the person later says the buyer paid, mark THAT sale's invoice paid (invoice_mark_paid). Proposed write — one card, one «Так». CONFIRMATION: this tool is PROPOSED, never performed directly. You get status='confirmation_required' with an action_id and a plan_token, and the write happens only after confirm_action.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "lines": "<lines>",
      "payment": "<payment>"
    },
    "name": "erp_record_sale"
  }
}

Input Schema

NameRequiredDescriptionDefault
dateNo
noteNo
linesYes
totalNoThe total the person stated.
clientNoThe buyer's name as the person said it.
methodNo
lead_idNo
paymentYes
currencyNo
again_refNoOnly for a SECOND identical sale the person confirmed: any new word.
warehouseNo
new_clientNoThe person said it is a NEW client with this exact name.
paid_amountNo
organization_idNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Goes well beyond the annotations by disclosing the two-phase confirmation protocol (status='confirmation_required', action_id, plan_token, write only after confirm_action), duplicate-sale refusal, unknown-client and multi-match refusal behavior, and insufficient-stock refusal. This is exactly the mutation/irreversibility context an agent needs and annotations alone (readOnlyHint=false, destructiveHint=true) could not supply.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with purpose, then constraints, then the confirmation protocol; nearly every clause carries new information, and the worked examples («1060-%=980» → price 980) are dense but valuable. It reads as one long semicolon-chained block, so scanning is harder than it needs to be, but the length is defensible for a 14-parameter multi-entity mutation.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive, multi-entity write with no output schema and 14 parameters, the description covers confirmation flow, dedupe, client resolution, and all major failure modes — enough for correct invocation. It falls short only on peripheral fields (currency, warehouse, note, again_ref) and on whether the multi-entity write is atomic when one line fails validation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With only 29% schema description coverage across 14 params, the description does heavy lifting: it defines 'client' resolution, per-line 'item' matching (name words, number, barcode), 'quantity' default, 'price' vs 'list_price' with a worked discount example, 'total' cross-checking, and the three payment states plus 'date'. Gaps remain — 'currency', 'warehouse', 'note', and especially 'again_ref' (the escape hatch for the described duplicate refusal) are never explained in prose.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb+resource ("Record a SALE that already happened") and immediately decomposes it into the three artifacts created: sales order, stock write-off, and linked invoice + payment. It explicitly names the siblings it is not (invoice_create, erp_stock_batch) so an agent can discriminate without opening other schemas.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit when-to-use triggers (multi-language phrases «відміть / зафіксуй продаж», «продав …»), explicit when-not-to (invoice_create only bills, erp_stock_batch only moves stock), and routes the payment-later case to invoice_mark_paid. The alternative selection logic is fully spelled out rather than inferred.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources