{
  "id": "teal-services",
  "templateId": "teal-services",
  "version": 1,
  "minEngine": 2,
  "name": "Teal Services",
  "description": "Clean A4 tax invoice — every setting supported",
  "engine": 2,
  "gap": 10,
  "page": {
    "size": "a4",
    "margin": 22
  },
  "theme": {
    "primary": "#0F766E",
    "text": "#0F172A",
    "muted": "#64748B",
    "border": "#CBD5E1"
  },
  "styles": {
    "body": {
      "size": 9.5,
      "color": "#0F172A"
    },
    "small": {
      "size": 8.5,
      "color": "#0F172A"
    },
    "muted": {
      "size": 8.5,
      "color": "#64748B"
    },
    "totals": {
      "size": 9,
      "color": "#0F172A",
      "role": "totals"
    },
    "label": {
      "size": 7.5,
      "bold": true,
      "color": "#0F766E",
      "letterSpacing": 0.6
    }
  },
  "layout": [
    {
      "type": "row",
      "gap": 16,
      "children": [
        {
          "type": "column",
          "width": "58%",
          "gap": 1,
          "children": [
            {
              "type": "image",
              "source": "logo",
              "align": "left",
              "if": {
                "path": "settings.logoPosition",
                "equals": "left"
              }
            },
            {
              "type": "text",
              "value": "{{company.name}}",
              "size": 17,
              "bold": true,
              "role": "companyName"
            },
            {
              "type": "text",
              "value": "{{company.address}}",
              "style": "muted"
            },
            {
              "type": "text",
              "value": "{{company.phone}}",
              "style": "muted"
            },
            {
              "type": "text",
              "value": "{{company.email}}",
              "style": "muted"
            },
            {
              "type": "text",
              "value": "{{company.website}}",
              "style": "muted"
            },
            {
              "type": "text",
              "value": "{{company.taxLabel}}: {{company.gstin}}",
              "style": "muted"
            },
            {
              "type": "text",
              "value": "{{company.panLabel}}: {{company.pan}}",
              "style": "muted"
            },
            {
              "type": "text",
              "value": "FSSAI: {{company.fssai}}",
              "style": "muted"
            }
          ]
        },
        {
          "type": "column",
          "gap": 2,
          "children": [
            {
              "type": "image",
              "source": "logo",
              "align": "right",
              "if": {
                "path": "settings.logoPosition",
                "equals": "right"
              }
            },
            {
              "type": "text",
              "value": "{{invoice.title|upper}}",
              "size": 18,
              "bold": true,
              "color": "#0F766E",
              "align": "right",
              "role": "docTitle"
            },
            {
              "type": "repeat",
              "source": "invoice.keyFields",
              "child": {
                "type": "text",
                "value": "**{{row.label}}:** {{row.value}}",
                "style": "small",
                "align": "right"
              }
            }
          ]
        }
      ]
    },
    {
      "type": "divider",
      "color": "#0F766E",
      "thickness": 1.2
    },
    {
      "type": "grid",
      "source": "invoice.customFields",
      "columns": 3,
      "border": 0.5,
      "borderColor": "#CBD5E1",
      "outerBorder": true,
      "cell": {
        "type": "box",
        "padding": [
          3,
          5
        ],
        "child": {
          "type": "column",
          "children": [
            {
              "type": "text",
              "value": "{{row.label}}",
              "size": 7.5,
              "bold": true,
              "color": "#64748B"
            },
            {
              "type": "text",
              "value": "{{row.value}}",
              "style": "small"
            }
          ]
        }
      }
    },
    {
      "type": "row",
      "gap": 20,
      "children": [
        {
          "type": "column",
          "gap": 2,
          "children": [
            {
              "type": "text",
              "value": "BILLED TO",
              "style": "label"
            },
            {
              "type": "text",
              "value": "{{customer.name}}",
              "style": "body",
              "bold": true
            },
            {
              "type": "text",
              "value": "{{customer.businessName}}",
              "style": "small"
            },
            {
              "type": "text",
              "value": "{{customer.address}}",
              "style": "small"
            },
            {
              "type": "text",
              "value": "{{customer.phone}}",
              "style": "small"
            },
            {
              "type": "text",
              "value": "{{customer.email}}",
              "style": "small"
            },
            {
              "type": "text",
              "value": "{{company.taxLabel}}: {{customer.gstin}}",
              "style": "small"
            },
            {
              "type": "repeat",
              "source": "invoice.gstLines",
              "child": {
                "type": "text",
                "value": "{{row.label}}: {{row.value}}",
                "style": "small"
              }
            },
            {
              "type": "grid",
              "source": "customer.fields",
              "columns": 2,
              "spanLast": true,
              "cell": {
                "type": "box",
                "padding": [
                  2,
                  0
                ],
                "child": {
                  "type": "text",
                  "value": "**{{row.label}}:** {{row.value}}",
                  "style": "small"
                }
              }
            }
          ]
        },
        {
          "type": "column",
          "if": "shipTo.address",
          "gap": 2,
          "children": [
            {
              "type": "text",
              "value": "SHIP TO",
              "style": "label"
            },
            {
              "type": "repeat",
              "source": "shipTo.lines",
              "child": {
                "type": "text",
                "value": "{{row.value}}",
                "style": "small"
              }
            }
          ]
        }
      ]
    },
    {
      "type": "table",
      "source": "items",
      "border": "horizontal",
      "borderColor": "#CBD5E1",
      "borderWidth": 0.6,
      "header": {
        "background": "#0F766E",
        "color": "#FFFFFF",
        "size": 7.5
      },
      "size": 8,
      "cellPadding": [
        4,
        3
      ],
      "columns": [
        {
          "id": "sl",
          "if": "settings.showSlNo",
          "label": "#",
          "width": "4%",
          "align": "center",
          "value": "{{row.slNo}}"
        },
        {
          "id": "item",
          "label": "Item",
          "width": "24%",
          "cell": [
            {
              "value": "{{row.displayName}}"
            },
            {
              "value": "{{row.description}}",
              "if": "!settings.descriptionNewLine",
              "italic": true,
              "size": 7.5,
              "color": "#6B7280"
            },
            {
              "value": "{{row.typeTag|capitalize}}",
              "if": "settings.showTypeTag",
              "size": 7,
              "color": "#9CA3AF"
            }
          ]
        },
        {
          "id": "hsn",
          "if": "settings.showGst",
          "label": "HSN/SAC",
          "width": "10%",
          "align": "center",
          "value": "{{row.hsn}}"
        },
        {
          "each": "settings.metadataColumns",
          "width": "10%",
          "align": "center",
          "size": 7.5
        },
        {
          "id": "qty",
          "if": "settings.showQuantity",
          "label": "Qty",
          "width": "9%",
          "align": "center",
          "value": "{{row.qty|qty}} {{row.unit}}"
        },
        {
          "id": "rate",
          "label": "Rate",
          "width": "11%",
          "align": "right",
          "value": "{{row.rate|number}}"
        },
        {
          "id": "disc",
          "if": "settings.showDiscount",
          "label": "Disc.",
          "width": "8%",
          "align": "right",
          "value": "{{row.discount|number}}"
        },
        {
          "id": "cgst",
          "if": "settings.showCgstSgst",
          "label": "CGST",
          "width": "11%",
          "align": "right",
          "cell": [
            {
              "value": "{{row.cgst|number}}"
            },
            {
              "value": "{{row.cgstRate|percent}}",
              "size": 7,
              "color": "#6B7280"
            }
          ]
        },
        {
          "id": "sgst",
          "if": "settings.showCgstSgst",
          "label": "SGST",
          "width": "11%",
          "align": "right",
          "cell": [
            {
              "value": "{{row.sgst|number}}"
            },
            {
              "value": "{{row.sgstRate|percent}}",
              "size": 7,
              "color": "#6B7280"
            }
          ]
        },
        {
          "id": "igst",
          "if": "settings.showIgst",
          "label": "IGST",
          "width": "12%",
          "align": "right",
          "cell": [
            {
              "value": "{{row.igst|number}}"
            },
            {
              "value": "{{row.igstRate|percent}}",
              "size": 7,
              "color": "#6B7280"
            }
          ]
        },
        {
          "id": "tax",
          "if": [
            "settings.showTaxColumn",
            "!settings.showCgstSgst",
            "!settings.showIgst"
          ],
          "label": "Tax",
          "width": "11%",
          "align": "right",
          "cell": [
            {
              "value": "{{row.tax|number}}"
            },
            {
              "value": "{{row.taxRate|percent}}",
              "size": 7,
              "color": "#6B7280"
            }
          ]
        },
        {
          "id": "amt",
          "label": "Amount",
          "width": "14%",
          "align": "right",
          "value": "{{row.amount|number}}"
        }
      ],
      "footerRows": [
        {
          "if": [
            "settings.showTotalQuantity",
            "settings.showQuantity"
          ],
          "bold": true,
          "cells": {
            "item": "Total Quantity",
            "qty": "{{totals.totalQty|qty}}"
          }
        }
      ],
      "detailRow": {
        "value": "{{row.description}}",
        "if": "settings.descriptionNewLine",
        "italic": true,
        "size": 7.5,
        "color": "#6B7280"
      },
      "zebra": "#F0FDFA"
    },
    {
      "type": "row",
      "gap": 20,
      "children": [
        {
          "type": "column",
          "width": "55%",
          "gap": 6,
          "children": [
            {
              "type": "column",
              "children": [
                {
                  "type": "text",
                  "value": "AMOUNT IN WORDS",
                  "style": "label"
                },
                {
                  "type": "text",
                  "value": "{{totals.totalInWords}}",
                  "style": "small",
                  "bold": true
                }
              ]
            },
            {
              "type": "box",
              "if": [
                "invoice.notes"
              ],
              "background": "#F0FDFA",
              "padding": 8,
              "radius": 3,
              "border": {
                "left": 2.5,
                "color": "#0F766E"
              },
              "child": {
                "type": "column",
                "gap": 2,
                "children": [
                  {
                    "type": "text",
                    "value": "NOTES",
                    "style": "label"
                  },
                  {
                    "type": "text",
                    "value": "{{invoice.notes}}",
                    "style": "small"
                  }
                ]
              }
            },
            {
              "type": "box",
              "if": "invoice.returnLines",
              "padding": [
                4,
                0
              ],
              "child": {
                "type": "repeat",
                "source": "invoice.returnLines",
                "child": {
                  "type": "text",
                  "value": "{{row.value}}",
                  "style": "small",
                  "italic": true
                }
              }
            },
            {
              "type": "text",
              "value": "{{settings.thankYouNote}}",
              "style": "muted",
              "italic": true
            }
          ]
        },
        {
          "type": "column",
          "gap": 2,
          "children": [
            {
              "type": "row",
              "children": [
                {
                  "type": "text",
                  "value": "Subtotal",
                  "style": "totals",
                  "bold": false
                },
                {
                  "type": "text",
                  "value": "{{totals.grossSubtotal|money}}",
                  "style": "totals",
                  "bold": false,
                  "align": "right",
                  "width": "45%"
                }
              ]
            },
            {
              "type": "row",
              "children": [
                {
                  "type": "text",
                  "value": "Discount",
                  "style": "totals",
                  "bold": false
                },
                {
                  "type": "text",
                  "value": "- {{totals.discount|money}}",
                  "style": "totals",
                  "bold": false,
                  "align": "right",
                  "width": "45%"
                }
              ],
              "if": "totals.discount"
            },
            {
              "type": "repeat",
              "source": "charges",
              "child": {
                "type": "row",
                "children": [
                  {
                    "type": "text",
                    "value": "{{row.label}}",
                    "style": "totals",
                    "bold": false
                  },
                  {
                    "type": "text",
                    "value": "{{row.amount|money}}",
                    "style": "totals",
                    "bold": false,
                    "align": "right",
                    "width": "45%"
                  }
                ]
              }
            },
            {
              "type": "row",
              "children": [
                {
                  "type": "text",
                  "value": "CGST",
                  "style": "totals",
                  "bold": false
                },
                {
                  "type": "text",
                  "value": "{{totals.cgst|money}}",
                  "style": "totals",
                  "bold": false,
                  "align": "right",
                  "width": "45%"
                }
              ],
              "if": "settings.showCgstSgst"
            },
            {
              "type": "row",
              "children": [
                {
                  "type": "text",
                  "value": "SGST",
                  "style": "totals",
                  "bold": false
                },
                {
                  "type": "text",
                  "value": "{{totals.sgst|money}}",
                  "style": "totals",
                  "bold": false,
                  "align": "right",
                  "width": "45%"
                }
              ],
              "if": "settings.showCgstSgst"
            },
            {
              "type": "row",
              "children": [
                {
                  "type": "text",
                  "value": "IGST",
                  "style": "totals",
                  "bold": false
                },
                {
                  "type": "text",
                  "value": "{{totals.igst|money}}",
                  "style": "totals",
                  "bold": false,
                  "align": "right",
                  "width": "45%"
                }
              ],
              "if": "settings.showIgst"
            },
            {
              "type": "row",
              "children": [
                {
                  "type": "text",
                  "value": "Tax",
                  "style": "totals",
                  "bold": false
                },
                {
                  "type": "text",
                  "value": "{{totals.tax|money}}",
                  "style": "totals",
                  "bold": false,
                  "align": "right",
                  "width": "45%"
                }
              ],
              "if": [
                "settings.showGst",
                "totals.tax",
                "!settings.showCgstSgst",
                "!settings.showIgst"
              ]
            },
            {
              "if": [
                "!totals.previousBalanceDue",
                "!settings.showRoundOff"
              ],
              "type": "box",
              "background": "#0F766E",
              "padding": [
                5,
                6
              ],
              "radius": 3,
              "child": {
                "type": "row",
                "children": [
                  {
                    "type": "text",
                    "value": "Total",
                    "size": 10.5,
                    "bold": true,
                    "color": "#FFFFFF",
                    "role": "totals"
                  },
                  {
                    "type": "text",
                    "value": "{{totals.total|money}}",
                    "size": 10.5,
                    "bold": true,
                    "color": "#FFFFFF",
                    "align": "right",
                    "role": "totals",
                    "width": "50%"
                  }
                ]
              }
            },
            {
              "type": "row",
              "children": [
                {
                  "type": "text",
                  "value": "Total",
                  "style": "totals",
                  "bold": true
                },
                {
                  "type": "text",
                  "value": "{{totals.total|money}}",
                  "style": "totals",
                  "bold": true,
                  "align": "right",
                  "width": "45%"
                }
              ],
              "if": [
                "totals.previousBalanceDue"
              ]
            },
            {
              "type": "row",
              "children": [
                {
                  "type": "text",
                  "value": "Total",
                  "style": "totals",
                  "bold": true
                },
                {
                  "type": "text",
                  "value": "{{totals.total|money}}",
                  "style": "totals",
                  "bold": true,
                  "align": "right",
                  "width": "45%"
                }
              ],
              "if": [
                "!totals.previousBalanceDue",
                "settings.showRoundOff"
              ]
            },
            {
              "type": "row",
              "children": [
                {
                  "type": "text",
                  "value": "Previous Balance Due",
                  "style": "totals",
                  "bold": false
                },
                {
                  "type": "text",
                  "value": "{{totals.previousBalanceDue|money}}",
                  "style": "totals",
                  "bold": false,
                  "align": "right",
                  "width": "45%"
                }
              ],
              "if": "totals.previousBalanceDue"
            },
            {
              "if": [
                "totals.previousBalanceDue",
                "!settings.showRoundOff"
              ],
              "type": "box",
              "background": "#0F766E",
              "padding": [
                5,
                6
              ],
              "radius": 3,
              "child": {
                "type": "row",
                "children": [
                  {
                    "type": "text",
                    "value": "Total Due",
                    "size": 10.5,
                    "bold": true,
                    "color": "#FFFFFF",
                    "role": "totals"
                  },
                  {
                    "type": "text",
                    "value": "{{totals.totalDue|money}}",
                    "size": 10.5,
                    "bold": true,
                    "color": "#FFFFFF",
                    "align": "right",
                    "role": "totals",
                    "width": "50%"
                  }
                ]
              }
            },
            {
              "type": "row",
              "children": [
                {
                  "type": "text",
                  "value": "Total Due",
                  "style": "totals",
                  "bold": true
                },
                {
                  "type": "text",
                  "value": "{{totals.totalDue|money}}",
                  "style": "totals",
                  "bold": true,
                  "align": "right",
                  "width": "45%"
                }
              ],
              "if": [
                "totals.previousBalanceDue",
                "settings.showRoundOff"
              ]
            },
            {
              "type": "row",
              "children": [
                {
                  "type": "text",
                  "value": "Round off",
                  "style": "totals",
                  "bold": false
                },
                {
                  "type": "text",
                  "value": "{{totals.roundOff|money}}",
                  "style": "totals",
                  "bold": false,
                  "align": "right",
                  "width": "45%"
                }
              ],
              "if": "settings.showRoundOff"
            },
            {
              "if": "settings.showRoundOff",
              "type": "box",
              "background": "#0F766E",
              "padding": [
                5,
                6
              ],
              "radius": 3,
              "child": {
                "type": "row",
                "children": [
                  {
                    "type": "text",
                    "value": "Net Amount",
                    "size": 10.5,
                    "bold": true,
                    "color": "#FFFFFF",
                    "role": "totals"
                  },
                  {
                    "type": "text",
                    "value": "{{totals.roundedTotal|money}}",
                    "size": 10.5,
                    "bold": true,
                    "color": "#FFFFFF",
                    "align": "right",
                    "role": "totals",
                    "width": "50%"
                  }
                ]
              }
            },
            {
              "type": "row",
              "children": [
                {
                  "type": "text",
                  "value": "Amount Paid",
                  "style": "totals",
                  "bold": false
                },
                {
                  "type": "text",
                  "value": "{{totals.amountPaid|money}}",
                  "style": "totals",
                  "bold": false,
                  "align": "right",
                  "width": "45%"
                }
              ],
              "if": "totals.amountPaid"
            },
            {
              "type": "row",
              "children": [
                {
                  "type": "text",
                  "value": "Balance",
                  "style": "totals",
                  "bold": true
                },
                {
                  "type": "text",
                  "value": "{{totals.balance|money}}",
                  "style": "totals",
                  "bold": true,
                  "align": "right",
                  "width": "45%"
                }
              ],
              "if": "totals.amountPaid"
            }
          ]
        }
      ]
    },
    {
      "type": "row",
      "gap": 16,
      "children": [
        {
          "type": "column",
          "width": "40%",
          "children": [
            {
              "type": "column",
              "if": "bank.account",
              "gap": 1,
              "children": [
                {
                  "type": "text",
                  "value": "PAYMENT DETAILS",
                  "style": "label"
                },
                {
                  "type": "text",
                  "value": "Bank: {{bank.name}}",
                  "style": "small"
                },
                {
                  "type": "text",
                  "value": "A/C: {{bank.account}}",
                  "style": "small"
                },
                {
                  "type": "text",
                  "value": "IFSC: {{bank.ifsc}}",
                  "style": "small"
                },
                {
                  "type": "text",
                  "value": "IBAN: {{bank.iban}}",
                  "style": "small"
                }
              ]
            }
          ]
        },
        {
          "type": "column",
          "width": "25%",
          "align": "center",
          "children": [
            {
              "type": "qr",
              "title": "{{payment.qrTitle}}",
              "size": 64,
              "caption": "{{bank.upi}}"
            }
          ]
        },
        {
          "type": "column",
          "align": "right",
          "children": [
            {
              "type": "text",
              "value": "For {{company.name}}",
              "style": "small",
              "bold": true,
              "align": "right"
            },
            {
              "type": "signature"
            }
          ]
        }
      ]
    }
  ]
}