hdm-am 0.3.0

Client for the Armenian fiscal cash register (HDM) protocol per the State Revenue Committee spec
Documentation
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "ReturnableReceiptResponse",
  "description": "Op 6 response: the looked-up receipt's full fiscal contents.\n\n**Unverified against hardware.** On the available N950 test stand op 6 always returns vendor\ncode 503 with an empty body — the firmware never exposes the server-side `Receipt_ID` this\nlookup keys on (op 4 omits the `qr` field entirely), so the request can't be satisfied. This\nstruct is therefore modelled purely from spec §4.5.6, which is internally inconsistent: its\nfield table and the Code Block 7 example disagree (the example adds `type`, omits\n`rseq`/`subType`/`refcrn`, and uses JSON numbers where the table says String). Fields follow the\nCode Block 7 example — whose numeric types match what real firmware sends for op 4 — and are all\noptional/lenient. The raw decrypted payload is logged at TRACE so the true shape can be\nconfirmed once a device ever returns one.",
  "type": "object",
  "properties": {
    "rseq": {
      "description": "Receipt sequence number.",
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "default": null
    },
    "cid": {
      "description": "Cashier ID (`Գանձապահի ID`). The English spec.md mislabels this \"Customer ID\".",
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "default": null
    },
    "time": {
      "description": "Receipt registration/print time (ms since epoch, Greenwich).",
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "default": null
    },
    "type": {
      "description": "Transaction type as the Code Block 7 example's `type` field (mirrors `sale_type`).",
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "default": null
    },
    "saleType": {
      "description": "Sale type: `0` sale, `2` return, `3` prepayment.",
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "default": null
    },
    "subType": {
      "description": "Receipt sub-type: `1` simple, `2` itemised. (In the field table only; absent from the example.)",
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "default": null
    },
    "did": {
      "description": "Department of a simple receipt.",
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "default": null
    },
    "ta": {
      "description": "Total amount.",
      "type": [
        "number",
        "null"
      ],
      "format": "double",
      "default": null
    },
    "cash": {
      "description": "Cash paid.",
      "type": [
        "number",
        "null"
      ],
      "format": "double",
      "default": null
    },
    "card": {
      "description": "Card (cashless) paid.",
      "type": [
        "number",
        "null"
      ],
      "format": "double",
      "default": null
    },
    "ppa": {
      "description": "Partial-payment amount.",
      "type": [
        "number",
        "null"
      ],
      "format": "double",
      "default": null
    },
    "ppu": {
      "description": "Used prepayment amount.",
      "type": [
        "number",
        "null"
      ],
      "format": "double",
      "default": null
    },
    "pTin": {
      "description": "Buyer TIN (8 digits) for a B2B receipt, or `null`.",
      "type": [
        "string",
        "null"
      ],
      "default": null
    },
    "ref": {
      "description": "When this receipt is itself a return, the number of the receipt it returned (`ref`).",
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "default": null
    },
    "refcrn": {
      "description": "crn of the HDM that printed the returned receipt (set only for return-type receipts).",
      "type": [
        "string",
        "null"
      ],
      "default": null
    },
    "eMarks": {
      "description": "eMark codes of marked goods on the receipt.",
      "type": "array",
      "items": {
        "type": "string"
      },
      "default": []
    },
    "totals": {
      "description": "Line items (empty for simple/prepayment receipts, where the spec sends `null`).",
      "type": "array",
      "items": {
        "$ref": "#/$defs/ReturnableReceiptItem"
      },
      "default": []
    }
  },
  "$defs": {
    "ReturnableReceiptItem": {
      "description": "A single line item in a [`ReturnableReceiptResponse`] (`totals[]`). All fields optional/lenient\nfor the same reason as the parent — modelled from spec §4.5.6 Code Block 7, unverified.",
      "type": "object",
      "properties": {
        "gc": {
          "description": "Product code (`gc`).",
          "type": [
            "string",
            "null"
          ],
          "default": null
        },
        "gn": {
          "description": "Product name (`gn`).",
          "type": [
            "string",
            "null"
          ],
          "default": null
        },
        "qty": {
          "description": "Quantity (`qty`).",
          "type": [
            "number",
            "null"
          ],
          "format": "double",
          "default": null
        },
        "p": {
          "description": "Unit price (`p`).",
          "type": [
            "number",
            "null"
          ],
          "format": "double",
          "default": null
        },
        "mu": {
          "description": "Unit of measure (`mu`).",
          "type": [
            "string",
            "null"
          ],
          "default": null
        },
        "rpid": {
          "description": "Row sequence number (`rpid`) — the handle used for per-item partial returns in op 10.",
          "type": [
            "integer",
            "null"
          ],
          "format": "int64",
          "default": null
        },
        "dsc": {
          "description": "Primary discount (`dsc`).",
          "type": [
            "number",
            "null"
          ],
          "format": "double",
          "default": null
        },
        "adsc": {
          "description": "Proportional secondary discount (`adsc`).",
          "type": [
            "number",
            "null"
          ],
          "format": "double",
          "default": null
        },
        "dsct": {
          "description": "Discount type (`dsct`).",
          "type": [
            "integer",
            "null"
          ],
          "format": "int64",
          "default": null
        },
        "did": {
          "description": "Department (`did`).",
          "type": [
            "integer",
            "null"
          ],
          "format": "int64",
          "default": null
        },
        "dt": {
          "description": "Department VAT amount (`dt`).",
          "type": [
            "number",
            "null"
          ],
          "format": "double",
          "default": null
        },
        "dtm": {
          "description": "Department tax regime (`dtm`).",
          "type": [
            "integer",
            "null"
          ],
          "format": "int64",
          "default": null
        },
        "t": {
          "description": "Line total excluding VAT (`t`).",
          "type": [
            "number",
            "null"
          ],
          "format": "double",
          "default": null
        },
        "tt": {
          "description": "Line total including VAT (`tt`).",
          "type": [
            "number",
            "null"
          ],
          "format": "double",
          "default": null
        }
      }
    }
  }
}