{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "legal project billing record",
    "type": "object",
    "properties": {
        "approval": {
            "$ref": "#/definitions/approval"
        },
        "client": {
            "$ref": "#/definitions/client"
        },
        "completed": {
            "$ref": "#/definitions/completed"
        },
        "contacts": {
            "$ref": "#/definitions/contacts"
        },
        "limit": {
            "properties": {
                "type": {
                    "enum": [
                        "cap",
                        "estimate"
                    ]
                },
                "amount": {
                    "type": "integer",
                    "minimum": 0
                }
            }
        },
        "notes": {
            "type": "array",
            "items": {
                "type": "string"
            }
        },
        "parties": {
            "$ref": "#/definitions/parties"
        },
        "project": {
            "$ref": "#/definitions/project"
        },
        "service": {
            "$ref": "#/definitions/service"
        },
        "tags": {
            "$ref": "#/definitions/tags"
        }
    },
    "required": [
        "client",
        "contacts",
        "project",
        "service"
    ],
    "additionalProperties": false,
    "definitions": {
        "approval": {
            "title": "project approval",
            "properties": {
                "by": {
                    "$ref": "#/definitions/person"
                },
                "date": {
                    "type": "string",
                    "format": "date-time"
                },
                "method": {
                    "enum": [
                        "e-mail",
                        "GitHub",
                        "conversation"
                    ]
                }
            },
            "required": [
                "by",
                "date",
                "method"
            ],
            "additionalProperties": false
        },
        "client": {
            "title": "client name",
            "type": "string",
            "minLength": 1
        },
        "completed": {
            "title": "date of completion",
            "type": "string",
            "format": "date-time"
        },
        "contacts": {
            "title": "project contacts",
            "description": "client personnel involved in the project",
            "type": "array",
            "items": {
                "$ref": "#/definitions/person"
            },
            "minItems": 1,
            "_uniqueItems": true
        },
        "parties": {
            "title": "counterparties",
            "type": "array",
            "items": {
                "type": "string",
                "minLength": 1
            },
            "_uniqueItems": true
        },
        "project": {
            "title": "project title",
            "type": "string",
            "minLength": 1
        },
        "tags": {
            "title": "project metadata tags",
            "type": "array",
            "items": {
                "type": "string",
                "minLength": 1
            },
            "minItems": 1,
            "_uniqueItems": true
        },
        "person": {
            "title": "name of a person",
            "type": "string",
            "minLength": 1
        },
        "entry": {
            "title": "total time entry",
            "description": "entry of total time served",
            "type": "object",
            "properties": {
                "adjustment": {
                    "$ref": "#/definitions/adjustment"
                },
                "date": {
                    "type": "string",
                    "format": "date-time"
                },
                "narrative": {
                    "$ref": "#/definitions/narrative"
                },
                "time": {
                    "type": "number",
                    "multipleOf": 0.25,
                    "minimum": 0.25
                },
                "spans": {
                    "$ref": "#/definitions/span"
                }
            },
            "required": [
                "narrative"
            ],
            "additionalProperties": false
        },
        "adjustment": {
            "title": "time entry manual adjustment",
            "type": "number",
            "multipleOf": 0.25
        },
        "narrative": {
            "title": "narrative",
            "description": "list of tasks performed",
            "type": "array",
            "items": {
                "type": "string",
                "minLength": 1
            },
            "minItems": 1,
            "_uniqueItems": true
        },
        "service": {
            "title": "list of service entries",
            "type": "array",
            "items": {
                "$ref": "#/definitions/entry"
            }
        },
        "span": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "adjustment": {
                        "$ref": "#/definitions/adjustment"
                    },
                    "end": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "start": {
                        "type": "string",
                        "format": "date-time"
                    }
                },
                "required": [
                    "start",
                    "end"
                ],
                "additionalProperties": false
            }
        }
    }
}