{
	"$schema": "http://json-schema.org/draft-03/schema#",
	"title": "Draft quote schema",
	"description": "A schema for retrieving a draft quote.",
	"type": "object",
	"restdocs": "http://restdocs.e-conomic.com/#get-quotes-drafts-quotenumber",
	"properties": {
		"quoteNumber": {
			"type": "integer",
			"minimum": 1,
			"maximum": 999999999,
			"filterable": true,
			"sortable": true,
			"description": "A reference number for the quote document."
		},
		"date": {
			"type": "string",
			"format": "full-date",
			"pattern": "\\d{4}-\\d{2}-\\d{2}",
			"filterable": true,
			"sortable": true,
			"description": "quote issue date. Format according to ISO-8601 (YYYY-MM-DD)."
		},
		"currency": {
			"type": "string",
			"pattern": "[a-zA-Z]{3}",
			"filterable": true,
			"sortable": true,
			"description": "The ISO 4217 currency code of the quote."
		},
		"exchangeRate": {
			"type": "number",
			"filterable": true,
			"sortable": true,
			"maxDecimal": 6,
			"description": "The exchange rate between the quote currency and the base currency of the agreement. The exchange rate expresses how much it will cost in base currency to buy 100 units of the quote currency."
		},
		"netAmount": {
			"type": "number",
			"maxDecimal": 2,
			"description": "The total quote amount in the quote currency before all taxes and discounts have been applied."
		},
		"netAmountInBaseCurrency": {
			"type": "number",
			"maxDecimal": 2,
			"description": "The total quote amount in the base currency of the agreement before all taxes and discounts have been applied."
		},
		"grossAmount": {
			"type": "number",
			"maxDecimal": 2,
			"description": "The total quote amount in the quote currency after all taxes and discounts have been applied."
		},
		"grossAmountInBaseCurrency": {
			"type": "number",
			"maxDecimal": 2,
			"description": "The total quote amount in the base currency of the agreement after all taxes and discounts have been applied."
		},
		"marginInBaseCurrency": {
			"type": "number",
			"maxDecimal": 2,
			"description": "The difference between the cost price of the items on the quote and the sales net quote amount in base currency."
		},
		"marginPercentage": {
			"type": "number",
			"maxDecimal": 2,
			"description": "The margin expressed as a percentage. If the net quote amount is less than the cost price this number will be negative."
		},
		"vatAmount": {
			"type": "number",
			"maxDecimal": 2,
			"description": "The total amount of VAT on the quote in the quote currency. This will have the same sign as net amount"
		},
		"roundingAmount": {
			"type": "number",
			"maxDecimal": 2,
			"description": "The total rounding error, if any, on the quote in base currency."
		},
		"costPriceInBaseCurrency": {
			"type": "number",
			"maxDecimal": 2,
			"description": "The total cost of the items on the quote in the base currency of the agreement."
		},
		"dueDate": {
			"type": "string",
			"format": "full-date",
			"pattern": "\\d{4}-\\d{2}-\\d{2}",
			"description": "The date the quote, is due for payment. Format according to ISO-8601 (YYYY-MM-DD). This is only used if the terms of payment is of type 'duedate'."
		},
		"attachment": {
			"type": "string",
			"format": "uri",
			"description": "A unique reference to the attachment file on the given draft quote."
		},
		"layout": {
			"type": "object",
			"description": "Layout to be applied for draft quotes and other documents for this customer.",
			"properties": {
				"layoutNumber": {
					"type": "integer",
					"description": "The unique identifier of the layout."
				},
				"self": {
					"type": "string",
					"format": "uri",
					"description": "A unique link reference to the layout item.",
					"required": true
				}
			}
		},
		"paymentTerms": {
			"type": "object",
			"description": "The terms of payment for the quote.",
			"properties": {
				"paymentTermsNumber": {
					"type": "integer",
					"minimum": 0,
					"exclusiveMinimum": true,
					"filterable": true,
					"sortable": true,
					"description": "A unique identifier of the payment term."
				},
				"daysOfCredit": {
					"type": "integer",
					"minimum": 0,
					"description": "The number of days of credit on the quote. This field is only valid if terms of payment is not of type duedate."
				},
				"name": {
					"type": "string",
					"maxLength": 50,
					"description": "The name of the payment terms."
				},
				"paymentTermsType": {
					"enum": [ "net", "invoiceMonth", "paidInCash", "prepaid", "dueDate", "factoring", "invoiceWeekStartingSunday", "invoiceWeekStartingMonday", "creditcard" ],
					"description": "The type of payment term."
				},
				"self": {
					"type": "string",
					"format": "uri",
					"description": "A unique reference to the payment term resource.",
					"required": true
				}
			}
		},
		"customer": {
			"type": "object",
			"description": "The customer of the quote.",
			"properties": {
				"customerNumber": {
					"type": "integer",
					"maximum": 999999999,
					"minimum": 1,
					"filterable": true,
					"sortable": true,
					"description": "The customer id number. The customer id number can be either positive or negative, but it can't be zero."
				},
				"self": {
					"type": "string",
					"format": "uri",
					"description": "A unique reference to the customer resource.",
					"required": true
				}
			}
		},
		"recipient": {
			"type": "object",
			"description": "The actual recipient of the quote. This may be the same info found on the customer (and will probably be so in most cases) but it may also be a different recipient. For instance, the customer placing the quote may be ACME Headquarters, but the recipient of the quote may be ACME IT.",
			"properties": {
				"name": {
					"type": "string",
					"maxLength": 250,
					"filterable": true,
					"sortable": true,
					"description": "The name of the actual recipient."
				},
				"address": {
					"type": "string",
					"maxLength": 250,
					"filterable": true,
					"sortable": true,
					"description": "The street address of the actual recipient."
				},
				"zip": {
					"type": "string",
					"maxLength": 50,
					"filterable": true,
					"sortable": true,
					"description": "The zip code of the actual recipient."
				},
				"city": {
					"type": "string",
					"maxLength": 250,
					"filterable": true,
					"sortable": true,
					"description": "The city of the actual recipient."
				},
				"country": {
					"type": "string",
					"maxLength": 50,
					"filterable": true,
					"sortable": true,
					"description": "The country of the actual recipient."
				},
				"ean": {
					"type": "string",
					"maxLength": 13,
					"filterable": true,
					"sortable": true,
					"description": "The 'European Article Number' of the actual recipient."
				},
				"publicEntryNumber": {
					"type": "string",
					"maxLength": 40,
					"filterable": true,
					"sortable": true,
					"description": "The public entry number of the actual recipient."
				},
				"attention": {
					"type": "object",
					"description": "The person to whom this quote is addressed.",
					"properties": {
						"customerContactNumber": {
							"type": "integer",
							"description": "Unique identifier of the customer employee."
						},
						"self": {
							"type": "string",
							"format": "uri",
							"description": "A unique reference to the customer employee.",
							"required": true
						}
					}
				},
				"vatZone": {
					"type": "object",
					"description": "Recipient vat zone.",
					"properties": {
						"vatZoneNumber": {
							"type": "integer",
							"description": "Unique identifier of the vat zone."
						},
						"self": {
							"type": "string",
							"format": "uri",
							"description": "A unique reference to the vat zone.",
							"required": true
						}
					}
				},
				"cvr": {
					"type": "string",
					"description": "The Corporate Identification Number of the recipient for example CVR in Denmark.",
					"maxLength": 40
				},
				"nemHandelType": {
					"enum": [ "ean", "corporateIdentificationNumber", "pNumber", "peppol", null ],
					"description": "Chosen NemHandel type used for e-invoicing."
				}
			}
		},
		"deliveryLocation": {
			"type": "object",
			"description": "A reference to the place of delivery for the goods on the quote",
			"properties": {
				"deliveryLocationNumber": {
					"type": "integer",
					"filterable": true,
					"sortable": true,
					"description": "A unique identifier for the delivery location."
				},
				"self": {
					"type": "string",
					"format": "uri",
					"description": "A unique reference to the delivery location resource.",
					"required": true
				}
			}
		},
		"delivery": {
			"type": "object",
			"description": "The actual place of delivery for the goods on the quote. This is usually the same place as the one referenced in the deliveryLocation property, but may be edited as required.",
			"properties": {
				"address": {
					"type": "string",
					"maxLength": 255,
					"filterable": true,
					"sortable": true,
					"description": "Street address where the goods must be delivered to the customer."
				},
				"zip": {
					"type": "string",
					"maxLength": 30,
					"filterable": true,
					"sortable": true,
					"description": "The zip code of the place of delivery."
				},
				"city": {
					"type": "string",
					"maxLength": 50,
					"filterable": true,
					"sortable": true,
					"description": "The city of the place of delivery"
				},
				"country": {
					"type": "string",
					"maxLength": 50,
					"filterable": true,
					"sortable": true,
					"description": "The country of the place of delivery"
				},
				"deliveryTerms": {
					"type": "string",
					"maxLength": 100,
					"filterable": true,
					"sortable": true,
					"description": "Details about the terms of delivery."
				},
				"deliveryDate": {
					"type": "string",
					"format": "full-date",
					"pattern": "\\d{4}-\\d{2}-\\d{2}",
					"filterable": true,
					"sortable": true,
					"description": "The date of delivery."
				}
			}
		},
		"notes": {
			"type": "object",
			"description": "Notes on the quote.",
			"properties": {
				"heading": {
					"type": "string",
					"maxLength": 250,
					"filterable": true,
					"sortable": true,
					"description": "The quote heading. Usually displayed at the top of the quote."
				},
				"textLine1": {
					"type": "string",
					"maxLength": 1000,
					"filterable": true,
					"sortable": true,
					"description": "The first line of supplementary text on the quote. This is usually displayed right under the heading in a smaller font."
				},
				"textLine2": {
					"type": "string",
					"maxLength": 1000,
					"filterable": true,
					"sortable": true,
					"description": "The second line of supplementary text in the notes on the quote. This is usually displayed as a footer on the quote."
				}
			}
		},
		"references": {
			"type": "object",
			"description": "Customer and company references related to this quote.",
			"properties": {
				"customerContact": {
					"type": "object",
					"description": "The customer contact is a reference to the employee at the customer to contact regarding the quote.",
					"properties": {
						"customerContactNumber": {
							"type": "integer",
							"minimum": 0,
							"exclusiveMinimum": true,
							"description": "Unique identifier of the customer contact."
						},
						"customer": {
							"type": "object",
							"description": "The customer this contact belongs to.",
							"properties": {
								"customerNumber": {
									"type": "integer",
									"maximum": 999999999,
									"minimum": 1,
									"filterable": true,
									"sortable": true,
									"description": "The customer id number. The customer id number can be either positive or negative, but it can't be zero."
								},
								"self": {
									"type": "string",
									"format": "uri",
									"description": "A unique reference to the customer resource.",
									"required": true
								}
							}
						},
						"self": {
							"type": "string",
							"format": "uri",
							"description": "A unique reference to the customer contact resource.",
							"required": true
						}
					}
				},
				"salesPerson": {
					"type": "object",
					"description": "The sales person is a reference to the employee who sold the goods on the quote. This is also the person who is credited with this sale in reports.",
					"properties": {
						"employeeNumber": {
							"type": "integer",
							"minimum": 1,
							"filterable": true,
							"sortable": true,
							"description": "Unique identifier of the employee."
						},
						"self": {
							"type": "string",
							"format": "uri",
							"description": "A unique reference to the employee resource.",
							"required": true
						}
					}
				},
				"vendorReference": {
					"type": "object",
					"description": "A reference to any second employee involved in the sale.",
					"properties": {
						"employeeNumber": {
							"type": "integer",
							"minimum": 1,
							"filterable": true,
							"sortable": true,
							"description": "Unique identifier of the employee."
						},
						"self": {
							"type": "string",
							"format": "uri",
							"description": "A unique reference to the employee resource.",
							"required": true
						}
					}
				},
				"other": {
					"type": "string",
					"maxLength": 250,
					"filterable": true,
					"sortable": true,
					"description": "A text field that can be used to save any custom reference on the quote."
				}
			}
		},
		"project": {
			"type": "object",
			"description": "The project the quote is connected to.",
			"properties": {
				"projectNumber": {
					"type": "integer",
					"minimum": 1,
					"description": "A unique identifier of the project."
				},
				"self": {
					"type": "string",
					"format": "uri",
					"description": "A unique reference to the project resource.",
					"required": true
				}
			}
		},
		"lastUpdated": {
			"type": "string",
			"format": "full-date",
			"pattern": "\\d{4}-\\d{2}-\\d{2}Td{2}:d{2}:d{2}Z",
			"filterable": true,
			"readOnly": true,
			"description": "The last time the quote was updated. The date is formatted according to ISO-8601."
		},
		"pdf": {
			"type": "object",
			"description": "References a pdf representation of this quote.",
			"properties": {
				"download": {
					"type": "string",
					"format": "uri",
					"description": "The unique reference of the pdf representation for this quote."
				}
			}
		},
		"soap": {
			"type": "object",
			"description": "References a SOAP quote handle.",
			"properties": {
				"quoteHandle": {
					"type": "object",
					"description": "The unique reference of the SOAP quote handle.",
					"properties": {
						"id": {
							"type": "integer",
							"description": "ID of the SOAP quote handle.",
							"filterable": true,
							"sortable": true
						}
					}
				}
			}
		},
		"templates": {
			"type": "object",
			"description": "References to all templates on this quote.",
			"readonly": true,
			"properties": {
				"upgradeInstructions": {
					"type": "string",
					"format": "uri",
					"description": "The self reference to the document to POST to /invoices/drafts to upgrade the quote to an invoice draft."
				},
				"self": {
					"type": "string",
					"format": "uri",
					"description": "The self reference to the quote templates resource.",
					"required": true
				}
			}
		},
		"lines": {
			"title": "quote lines",
			"type": "array",
			"description": "An array containing the specific quote lines.",
			"items": {
				"type": "object",
				"description": "An array of the quote lines that make up the quote.",
				"properties": {
					"lineNumber": {
						"type": "integer",
						"description": "The line number is a unique number within the quote.",
						"minimum": 0,
						"exclusiveMinimum": true
					},
					"sortKey": {
						"type": "integer",
						"description": "A sort key used to sort the lines in ascending quote within the quote.",
						"minimum": 0,
						"exclusiveMinimum": true
					},
					"description": {
						"type": "string",
						"maxLength": 2500,
						"description": "A description of the product or service sold."
					},
					"accrual": {
						"type": "object",
						"description": "Accrual is used to allocate costs and/or revenues over several periods.",
						"properties": {
							"startDate": {
								"type": "string",
								"format": "full-date",
								"pattern": "\\d{4}-\\d{2}-\\d{2}",
								"description": "The start date for the accrual. Format: YYYY-MM-DD."
							},
							"endDate": {
								"type": "string",
								"format": "full-date",
								"pattern": "\\d{4}-\\d{2}-\\d{2}",
								"description": "The end date for the accrual. Format: YYYY-MM-DD."
							}
						}
					},
					"unit": {
						"type": "object",
						"description": "The unit of measure applied to the quote line.",
						"properties": {
							"unitNumber": {
								"type": "integer",
								"description": "The unique identifier of the unit.",
								"minimum": 0,
								"exclusiveMinimum": true
							},
							"name": {
								"type": "string",
								"required": true,
								"maxLength": 100,
								"description": "The name of the unit (e.g. 'kg' for weight or 'l' for volume)."
							},
							"self": {
								"type": "string",
								"format": "uri",
								"description": "A unique reference to the unit resource.",
								"required": true
							}
						}
					},
					"product": {
						"type": "object",
						"description": "The product or service offered on the quote line.",
						"properties": {
							"productNumber": {
								"type": "string",
								"maxLength": 25,
								"description": "The unique product number. This can be a stock keeping unit identifier (SKU)."
							},
							"self": {
								"type": "string",
								"format": "uri",
								"description": "A unique reference to the product resource.",
								"required": true
							}
						}
					},
					"quantity": {
						"type": "number",
						"minimum": 0.01,
						"maximum": 999999999999999999,
						"maxDecimal": 2,
						"description": "The number of units of goods on the quote line."
					},
					"unitNetPrice": {
						"type": "number",
						"maxDecimal": 2,
						"description": "The price of 1 unit of the goods or services on the quote line in the quote currency."
					},
					"discountPercentage": {
						"type": "number",
						"maxDecimal": 2,
						"description": "A line discount expressed as a percentage."
					},
					"unitCostPrice": {
						"type": "number",
						"maxDecimal": 2,
						"description": "The cost price of 1 unit of the goods or services in the quote currency."
					},
					"totalNetAmount": {
						"type": "number",
						"maxDecimal": 2,
						"description": "The total net amount on the quote line in the quote currency."
					},
					"marginInBaseCurrency": {
						"type": "number",
						"maxDecimal": 2,
						"description": "The difference between the net price and the cost price on the quote line in base currency."
					},
					"marginPercentage": {
						"type": "number",
						"maxDecimal": 2,
						"description": "The margin on the quote line expressed as a percentage."
					},
					"departmentalDistribution": {
						"type": "object",
						"description": "A departmental distribution defines which departments this entry is distributed between. This requires the departments module to be enabled.",
						"properties": {
							"departmentalDistributionNumber": {
								"type": "integer",
								"minimum": 1,
								"description": "A unique identifier of the departmental distribution."
							},
							"distributionType": {
								"type": "string",
								"description": "Type of the distribution"
							},
							"self": {
								"type": "string",
								"format": "uri",
								"description": "A unique reference to the departmental distribution resource.",
								"required": true
							}
						}
					}
				}
			}
		},
		"self": {
			"type": "string",
			"format": "uri",
			"description": "The unique self reference of the draft quote.",
			"required": true
		}
	}
}
