{
  "template": {
    "ir": "0.1.0",
    "meta": {
      "name": "zatca-invoice",
      "version": "1.0.0"
    },
    "page": {
      "size": "A4",
      "margins": "15mm",
      "direction": "rtl"
    },
    "styles": {
      "body": {
        "font": "Cairo",
        "size": "10pt",
        "lineHeight": 1.7
      },
      "coName": {
        "font": "Cairo",
        "weight": 700,
        "size": "16pt",
        "color": "#1A3C6E"
      },
      "title": {
        "font": "Cairo",
        "weight": 700,
        "size": "13pt",
        "align": "center",
        "color": "#FFFFFF",
        "background": "#8A1538",
        "padding": "2mm"
      },
      "lbl": {
        "font": "Cairo",
        "weight": 700,
        "size": "9.5pt"
      },
      "th": {
        "font": "Cairo",
        "weight": 700,
        "size": "9.5pt",
        "align": "center",
        "color": "#FFFFFF",
        "background": "#1A3C6E"
      },
      "td": {
        "font": "Cairo",
        "size": "9.5pt",
        "align": "center"
      },
      "totLbl": {
        "font": "Cairo",
        "weight": 700,
        "size": "10pt",
        "align": "end"
      },
      "tot": {
        "font": "Cairo",
        "weight": 700,
        "size": "11pt",
        "color": "#8A1538"
      },
      "mut": {
        "font": "Cairo",
        "size": "8.5pt",
        "color": "#66788c"
      }
    },
    "body": [
      {
        "type": "row",
        "align": "space-between",
        "children": [
          {
            "type": "text",
            "bind": "$.seller.name",
            "style": "coName"
          },
          {
            "type": "keyValue",
            "items": [
              {
                "label": "الرقم الضريبي",
                "bind": "$.seller.vat"
              },
              {
                "label": "السجل التجاري",
                "bind": "$.seller.cr"
              }
            ]
          }
        ]
      },
      {
        "type": "spacer",
        "height": "4mm"
      },
      {
        "type": "heading",
        "text": "فاتورة ضريبية مبسطة",
        "level": 2,
        "style": "title"
      },
      {
        "type": "spacer",
        "height": "3mm"
      },
      {
        "type": "keyValue",
        "columns": 2,
        "items": [
          {
            "label": "رقم الفاتورة",
            "bind": "$.invoice.number"
          },
          {
            "label": "التاريخ",
            "bind": "$.invoice.date",
            "format": {
              "dateStyle": "long"
            }
          },
          {
            "label": "العميل",
            "bind": "$.customer.name"
          },
          {
            "label": "طريقة الدفع",
            "bind": "$.invoice.payment"
          }
        ]
      },
      {
        "type": "spacer",
        "height": "4mm"
      },
      {
        "type": "table",
        "bind": "$.items",
        "headerStyle": "th",
        "cellStyle": "td",
        "widths": [
          "46%",
          "18%",
          "18%",
          "18%"
        ],
        "columns": [
          {
            "header": "البيان",
            "cell": {
              "bind": "item.name"
            }
          },
          {
            "header": "الكمية",
            "cell": {
              "bind": "item.qty"
            }
          },
          {
            "header": "سعر الوحدة",
            "cell": {
              "bind": "item.price",
              "format": {
                "currency": "SAR",
                "kind": "currency"
              }
            }
          },
          {
            "header": "الإجمالي",
            "cell": {
              "bind": "item.total",
              "format": {
                "currency": "SAR",
                "kind": "currency"
              }
            }
          }
        ]
      },
      {
        "type": "spacer",
        "height": "4mm"
      },
      {
        "type": "row",
        "align": "space-between",
        "children": [
          {
            "type": "qrcode",
            "size": "30mm",
            "zatca": {
              "sellerBind": "$.seller.name",
              "vatBind": "$.seller.vat",
              "timestampBind": "$.invoice.issuedAt",
              "totalBind": "$.totals.total",
              "vatAmountBind": "$.totals.vat"
            }
          },
          {
            "type": "keyValue",
            "items": [
              {
                "label": "الإجمالي قبل الضريبة",
                "bind": "$.totals.subtotal",
                "format": {
                  "currency": "SAR",
                  "kind": "currency"
                }
              },
              {
                "label": "ضريبة القيمة المضافة 15٪",
                "bind": "$.totals.vat",
                "format": {
                  "currency": "SAR",
                  "kind": "currency"
                }
              },
              {
                "label": "الإجمالي المستحق",
                "bind": "$.totals.total",
                "format": {
                  "currency": "SAR",
                  "kind": "currency"
                }
              }
            ]
          }
        ]
      },
      {
        "type": "spacer",
        "height": "3mm"
      },
      {
        "type": "text",
        "text": "امسح رمز QR للتحقق من الفاتورة — متوافق مع متطلبات المرحلة الأولى من الفوترة الإلكترونية.",
        "style": "mut"
      }
    ]
  },
  "data": {
    "seller": {
      "name": "مؤسسة النور التجارية",
      "vat": "310122393500003",
      "cr": "1010101010"
    },
    "customer": {
      "name": "شركة الأفق للمقاولات"
    },
    "invoice": {
      "number": "INV-2026-0413",
      "date": "2026-08-14",
      "issuedAt": "2026-08-14T10:30:00Z",
      "payment": "تحويل بنكي"
    },
    "items": [
      {
        "name": "توريد أجهزة حاسب محمولة",
        "qty": 3,
        "price": 4200,
        "total": 12600
      },
      {
        "name": "خدمات تركيب وتهيئة",
        "qty": 1,
        "price": 1500,
        "total": 1500
      }
    ],
    "totals": {
      "subtotal": 14100,
      "vat": 2115,
      "total": 16215
    }
  }
}