{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://developer.linet.app/print/linet.print-1.schema.json",
    "title": "Linet document print template (linet.print/1)",
    "type": "object",
    "additionalProperties": false,
    "required": [
        "spec",
        "blocks"
    ],
    "properties": {
        "spec": {
            "const": "linet.print/1"
        },
        "page": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "size": {
                    "enum": [
                        "A4",
                        "A5",
                        "Letter",
                        "Legal"
                    ]
                },
                "orientation": {
                    "enum": [
                        "portrait",
                        "landscape"
                    ]
                },
                "margins_mm": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                        "top": {
                            "type": "number",
                            "minimum": 0,
                            "maximum": 50
                        },
                        "end": {
                            "type": "number",
                            "minimum": 0,
                            "maximum": 50
                        },
                        "bottom": {
                            "type": "number",
                            "minimum": 0,
                            "maximum": 50
                        },
                        "start": {
                            "type": "number",
                            "minimum": 0,
                            "maximum": 50
                        }
                    }
                }
            }
        },
        "theme": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "font": {
                    "enum": [
                        "sans",
                        "serif"
                    ]
                },
                "font_size_pt": {
                    "type": "number",
                    "minimum": 7,
                    "maximum": 14
                },
                "color_text": {
                    "type": "string",
                    "pattern": "^#[0-9a-fA-F]{6}$"
                },
                "color_accent": {
                    "type": "string",
                    "pattern": "^#[0-9a-fA-F]{6}$"
                },
                "color_muted": {
                    "type": "string",
                    "pattern": "^#[0-9a-fA-F]{6}$"
                },
                "table": {
                    "enum": [
                        "lines",
                        "zebra",
                        "boxed"
                    ]
                },
                "css": {
                    "type": "string",
                    "maxLength": 20000,
                    "description": "Your own CSS, scoped to the print (every selector under .lp-doc). @media print/screen only; no @import, @font-face or @page; url() only as data:image. See the class map."
                }
            }
        },
        "header": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "logo": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                        "show": {
                            "type": "boolean"
                        },
                        "max_height_mm": {
                            "type": "number",
                            "minimum": 5,
                            "maximum": 60
                        },
                        "align": {
                            "enum": [
                                "start",
                                "center",
                                "end"
                            ]
                        }
                    }
                },
                "company": {
                    "type": "array",
                    "items": {
                        "enum": [
                            "name",
                            "vat_number",
                            "address",
                            "phone",
                            "fax",
                            "email",
                            "website",
                            "logo"
                        ]
                    }
                },
                "text": {
                    "oneOf": [
                        {
                            "type": "string",
                            "maxLength": 20000
                        },
                        {
                            "type": "object",
                            "propertyNames": {
                                "pattern": "^[a-z]{2}_[a-z]{2}$"
                            },
                            "additionalProperties": {
                                "type": "string"
                            },
                            "minProperties": 1
                        }
                    ]
                }
            }
        },
        "blocks": {
            "type": "array",
            "maxItems": 60,
            "items": {
                "oneOf": [
                    {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                            "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,31}$"
                            },
                            "show": {
                                "type": "boolean"
                            },
                            "when": {
                                "type": "string",
                                "pattern": "^(has_lines|has_payments|foreign_currency|doctype:\\d+(,\\d+)*)$"
                            },
                            "title": {
                                "oneOf": [
                                    {
                                        "type": "string"
                                    },
                                    {
                                        "type": "object",
                                        "propertyNames": {
                                            "pattern": "^[a-z]{2}_[a-z]{2}$"
                                        },
                                        "additionalProperties": {
                                            "type": "string"
                                        },
                                        "minProperties": 1
                                    }
                                ]
                            },
                            "align": {
                                "enum": [
                                    "start",
                                    "center",
                                    "end"
                                ]
                            },
                            "type": {
                                "const": "title"
                            },
                            "show_copy_label": {
                                "type": "boolean"
                            }
                        },
                        "required": [
                            "id",
                            "type"
                        ]
                    },
                    {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                            "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,31}$"
                            },
                            "show": {
                                "type": "boolean"
                            },
                            "when": {
                                "type": "string",
                                "pattern": "^(has_lines|has_payments|foreign_currency|doctype:\\d+(,\\d+)*)$"
                            },
                            "title": {
                                "oneOf": [
                                    {
                                        "type": "string"
                                    },
                                    {
                                        "type": "object",
                                        "propertyNames": {
                                            "pattern": "^[a-z]{2}_[a-z]{2}$"
                                        },
                                        "additionalProperties": {
                                            "type": "string"
                                        },
                                        "minProperties": 1
                                    }
                                ]
                            },
                            "align": {
                                "enum": [
                                    "start",
                                    "center",
                                    "end"
                                ]
                            },
                            "type": {
                                "const": "doctype_text"
                            },
                            "part": {
                                "enum": [
                                    "header",
                                    "footer"
                                ]
                            }
                        },
                        "required": [
                            "id",
                            "type",
                            "part"
                        ]
                    },
                    {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                            "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,31}$"
                            },
                            "show": {
                                "type": "boolean"
                            },
                            "when": {
                                "type": "string",
                                "pattern": "^(has_lines|has_payments|foreign_currency|doctype:\\d+(,\\d+)*)$"
                            },
                            "title": {
                                "oneOf": [
                                    {
                                        "type": "string"
                                    },
                                    {
                                        "type": "object",
                                        "propertyNames": {
                                            "pattern": "^[a-z]{2}_[a-z]{2}$"
                                        },
                                        "additionalProperties": {
                                            "type": "string"
                                        },
                                        "minProperties": 1
                                    }
                                ]
                            },
                            "align": {
                                "enum": [
                                    "start",
                                    "center",
                                    "end"
                                ]
                            },
                            "type": {
                                "const": "parties"
                            },
                            "fields": {
                                "type": "array",
                                "items": {
                                    "enum": [
                                        "name",
                                        "vat_number",
                                        "address",
                                        "shipping_address",
                                        "phone",
                                        "email",
                                        "contact"
                                    ]
                                }
                            }
                        },
                        "required": [
                            "id",
                            "type"
                        ]
                    },
                    {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                            "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,31}$"
                            },
                            "show": {
                                "type": "boolean"
                            },
                            "when": {
                                "type": "string",
                                "pattern": "^(has_lines|has_payments|foreign_currency|doctype:\\d+(,\\d+)*)$"
                            },
                            "title": {
                                "oneOf": [
                                    {
                                        "type": "string"
                                    },
                                    {
                                        "type": "object",
                                        "propertyNames": {
                                            "pattern": "^[a-z]{2}_[a-z]{2}$"
                                        },
                                        "additionalProperties": {
                                            "type": "string"
                                        },
                                        "minProperties": 1
                                    }
                                ]
                            },
                            "align": {
                                "enum": [
                                    "start",
                                    "center",
                                    "end"
                                ]
                            },
                            "type": {
                                "const": "fields"
                            },
                            "fields": {
                                "type": "array",
                                "items": {
                                    "enum": [
                                        "id",
                                        "type_id",
                                        "type_name",
                                        "number",
                                        "issue_date",
                                        "due_date",
                                        "reference",
                                        "currency",
                                        "currency_rate",
                                        "comments",
                                        "description",
                                        "copy_label",
                                        "allocation_number",
                                        "language",
                                        "status",
                                        "sales_rep",
                                        "account_balance"
                                    ]
                                }
                            }
                        },
                        "required": [
                            "id",
                            "type"
                        ]
                    },
                    {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                            "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,31}$"
                            },
                            "show": {
                                "type": "boolean"
                            },
                            "when": {
                                "type": "string",
                                "pattern": "^(has_lines|has_payments|foreign_currency|doctype:\\d+(,\\d+)*)$"
                            },
                            "title": {
                                "oneOf": [
                                    {
                                        "type": "string"
                                    },
                                    {
                                        "type": "object",
                                        "propertyNames": {
                                            "pattern": "^[a-z]{2}_[a-z]{2}$"
                                        },
                                        "additionalProperties": {
                                            "type": "string"
                                        },
                                        "minProperties": 1
                                    }
                                ]
                            },
                            "align": {
                                "enum": [
                                    "start",
                                    "center",
                                    "end"
                                ]
                            },
                            "type": {
                                "const": "lines"
                            },
                            "columns": {
                                "type": "array",
                                "items": {
                                    "type": "object",
                                    "additionalProperties": false,
                                    "properties": {
                                        "field": {
                                            "oneOf": [
                                                {
                                                    "enum": [
                                                        "line",
                                                        "item_id",
                                                        "sku",
                                                        "manufacturer_sku",
                                                        "manufacturer",
                                                        "picture",
                                                        "barcode",
                                                        "name",
                                                        "description",
                                                        "serial",
                                                        "warehouse",
                                                        "warehouse_address",
                                                        "qty",
                                                        "unit",
                                                        "unit_price",
                                                        "unit_price_with_vat",
                                                        "unit_price_after_discount",
                                                        "discount",
                                                        "line_total",
                                                        "line_total_with_vat",
                                                        "vat_rate",
                                                        "currency"
                                                    ]
                                                },
                                                {
                                                    "type": "string",
                                                    "pattern": "^custom\\.[A-Za-z0-9_]{1,64}$"
                                                }
                                            ]
                                        },
                                        "label": {
                                            "oneOf": [
                                                {
                                                    "type": "string"
                                                },
                                                {
                                                    "type": "object",
                                                    "propertyNames": {
                                                        "pattern": "^[a-z]{2}_[a-z]{2}$"
                                                    },
                                                    "additionalProperties": {
                                                        "type": "string"
                                                    },
                                                    "minProperties": 1
                                                }
                                            ]
                                        },
                                        "width": {
                                            "type": "string",
                                            "pattern": "^(auto|\\d{1,3}(\\.\\d)?(mm|%))$"
                                        },
                                        "align": {
                                            "enum": [
                                                "start",
                                                "center",
                                                "end"
                                            ]
                                        }
                                    },
                                    "required": [
                                        "field"
                                    ]
                                }
                            },
                            "group_by": {
                                "enum": [
                                    null,
                                    "group"
                                ]
                            },
                            "qty_sum": {
                                "type": "boolean"
                            },
                            "descriptions": {
                                "type": "boolean"
                            }
                        },
                        "required": [
                            "id",
                            "type"
                        ]
                    },
                    {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                            "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,31}$"
                            },
                            "show": {
                                "type": "boolean"
                            },
                            "when": {
                                "type": "string",
                                "pattern": "^(has_lines|has_payments|foreign_currency|doctype:\\d+(,\\d+)*)$"
                            },
                            "title": {
                                "oneOf": [
                                    {
                                        "type": "string"
                                    },
                                    {
                                        "type": "object",
                                        "propertyNames": {
                                            "pattern": "^[a-z]{2}_[a-z]{2}$"
                                        },
                                        "additionalProperties": {
                                            "type": "string"
                                        },
                                        "minProperties": 1
                                    }
                                ]
                            },
                            "align": {
                                "enum": [
                                    "start",
                                    "center",
                                    "end"
                                ]
                            },
                            "type": {
                                "const": "payments"
                            },
                            "columns": {
                                "type": "array",
                                "items": {
                                    "type": "object",
                                    "additionalProperties": false,
                                    "properties": {
                                        "field": {
                                            "enum": [
                                                "line",
                                                "method",
                                                "details",
                                                "date",
                                                "amount",
                                                "amount_in_doc_currency",
                                                "currency"
                                            ]
                                        },
                                        "label": {
                                            "oneOf": [
                                                {
                                                    "type": "string"
                                                },
                                                {
                                                    "type": "object",
                                                    "propertyNames": {
                                                        "pattern": "^[a-z]{2}_[a-z]{2}$"
                                                    },
                                                    "additionalProperties": {
                                                        "type": "string"
                                                    },
                                                    "minProperties": 1
                                                }
                                            ]
                                        },
                                        "width": {
                                            "type": "string",
                                            "pattern": "^(auto|\\d{1,3}(\\.\\d)?(mm|%))$"
                                        },
                                        "align": {
                                            "enum": [
                                                "start",
                                                "center",
                                                "end"
                                            ]
                                        }
                                    },
                                    "required": [
                                        "field"
                                    ]
                                }
                            }
                        },
                        "required": [
                            "id",
                            "type"
                        ]
                    },
                    {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                            "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,31}$"
                            },
                            "show": {
                                "type": "boolean"
                            },
                            "when": {
                                "type": "string",
                                "pattern": "^(has_lines|has_payments|foreign_currency|doctype:\\d+(,\\d+)*)$"
                            },
                            "title": {
                                "oneOf": [
                                    {
                                        "type": "string"
                                    },
                                    {
                                        "type": "object",
                                        "propertyNames": {
                                            "pattern": "^[a-z]{2}_[a-z]{2}$"
                                        },
                                        "additionalProperties": {
                                            "type": "string"
                                        },
                                        "minProperties": 1
                                    }
                                ]
                            },
                            "align": {
                                "enum": [
                                    "start",
                                    "center",
                                    "end"
                                ]
                            },
                            "type": {
                                "const": "totals"
                            },
                            "rows": {
                                "type": "array",
                                "items": {
                                    "enum": [
                                        "subtotal",
                                        "discount",
                                        "exempt",
                                        "taxable",
                                        "vat_by_rate",
                                        "vat",
                                        "rounding",
                                        "total",
                                        "local_currency_total",
                                        "qty_sum",
                                        "paid"
                                    ]
                                }
                            }
                        },
                        "required": [
                            "id",
                            "type"
                        ]
                    },
                    {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                            "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,31}$"
                            },
                            "show": {
                                "type": "boolean"
                            },
                            "when": {
                                "type": "string",
                                "pattern": "^(has_lines|has_payments|foreign_currency|doctype:\\d+(,\\d+)*)$"
                            },
                            "title": {
                                "oneOf": [
                                    {
                                        "type": "string"
                                    },
                                    {
                                        "type": "object",
                                        "propertyNames": {
                                            "pattern": "^[a-z]{2}_[a-z]{2}$"
                                        },
                                        "additionalProperties": {
                                            "type": "string"
                                        },
                                        "minProperties": 1
                                    }
                                ]
                            },
                            "align": {
                                "enum": [
                                    "start",
                                    "center",
                                    "end"
                                ]
                            },
                            "type": {
                                "const": "custom_fields"
                            },
                            "fields": {
                                "oneOf": [
                                    {
                                        "const": "all"
                                    },
                                    {
                                        "type": "array",
                                        "items": {
                                            "type": "string",
                                            "pattern": "^[A-Za-z0-9_]{1,64}$"
                                        }
                                    }
                                ]
                            }
                        },
                        "required": [
                            "id",
                            "type"
                        ]
                    },
                    {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                            "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,31}$"
                            },
                            "show": {
                                "type": "boolean"
                            },
                            "when": {
                                "type": "string",
                                "pattern": "^(has_lines|has_payments|foreign_currency|doctype:\\d+(,\\d+)*)$"
                            },
                            "title": {
                                "oneOf": [
                                    {
                                        "type": "string"
                                    },
                                    {
                                        "type": "object",
                                        "propertyNames": {
                                            "pattern": "^[a-z]{2}_[a-z]{2}$"
                                        },
                                        "additionalProperties": {
                                            "type": "string"
                                        },
                                        "minProperties": 1
                                    }
                                ]
                            },
                            "align": {
                                "enum": [
                                    "start",
                                    "center",
                                    "end"
                                ]
                            },
                            "type": {
                                "const": "text"
                            },
                            "text": {
                                "oneOf": [
                                    {
                                        "type": "string",
                                        "maxLength": 20000
                                    },
                                    {
                                        "type": "object",
                                        "propertyNames": {
                                            "pattern": "^[a-z]{2}_[a-z]{2}$"
                                        },
                                        "additionalProperties": {
                                            "type": "string"
                                        },
                                        "minProperties": 1
                                    }
                                ]
                            }
                        },
                        "required": [
                            "id",
                            "type",
                            "text"
                        ]
                    },
                    {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                            "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,31}$"
                            },
                            "show": {
                                "type": "boolean"
                            },
                            "when": {
                                "type": "string",
                                "pattern": "^(has_lines|has_payments|foreign_currency|doctype:\\d+(,\\d+)*)$"
                            },
                            "title": {
                                "oneOf": [
                                    {
                                        "type": "string"
                                    },
                                    {
                                        "type": "object",
                                        "propertyNames": {
                                            "pattern": "^[a-z]{2}_[a-z]{2}$"
                                        },
                                        "additionalProperties": {
                                            "type": "string"
                                        },
                                        "minProperties": 1
                                    }
                                ]
                            },
                            "align": {
                                "enum": [
                                    "start",
                                    "center",
                                    "end"
                                ]
                            },
                            "type": {
                                "const": "html"
                            },
                            "html": {
                                "oneOf": [
                                    {
                                        "type": "string",
                                        "maxLength": 20000
                                    },
                                    {
                                        "type": "object",
                                        "propertyNames": {
                                            "pattern": "^[a-z]{2}_[a-z]{2}$"
                                        },
                                        "additionalProperties": {
                                            "type": "string"
                                        },
                                        "minProperties": 1
                                    }
                                ]
                            }
                        },
                        "required": [
                            "id",
                            "type",
                            "html"
                        ]
                    },
                    {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                            "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,31}$"
                            },
                            "show": {
                                "type": "boolean"
                            },
                            "when": {
                                "type": "string",
                                "pattern": "^(has_lines|has_payments|foreign_currency|doctype:\\d+(,\\d+)*)$"
                            },
                            "title": {
                                "oneOf": [
                                    {
                                        "type": "string"
                                    },
                                    {
                                        "type": "object",
                                        "propertyNames": {
                                            "pattern": "^[a-z]{2}_[a-z]{2}$"
                                        },
                                        "additionalProperties": {
                                            "type": "string"
                                        },
                                        "minProperties": 1
                                    }
                                ]
                            },
                            "align": {
                                "enum": [
                                    "start",
                                    "center",
                                    "end"
                                ]
                            },
                            "type": {
                                "const": "code"
                            },
                            "kind": {
                                "enum": [
                                    "tax_qr",
                                    "pay_link_qr",
                                    "barcode",
                                    "code39"
                                ]
                            }
                        },
                        "required": [
                            "id",
                            "type",
                            "kind"
                        ]
                    },
                    {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                            "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,31}$"
                            },
                            "show": {
                                "type": "boolean"
                            },
                            "when": {
                                "type": "string",
                                "pattern": "^(has_lines|has_payments|foreign_currency|doctype:\\d+(,\\d+)*)$"
                            },
                            "title": {
                                "oneOf": [
                                    {
                                        "type": "string"
                                    },
                                    {
                                        "type": "object",
                                        "propertyNames": {
                                            "pattern": "^[a-z]{2}_[a-z]{2}$"
                                        },
                                        "additionalProperties": {
                                            "type": "string"
                                        },
                                        "minProperties": 1
                                    }
                                ]
                            },
                            "align": {
                                "enum": [
                                    "start",
                                    "center",
                                    "end"
                                ]
                            },
                            "type": {
                                "const": "signature"
                            }
                        },
                        "required": [
                            "id",
                            "type"
                        ]
                    },
                    {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                            "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,31}$"
                            },
                            "show": {
                                "type": "boolean"
                            },
                            "when": {
                                "type": "string",
                                "pattern": "^(has_lines|has_payments|foreign_currency|doctype:\\d+(,\\d+)*)$"
                            },
                            "title": {
                                "oneOf": [
                                    {
                                        "type": "string"
                                    },
                                    {
                                        "type": "object",
                                        "propertyNames": {
                                            "pattern": "^[a-z]{2}_[a-z]{2}$"
                                        },
                                        "additionalProperties": {
                                            "type": "string"
                                        },
                                        "minProperties": 1
                                    }
                                ]
                            },
                            "align": {
                                "enum": [
                                    "start",
                                    "center",
                                    "end"
                                ]
                            },
                            "type": {
                                "const": "spacer"
                            },
                            "height_mm": {
                                "type": "number",
                                "minimum": 1,
                                "maximum": 100
                            }
                        },
                        "required": [
                            "id",
                            "type"
                        ]
                    },
                    {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                            "id": {
                                "type": "string",
                                "pattern": "^[a-z][a-z0-9_]{0,31}$"
                            },
                            "show": {
                                "type": "boolean"
                            },
                            "when": {
                                "type": "string",
                                "pattern": "^(has_lines|has_payments|foreign_currency|doctype:\\d+(,\\d+)*)$"
                            },
                            "title": {
                                "oneOf": [
                                    {
                                        "type": "string"
                                    },
                                    {
                                        "type": "object",
                                        "propertyNames": {
                                            "pattern": "^[a-z]{2}_[a-z]{2}$"
                                        },
                                        "additionalProperties": {
                                            "type": "string"
                                        },
                                        "minProperties": 1
                                    }
                                ]
                            },
                            "align": {
                                "enum": [
                                    "start",
                                    "center",
                                    "end"
                                ]
                            },
                            "type": {
                                "const": "page_break"
                            }
                        },
                        "required": [
                            "id",
                            "type"
                        ]
                    }
                ]
            }
        },
        "footer": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "text": {
                    "oneOf": [
                        {
                            "type": "string",
                            "maxLength": 20000
                        },
                        {
                            "type": "object",
                            "propertyNames": {
                                "pattern": "^[a-z]{2}_[a-z]{2}$"
                            },
                            "additionalProperties": {
                                "type": "string"
                            },
                            "minProperties": 1
                        }
                    ]
                },
                "page_numbers": {
                    "type": "boolean"
                },
                "show_on": {
                    "enum": [
                        "last",
                        "every"
                    ]
                }
            }
        }
    }
}
