{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/paidnice-com/json-schema/paidnice-com-invoice-policy-check-schema.json",
  "title": "InvoicePolicyCheck",
  "x-generated": "2026-11-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/paidnice-com-openapi.json#/components/schemas/InvoicePolicyCheck",
  "type": "object",
  "properties": {
    "invoiceNumber": {
      "type": [
        "string",
        "null"
      ],
      "description": "Number of the invoice that was checked"
    },
    "groupName": {
      "type": "string",
      "description": "The contact's group, whose policies are checked"
    },
    "policies": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "policyId": {
            "type": "integer",
            "description": "Paidnice policy id"
          },
          "title": {
            "type": "string",
            "description": "Policy name"
          },
          "type": {
            "type": "string",
            "enum": [
              "reminder",
              "fee",
              "discount",
              "sms",
              "statement_late_fee",
              "statement",
              "escalation",
              "contact_escalation",
              "quote_email",
              "payment_plan_reminder",
              "on_demand_placeholder"
            ],
            "description": "The kind of policy, for example reminder, fee, discount or sms"
          },
          "state": {
            "type": "string",
            "enum": [
              "active",
              "inactive",
              "approval"
            ],
            "description": "active: the policy runs. inactive: it is switched off. approval: its actions wait for a user to approve them"
          },
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "applies": {
                  "type": "boolean",
                  "description": "True when the policy would create an action"
                },
                "appliesOn": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "When the action would run, null when the policy does not apply"
                },
                "reason": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "Why the policy does not apply, or a note on how it applies"
                }
              },
              "required": [
                "applies",
                "appliesOn",
                "reason"
              ]
            },
            "description": "One per action the policy would create, for example one per repeat of a repeating reminder"
          }
        },
        "required": [
          "policyId",
          "title",
          "type",
          "state",
          "results"
        ]
      },
      "description": "One per policy in the invoice's group"
    }
  },
  "required": [
    "invoiceNumber",
    "groupName",
    "policies"
  ]
}