{
  "name": "create_wht_certificate",
  "slug": "withholding-tax-certificate",
  "description": {
    "th": "เตรียมหนังสือรับรองการหักภาษี ณ ที่จ่าย (50 ทวิ) บนแบบของกรมสรรพากร ได้ยอดเงินที่จ่าย ภาษีที่หัก และลิงก์เปิดหน้าเว็บที่กรอกข้อมูลไว้แล้วให้ผู้ใช้ตรวจและดาวน์โหลด PDF",
    "en": "Prepares a Thai withholding tax certificate (50 Tawi) on the Revenue Department form. Returns the amount paid, the tax withheld and a link to a prefilled page where the user checks it and downloads the PDF."
  },
  "inputSchema": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "bookNo": {
        "description": "Book number (เล่มที่).",
        "type": "string",
        "maxLength": 20
      },
      "docNo": {
        "description": "Certificate number (เลขที่).",
        "type": "string",
        "maxLength": 20
      },
      "sequence": {
        "description": "Sequence number in the return (ลำดับที่ในแบบ).",
        "type": "string",
        "maxLength": 20
      },
      "signerName": {
        "description": "Name of the person who signs for the payer.",
        "type": "string",
        "maxLength": 120
      },
      "paidByOther": {
        "description": "Only with paidBy \"other\": what to print.",
        "type": "string",
        "maxLength": 40
      },
      "formType": {
        "description": "Return the tax is filed on: ภ.ง.ด.1ก, 1ก พิเศษ, 2, 3, 2ก, 3ก or 53.",
        "type": "string",
        "enum": [
          "pnd1a",
          "pnd1a_special",
          "pnd2",
          "pnd3",
          "pnd2a",
          "pnd3a",
          "pnd53"
        ]
      },
      "date": {
        "description": "Issue date, YYYY-MM-DD (Gregorian); default today.",
        "type": "string"
      },
      "payer": {
        "description": "The payer (who withholds).",
        "type": "object",
        "properties": {
          "name": {
            "description": "Name.",
            "type": "string",
            "maxLength": 120
          },
          "address": {
            "description": "Address.",
            "type": "string",
            "maxLength": 240
          },
          "taxId": {
            "description": "13-digit tax ID, as typed (dashes allowed); a foreign ID is allowed (a warning is returned).",
            "type": "string",
            "maxLength": 20
          },
          "kind": {
            "description": "Kind printed under the name, e.g. บุคคล, นิติบุคคล.",
            "type": "string",
            "maxLength": 40
          }
        },
        "additionalProperties": false
      },
      "payee": {
        "description": "The payee (who is paid).",
        "type": "object",
        "properties": {
          "name": {
            "description": "Name.",
            "type": "string",
            "maxLength": 120
          },
          "address": {
            "description": "Address.",
            "type": "string",
            "maxLength": 240
          },
          "taxId": {
            "description": "13-digit tax ID, as typed (dashes allowed); a foreign ID is allowed (a warning is returned).",
            "type": "string",
            "maxLength": 20
          },
          "kind": {
            "description": "Kind printed under the name, e.g. บุคคล, นิติบุคคล.",
            "type": "string",
            "maxLength": 40
          }
        },
        "additionalProperties": false
      },
      "payments": {
        "description": "Payments, 1 to 8.",
        "type": "array",
        "minItems": 1,
        "maxItems": 8,
        "items": {
          "type": "object",
          "properties": {
            "incomeType": {
              "description": "salary 40(1); fees_commission 40(2); royalties 40(3); interest 40(4)(a); dividends 40(4)(b); services: payments under orders made under section 3 tredecim (services, hire of work, rent, advertising, transport, prizes ...); other.",
              "type": "string",
              "enum": [
                "salary",
                "fees_commission",
                "royalties",
                "interest",
                "dividends",
                "services",
                "other"
              ]
            },
            "description": {
              "description": "What was paid, e.g. ค่าบริการ (for services and other).",
              "type": "string",
              "maxLength": 90
            },
            "date": {
              "description": "Date paid, YYYY-MM-DD (Gregorian).",
              "type": "string"
            },
            "amount": {
              "description": "Amount paid, baht (above 0).",
              "anyOf": [
                {
                  "type": "number",
                  "minimum": 0
                },
                {
                  "type": "string",
                  "pattern": "^\\s*(฿\\s*)?(\\d+|\\d{1,3}(,\\d{3})+)(\\.\\d{1,2})?\\s*$"
                }
              ]
            },
            "rate": {
              "description": "Tax percent of the amount (0–100). Not with tax.",
              "anyOf": [
                {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100
                },
                {
                  "type": "string",
                  "pattern": "^\\d+(\\.\\d{1,2})?$"
                }
              ]
            },
            "tax": {
              "description": "Tax withheld, baht, when not given as a rate.",
              "anyOf": [
                {
                  "type": "number",
                  "minimum": 0
                },
                {
                  "type": "string",
                  "pattern": "^\\s*(฿\\s*)?(\\d+|\\d{1,3}(,\\d{3})+)(\\.\\d{1,2})?\\s*$"
                }
              ]
            }
          },
          "required": [
            "incomeType",
            "amount"
          ],
          "additionalProperties": false
        }
      },
      "gpf": {
        "description": "Government pension / private school teacher fund paid, baht.",
        "anyOf": [
          {
            "type": "number",
            "minimum": 0
          },
          {
            "type": "string",
            "pattern": "^\\s*(฿\\s*)?(\\d+|\\d{1,3}(,\\d{3})+)(\\.\\d{1,2})?\\s*$"
          }
        ]
      },
      "sso": {
        "description": "Social security contribution paid, baht.",
        "anyOf": [
          {
            "type": "number",
            "minimum": 0
          },
          {
            "type": "string",
            "pattern": "^\\s*(฿\\s*)?(\\d+|\\d{1,3}(,\\d{3})+)(\\.\\d{1,2})?\\s*$"
          }
        ]
      },
      "pvd": {
        "description": "Provident fund contribution paid, baht.",
        "anyOf": [
          {
            "type": "number",
            "minimum": 0
          },
          {
            "type": "string",
            "pattern": "^\\s*(฿\\s*)?(\\d+|\\d{1,3}(,\\d{3})+)(\\.\\d{1,2})?\\s*$"
          }
        ]
      },
      "paidBy": {
        "description": "withheld (default), paid_always (payer pays the tax every time), paid_once, other.",
        "type": "string",
        "enum": [
          "withheld",
          "paid_always",
          "paid_once",
          "other"
        ]
      },
      "fileCopy": {
        "description": "Also print the payer's file copy; default false.",
        "type": "boolean"
      }
    },
    "required": [
      "payments"
    ],
    "additionalProperties": false
  }
}
