This page documents every supporting model used when buildingDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Eseperio/verifactu-php/llms.txt
Use this file to discover all available pages before exploring further.
InvoiceSubmission, InvoiceCancellation, and InvoiceQuery objects, plus the response models returned by the facade methods.
All models extend the abstract Model base class and expose a validate(): array method that returns an associative array of validation errors (empty means valid).
InvoiceId
InvoiceId
InvoiceId identifies a specific invoice within AEAT (IDFacturaType). It is used as the $invoiceId property on every InvoiceRecord subclass.Properties
Spanish tax identification number (NIF) of the invoice issuer (
IDEmisorFactura). Example: 'B12345678'Combined series and invoice number (
NumSerieFactura). Example: 'A-2025/001'. Max 60 characters.Issue date in
YYYY-MM-DD format (FechaExpedicionFactura). The library serialiser automatically converts this to DD-MM-YYYY as required by the AEAT XML schema. Example: '2025-01-15'Validation rules
issuerNif,seriesNumber,issueDateare all required strings.issueDatemust match the regex/^\d{4}-\d{2}-\d{2}$/.
Breakdown
Breakdown
Breakdown is the container for one or more tax breakdown lines (DesgloseType). It maps to the <sfLR:Desglose> XML element and holds an array of BreakdownDetail objects.Methods
addDetail(BreakdownDetail|array $detail): static
Appends a single breakdown line. Accepts a
BreakdownDetail object or an associative array whose keys correspond to BreakdownDetail properties (taxType, regimeKey, operationQualification, exemptOperation, taxRate, taxableBase, costBasedTaxableBase, taxAmount, equivalenceSurchargeRate, equivalenceSurchargeAmount).setDetails(array $details): static
Replaces all existing details with the provided array. Each element may be a
BreakdownDetail object or an associative array.getDetails(): BreakdownDetail[]
Returns the current array of
BreakdownDetail instances.Validation rules
- At least one
BreakdownDetailis required. - Each detail must be a valid
BreakdownDetailinstance (passes its ownvalidate()check).
BreakdownDetail
BreakdownDetail
BreakdownDetail represents a single tax line within a Breakdown (DetalleType). It maps to the <sfLR:DetalleDesglose> XML element.Properties
Taxable base or non-subject amount (
BaseImponibleOimporteNoSujeto). Always required.The type of tax applied to this line (
Impuesto, optional).| Enum case | Value | Description |
|---|---|---|
TaxType::IVA | '01' | Value Added Tax (IVA) |
TaxType::IPSI | '02' | IPSI — Ceuta & Melilla production tax |
TaxType::IGIC | '03' | IGIC — Canary Islands indirect tax |
TaxType::OTHER | '05' | Other taxes |
Special regime key or additional transcendence code (
See the
ClaveRegimen, optional). Common values:| Enum case | Value | Description |
|---|---|---|
RegimeType::GENERAL | '01' | General regime |
RegimeType::EXPORT | '02' | Export |
RegimeType::CASH_BASIS | '07' | Cash basis accounting |
RegimeType::EQUIVALENCE_SURCHARGE | '18' | Equivalence surcharge |
RegimeType::SIMPLIFIED | '20' | Simplified regime |
RegimeType enum for all 17 codes.Operation qualification (
CalificacionOperacion). Either this or exemptOperation must be set (not both, and at least one is required).| Enum case | Value | Description |
|---|---|---|
SUBJECT_NO_EXEMPT_NO_REVERSE | 'S1' | Subject, not exempt, no reverse charge |
SUBJECT_NO_EXEMPT_REVERSE | 'S2' | Subject, not exempt, with reverse charge |
NOT_SUBJECT_ARTICLE | 'N1' | Not subject (Art. 7, 14, etc.) |
NOT_SUBJECT_LOCATION | 'N2' | Not subject due to location rules |
Exempt operation code (
OperacionExenta). Either this or operationQualification must be set. Values: E1 through E8.Applicable tax rate as a percentage (
TipoImpositivo, optional). Example: 21.0 for 21% IVA.Cost-based taxable base (
BaseImponibleACoste, optional). Used in specific regime scenarios.Tax amount charged (
CuotaRepercutida, optional). The total tax for this breakdown line.Equivalence surcharge rate (
TipoRecargoEquivalencia, optional).Equivalence surcharge amount (
CuotaRecargoEquivalencia, optional).Validation rules
taxableBaseis always required.- At least one of
operationQualificationorexemptOperationmust be set. - Numeric fields (
taxRate,taxableBase,taxAmount, etc.) must befloat,int, ornull. - Enum fields must be the correct enum type when set.
Chaining
Chaining
Chaining encapsulates the hash-chaining data (EncadenamientoType) that links each record to the previous one in the submission chain, providing tamper-evident integrity. Every InvoiceRecord must have a Chaining set — either as the first record or with a link to the previous record.Properties
First record indicator (
PrimerRegistro). The string 'S' when this is the first record in the chain, null otherwise. Set automatically by setAsFirstRecord() — do not set manually to any other value.Methods
setAsFirstRecord(): static
Marks this as the first record in the chain. Sets
firstRecord = 'S' and clears any previousInvoice. Mutually exclusive with setPreviousInvoice().setPreviousInvoice(PreviousInvoiceChaining|array $previousInvoice): static
Sets the link to the previous record. Accepts a
PreviousInvoiceChaining object or an array with issuerNif, seriesNumber, issueDate, and hash keys. Clears firstRecord automatically.getPreviousInvoice(): PreviousInvoiceChaining|null
Returns the stored
PreviousInvoiceChaining object, or null if this is the first record.Validation rules
- Exactly one of
firstRecordorpreviousInvoicemust be set (not both, and not neither). - If
firstRecordis set, its value must be the string'S'.
PreviousInvoiceChaining
PreviousInvoiceChaining
PreviousInvoiceChaining holds the reference to the previous invoice in the submission chain (EncadenamientoFacturaAnteriorType). Used inside Chaining when this is not the first record.Properties
NIF of the issuer of the previous invoice (
IDEmisorFactura).Series and number of the previous invoice (
NumSerieFactura).Issue date of the previous invoice (
FechaExpedicionFactura). Format: DD-MM-YYYY (note: day-first, unlike InvoiceId which uses YYYY-MM-DD).SHA-256 hash (
Huella) of the previous record. This is the value stored in InvoiceRecord::$hash after the previous submission.Validation rules
- All four fields are required strings.
issueDatemust match/^\d{2}-\d{2}-\d{4}$/.
ComputerSystem
ComputerSystem
ComputerSystem describes the billing software generating the invoice (SistemaInformaticoType). AEAT uses this information to audit which systems are submitting records.Properties
Name of the software provider company (
NombreRazon).Name of the billing software system (
NombreSistemaInformatico).System identifier code (
IdSistemaInformatico). Typically '01' unless multiple systems are used.Software version string (
Version). Example: '2.0.0'Installation instance number (
NumeroInstalacion). Typically '1' for a single installation.Whether this system exclusively uses VERI*FACTU (
TipoUsoPosibleSoloVerifactu). YesNoType::YES or YesNoType::NO.Whether the system supports multiple taxpayer obligations (
TipoUsoPosibleMultiOT). YesNoType::YES or YesNoType::NO.Whether this installation is currently serving multiple tax obligations (
IndicadorMultiplesOT). YesNoType::YES or YesNoType::NO.Methods
setProviderId(LegalPerson|array $providerId): static
Sets the provider identity. Accepts a
LegalPerson object or an array with name and either nif or otherId keys. See LegalPerson.getProviderId(): LegalPerson
Returns the stored
LegalPerson provider identity.Validation rules
- All nine public properties plus
providerIdare required. onlyVerifactu,multipleObligations,hasMultipleObligationsmust beYesNoTypeinstances.providerIdmust be aLegalPersoninstance.
LegalPerson
LegalPerson
LegalPerson represents a natural person or legal entity (PersonaFisicaJuridicaType). Used for invoice recipients, third-party issuers, generator data, and computer system provider IDs. Either a Spanish NIF or a foreign OtherID must be provided.Properties
Legal name or company name (
NombreRazon).Spanish NIF (
NIF). Required when otherId is not set. Use this for Spanish residents and companies.Methods
setOtherId(OtherID|array $otherId): static
Sets a foreign entity identifier. Required when
nif is not set. Accepts an OtherID object or an array with countryCode, idType, and id keys. Throws \Exception if the OtherID fails its own validation.getOtherId(): OtherID|null
Returns the stored
OtherID object, or null if using a NIF.Validation rules
nameis required.- At least one of
niforotherIdmust be set.
OtherID
OtherID
OtherID holds a non-Spanish tax identifier for a foreign entity (IDOtroType). Used inside LegalPerson when the entity has no Spanish NIF.Properties
Identifier type code (
IDType). Must be one of the LegalPersonIdType enum values:| Enum case | Value | Description |
|---|---|---|
LegalPersonIdType::VAT_ID | '02' | NIF-IVA (EU VAT number) |
LegalPersonIdType::PASSPORT | '03' | Passport number |
LegalPersonIdType::ID_IN_COUNTRY_OF_RESIDENCE | '04' | ID document in country of residence |
LegalPersonIdType::RESIDENCE_CERTIFICATE | '05' | Residence certificate |
LegalPersonIdType::OTHER_PROOF_DOCUMENT | '06' | Other identifying document |
LegalPersonIdType::NOT_REGISTERED | '07' | Not registered |
The identifier value (
ID). For example, a VAT number or passport number.ISO 3166-1 alpha-2 country code (
CodigoPais, optional for idType = '02', required for all other types). Examples: 'FR', 'DE', 'GB', 'NL'.As of the AEAT 2026 denomination update (v1.2.1, 23/02/2026), the Netherlands uses code
'NL'. The internal AEAT label was updated from “Holanda” to “Países Bajos” but the ISO code 'NL' remains correct and unchanged.Validation rules
idTypeandidare required strings.idTypemust be one of:'02','03','04','05','06','07'.countryCodeis required whenidTypeis not'02'(VAT_ID).
RectificationBreakdown
RectificationBreakdown
RectificationBreakdown holds the original invoice amounts being corrected in a rectification invoice (DesgloseRectificacionType). Required for rectification invoices (R1–R5) that use the substitutive (S) rectification type.Properties
The rectified taxable base amount (
BaseRectificada). Typically a negative value representing the base that is being reversed.The rectified tax amount (
CuotaRectificada). Typically negative.The rectified equivalence surcharge amount (
CuotaRecargoRectificado, optional). Set when the original invoice included an equivalence surcharge.Validation rules
rectifiedBaseandrectifiedTaxare required.- All three fields must be numeric (
float,int, ornull).
EventRecord
EventRecord
EventRecord represents a system event record submitted to AEAT (RegistroEvento — EventosSIF.xsd). Used for reporting billing system lifecycle events such as activations and deactivations.Properties
Schema version identifier (
IDVersion). Example: '1.0'The event payload (
Evento). An associative array of event fields as defined by the EventosSIF.xsd schema.Validation rules
versionId(string) andeventData(array) are both required.
InvoiceResponse
InvoiceResponse
InvoiceResponse is the return type of both Verifactu::registerInvoice() and Verifactu::cancelInvoice(). It maps to the RespuestaRegFactuSistemaFacturacionType schema.Constants
| Constant | Value | Description |
|---|---|---|
InvoiceResponse::STATUS_OK | 'Correcto' | All records accepted successfully |
Partial acceptance (
'ParcialmenteCorrecto') and full rejection ('Incorrecto') are reflected in submissionStatus with details available via getErrors() and lineResponses.Properties
Overall submission status (
EstadoEnvio). Compare against InvoiceResponse::STATUS_OK ('Correcto'). Other values include 'ParcialmenteCorrecto' (partial) and 'Incorrecto' (rejected).Secure Verification Code (
CSV) generated by AEAT. Only present when the submission is fully accepted (STATUS_OK). Store this alongside your invoice for future reference and QR code generation.Array of per-line response details (
RespuestaLinea). Each element is an associative array. Contains CodigoErrorRegistro and DescripcionErrorRegistro keys when a line was rejected.Response header (
Cabecera) from AEAT.Recommended wait time before the next submission (
TiempoEsperaEnvio).Presentation metadata (
DatosPresentacion, optional).Methods
getErrors(): array
Returns an associative array of
error_code => error_description pairs extracted from all lineResponses entries that contain a non-empty CodigoErrorRegistro. Returns an empty array when there are no errors.QueryResponse
QueryResponse
QueryResponse is the return type of Verifactu::queryInvoices(). It maps to RespuestaConsultaFactuSistemaFacturacionType.Properties
Textual result of the query (
ResultadoConsulta).| Value | Meaning |
|---|---|
'ConDatos' | At least one record was found |
'SinDatos' | No records matched |
Array of matched invoice records (
RegistroRespuestaConsultaFactuSistemaFacturacion). Each element is a raw associative array from the AEAT SOAP response. May be null when there are no results.Pagination flag (
IndicadorPaginacion). Value 'S' means more pages are available; 'N' means this is the last page.Raw pagination cursor data (
ClavePaginacion) from AEAT. Only present when paginationIndicator === 'S'. To fetch the next page, call $query->setPaginationKey($nextPage, $pageSize) with your desired page number and size.Response header (
Cabecera) from AEAT.Period attribution data (
PeriodoImputacion) for the returned records.Validation rules
header,period,paginationIndicator, andqueryResultare required.header,period,foundRecords, andpaginationKeymust be arrays when set.paginationIndicatorandqueryResultmust be strings.