Documentation Index
Fetch the complete documentation index at: https://mintlify.com/josemmo/Verifactu-PHP/llms.txt
Use this file to discover all available pages before exploring further.
RegistrationRecord (josemmo\Verifactu\Models\Records\RegistrationRecord) is the primary object for reporting a new or corrected invoice to the AEAT VERI*FACTU system. Each instance corresponds to a single RegistroAlta XML element and must be chained to its predecessor in the billing sequence before being exported or submitted.
Inherited properties (from Record)
All record types extend the abstract josemmo\Verifactu\Models\Records\Record base class, which provides the chaining and hash fields common to both registrations and cancellations.
Identifies the invoice this record refers to. Maps to the
<IDFactura> XML element.
Must pass NotBlank and Valid constraints — all three sub-fields (issuerId, invoiceNumber, issueDate) must be populated.The
InvoiceIdentifier of the immediately preceding record in the billing chain
(<Encadenamiento/RegistroAnterior>). Set to null when this is the first record in the
chain; both previousInvoiceId and previousHash must be null together (or both set).The SHA-256 hash (uppercase hex, exactly 64 characters,
/^[0-9A-F]{64}$/) of the previous
record in the chain (<Huella> inside <RegistroAnterior>). null when this is the first
record. Must be provided together with previousInvoiceId.The SHA-256 hash of this record’s canonical payload (uppercase hex, exactly 64 characters).
Computed by
calculateHash() and stored in <Huella>. Subject to NotBlank and regex
/^[0-9A-F]{64}$/ constraints; validation also confirms the value equals calculateHash().The timestamp at which the hash was generated, serialised as an ISO 8601 string in
<FechaHoraHusoGenRegistro>. Subject to NotBlank.RegistrationRecord-specific properties
Set to
true to flag this record as a re-submission (<Subsanacion>) correcting a previously
generated registration record. Exported as S / N. Must not be null.Indicates that this is a resubmission of a registration record that was previously rejected by
AEAT (
<RechazoPrevio>). Valid values:true— the prior record was submitted to AEAT and rejected (exported asS)false— not a prior-rejection resubmission (exported asN, or omitted)null— the rejected record was never sent to AEAT (exported asX)
false when isCorrection is also true.Legal name or trading name of the party obliged to issue the invoice
(
<NombreRazonEmisor>). Subject to NotBlank and Length(max: 120).The invoice classification (
<TipoFactura>). Subject to NotBlank.
See InvoiceType for all accepted values (F1, F2, F3, R1–R5).The calendar date on which the underlying commercial operation took place
(
<FechaOperacion>, formatted dd-mm-yyyy). The time component is ignored. Optional.Free-text description of the invoice subject matter (
<DescripcionOperacion>).
Subject to NotBlank and Length(max: 500).Array of up to 1 000 invoice recipients (
<Destinatarios>), each being either a
FiscalIdentifier (Spanish NIF) or a ForeignFiscalIdentifier (foreign entity). Subject to
Valid and Count(max: 1000).Whether a corrective invoice works by full substitution or by differences
(
<TipoRectificativa>). Required when invoiceType is one of R1–R5; must be null
for all other types. See CorrectiveType.List of original invoices being corrected (
<FacturasRectificadas>). Used for R1–R5 invoice
types. Must be empty for non-corrective types.The corrected taxable base amount (
<ImporteRectificacion/BaseRectificada>), formatted as a
decimal string matching /^-?\d{1,12}\.\d{2}$/. Required when correctiveType is
Substitution; must be null otherwise.The corrected tax quota (
<ImporteRectificacion/CuotaRectificada>), formatted as a decimal
string matching /^-?\d{1,12}\.\d{2}$/. Required when correctiveType is Substitution;
must be null otherwise.List of simplified invoices being replaced (
<FacturasSustituidas>). Only applicable when
invoiceType is Sustitutiva (F3). Must be empty for all other types.Tax breakdown lines (
<Desglose>), each describing a taxable base, rate, and quota. Subject to
Valid, Count(min: 1), and Count(max: 12). At least one line is always required.Sum of all tax quotas across the breakdown lines (
<CuotaTotal>), formatted as
/^-?\d{1,12}\.\d{2}$/. Must equal the sum of taxAmount + surchargeAmount across all
BreakdownDetails entries. Subject to NotBlank.Total invoice amount including tax (
<ImporteTotal>), formatted as /^-?\d{1,12}\.\d{2}$/.
Validated against the sum of all base amounts plus totalTaxAmount (±€0.02 tolerance).
Subject to NotBlank.calculateHash() algorithm
The calculateHash(): string method computes the SHA-256 fingerprint that AEAT uses to verify record integrity. The input string is built by concatenating key–value pairs in the exact order shown below, separated by &, with no URL encoding applied:
AEAT explicitly requires that values are not URL-encoded or escaped in any way before
hashing — use raw field values exactly as stored.
Static methods
Parses a
<sum1:RegistroAlta> XML element and returns a fully populated RegistrationRecord
instance. All sub-elements are mapped to their corresponding PHP properties.Throws josemmo\Verifactu\Exceptions\ImportException if any required element is missing or
contains an invalid value.Instance methods
| Method | Return type | Description |
|---|---|---|
export(UXML $xml, ComputerSystem $system): void | void | Serialises this record into a <sum1:RegistroAlta> child element appended to $xml, including the IDVersion, chaining block, system info, timestamp, and hash. |
calculateHash(): string | string | Returns the expected SHA-256 hash for this record’s canonical payload. |
validate(): void | void | Runs all Symfony Validator constraints; throws InvalidModelException on failure. |