{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://rangka-os.github.io/rangka-os/schema/0.5/config.json",
  "title": "Rangka organisation config",
  "description": "Layer 4: defaults for an organisation (company). Organisations and members themselves are data in the database, managed in Console; this file seeds defaults and is what Rangka AI edits through change sets.",
  "type": "object",
  "required": [],
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "type": "string"
    },
    "locale": {
      "type": "string",
      "default": "id-ID"
    },
    "currency": {
      "enum": [
        "IDR"
      ],
      "default": "IDR"
    },
    "timezone": {
      "type": "string",
      "default": "Asia/Jakarta"
    },
    "fiscal_year_start": {
      "type": "string",
      "pattern": "^[0-1][0-9]-[0-3][0-9]$",
      "default": "01-01"
    },
    "tax": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "ppn_rate": {
          "type": "number",
          "minimum": 0,
          "maximum": 100,
          "default": 12
        },
        "dpp_ratio": {
          "type": "string",
          "default": "11/12"
        },
        "pkp": {
          "type": "boolean",
          "default": false
        },
        "ppn_fee_only": {
          "type": "boolean",
          "default": false,
          "description": "PPN on the service fee only: invoice lines marked as the workers' wages (ppn_exclude) stay out of the PPN base (DPP nilai lain, PMK 83/2012). Default false."
        }
      }
    },
    "numbering": {
      "type": "object",
      "additionalProperties": {
        "oneOf": [
          {
            "type": "string"
          },
          {
            "type": "object",
            "required": [
              "pattern"
            ],
            "properties": {
              "pattern": {
                "$ref": "model.json#/$defs/number_pattern"
              },
              "reset": {
                "$ref": "model.json#/$defs/number_reset"
              },
              "start": {
                "type": "integer",
                "minimum": 1,
                "maximum": 999999999999999,
                "description": "lowest number the series issues in every period (default 1)"
              }
            },
            "additionalProperties": false
          }
        ]
      },
      "description": "A series (object) or a per-model naming override (string), e.g. sales_invoice: 'INV-{YYYY}-{#####}'"
    },
    "plan": {
      "$ref": "model.json#/$defs/name"
    },
    "theme": {
      "$ref": "model.json#/$defs/name"
    },
    "layout": {
      "$ref": "model.json#/$defs/name"
    },
    "sso": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "domains": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "hostname"
          }
        },
        "upstream": {
          "$ref": "model.json#/$defs/name"
        },
        "required": {
          "type": "boolean",
          "default": false
        }
      }
    },
    "ai": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "enabled": {
          "type": "boolean",
          "default": true
        },
        "auto_apply": {
          "enum": [
            "never",
            "low_risk"
          ],
          "default": "never",
          "description": "low_risk lets Rangka AI apply layer-6 changes (theme, layout, labels) without approval"
        },
        "approvers": {
          "type": "array",
          "items": {
            "$ref": "model.json#/$defs/name"
          },
          "description": "Roles that can approve change sets"
        },
        "proposers": {
          "type": "array",
          "items": {
            "$ref": "model.json#/$defs/name"
          },
          "default": [],
          "description": "Roles (besides the approvers) that can propose change sets from the web app's Ubah mode"
        }
      }
    },
    "onboarding": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "process": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9_]*$",
          "description": "The process Mulai di sini follows (contract 0053 §2)"
        }
      }
    },
    "apps": {
      "type": "array",
      "items": {
        "$ref": "model.json#/$defs/name"
      },
      "uniqueItems": true,
      "description": "Installed apps, in menu order. Must be allowed by the plan."
    },
    "modules": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      },
      "description": "module → version range (^1.0, >=1.2): modules installed on their own, next to apps (contract 0032). The validators add each module's requires; the plan must allow them. Not allowed under orgs.<id>.config."
    },
    "connectors": {
      "type": "array",
      "items": {
        "$ref": "model.json#/$defs/name"
      },
      "uniqueItems": true,
      "description": "Connectors switched on before any flow uses them (contract 0036). Site-wide: not allowed under orgs.<id>.config."
    },
    "connector_auth": {
      "type": "array",
      "items": {
        "$ref": "model.json#/$defs/name"
      },
      "uniqueItems": true,
      "description": "Roles (besides owner) that may set and remove connector secrets through the API (contract 0017 §3). Site-wide."
    },
    "org": {
      "type": "object",
      "description": "The legal entity printed on documents",
      "additionalProperties": false,
      "properties": {
        "legal_name": {
          "type": "string"
        },
        "npwp": {
          "type": "string"
        },
        "pkp": {
          "type": "boolean",
          "default": false
        }
      }
    },
    "orgs": {
      "type": "object",
      "description": "Per-org settings by org id; an org's config overrides this file's keys for that org (contract 0010)",
      "propertyNames": {
        "$ref": "model.json#/$defs/name"
      },
      "additionalProperties": {
        "type": "object",
        "required": [
          "name"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1
          },
          "code": {
            "type": "string",
            "pattern": "^[A-Z0-9]{1,8}$"
          },
          "config": {
            "$ref": "#",
            "description": "Any config.rk key, overriding the site value for this org (orgs not allowed)"
          }
        }
      }
    }
  }
}
