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.
CancellationRecord (josemmo\Verifactu\Models\Records\CancellationRecord) represents a billing record that annuls a previously registered invoice in the AEAT VERI*FACTU system. Each instance maps to a <RegistroAnulacion> XML element. Unlike registration records, a cancellation always requires both previousInvoiceId and previousHash — there is no concept of a “first” cancellation without a chain predecessor.
Inherited properties (from Record)
All record types extend the abstract josemmo\Verifactu\Models\Records\Record base class. The fields below are inherited from it.
Identifies the invoice being cancelled (
<IDFactura>). All three sub-fields — issuerId
(9-character NIF), invoiceNumber (max 60 chars), and issueDate — must be populated.
Subject to NotBlank and Valid constraints.The
InvoiceIdentifier of the immediately preceding record in the billing chain
(<Encadenamiento/RegistroAnterior>).SHA-256 hash of the preceding record (uppercase hex, exactly 64 characters,
/^[0-9A-F]{64}$/), stored in <Encadenamiento/RegistroAnterior/Huella>.SHA-256 hash of this record’s canonical payload (uppercase hex, 64 characters), stored in
<Huella>. Computed by calculateHash(). Subject to NotBlank and regex
/^[0-9A-F]{64}$/; validation also confirms the value matches the calculated hash.Timestamp at which the hash was generated, serialised as ISO 8601 in
<FechaHoraHusoGenRegistro>. Subject to NotBlank.CancellationRecord-specific properties
Set to
true when the original registration record does not exist in AEAT or the billing
information system (SIF) — for example, when cancelling an invoice that was never successfully
submitted (<SinRegistroPrevio>, exported as S). Must not be null.Set to
true when resubmitting a cancellation record that was previously rejected by AEAT in
its most recent submission (<RechazoPrevio>, exported as S). Must not be null.Unlike
RegistrationRecord::$isPriorRejection, this property is a plain bool — null is
not a valid value for cancellation records.calculateHash() algorithm
The cancellation hash input string uses the cancelled invoice’s identity fields and omits the invoice type and amount fields present in the registration hash. Key–value pairs are concatenated in order with & separators and no URL encoding:
The
previousHash field is used in the hash payload even though it is always required — if
somehow null (invalid state), the empty string is used as a fallback.Static methods
Parses a
<sum1:RegistroAnulacion> XML element and returns a fully populated
CancellationRecord instance.Throws josemmo\Verifactu\Exceptions\ImportException if any required element is missing or
contains an invalid value (e.g. unknown <RechazoPrevio> value).Instance methods
| Method | Return type | Description |
|---|---|---|
export(UXML $xml, ComputerSystem $system): void | void | Serialises this record into a <sum1:RegistroAnulacion> 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 cancellation record. |
validate(): void | void | Runs all Symfony Validator constraints; throws InvalidModelException on failure. |