{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/xero/main/json-schema/xero-profit-and-loss-response-schema.json",
  "title": "ProfitAndLossResponse",
  "x-generated": "2026-10-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/xero-finance-api-openapi.yml#/components/schemas/ProfitAndLossResponse",
  "type": "object",
  "properties": {
    "startDate": {
      "type": "string",
      "description": "Start date of the report",
      "format": "date"
    },
    "endDate": {
      "type": "string",
      "description": "End date of the report",
      "format": "date"
    },
    "netProfitLoss": {
      "type": "number",
      "description": "Net profit loss value",
      "format": "double",
      "x-is-money": true
    },
    "revenue": {
      "$ref": "#/$defs/PnlAccountClass"
    },
    "expense": {
      "$ref": "#/$defs/PnlAccountClass"
    }
  },
  "additionalProperties": false,
  "$defs": {
    "PnlAccount": {
      "type": "object",
      "properties": {
        "accountID": {
          "type": "string",
          "description": "ID of the account",
          "format": "uuid"
        },
        "accountType": {
          "type": "string",
          "description": "The type of the account. See <a href='https://developer.xero.com/documentation/api/types#AccountTypes'>Account Types</a>"
        },
        "code": {
          "type": "string",
          "description": "Account code"
        },
        "name": {
          "type": "string",
          "description": "Account name"
        },
        "reportingCode": {
          "type": "string",
          "description": "Reporting code (Shown if set)"
        },
        "total": {
          "type": "number",
          "description": "Total movement on this account",
          "format": "double",
          "x-is-money": true
        }
      },
      "additionalProperties": false
    },
    "PnlAccountClass": {
      "type": "object",
      "properties": {
        "total": {
          "type": "number",
          "description": "Total revenue/expense value",
          "format": "double",
          "x-is-money": true
        },
        "accountTypes": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/PnlAccountType"
          },
          "description": "Contains trading income and other income for revenue section / operating expenses and direct cost for expense section if the data is available for each section. Refer to the account type element below"
        }
      },
      "additionalProperties": false
    },
    "PnlAccountType": {
      "type": "object",
      "properties": {
        "total": {
          "type": "number",
          "description": "Total movement on this account type",
          "format": "double",
          "x-is-money": true
        },
        "title": {
          "type": "string",
          "description": "Name of this account type, it will be either Trading Income or Other Income for Revenue section / Direct Cost or Operating Expenses for Expense section"
        },
        "accounts": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/PnlAccount"
          },
          "description": "A list of the movement on each account detail during the query period. Refer to the account detail element below"
        }
      },
      "additionalProperties": false
    }
  }
}