{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/spaceinvoices-com/json-schema/spaceinvoices-com-invoice-with-relations-schema.json",
  "title": "InvoiceWithRelations",
  "description": "(tsType: InvoiceWithRelations, schemaOptions: { includeRelations: true })",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/spaceinvoices-com-openapi.json#/components/schemas/InvoiceWithRelations",
  "type": "object",
  "properties": {
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "custom": {
      "type": "object",
      "description": "Custom field for free input data"
    },
    "l10n": {
      "type": "object",
      "description": "Object for storing localized values of strings"
    },
    "_isDeleted": {
      "type": "boolean"
    },
    "deletedAt": {
      "type": "string",
      "format": "date-time"
    },
    "number": {
      "type": "string"
    },
    "date": {
      "type": "string",
      "format": "date-time"
    },
    "reference": {
      "type": "string",
      "description": "Reference for payment identification"
    },
    "total": {
      "type": "number"
    },
    "totalConverted": {
      "type": "number"
    },
    "totalDiscount": {
      "type": "number"
    },
    "totalWithTax": {
      "type": "number"
    },
    "totalWithTaxConverted": {
      "type": "number"
    },
    "decimalPlaces": {
      "type": "number",
      "minimum": 0,
      "maximum": 9
    },
    "note": {
      "type": "string"
    },
    "taxClause": {
      "type": "string",
      "description": "Document tax clause used to replace [tax clause] smart code when visualising document. Automatically populated on document save/update if not provided."
    },
    "omitTaxes": {
      "type": "boolean",
      "description": "If taxes should be omited when issuing document. Automatically populated on document if set using omit_tax_ default."
    },
    "footer": {
      "type": "string"
    },
    "signature": {
      "type": "string"
    },
    "type": {
      "type": "string"
    },
    "sentSnailMail": {
      "type": "boolean"
    },
    "currencyId": {
      "type": "string",
      "description": "Document 3 letter currency id based on ISO 4217 standard."
    },
    "_documentTaxes": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/DocumentTax"
      }
    },
    "_documentReverseTaxes": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/DocumentTax"
      }
    },
    "hasUnit": {
      "type": "boolean",
      "description": "Indicates if document has any items with unit specified. Used for display."
    },
    "uniqueId": {
      "type": "string",
      "description": "Optional user defined random unique value for each unique document used to prevent saving same document twice in case of connection drop. If a match happens the system returns the found document instead of a new one."
    },
    "equalization": {
      "type": "number",
      "description": "Cent equalization amount"
    },
    "issuedAt": {
      "type": "string",
      "format": "date-time",
      "description": "Date document was issued, can be different than createdAt if created as draft"
    },
    "dateYear": {
      "type": "number"
    },
    "shareableId": {
      "type": "string"
    },
    "_documentIssuer": {
      "type": "object"
    },
    "_documentClient": {
      "type": "object"
    },
    "_documentItems": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/DocumentItem"
      }
    },
    "incoming": {
      "type": "boolean"
    },
    "id": {
      "type": "string"
    },
    "draft": {
      "type": "boolean"
    },
    "dateService": {
      "type": "string",
      "format": "date-time"
    },
    "dateServiceTo": {
      "type": "string",
      "format": "date-time"
    },
    "dateDue": {
      "type": "string",
      "format": "date-time"
    },
    "canceled": {
      "type": "boolean"
    },
    "totalPaid": {
      "type": "number"
    },
    "totalDue": {
      "type": "number"
    },
    "paidInFull": {
      "type": "boolean"
    },
    "chargesDisabled": {
      "type": "boolean",
      "description": "Indicates if payment processing via Pay now button is disabled for this document"
    },
    "stripeConnectPaymentIntent": {
      "type": "object"
    },
    "organizationId": {
      "type": "string"
    },
    "accountId": {
      "type": "string"
    },
    "clientId": {
      "type": "string"
    },
    "_fatturaPa": {
      "type": "object"
    },
    "organization": {
      "$ref": "#/$defs/OrganizationWithRelations"
    },
    "account": {
      "$ref": "#/$defs/AccountWithRelations"
    },
    "client": {
      "$ref": "#/$defs/ClientWithRelations"
    }
  },
  "required": [
    "date",
    "total",
    "totalWithTax",
    "currencyId",
    "hasUnit",
    "dateYear",
    "_documentIssuer",
    "_documentClient",
    "_documentItems"
  ],
  "additionalProperties": false,
  "x-typescript-type": "InvoiceWithRelations",
  "$defs": {
    "AccessTokenWithRelations": {
      "title": "AccessTokenWithRelations",
      "type": "object",
      "description": "(tsType: AccessTokenWithRelations, schemaOptions: { includeRelations: true })",
      "properties": {
        "id": {
          "type": "string"
        },
        "ttl": {
          "type": "number"
        },
        "scopes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "created": {
          "type": "string",
          "format": "date-time"
        },
        "userId": {
          "type": "string"
        },
        "user": {
          "$ref": "#/$defs/AccountWithRelations"
        }
      },
      "required": [
        "userId"
      ],
      "additionalProperties": false,
      "x-typescript-type": "AccessTokenWithRelations"
    },
    "AccountWithRelations": {
      "title": "AccountWithRelations",
      "type": "object",
      "description": "(tsType: AccountWithRelations, schemaOptions: { includeRelations: true })",
      "properties": {
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "custom": {
          "type": "object",
          "description": "Custom field for free input data"
        },
        "id": {
          "type": "string"
        },
        "password": {
          "type": "string"
        },
        "email": {
          "type": "string"
        },
        "emailVerified": {
          "type": "boolean"
        },
        "verificationToken": {
          "type": "string"
        },
        "locale": {
          "type": "string"
        },
        "firstname": {
          "type": "string"
        },
        "lastname": {
          "type": "string"
        },
        "taxNumber": {
          "type": "string",
          "description": "Personal tax number, required for fiscalization."
        },
        "label": {
          "type": "string",
          "description": "Label of person issuing invoices. Required for fiscalization. Should be unique per organization but we can't validate this. But can be checked based on accountId saved to _furs object."
        },
        "parentId": {
          "type": "string"
        },
        "masterId": {
          "type": "string"
        },
        "billingOrganizationId": {
          "type": "string"
        },
        "role": {
          "type": "string",
          "description": "Role within organization."
        },
        "softwareSupplierTaxNumber": {
          "type": "string",
          "description": "For tax number of primary account providing fiscal verification to their end customers."
        },
        "activateRedirect": {
          "type": "string",
          "description": "Custom activation redirect URL for sub-accounts."
        },
        "invitationLink": {
          "type": "string",
          "description": "Custom link where invited user can review invitations."
        },
        "invitationNewLink": {
          "type": "string",
          "description": "Custom link to view invitation for non existing user."
        },
        "documentShareableLink": {
          "type": "string",
          "description": "Custom link for shareable document view."
        },
        "disableCreatingChildOrganizations": {
          "type": "boolean",
          "description": "Disable child accounts creating organizations"
        },
        "resetRedirect": {
          "type": "string",
          "description": "Custom password reset redirect URL for sub accounts of this account."
        },
        "skipChildAccountVerification": {
          "type": "boolean"
        },
        "accessTokens": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/AccessTokenWithRelations"
          }
        },
        "organizations": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/OrganizationWithRelations"
          }
        },
        "stripeConnect": {
          "$ref": "#/$defs/StripeConnectWithRelations"
        },
        "paymentProcessing": {
          "$ref": "#/$defs/PaymentProcessingWithRelations"
        },
        "emailAddress": {
          "$ref": "#/$defs/EmailAddressWithRelations"
        }
      },
      "required": [
        "password",
        "email"
      ],
      "additionalProperties": false,
      "x-typescript-type": "AccountWithRelations"
    },
    "At": {
      "properties": {
        "hashSource": {
          "type": "string"
        },
        "hash": {
          "type": "string"
        },
        "qrString": {
          "type": "string"
        },
        "qrCode": {
          "type": "string"
        },
        "certificateVersion": {
          "type": "string"
        },
        "certificateId": {
          "type": "string"
        },
        "hashExtract": {
          "type": "string"
        },
        "printCount": {
          "default": 0,
          "description": "Number of prints of document. If > 1 should print 'copy n' on it.",
          "type": "number",
          "format": "double"
        },
        "cancellationReason": {
          "type": "string"
        },
        "canceledByAccountId": {
          "type": "string"
        },
        "hasOriginalDocument": {
          "type": "boolean"
        },
        "isManual": {
          "default": false,
          "type": "boolean"
        },
        "manualNumber": {
          "type": "string"
        },
        "manualNumberSeries": {
          "type": "string"
        },
        "manualNumberSequentialNumber": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "accountId": {
          "$ref": "#/$defs/ObjectID"
        },
        "previousDocumentId": {
          "$ref": "#/$defs/ObjectID"
        },
        "atcudSeriesId": {
          "$ref": "#/$defs/ObjectID"
        }
      },
      "additionalProperties": false
    },
    "ClientWithRelations": {
      "title": "ClientWithRelations",
      "type": "object",
      "description": "(tsType: ClientWithRelations, schemaOptions: { includeRelations: true })",
      "properties": {
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "custom": {
          "type": "object",
          "description": "Custom field for free input data"
        },
        "name": {
          "type": "string"
        },
        "address": {
          "type": "string"
        },
        "address2": {
          "type": "string"
        },
        "city": {
          "type": "string"
        },
        "zip": {
          "type": "string"
        },
        "state": {
          "type": "string"
        },
        "country": {
          "type": "string"
        },
        "countryAlpha2Code": {
          "type": "string"
        },
        "taxNumber": {
          "type": "string"
        },
        "taxSubject": {
          "type": "boolean"
        },
        "companyNumber": {
          "type": "string"
        },
        "IBAN": {
          "type": "string"
        },
        "bank": {
          "type": "string"
        },
        "SWIFT": {
          "type": "string"
        },
        "website": {
          "type": "string"
        },
        "email": {
          "type": "string"
        },
        "phone": {
          "type": "string"
        },
        "businessType": {
          "type": "string",
          "description": "Type of business entity."
        },
        "startingCapital": {
          "type": "number"
        },
        "_isDeleted": {
          "type": "boolean"
        },
        "deletedAt": {
          "type": "string",
          "format": "date-time"
        },
        "id": {
          "type": "string"
        },
        "contact": {
          "type": "string"
        },
        "note": {
          "type": "string"
        },
        "isEndCustomer": {
          "type": "boolean"
        },
        "type": {
          "type": "string",
          "description": "Type of client, customer, supplier or both."
        },
        "companyId": {
          "type": "string",
          "description": "Reference to companies model for internal analysis."
        },
        "organizationId": {
          "type": "string"
        },
        "organization": {
          "$ref": "#/$defs/OrganizationWithRelations"
        }
      },
      "required": [
        "name"
      ],
      "additionalProperties": false,
      "x-typescript-type": "ClientWithRelations"
    },
    "Component": {
      "properties": {
        "id": {
          "type": "string"
        },
        "amount": {
          "description": "How many of this component go into one parent composed item.",
          "type": "number",
          "format": "double"
        },
        "itemId": {
          "$ref": "#/$defs/ObjectID"
        },
        "custom": {
          "default": {},
          "description": "Custom field for freeform data input",
          "type": "object"
        }
      },
      "required": [
        "id",
        "amount"
      ],
      "additionalProperties": false
    },
    "Data": {
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "description": "Name identifier of data",
          "type": "string"
        },
        "value": {
          "$ref": "#/$defs/x-any"
        },
        "options": {
          "description": "Different data options.\nIe. should the value be persistem to the document `onPDF: boolean`.\nThis includes displaying on PDF.\nNote that only two values will be displayed per PDF on Client.\nAdd Document data to export using `export: boolean`",
          "type": "object"
        }
      },
      "required": [
        "id",
        "name"
      ],
      "additionalProperties": false
    },
    "DefaultWithRelations": {
      "title": "DefaultWithRelations",
      "type": "object",
      "description": "(tsType: DefaultWithRelations, schemaOptions: { includeRelations: true })",
      "properties": {
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "l10n": {
          "type": "object",
          "description": "Object for storing localized values of strings"
        },
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "value": {},
        "description": {
          "type": "string"
        },
        "organizationId": {
          "type": "string"
        },
        "organization": {
          "$ref": "#/$defs/OrganizationWithRelations"
        }
      },
      "required": [
        "organizationId"
      ],
      "additionalProperties": false,
      "x-typescript-type": "DefaultWithRelations"
    },
    "DocumentConversionRate": {
      "properties": {
        "id": {
          "type": "string"
        },
        "dualCurrency": {
          "description": "Is conversion meant for dual currency display.\ni.e. for Croatian organizations from 5.9.2022 to 1.1.2023\nShows conversion only for total and not taxes",
          "type": "boolean"
        },
        "from": {
          "type": "string"
        },
        "to": {
          "type": "string"
        },
        "rate": {
          "type": "number",
          "format": "double"
        },
        "date": {
          "type": "string",
          "format": "date-time"
        },
        "source": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "from",
        "to",
        "rate",
        "date",
        "source"
      ],
      "additionalProperties": false
    },
    "DocumentItem": {
      "properties": {
        "id": {
          "type": "string"
        },
        "discount": {
          "type": "number",
          "format": "double"
        },
        "discountIsAmount": {
          "default": false,
          "type": "boolean"
        },
        "quantity": {
          "type": "number",
          "format": "double"
        },
        "total": {
          "type": "number",
          "format": "double"
        },
        "totalWithTax": {
          "type": "number",
          "format": "double"
        },
        "totalTax": {
          "type": "number",
          "format": "double"
        },
        "totalDiscount": {
          "type": "number",
          "format": "double"
        },
        "isSeparator": {
          "default": false,
          "type": "boolean"
        },
        "name": {
          "type": "string"
        },
        "description": {
          "default": "",
          "type": "string"
        },
        "price": {
          "type": "number",
          "format": "double"
        },
        "priceGross": {
          "type": "number",
          "format": "double"
        },
        "classification": {
          "type": "string"
        },
        "unit": {
          "type": "string"
        },
        "SKU": {
          "type": "string"
        },
        "EAN": {
          "type": "string"
        },
        "trackInventory": {
          "type": "boolean"
        },
        "onBehalf": {
          "description": "tax number of company selling this item/service on behalf of",
          "type": "string"
        },
        "taxExemptionCode": {
          "description": "Has to be specified in some countries if the tax is 0 or not present",
          "type": "string"
        },
        "taxExemptionReason": {
          "description": "Has to be specified in some countries if the tax is 0 or not present",
          "type": "string"
        },
        "kpd": {
          "description": "KPD classification code (Croatian CPA) - format XX.XX.XX",
          "type": "string"
        },
        "itemId": {
          "$ref": "#/$defs/ObjectID"
        },
        "_taxExemption": {
          "$ref": "#/$defs/TaxExemption"
        },
        "custom": {
          "default": {},
          "description": "Custom field for freeform data input",
          "type": "object"
        },
        "l10n": {
          "description": "Object for storing localized values of strings",
          "type": "object"
        },
        "_documentItemTaxes": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DocumentItemTax"
          }
        },
        "_components": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Component"
          }
        },
        "_data": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Data"
          }
        }
      },
      "required": [
        "id"
      ],
      "additionalProperties": false
    },
    "DocumentItemTax": {
      "properties": {
        "id": {
          "type": "string"
        },
        "rate": {
          "type": "number",
          "format": "double"
        },
        "reverseCharged": {
          "default": false,
          "type": "boolean"
        },
        "name": {
          "type": "string"
        },
        "abbreviation": {
          "type": "string"
        },
        "recoverable": {
          "default": true,
          "type": "boolean"
        },
        "compound": {
          "default": false,
          "type": "boolean"
        },
        "taxNumber": {
          "description": "Tax number associated with this tax.",
          "type": "string"
        },
        "taxExemptionReason": {
          "description": "Tax number associated with this tax.",
          "type": "string"
        },
        "taxExemptionCode": {
          "description": "Tax exemption code associated with this tax.",
          "type": "string"
        },
        "taxId": {
          "$ref": "#/$defs/ObjectID"
        }
      },
      "required": [
        "id",
        "rate",
        "reverseCharged",
        "recoverable",
        "compound"
      ],
      "additionalProperties": false
    },
    "DocumentTax": {
      "title": "DocumentTax",
      "type": "object",
      "properties": {
        "taxId": {
          "type": "string"
        },
        "tax": {
          "type": "number"
        },
        "base": {
          "type": "number"
        },
        "baseConverted": {
          "type": "number"
        },
        "abbreviation": {
          "type": "string"
        },
        "totalTax": {
          "type": "number"
        },
        "totalTaxConverted": {
          "type": "number"
        }
      },
      "required": [
        "tax",
        "base",
        "totalTax",
        "totalTaxConverted"
      ],
      "additionalProperties": false
    },
    "DocumentWithRelations": {
      "title": "DocumentWithRelations",
      "type": "object",
      "description": "(tsType: DocumentWithRelations, schemaOptions: { includeRelations: true })",
      "properties": {
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "custom": {
          "type": "object",
          "description": "Custom field for free input data"
        },
        "l10n": {
          "type": "object",
          "description": "Object for storing localized values of strings"
        },
        "_isDeleted": {
          "type": "boolean"
        },
        "deletedAt": {
          "type": "string",
          "format": "date-time"
        },
        "number": {
          "type": "string"
        },
        "draft": {
          "type": "boolean"
        },
        "date": {
          "type": "string",
          "format": "date-time"
        },
        "dateService": {
          "type": "string",
          "format": "date-time"
        },
        "dateServiceTo": {
          "type": "string",
          "format": "date-time"
        },
        "dateDue": {
          "type": "string",
          "format": "date-time"
        },
        "dateValidTill": {
          "type": "string",
          "format": "date-time"
        },
        "datePaid": {
          "type": "string",
          "format": "date-time"
        },
        "dateReceived": {
          "type": "string",
          "format": "date-time",
          "description": "Date document was received, used for incoming documents."
        },
        "reference": {
          "type": "string",
          "description": "Reference for payment identification"
        },
        "total": {
          "type": "number"
        },
        "totalConverted": {
          "type": "number"
        },
        "totalDiscount": {
          "type": "number"
        },
        "totalWithTax": {
          "type": "number"
        },
        "totalWithTaxConverted": {
          "type": "number"
        },
        "decimalPlaces": {
          "type": "number"
        },
        "note": {
          "type": "string"
        },
        "taxClause": {
          "type": "string",
          "description": "Document tax clause used to replace [tax clause] smart code when visualising document. Automatically populated on document save/update if not provided."
        },
        "omitTaxes": {
          "type": "boolean",
          "description": "If taxes should be omited when issuing document. Automatically populated on document if set using omit_tax_ default."
        },
        "keepPricesAsGross": {
          "type": "boolean",
          "description": "Forces not removing tax from gross price when using omitTaxes"
        },
        "footer": {
          "type": "string"
        },
        "signature": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "displayName": {
          "type": "string",
          "description": "Customize the dispay name of a document type"
        },
        "canceled": {
          "type": "boolean"
        },
        "sentSnailMail": {
          "type": "boolean"
        },
        "totalPaid": {
          "type": "number"
        },
        "totalDue": {
          "type": "number"
        },
        "paidInFull": {
          "type": "boolean"
        },
        "currencyId": {
          "type": "string",
          "description": "Because currency is not an actual lb model it can't be used as relation. Since this value matches isoName of currency there is never a need to expand the relational data. It can still be loaded separately by id from Currency model if needed."
        },
        "_documentTaxes": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DocumentTax"
          }
        },
        "_documentReverseTaxes": {
          "type": "array",
          "items": {
            "type": "object",
            "description": "Array of unique taxes on document. Used for display."
          }
        },
        "hasUnit": {
          "type": "boolean",
          "description": "Indicates if document has any items with unit specified. Used for display."
        },
        "validateEslog": {
          "type": "boolean",
          "description": "Indicates if document should be validated based on eslog format."
        },
        "isValidEslog": {
          "type": "boolean",
          "description": "Property indicating that a document is in valid eslog format"
        },
        "uniqueId": {
          "type": "string",
          "description": "Optional user defined random unique value for each unique document used to prevent saving same document twice in case of connection drop. If a match happens the system returns the found document instead of a new one."
        },
        "customTotals": {
          "type": "boolean",
          "description": "If true document tax and amount totals won't be calculated, provided values will be used instead"
        },
        "incoming": {
          "type": "boolean",
          "description": "Indicates document is incoming ie. expense if invoices etc."
        },
        "numberInternal": {
          "type": "string",
          "description": "Internal tracking number"
        },
        "equalization": {
          "type": "number",
          "description": "Cent equalization amount"
        },
        "sandbox": {
          "type": "boolean"
        },
        "issuedAt": {
          "type": "string",
          "format": "date-time",
          "description": "Date document was issued, can be different than createdAt if created as draft"
        },
        "shareableId": {
          "type": "string"
        },
        "chargesDisabled": {
          "type": "boolean",
          "description": "Indicates if payment processing via Pay now button is disabled for this document"
        },
        "stripeConnectPaymentIntent": {
          "type": "object"
        },
        "_documentIssuer": {
          "type": "object"
        },
        "_documentClient": {
          "type": "object"
        },
        "_documentItems": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DocumentItem"
          }
        },
        "_fatturaPa": {
          "type": "object"
        },
        "id": {
          "type": "string"
        },
        "unitId": {
          "type": "string"
        },
        "documentIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "organizationId": {
          "type": "string"
        },
        "accountId": {
          "type": "string"
        },
        "clientId": {
          "type": "string"
        },
        "_at": {
          "$ref": "#/$defs/At"
        },
        "_documentConversionRate": {
          "$ref": "#/$defs/DocumentConversionRate"
        },
        "referencedDocuments": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DocumentWithRelations"
          }
        },
        "payments": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/PaymentWithRelations"
          }
        },
        "organization": {
          "$ref": "#/$defs/OrganizationWithRelations"
        },
        "account": {
          "$ref": "#/$defs/AccountWithRelations"
        },
        "paymentIntents": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/PaymentIntentWithRelations"
          }
        },
        "client": {
          "$ref": "#/$defs/ClientWithRelations"
        }
      },
      "required": [
        "type",
        "canceled",
        "currencyId",
        "organizationId",
        "accountId"
      ],
      "additionalProperties": false,
      "x-typescript-type": "DocumentWithRelations"
    },
    "EmailAddressWithRelations": {
      "title": "EmailAddressWithRelations",
      "type": "object",
      "description": "(tsType: EmailAddressWithRelations, schemaOptions: { includeRelations: true })",
      "properties": {
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "id": {
          "type": "string"
        },
        "email": {
          "type": "string"
        },
        "emailVerificationStatus": {
          "type": "string",
          "enum": [
            "Pending",
            "Success",
            "Failed",
            "TemporaryFailure",
            "NotStarted"
          ]
        },
        "domainVerificationStatus": {
          "type": "string",
          "enum": [
            "Pending",
            "Success",
            "Failed",
            "TemporaryFailure",
            "NotStarted"
          ]
        },
        "tokens": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "accountId": {
          "type": "string"
        },
        "organizationId": {
          "type": "string"
        },
        "account": {
          "$ref": "#/$defs/AccountWithRelations"
        },
        "organization": {
          "$ref": "#/$defs/OrganizationWithRelations"
        }
      },
      "required": [
        "email",
        "tokens"
      ],
      "additionalProperties": false,
      "oneOf": [
        {
          "required": [
            "accountId"
          ]
        },
        {
          "required": [
            "organizationId"
          ]
        }
      ],
      "x-typescript-type": "EmailAddressWithRelations"
    },
    "InvoiceWithRelations": {
      "title": "InvoiceWithRelations",
      "type": "object",
      "description": "(tsType: InvoiceWithRelations, schemaOptions: { includeRelations: true })",
      "properties": {
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "custom": {
          "type": "object",
          "description": "Custom field for free input data"
        },
        "l10n": {
          "type": "object",
          "description": "Object for storing localized values of strings"
        },
        "_isDeleted": {
          "type": "boolean"
        },
        "deletedAt": {
          "type": "string",
          "format": "date-time"
        },
        "number": {
          "type": "string"
        },
        "date": {
          "type": "string",
          "format": "date-time"
        },
        "reference": {
          "type": "string",
          "description": "Reference for payment identification"
        },
        "total": {
          "type": "number"
        },
        "totalConverted": {
          "type": "number"
        },
        "totalDiscount": {
          "type": "number"
        },
        "totalWithTax": {
          "type": "number"
        },
        "totalWithTaxConverted": {
          "type": "number"
        },
        "decimalPlaces": {
          "type": "number",
          "minimum": 0,
          "maximum": 9
        },
        "note": {
          "type": "string"
        },
        "taxClause": {
          "type": "string",
          "description": "Document tax clause used to replace [tax clause] smart code when visualising document. Automatically populated on document save/update if not provided."
        },
        "omitTaxes": {
          "type": "boolean",
          "description": "If taxes should be omited when issuing document. Automatically populated on document if set using omit_tax_ default."
        },
        "footer": {
          "type": "string"
        },
        "signature": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "sentSnailMail": {
          "type": "boolean"
        },
        "currencyId": {
          "type": "string",
          "description": "Document 3 letter currency id based on ISO 4217 standard."
        },
        "_documentTaxes": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DocumentTax"
          }
        },
        "_documentReverseTaxes": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DocumentTax"
          }
        },
        "hasUnit": {
          "type": "boolean",
          "description": "Indicates if document has any items with unit specified. Used for display."
        },
        "uniqueId": {
          "type": "string",
          "description": "Optional user defined random unique value for each unique document used to prevent saving same document twice in case of connection drop. If a match happens the system returns the found document instead of a new one."
        },
        "equalization": {
          "type": "number",
          "description": "Cent equalization amount"
        },
        "issuedAt": {
          "type": "string",
          "format": "date-time",
          "description": "Date document was issued, can be different than createdAt if created as draft"
        },
        "dateYear": {
          "type": "number"
        },
        "shareableId": {
          "type": "string"
        },
        "_documentIssuer": {
          "type": "object"
        },
        "_documentClient": {
          "type": "object"
        },
        "_documentItems": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DocumentItem"
          }
        },
        "incoming": {
          "type": "boolean"
        },
        "id": {
          "type": "string"
        },
        "draft": {
          "type": "boolean"
        },
        "dateService": {
          "type": "string",
          "format": "date-time"
        },
        "dateServiceTo": {
          "type": "string",
          "format": "date-time"
        },
        "dateDue": {
          "type": "string",
          "format": "date-time"
        },
        "canceled": {
          "type": "boolean"
        },
        "totalPaid": {
          "type": "number"
        },
        "totalDue": {
          "type": "number"
        },
        "paidInFull": {
          "type": "boolean"
        },
        "chargesDisabled": {
          "type": "boolean",
          "description": "Indicates if payment processing via Pay now button is disabled for this document"
        },
        "stripeConnectPaymentIntent": {
          "type": "object"
        },
        "organizationId": {
          "type": "string"
        },
        "accountId": {
          "type": "string"
        },
        "clientId": {
          "type": "string"
        },
        "_fatturaPa": {
          "type": "object"
        },
        "organization": {
          "$ref": "#/$defs/OrganizationWithRelations"
        },
        "account": {
          "$ref": "#/$defs/AccountWithRelations"
        },
        "client": {
          "$ref": "#/$defs/ClientWithRelations"
        }
      },
      "required": [
        "date",
        "total",
        "totalWithTax",
        "currencyId",
        "hasUnit",
        "dateYear",
        "_documentIssuer",
        "_documentClient",
        "_documentItems"
      ],
      "additionalProperties": false,
      "x-typescript-type": "InvoiceWithRelations"
    },
    "MerchantWithRelations": {
      "title": "MerchantWithRelations",
      "type": "object",
      "description": "(tsType: MerchantWithRelations, schemaOptions: { includeRelations: true })",
      "properties": {
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "id": {
          "type": "string"
        },
        "merchantId": {
          "type": "string",
          "description": "Payment processor merchant id"
        },
        "applicationId": {
          "type": "string",
          "description": "Payment processor application id"
        },
        "link": {
          "type": "string",
          "description": "Payment processor onboarding link"
        },
        "chargesEnabled": {
          "type": "boolean",
          "description": "Indicates if merchant is permitted to execute charges"
        },
        "active": {
          "type": "boolean"
        },
        "organizationId": {
          "type": "string"
        },
        "paymentProcessingId": {
          "type": "string"
        },
        "organization": {
          "$ref": "#/$defs/OrganizationWithRelations"
        },
        "paymentProcessing": {
          "$ref": "#/$defs/PaymentProcessingWithRelations"
        }
      },
      "required": [
        "organizationId",
        "paymentProcessingId"
      ],
      "additionalProperties": false,
      "x-typescript-type": "MerchantWithRelations"
    },
    "ObjectID": {
      "type": "string",
      "pattern": "^[a-fA-F\\d]{24}$"
    },
    "OrganizationWithRelations": {
      "title": "OrganizationWithRelations",
      "type": "object",
      "description": "(tsType: OrganizationWithRelations, schemaOptions: { includeRelations: true })",
      "properties": {
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "custom": {
          "type": "object",
          "description": "Custom field for free input data"
        },
        "name": {
          "type": "string"
        },
        "address": {
          "type": "string"
        },
        "address2": {
          "type": "string"
        },
        "city": {
          "type": "string"
        },
        "zip": {
          "type": "string"
        },
        "state": {
          "type": "string"
        },
        "country": {
          "type": "string"
        },
        "countryAlpha2Code": {
          "type": "string"
        },
        "taxNumber": {
          "type": "string"
        },
        "taxSubject": {
          "type": "boolean"
        },
        "companyNumber": {
          "type": "string"
        },
        "IBAN": {
          "type": "string"
        },
        "bank": {
          "type": "string"
        },
        "SWIFT": {
          "type": "string"
        },
        "website": {
          "type": "string"
        },
        "email": {
          "type": "string"
        },
        "phone": {
          "type": "string"
        },
        "businessType": {
          "type": "string",
          "description": "Type of business entity."
        },
        "startingCapital": {
          "type": "number"
        },
        "id": {
          "type": "string"
        },
        "locale": {
          "type": "string"
        },
        "timezone": {
          "type": "string"
        },
        "active": {
          "type": "boolean"
        },
        "supportPin": {
          "type": "number"
        },
        "size": {
          "type": "string"
        },
        "industry": {
          "type": "string"
        },
        "companyId": {
          "type": "string",
          "description": "Reference to companies model for internal tracking."
        },
        "billingEmail": {
          "type": "string",
          "description": "Billing email used for SI customers if is billing organization"
        },
        "activatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "deactivatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "sandbox": {
          "type": "boolean"
        },
        "fiscalRegionCode": {
          "type": "string",
          "description": "Fiscal region used in portugal. Possible values: PT, PT-AC, PT-MD"
        },
        "stripeConnectAccount": {
          "$ref": "#/$defs/StripeConnectAccountWithRelations"
        },
        "merchant": {
          "$ref": "#/$defs/MerchantWithRelations"
        },
        "accounts": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/AccountWithRelations"
          }
        },
        "invoices": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/InvoiceWithRelations"
          }
        },
        "_defaults": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DefaultWithRelations"
          }
        },
        "clients": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ClientWithRelations"
          }
        },
        "taxes": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/TaxWithRelations"
          }
        },
        "transactions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/TransactionWithRelations"
          }
        },
        "paymentIntents": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/PaymentIntentWithRelations"
          }
        },
        "emailAddress": {
          "$ref": "#/$defs/EmailAddressWithRelations"
        }
      },
      "required": [
        "name"
      ],
      "additionalProperties": false,
      "x-typescript-type": "OrganizationWithRelations"
    },
    "PaymentIntentWithRelations": {
      "title": "PaymentIntentWithRelations",
      "type": "object",
      "description": "(tsType: PaymentIntentWithRelations, schemaOptions: { includeRelations: true })",
      "properties": {
        "id": {
          "type": "string"
        },
        "getPaidPaymentId": {
          "type": "string"
        },
        "paymentLink": {
          "type": "string",
          "description": "Link to payment page"
        },
        "amount": {
          "type": "number"
        },
        "reference": {
          "type": "string"
        },
        "returnURL": {
          "type": "string"
        },
        "allowRecurring": {
          "type": "boolean"
        },
        "currencyId": {
          "type": "string"
        },
        "expiresAt": {
          "type": "string",
          "format": "date-time"
        },
        "applicationFee": {
          "type": "number"
        },
        "spaceInvoicesFee": {
          "type": "number"
        },
        "initialPaymentIntentId": {
          "type": "string"
        },
        "status": {
          "type": "string"
        },
        "succeeded": {
          "type": "boolean"
        },
        "documentId": {
          "type": "string"
        },
        "organizationId": {
          "type": "string"
        },
        "document": {
          "$ref": "#/$defs/DocumentWithRelations"
        },
        "organization": {
          "$ref": "#/$defs/OrganizationWithRelations"
        }
      },
      "required": [
        "getPaidPaymentId",
        "amount",
        "reference",
        "currencyId",
        "applicationFee",
        "spaceInvoicesFee",
        "status",
        "organizationId"
      ],
      "additionalProperties": false,
      "x-typescript-type": "PaymentIntentWithRelations"
    },
    "PaymentProcessingWithRelations": {
      "title": "PaymentProcessingWithRelations",
      "type": "object",
      "description": "(tsType: PaymentProcessingWithRelations, schemaOptions: { includeRelations: true })",
      "properties": {
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "custom": {
          "type": "object",
          "description": "Custom field for free input data"
        },
        "id": {
          "type": "string"
        },
        "approved": {
          "type": "boolean"
        },
        "active": {
          "type": "boolean"
        },
        "applicationFee": {
          "type": "number",
          "description": "Application Fee percent to collect on top of default payment fee",
          "minimum": 0,
          "maximum": 99
        },
        "spaceInvoicesFee": {
          "type": "number",
          "description": "Application Fee collected by Space Invoices",
          "minimum": 0,
          "maximum": 1
        },
        "paymentCompleteReturnURL": {
          "type": "string"
        },
        "environment": {
          "type": "string",
          "enum": [
            "sandbox",
            "production"
          ]
        },
        "accountId": {
          "type": "string"
        },
        "merchantId": {
          "type": "string"
        },
        "account": {
          "$ref": "#/$defs/AccountWithRelations"
        },
        "merchant": {
          "$ref": "#/$defs/MerchantWithRelations"
        },
        "merchants": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/MerchantWithRelations"
          }
        }
      },
      "additionalProperties": false,
      "x-typescript-type": "PaymentProcessingWithRelations"
    },
    "PaymentWithRelations": {
      "title": "PaymentWithRelations",
      "type": "object",
      "description": "(tsType: PaymentWithRelations, schemaOptions: { includeRelations: true })",
      "properties": {
        "_isDeleted": {
          "type": "boolean"
        },
        "deletedAt": {
          "type": "string",
          "format": "date-time"
        },
        "custom": {
          "type": "object",
          "description": "Custom field for free input data"
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "id": {
          "type": "string"
        },
        "amount": {
          "type": "number"
        },
        "type": {
          "type": "string",
          "enum": [
            "bank",
            "online",
            "paypal",
            "cash",
            "card",
            "debit-card",
            "credit-card",
            "crypto",
            "coupon",
            "other"
          ]
        },
        "tag": {
          "type": "string",
          "description": "Payment tag for sub-categorization"
        },
        "date": {
          "type": "string",
          "format": "date-time"
        },
        "note": {
          "type": "string"
        },
        "organizationId": {
          "type": "string"
        },
        "documentId": {
          "type": "string"
        },
        "transactionId": {
          "type": "string",
          "description": "Link to related transaction that was the source of the payment"
        },
        "organization": {
          "$ref": "#/$defs/OrganizationWithRelations"
        },
        "document": {
          "$ref": "#/$defs/DocumentWithRelations"
        },
        "transaction": {
          "$ref": "#/$defs/TransactionWithRelations"
        }
      },
      "required": [
        "amount",
        "type",
        "organizationId",
        "documentId"
      ],
      "additionalProperties": false,
      "x-typescript-type": "PaymentWithRelations"
    },
    "StripeConnectAccountWithRelations": {
      "title": "StripeConnectAccountWithRelations",
      "type": "object",
      "description": "(tsType: StripeConnectAccountWithRelations, schemaOptions: { includeRelations: true })",
      "properties": {
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "id": {
          "type": "string"
        },
        "stripeAccountId": {
          "type": "string"
        },
        "chargesEnabled": {
          "type": "boolean",
          "description": "Indicates if charges are enabled on Stripe for this Account"
        },
        "active": {
          "type": "boolean"
        },
        "organizationId": {
          "type": "string"
        },
        "stripeConnectId": {
          "type": "string"
        },
        "organization": {
          "$ref": "#/$defs/OrganizationWithRelations"
        },
        "stripeConnect": {
          "$ref": "#/$defs/StripeConnectWithRelations"
        }
      },
      "required": [
        "stripeAccountId",
        "organizationId",
        "stripeConnectId"
      ],
      "additionalProperties": false,
      "x-typescript-type": "StripeConnectAccountWithRelations"
    },
    "StripeConnectWithRelations": {
      "title": "StripeConnectWithRelations",
      "type": "object",
      "description": "(tsType: StripeConnectWithRelations, schemaOptions: { includeRelations: true })",
      "properties": {
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "custom": {
          "type": "object",
          "description": "Custom field for free input data"
        },
        "id": {
          "type": "string"
        },
        "privateKey": {
          "type": "string"
        },
        "publicKey": {
          "type": "string"
        },
        "webhookSecret": {
          "type": "string",
          "description": "Stripe webhooks secret"
        },
        "connectWebhookSecret": {
          "type": "string",
          "description": "Stripe webhooks secret for Connect specific calls"
        },
        "active": {
          "type": "boolean"
        },
        "refreshUrl": {
          "type": "string",
          "description": "URL to redirect to when account onboarding link needs to be re-generated.",
          "format": "uri"
        },
        "returnUrl": {
          "type": "string",
          "description": "URL to return to once account onboarding is completed.",
          "format": "uri"
        },
        "applicationFee": {
          "type": "number",
          "description": "Application Fee collected by Stripe Connect Platform",
          "minimum": 0,
          "maximum": 99
        },
        "spaceInvoicesFee": {
          "type": "number",
          "description": "Application Fee collected by Space Invoices",
          "minimum": 0,
          "maximum": 1
        },
        "accountId": {
          "type": "string"
        },
        "account": {
          "$ref": "#/$defs/AccountWithRelations"
        },
        "stripeConnectAccounts": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/StripeConnectAccountWithRelations"
          }
        }
      },
      "required": [
        "privateKey",
        "publicKey"
      ],
      "additionalProperties": false,
      "x-typescript-type": "StripeConnectWithRelations"
    },
    "TaxExemption": {
      "properties": {
        "code": {
          "type": "string"
        },
        "reason": {
          "type": "string"
        },
        "id": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "TaxRate": {
      "properties": {
        "id": {
          "type": "string"
        },
        "dateValidFrom": {
          "type": "string",
          "format": "date-time"
        },
        "rate": {
          "type": "number",
          "format": "double"
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "custom": {
          "default": {},
          "description": "Custom field for freeform data input",
          "type": "object"
        }
      },
      "required": [
        "id",
        "dateValidFrom",
        "rate"
      ],
      "additionalProperties": false
    },
    "TaxWithRelations": {
      "title": "TaxWithRelations",
      "type": "object",
      "description": "(tsType: TaxWithRelations, schemaOptions: { includeRelations: true })",
      "properties": {
        "name": {
          "type": "string"
        },
        "abbreviation": {
          "type": "string"
        },
        "recoverable": {
          "type": "boolean"
        },
        "compound": {
          "type": "boolean"
        },
        "taxNumber": {
          "type": "string",
          "description": "Tax number associated with this tax."
        },
        "taxExemptionCode": {
          "type": "string"
        },
        "taxExemptionReason": {
          "type": "string"
        },
        "_isDeleted": {
          "type": "boolean"
        },
        "deletedAt": {
          "type": "string",
          "format": "date-time"
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "custom": {
          "type": "object",
          "description": "Custom field for free input data"
        },
        "id": {
          "type": "string"
        },
        "classification": {
          "type": "string"
        },
        "_taxRates": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/TaxRate"
          }
        },
        "organizationId": {
          "type": "string"
        },
        "organization": {
          "$ref": "#/$defs/OrganizationWithRelations"
        }
      },
      "additionalProperties": false,
      "x-typescript-type": "TaxWithRelations"
    },
    "TransactionWithRelations": {
      "title": "TransactionWithRelations",
      "type": "object",
      "description": "(tsType: TransactionWithRelations, schemaOptions: { includeRelations: true })",
      "properties": {
        "_isDeleted": {
          "type": "boolean"
        },
        "deletedAt": {
          "type": "string",
          "format": "date-time"
        },
        "custom": {
          "type": "object",
          "description": "Custom field for free input data"
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "id": {
          "type": "string"
        },
        "date": {
          "type": "string",
          "format": "date-time"
        },
        "amount": {
          "type": "number"
        },
        "type": {
          "type": "string",
          "enum": [
            "debit",
            "credit"
          ]
        },
        "source": {
          "type": "string",
          "enum": [
            "getpaid",
            "stripe"
          ]
        },
        "processorId": {
          "type": "string",
          "description": "Used to link to external system that was the source of the transaction"
        },
        "organizationId": {
          "type": "string"
        },
        "documentId": {
          "type": "string",
          "description": "Link to related document that was the source of the transaction"
        },
        "paymentIntentId": {
          "type": "string",
          "description": "Links to related payment intent that was the source of the transaction"
        },
        "organization": {
          "$ref": "#/$defs/OrganizationWithRelations"
        },
        "document": {
          "$ref": "#/$defs/DocumentWithRelations"
        },
        "paymentIntent": {
          "$ref": "#/$defs/PaymentIntentWithRelations"
        }
      },
      "required": [
        "date",
        "amount",
        "type",
        "source",
        "organizationId"
      ],
      "additionalProperties": false,
      "x-typescript-type": "TransactionWithRelations"
    },
    "x-any": {
      "properties": {}
    }
  }
}