{
	"$schema": "http://json-schema.org/draft-03/schema#",
	"title": "Accounts collection schema",
	"description": "A schema for retrieving the accounts of the chart of accounts.",
	"type": "object",
	"restdocs": "http://restdocs.e-conomic.com/#get-accounts",
	"properties": {
		"collection": {
			"type": "array",
			"description": "A collection of the accounts.",
			"items": {
				"title": "Account schema",
				"type": "object",
				"description": "A schema for information about an account.",
				"properties": {
					"accountNumber": {
						"type": "integer",
						"filterable": true,
						"sortable": true,
						"defaultsorting": "ascending",
						"description": "The account's number."
					},
					"accountType": {
						"enum": [ "profitAndLoss", "status", "totalFrom", "heading", "headingStart", "sumInterval", "sumAlpha" ],
						"default": "profitAndLoss",
						"filterable": true,
						"sortable": true,
						"description": "The type of account in the chart of accounts."
					},
					"balance": {
						"type": "number",
						"maxDecimal": 2,
						"filterable": true,
						"sortable": true,
						"description": "The current balanace of the account."
					},
					"draftBalance": {
						"type": "number",
						"maxDecimals": 2,
						"description": "The current balance of the account including draft (not yet booked) entries."
					},
					"barred": {
						"type": "boolean",
						"filterable": true,
						"description": "Shows if the account is barred from being used."
					},
					"blockDirectEntries": {
						"type": "boolean",
						"sortable": true,
						"filterable": true,
						"description": "Determines if the account can be manually updated with entries."
					},
					"contraAccount": {
						"type": "object",
						"description": "The default contra account of the account.",
						"properties": {
							"accountNumber": {
								"type": "integer",
								"description": "Account number of the contra account."
							},
							"self": {
								"type": "string",
								"format": "uri",
								"description": "The unique self link of the contra account.",
								"required": true
							}
						}
					},
					"debitCredit": {
						"enum": [ "debit", "credit" ],
						"default": "debit",
						"sortable": true,
						"filterable": true,
						"description": "Describes the default update type of the account."
					},
					"department": {
						"type": "object",
						"description": "The department associated with this account.",
						"properties": {
							"departmentNumber": {
								"type": "integer",
								"description": "A unique identifier of the department."
							},
							"name": {
								"type": "string",
								"maxLength": 250,
								"description": "The name of the department."
							},
							"barred": {
								"type": "boolean",
								"description": "Indicates if the department is barred from usage. Default is false."
							},
							"self": {
								"type": "string",
								"format": "uri",
								"description": "A unique link reference to the department item.",
								"required": true
							}
						}
					},
					"departmentalDistribution": {
						"type": "object",
						"description": "Information about a departmental distribution.",
						"properties": {
							"departmentalDistributionNumber": {
								"type": "integer",
								"description": "A unique numeric identifier for the departmental distribution."
							},
							"name": {
								"type": "string",
								"maxLength": 250,
								"description": "A descriptive name of the specific departmental distribution."
							},
							"distributionType": {
								"type": "string",
								"enum": [ "distribution", "department" ],
								"description": "This property indicates whether the distribution is system generated from a departmentor if it is one created by a user. In order to make it easy to distribute everything to one department, the system generates a distribution for each department."
							},
							"distributions": {
								"type": "array",
								"description": "A list of departments and their share of the distribution in percentage. The percentages always add up to 100%.",
								"items": {
									"title": "Distribution",
									"type": "object",
									"description": "Description of the distributions that make up a departmental distribution.",
									"properties": {
										"percentage": {
											"type": "number",
											"maximum": 100,
											"minimum": 0,
											"exclusiveMinimum": true,
											"description": "The percentage distributed to this department."
										},
										"department": {
											"type": "object",
											"description": "A reference to the department.",
											"properties": {
												"departmentNumber": {
													"type": "integer",
													"minimum": 1,
													"description": "A unique identifier of the department."
												},
												"self": {
													"type": "string",
													"format": "uri",
													"description": "The unique self reference of the department.",
													"required": true
												}
											}
										}
									}
								}
							},
							"self": {
								"type": "string",
								"format": "uri",
								"description": "The unique self reference of the departmental distribution.",
								"required": true
							}
						}
					},
					"name": {
						"type": "string",
						"maxLength": 125,
						"sortable": true,
						"filterable": true,
						"description": "The name of the account."
					},
					"vatAccount": {
						"type": "object",
						"desciption": "The default VAT code for this account.",
						"properties": {
							"vatCode": {
								"type": "string",
								"maxLength": 5,
								"description": "The VAT code of the VAT account for this account."
							},
							"self": {
								"type": "string",
								"format": "uri",
								"description": "The unique self link of the VAT code.",
								"required": true
							}
						}
					},
					"accountsSummed": {
						"type": "array",
						"description": "An array of the account intervals used for calculating the total for this account.",
						"items": {
							"type": "object",
							"description": "An account interval.",
							"properties": {
								"fromAccount": {
									"type": "object",
									"description": "The first account in the interval.",
									"properties": {
										"accountNumber": {
											"type": "integer",
											"description": "Account number of the first account in the interval."
										},
										"self": {
											"type": "string",
											"format": "uri",
											"description": "The unique self link of the first account in the interval.",
											"required": true
										}
									}
								},
								"toAccount": {
									"type": "object",
									"description": "The last account in the interval.",
									"properties": {
										"accountNumber": {
											"type": "integer",
											"description": "Account number of the last account in the interval."
										},
										"self": {
											"type": "string",
											"format": "uri",
											"description": "The unique self link of the last account in the interval.",
											"required": true
										}
									}
								}
							}
						}
					},
					"totalFromAccount": {
						"type": "object",
						"description": "The account from which the sum total for this account is calculated.",
						"properties": {
							"accountNumber": {
								"type": "integer",
								"description": "Account number of the first account."
							},
							"self": {
								"type": "string",
								"format": "uri",
								"description": "The unique self link of the first account.",
								"required": true
							}
						}
					},
					"accountingYears": {
						"type": "string",
						"format": "uri",
						"description": "A link to a list of accounting years for which the account is usable."
					},
					"self": {
						"type": "string",
						"format": "uri",
						"description": "A unique reference to the account resource.",
						"required": true
					}
				}
			}
		},
		"metaData": {
			"type": "object",
			"description": "Information about possible actions, endpoints and resource paths related to the endpoint."
		},
		"pagination": {
			"type": "object",
			"description": "Information about the pagination."
		},
		"self": {
			"type": "string",
			"format": "uri",
			"description": "The unique self reference of the accounts collection.",
			"required": true
		}
	}
}
