Skip to content

documentLine

Represents a single line item within a document (customerDocument or supplierDocument). Maps to the items array in a document.


Schema

Field Type Required Read-only Description
id integer — ✓ Internal line ID
item_type string — — Line type: P, A, S or T. See Line types
item_code string (max 15) — — Product/article code
description string (1–60) Yes — Line description. Printed only on S and T lines; on article lines the article's description is used
description_2 string (max 60) — — Additional description line
qty number (double, ≥ 0) Yes — Quantity
unit_of_measurement string (max 15) — — Unit of measurement (e.g., UN, KG, HR)
number_of_packages integer — — Number of packages
unit_price number (double, ≥ 0) Yes — Unit price
discount number (float, 0–100) — — Line discount percentage
vat number (float, 0–100) — — VAT rate percentage
vat_included integer — — 0: unit_price excludes VAT. Any other value: unit_price includes VAT (stored and returned as 1). Not a boolean
vat_exemption_code string (max 3) — — VAT exemption code (SAF-T M01–M99) for a line with vat = 0. Accepted on input; otherwise taken from the article or family configuration
vat_exemption_reason string (max 40) — — Exemption reason text matching vat_exemption_code. Accepted on input; optional, because Gestix fills it from the code
bar_code string (max 40) — ✓ Bar code copied from the linked article at the time the line was created.
serial_numbers array of serialNumber — — Serial-number input or batch / lot allocations for articles with the corresponding tracking mode.

Example

{
  "item_code": "WIDGET-A",
  "description": "Widget Type A — Standard",
  "qty": 1,
  "unit_of_measurement": "UN",
  "unit_price": 25.00,
  "discount": 5.0,
  "vat": 0.0,
  "vat_included": 0,
  "vat_exemption_code": "M10",
  "vat_exemption_reason": "Regime de IVA de caixa",
  "bar_code": "5601234567890",
  "serial_numbers": [
    { "serial_number": "SN-2024-001234" }
  ]
}

Line types

item_type Line item_code Printed description
P, or absent Article (product) Required The article's description; your description is ignored
A Article; treated as P Required The article's description
S Service An existing service code. An unknown code creates the service Your description
T Free text, no article Omit, or send "" Your description (required)

To print your own text on a line linked to a generic code, send item_type "S" with a service code. With P or no type, the article's description replaces yours.

Free-text lines (T) before 7.2.03

Before 7.2.03, a T line loses vat_exemption_code, so a 0 % T line is refused with 400 (no exemption reason). Use an S line with a generic service code and your own description instead. From 7.2.03, T lines keep vat_exemption_code (for example M07), and a T line with an empty description is refused with 400.

Free-text line with 0 % VAT and exemption M07 (7.2.03 and later):

{
  "item_type": "T",
  "description": "Event sponsorship - Silver",
  "qty": 1,
  "unit_price": 1000.00,
  "vat": 0,
  "vat_included": 0,
  "vat_exemption_code": "M07"
}

Receipt lines that settle a document have item_type D; see Receipts.


Numbers

Send numeric fields (qty, unit_price, discount, vat, ...) as JSON numbers (450.00) or as strings with a dot as the decimal point ("450.00"). Never send a decimal comma or thousands separators.

  • Before 7.2.03, a comma is dropped silently: "450,00" is stored as 45000.
  • From 7.2.03, a value with a decimal comma ("4,50") is refused with 400 (invalid number '4,50' (use a dot as the decimal point ...)), and nothing is stored. A line with an invalid value or an unknown field refuses the whole document.

Batch / lot allocations

For an existing batch-tracked article, keep the serial_numbers container and send one object per lot allocation:

Input field Type Required Meaning
serial_number string (1–20 bytes, non-blank) Yes Lot identifier
qty positive decimal (up to 6 decimal places) Yes Quantity allocated to this lot; not available_qty
production_date string (YYYY-MM-DD) For new lots, unless production dates are disabled Production / manufacture date
expiration_date string (YYYY-MM-DD) For new lots Expiration date

Example item within a document's items array, allocating a logical quantity of 10 across two lots:

{
  "item_code": "WIDGET-LOT",
  "description": "Lot-tracked widget",
  "qty": 10,
  "unit_price": 9.99,
  "vat": 23.0,
  "serial_numbers": [
    {
      "serial_number": "LOT-A",
      "qty": 6,
      "production_date": "2026-09-01",
      "expiration_date": "2027-09-01"
    },
    {
      "serial_number": "LOT-B",
      "qty": 4,
      "production_date": "2026-09-02",
      "expiration_date": "2027-09-02"
    }
  ]
}

Validation and storage behavior:

  • Allocated quantities must be positive, have at most six decimal places, and sum exactly to the parent item's qty. Nested qty requires an existing batch-tracked article.
  • Dates must be real calendar dates in YYYY-MM-DD format. For existing lots, omitted dates reuse the stored dates; supplied dates must match them.
  • New lots require expiration_date and also production_date unless the Gestix setting usr_batch_no_production is enabled.
  • Stock exits require the lot to exist with sufficient available quantity in the source warehouse and pass normal expiry validation.
  • Combine repeated allocations for the same article and lot within the document. Duplicate lots are rejected both within one item and across items for that article.
  • Each allocation becomes a separate stored document row, preserving the item's prices, taxes and order relationships. GET returns these rows separately rather than reconstructing the original logical item.
  • Stock and lot balances change through normal document processing. The allocation input does not bypass that processing.

Existing serial-number input remains unchanged: send serial identifiers without nested qty, with one serial entry per unit. On document GET responses, lot records also include qty, the allocated movement quantity. See serialNumber for the other returned serial / lot fields.


Notes

  • description is required; item_code is optional but recommended to link back to a product record in /articles.
  • When vat_included is 0 or absent, VAT is calculated on top of unit_price. Any other value (for example 1) means unit_price already includes VAT; the stored value is 1. With vat = 0 both give the same amounts.
  • vat_exemption_code and vat_exemption_reason apply to lines with vat = 0 and are required by the SAF-T (PT) audit file. Send vat_exemption_code on input, or let Gestix take it from the article or family configuration.
  • From 7.2.03, on receipt lines that settle a document (item_type D), taxable_amount is the amount paid (before, it showed qty × unit_price).
  • serial_numbers is only used for articles flagged with track_serial_number or track_batch_number. See article for the tracking flags.

Used By