{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "id": "http://tm.org.mx/edca/extensions/base.json",
    "title": "Base TM Extension",
    "description": "Basic extension to implement OCDS in Mexico",
    "type": "object",
    "additionalProperties": false,
    "definitions": {
        "audit": {
            "type": "object",
            "additionalProperties": false,
            "title": "Audit",
            "description": "Defines an audit process",
            "required": [
                "type",
                "auditor",
                "observations",
                "actions"
            ],
            "properties": {
                "type": {
                    "type": "string",
                    "title": "Type",
                    "description": "Type of audit process",
                    "default": "external",
                    "enum": [
                        "internal",
                        "external"
                    ]
                },
                "auditor": {
                    "type": "object"
                },
                "observations": {
                    "type": "array",
                    "minItems": 0,
                    "_uniqueItems": true,
                    "items": {
                        "type": "string"
                    },
                    "title": "Observation(s)",
                    "description": "Observations presented during the audit process",
                    "default": []
                },
                "actions": {
                    "type": "array",
                    "minItems": 0,
                    "_uniqueItems": true,
                    "items": {
                        "type": "string"
                    },
                    "title": "Action(s)",
                    "description": "Actions taken during the audit process",
                    "default": []
                }
            }
        },
        "planning": {
            "type": "object",
            "description": "Additional details applicable to the planning phase",
            "additionalProperties": false,
            "properties": {
                "budget": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                        "multipleYears": {
                            "type": "boolean",
                            "default": false,
                            "description": "Specify if the budget applies for more than 1 administrative year"
                        },
                        "exchangeRate": {
                            "type": "number",
                            "description": "Exchange rate applicable if the contract use any currency different from MXN"
                        }
                    }
                }
            }
        },
        "tender": {
            "type": "object",
            "description": "Additional details applicable to the tender phase",
            "additionalProperties": false,
            "properties": {
                "scope": {
                    "type": "string",
                    "description": "Specify the scope of the tender process",
                    "default": "national",
                    "enum": [
                        "national",
                        "international",
                        "internationalTreaty"
                    ]
                },
                "procurementStyle": {
                    "type": "string",
                    "description": "Specify the procurement style of the tender process",
                    "default": "multiple",
                    "enum": [
                        "presence",
                        "electronic",
                        "multiple"
                    ]
                },
                "hasSocialWitness": {
                    "type": "boolean",
                    "description": "Specify whether a social witness participate during the tender process or not",
                    "default": "false"
                },
                "socialWitness": {
                    "type": "object",
                    "description": "Social witness entity (Organization object)"
                },
                "socialWitnessDesignationDate": {
                    "type": "string",
                    "format": "date-time"
                },
                "requiringEntity": {
                    "type": "object",
                    "description": "Entity requiring the contract process (Organization object)"
                },
                "technicalEntity": {
                    "type": "object",
                    "description": "Entity involved in the technical aspects of the contract process (Organization object)"
                }
            }
        },
        "award": {
            "type": "object",
            "description": "Additional details applicable to the award phase",
            "additionalProperties": false,
            "properties": {
                "complains": {
                    "type": "object",
                    "description": "Details about complains received during the award phase of the contracting process",
                    "additionalProperties": false,
                    "properties": {
                        "accepted": {
                            "type": "integer",
                            "default": 0
                        },
                        "notAccepted": {
                            "type": "integer",
                            "default": 0
                        }
                    }
                }
            }
        },
        "contract": {
            "type": "object",
            "description": "Additional details applicable to the contract phase",
            "additionalProperties": false,
            "properties": {
                "administratorEntity": {
                    "type": "object",
                    "description": "Entity with administrative lead during the contract process (Organization object)"
                },
                "hasModifications": {
                    "type": "boolean",
                    "default": false,
                    "description": "Specify if the contracting process have been modified/adjusted"
                }
            }
        },
        "implementation": {
            "type": "object",
            "description": "Additional details applicable to the implementation phase",
            "additionalProperties": false,
            "properties": {
                "hasAudits": {
                    "type": "boolean",
                    "description": "Specify if audits were performed during the contracting process"
                },
                "audits": {
                    "type": "array",
                    "minItems": 0,
                    "default": [],
                    "items": {
                        "$ref": "#/definitions/audit"
                    }
                }
            }
        }
    },
    "required": [
        "version"
    ],
    "properties": {
        "version": {
            "type": "string",
            "title": "Version",
            "description": "Semantic version of the extension",
            "default": "0.1.0"
        },
        "planning": {
            "$ref": "#/definitions/planning"
        },
        "tender": {
            "$ref": "#/definitions/tender"
        },
        "award": {
            "$ref": "#/definitions/award"
        },
        "contract": {
            "$ref": "#/definitions/contract"
        },
        "implementation": {
            "$ref": "#/definitions/implementation"
        }
    }
}