{
  "schemaVersion": 1,
  "name": "گزارش فروش",
  "unit": "mm",
  "locale": "fa-IR",
  "page": {
    "size": "A4",
    "orientation": "portrait",
    "margins": {
      "top": 12,
      "right": 12,
      "bottom": 12,
      "left": 12
    }
  },
  "dataSources": [
    {
      "name": "sales"
    }
  ],
  "styles": {
    "title": {
      "fontFamily": "Vazirmatn",
      "fontSize": 18,
      "fontWeight": "bold",
      "textAlign": "right"
    },
    "th": {
      "fontFamily": "Vazirmatn",
      "fontSize": 9,
      "fontWeight": "bold",
      "color": "#fff",
      "backgroundColor": "#334155",
      "padding": 1.5,
      "textAlign": "right"
    },
    "td": {
      "fontFamily": "Vazirmatn",
      "fontSize": 9.5,
      "padding": 1.5,
      "textAlign": "right",
      "border": {
        "width": 0.4,
        "color": "#e2e8f0",
        "style": "solid",
        "sides": [
          "bottom"
        ]
      }
    },
    "sub": {
      "fontFamily": "Vazirmatn",
      "fontSize": 10,
      "fontWeight": "bold",
      "backgroundColor": "#e2e8f0",
      "padding": 1.5,
      "textAlign": "right"
    }
  },
  "reportHeader": {
    "id": "rh",
    "height": 18,
    "components": [
      {
        "id": "title",
        "type": "text",
        "x": 0,
        "y": 0,
        "width": 186,
        "height": 10,
        "text": "گزارش فروش",
        "styleName": "title"
      },
      {
        "id": "sub",
        "type": "text",
        "x": 0,
        "y": 11,
        "width": 186,
        "height": 5,
        "text": "{{ count(sales) }} سفارش · تاریخ گزارش: {{ formatDate(today(), \"d MMMM yyyy\", \"persian\") }}",
        "style": {
          "fontFamily": "Vazirmatn",
          "fontSize": 9.5,
          "color": "#64748b",
          "textAlign": "right"
        }
      }
    ]
  },
  "body": [
    {
      "kind": "dataRegion",
      "id": "list",
      "dataSource": "sales",
      "header": {
        "id": "head",
        "height": 7,
        "components": [
          {
            "id": "h1",
            "type": "text",
            "x": 0,
            "y": 0,
            "width": 40,
            "height": 7,
            "text": "تاریخ",
            "styleName": "th"
          },
          {
            "id": "h2",
            "type": "text",
            "x": 40,
            "y": 0,
            "width": 40,
            "height": 7,
            "text": "قیمت واحد",
            "styleName": "th"
          },
          {
            "id": "h3",
            "type": "text",
            "x": 80,
            "y": 0,
            "width": 20,
            "height": 7,
            "text": "تعداد",
            "styleName": "th"
          },
          {
            "id": "h4",
            "type": "text",
            "x": 100,
            "y": 0,
            "width": 36,
            "height": 7,
            "text": "کالا",
            "styleName": "th"
          },
          {
            "id": "h5",
            "type": "text",
            "x": 136,
            "y": 0,
            "width": 50,
            "height": 7,
            "text": "مشتری",
            "styleName": "th"
          }
        ]
      },
      "detail": {
        "id": "row",
        "height": 7,
        "components": [
          {
            "id": "c1",
            "type": "text",
            "x": 0,
            "y": 0,
            "width": 40,
            "height": 7,
            "text": "{{ row.date }}",
            "styleName": "td",
            "format": {
              "type": "date",
              "pattern": "yyyy/MM/dd",
              "calendar": "persian"
            }
          },
          {
            "id": "c2",
            "type": "text",
            "x": 40,
            "y": 0,
            "width": 40,
            "height": 7,
            "text": "{{ row.price }}",
            "styleName": "td",
            "format": {
              "type": "number",
              "decimals": 0,
              "thousandsSeparator": true
            }
          },
          {
            "id": "c3",
            "type": "text",
            "x": 80,
            "y": 0,
            "width": 20,
            "height": 7,
            "text": "{{ row.qty }}",
            "styleName": "td"
          },
          {
            "id": "c4",
            "type": "text",
            "x": 100,
            "y": 0,
            "width": 36,
            "height": 7,
            "text": "{{ row.product }}",
            "styleName": "td"
          },
          {
            "id": "c5",
            "type": "text",
            "x": 136,
            "y": 0,
            "width": 50,
            "height": 7,
            "text": "{{ row.customer }}",
            "styleName": "td"
          }
        ]
      },
      "footer": {
        "id": "foot",
        "height": 10,
        "components": [
          {
            "id": "f1",
            "type": "text",
            "x": 0,
            "y": 2,
            "width": 80,
            "height": 7,
            "text": "{{ sum(rows, r => r.qty * r.price) }}",
            "styleName": "sub",
            "format": {
              "type": "number",
              "decimals": 0,
              "thousandsSeparator": true
            }
          },
          {
            "id": "f2",
            "type": "text",
            "x": 80,
            "y": 2,
            "width": 106,
            "height": 7,
            "text": "جمع کل (ریال)",
            "styleName": "sub"
          }
        ]
      }
    }
  ]
}