{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/declararfacil-com/json-schema/declararfacil-com-invoice-update-input-schema.json",
  "title": "InvoiceUpdateInput",
  "description": "Partial update of an existing invoice. Omitted properties stay unchanged. Assessment fields update VAT without adding ledger entries.",
  "x-generated": "2026-11-05",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/declararfacil-com-openapi.json#/components/schemas/InvoiceUpdateInput",
  "type": "object",
  "required": [],
  "properties": {
    "tipo": {
      "type": "string",
      "enum": [
        "EMITIDA",
        "RECIBIDA"
      ],
      "description": "EMITIDA = the user issued it (income). RECIBIDA = the user received it (expense)."
    },
    "numeroFactura": {
      "type": [
        "string",
        "null"
      ]
    },
    "fechaFactura": {
      "type": "string",
      "description": "YYYY-MM-DD"
    },
    "fechaOperacion": {
      "type": [
        "string",
        "null"
      ],
      "description": "YYYY-MM-DD when it differs from fechaFactura"
    },
    "nombreClienteProveedor": {
      "type": "string",
      "description": "The other party (client for EMITIDA, supplier for RECIBIDA)"
    },
    "nifClienteProveedor": {
      "type": [
        "string",
        "null"
      ],
      "description": "NIF/CIF/NIE or EU VAT number, as printed"
    },
    "direccionCliente": {
      "type": [
        "string",
        "null"
      ]
    },
    "paisProveedor": {
      "type": [
        "string",
        "null"
      ],
      "description": "ISO 3166-1 alpha-2, e.g. ES, DE, US"
    },
    "tipoOperacion": {
      "type": "string",
      "enum": [
        "NACIONAL",
        "INTRACOMUNITARIA",
        "EXTRACOMUNITARIA"
      ],
      "default": "NACIONAL"
    },
    "operacionB2B": {
      "type": "boolean",
      "default": true
    },
    "esAdquisicionIntracomunitaria": {
      "type": "boolean",
      "default": false
    },
    "esServicioNoSujeto": {
      "type": "boolean",
      "default": false
    },
    "baseImponible": {
      "type": "number",
      "description": "Taxable base in EUR (sum of all bases if several rates; then tipoIVA is the main rate)"
    },
    "tipoIVA": {
      "type": "number",
      "description": "IVA rate in percent: 21, 10, 4 or 0"
    },
    "cuotaIVA": {
      "type": "number",
      "description": "Printed invoice VAT amount in EUR; keep printed zero for reverse charge"
    },
    "tipoIVAAutorrepercutido": {
      "type": [
        "number",
        "null"
      ],
      "minimum": 0,
      "maximum": 100,
      "description": "Applicable Spanish self-assessment rate, separately confirmed from the printed invoice rate. Never infer from printed 0%."
    },
    "fuenteTipoIVAAutorrepercutido": {
      "type": [
        "string",
        "null"
      ],
      "description": "Basis for the applicable rate, e.g. confirmed tax classification and AEAT rule. Missing basis requires review."
    },
    "porcentajeDeduccionIVA": {
      "type": [
        "number",
        "null"
      ],
      "minimum": 0,
      "maximum": 100,
      "description": "Independently confirmed VAT deduction percentage based on business use, valid evidence and applicable deduction rules. 0 means no deduction; null means unresolved. Independent of income-tax esDeducible."
    },
    "ivaAutorrepercutido": {
      "type": [
        "number",
        "null"
      ],
      "readOnly": true,
      "description": "Server result: base * self-assessment rate / 100, rounded per invoice to EUR cents; never added to the printed invoice total"
    },
    "tipoRetencion": {
      "type": [
        "number",
        "null"
      ],
      "description": "IRPF withholding rate in percent, if the invoice shows one (e.g. 15 or 7)"
    },
    "cuotaRetencion": {
      "type": [
        "number",
        "null"
      ],
      "description": "IRPF withholding amount in EUR"
    },
    "suplidos": {
      "type": [
        "number",
        "null"
      ],
      "default": 0
    },
    "tipoRecargoEquivalencia": {
      "type": [
        "number",
        "null"
      ]
    },
    "cuotaRecargoEquivalencia": {
      "type": [
        "number",
        "null"
      ]
    },
    "claveRegimenEspecial": {
      "type": [
        "string",
        "null"
      ]
    },
    "descripcionOperacion": {
      "type": [
        "string",
        "null"
      ],
      "description": "One line: what was sold or bought"
    },
    "esFacturaRectificativa": {
      "type": "boolean",
      "default": false
    },
    "numeroFacturaRectificada": {
      "type": [
        "string",
        "null"
      ]
    },
    "totalFactura": {
      "type": "number",
      "description": "Total to pay in EUR (base + IVA - retención + suplidos + recargo)"
    },
    "categoria": {
      "type": [
        "string",
        "null"
      ],
      "description": "Expense category for RECIBIDA (e.g. SOFTWARE, ALQUILER, SUMINISTROS, MATERIAL, SERVICIOS_PROFESIONALES, TRANSPORTE, OTROS)"
    },
    "esDeducible": {
      "type": "boolean",
      "default": true
    },
    "notas": {
      "type": [
        "string",
        "null"
      ]
    },
    "confianzaOCR": {
      "type": [
        "number",
        "null"
      ],
      "description": "Your own confidence 0..1 that every amount is read correctly"
    },
    "source_file": {
      "type": [
        "string",
        "null"
      ],
      "description": "Local file name, for the user's report only (never stored as a document)"
    }
  }
}