{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "#/components/schemas/Invoice",
  "title": "Invoice",
  "externalDocs": {
    "url": "http://developer.xero.com/documentation/api/invoices/"
  },
  "properties": {
    "Type": {
      "description": "See Invoice Types",
      "type": "string",
      "enum": [
        "ACCPAY",
        "ACCPAYCREDIT",
        "APOVERPAYMENT",
        "APPREPAYMENT",
        "ACCREC",
        "ACCRECCREDIT",
        "AROVERPAYMENT",
        "ARPREPAYMENT"
      ]
    },
    "Contact": {
      "$ref": "#/components/schemas/Contact"
    },
    "LineItems": {
      "description": "See LineItems",
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/LineItem"
      }
    },
    "Date": {
      "description": "Date invoice was issued \u2013 YYYY-MM-DD. If the Date element is not specified it will default to the current date based on the timezone setting of the organisation",
      "type": "string",
      "x-is-msdate": true
    },
    "DueDate": {
      "description": "Date invoice is due \u2013 YYYY-MM-DD",
      "type": "string",
      "x-is-msdate": true
    },
    "LineAmountTypes": {
      "$ref": "#/components/schemas/LineAmountTypes",
      "type": "string"
    },
    "InvoiceNumber": {
      "description": "ACCREC \u2013 Unique alpha numeric code identifying invoice (when missing will auto-generate from your Organisation Invoice Settings) (max length = 255)",
      "maxLength": 255,
      "type": "string"
    },
    "Reference": {
      "description": "ACCREC only \u2013 additional reference number",
      "type": "string"
    },
    "BrandingThemeID": {
      "description": "See BrandingThemes",
      "type": "string",
      "format": "uuid"
    },
    "Url": {
      "description": "URL link to a source document \u2013 shown as \u201cGo to [appName]\u201d in the Xero app",
      "type": "string"
    },
    "CurrencyCode": {
      "$ref": "#/components/schemas/CurrencyCode",
      "type": "string"
    },
    "CurrencyRate": {
      "description": "The currency rate for a multicurrency invoice. If no rate is specified, the XE.com day rate is used. (max length = [18].[6])",
      "type": "number",
      "format": "double",
      "x-is-money": true
    },
    "Status": {
      "description": "See Invoice Status Codes",
      "type": "string",
      "enum": [
        "DRAFT",
        "SUBMITTED",
        "DELETED",
        "AUTHORISED",
        "PAID",
        "VOIDED"
      ]
    },
    "SentToContact": {
      "description": "Boolean to set whether the invoice in the Xero app should be marked as \u201csent\u201d. This can be set only on invoices that have been approved",
      "type": "boolean"
    },
    "ExpectedPaymentDate": {
      "description": "Shown on sales invoices (Accounts Receivable) when this has been set",
      "type": "string",
      "x-is-msdate": true
    },
    "PlannedPaymentDate": {
      "description": "Shown on bills (Accounts Payable) when this has been set",
      "type": "string",
      "x-is-msdate": true
    },
    "CISDeduction": {
      "description": "CIS deduction for UK contractors",
      "readOnly": true,
      "type": "number",
      "format": "double",
      "x-is-money": true
    },
    "CISRate": {
      "description": "CIS Deduction rate for the organisation",
      "type": "number",
      "format": "double",
      "readOnly": true,
      "x-is-money": true
    },
    "SubTotal": {
      "description": "Total of invoice excluding taxes",
      "readOnly": true,
      "type": "number",
      "format": "double",
      "x-is-money": true
    },
    "TotalTax": {
      "description": "Total tax on invoice",
      "readOnly": true,
      "type": "number",
      "format": "double",
      "x-is-money": true
    },
    "Total": {
      "description": "Total of Invoice tax inclusive (i.e. SubTotal + TotalTax). This will be ignored if it doesn\u2019t equal the sum of the LineAmounts",
      "readOnly": true,
      "type": "number",
      "format": "double",
      "x-is-money": true
    },
    "TotalDiscount": {
      "description": "Total of discounts applied on the invoice line items",
      "readOnly": true,
      "type": "number",
      "format": "double",
      "x-is-money": true
    },
    "InvoiceID": {
      "description": "Xero generated unique identifier for invoice",
      "type": "string",
      "format": "uuid"
    },
    "RepeatingInvoiceID": {
      "description": "Xero generated unique identifier for repeating invoices",
      "type": "string",
      "format": "uuid"
    },
    "HasAttachments": {
      "description": "boolean to indicate if an invoice has an attachment",
      "readOnly": true,
      "type": "boolean",
      "default": "false",
      "example": "false"
    },
    "IsDiscounted": {
      "description": "boolean to indicate if an invoice has a discount",
      "readOnly": true,
      "type": "boolean"
    },
    "Payments": {
      "description": "See Payments",
      "readOnly": true,
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/Payment"
      }
    },
    "Prepayments": {
      "description": "See Prepayments",
      "readOnly": true,
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/Prepayment"
      }
    },
    "Overpayments": {
      "description": "See Overpayments",
      "readOnly": true,
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/Overpayment"
      }
    },
    "AmountDue": {
      "description": "Amount remaining to be paid on invoice",
      "readOnly": true,
      "type": "number",
      "format": "double",
      "x-is-money": true
    },
    "AmountPaid": {
      "description": "Sum of payments received for invoice",
      "readOnly": true,
      "type": "number",
      "format": "double",
      "x-is-money": true
    },
    "FullyPaidOnDate": {
      "description": "The date the invoice was fully paid. Only returned on fully paid invoices",
      "readOnly": true,
      "type": "string",
      "x-is-msdate": true
    },
    "AmountCredited": {
      "description": "Sum of all credit notes, over-payments and pre-payments applied to invoice",
      "readOnly": true,
      "type": "number",
      "format": "double",
      "x-is-money": true
    },
    "UpdatedDateUTC": {
      "description": "Last modified date UTC format",
      "type": "string",
      "x-is-msdate-time": true,
      "example": "/Date(1573755038314)/",
      "readOnly": true
    },
    "CreditNotes": {
      "description": "Details of credit notes that have been applied to an invoice",
      "readOnly": true,
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/CreditNote"
      }
    },
    "Attachments": {
      "description": "Displays array of attachments from the API",
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/Attachment"
      }
    },
    "HasErrors": {
      "description": "A boolean to indicate if a invoice has an validation errors",
      "type": "boolean",
      "default": "false",
      "example": "false"
    },
    "StatusAttributeString": {
      "description": "A string to indicate if a invoice status",
      "type": "string"
    },
    "ValidationErrors": {
      "description": "Displays array of validation error messages from the API",
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/ValidationError"
      }
    },
    "Warnings": {
      "description": "Displays array of warning messages from the API",
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/ValidationError"
      }
    },
    "InvoiceAddresses": {
      "description": "An array of addresses used to auto calculate sales tax",
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/InvoiceAddress"
      }
    }
  },
  "type": "object"
}