Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/NemonInvocash/verifactu-php/llms.txt

Use this file to discover all available pages before exploring further.

RegistroAnulacion is the cancellation record submitted to AEAT when a previously registered invoice must be voided. It identifies the original invoice by issuer NIF, series/number, and issue date, and optionally carries information about the party that generated the cancellation when it differs from the original issuer. Unlike RegistroAlta, this model takes a single flat array of data — no nested sub-model objects are required.

Construction

use verifactuPHP\Models\RegistroAnulacion;

$anulacion = new RegistroAnulacion([
    'IDEmisorFactura'        => 'B12345678',
    'numSerieFactura'        => 'FACT-2024-001',
    'fechaExpedicionFactura' => '2024-06-15',
    'refExterna'             => 'CANCEL-001',
]);
For cancellations generated by a third party (e.g. a gestoría or intermediary), also populate the generadoPor and generador* fields:
$anulacion = new RegistroAnulacion([
    'IDEmisorFactura'        => 'B12345678',
    'numSerieFactura'        => 'FACT-2024-001',
    'fechaExpedicionFactura' => '2024-06-15',
    'generadoPor'            => 3,     // lista L16
    'generadorNombreRazon'   => 'Gestoría Intermediaria S.L.',
    'generadorNIF'           => 'B99887766',
]);

Fields

Invoice identification

IDEmisorFactura
string
required
NIF of the issuer of the invoice being cancelled. Maps to API field IDEmisorFactura. Must match the IDEmisorFactura of the original RegistroAlta.
numSerieFactura
string
required
Series and number of the invoice being cancelled. Maps to API field NumSerieFactura. Must match the NumSerieFactura of the original RegistroAlta.
fechaExpedicionFactura
string
required
Issue date of the invoice being cancelled, in YYYY-MM-DD format. Maps to API field FechaExpedicionFactura. Must match the original record.
refExterna
string
Optional free-text external reference for your own internal systems. Maps to API field RefExterna.

Special flags

sinRegistroPrevio
int|string
Indicates that no prior AEAT registration exists for the invoice being cancelled, from lista L4. Both the integer ID and the string code are accepted. Maps to API field SinRegistroPrevio.
rechazoPrevioA
int|string
Prior rejection flag for the original registration, from lista L4. Both the integer ID and the string code are accepted. Maps to API field RechazoPrevioA.

Generator details

generadoPor
int|string
Identifies who generated this cancellation record, from lista L16. Both the integer ID and the string code are accepted. Maps to API field GeneradoPor. Populate when the cancellation is generated by a third party or recipient rather than the issuer.
generadorNombreRazon
string
Legal name of the party that generated this cancellation. Maps to API field Generador_NombreRazon. Required when generadoPor is set.
generadorNIF
string
Spanish NIF of the party that generated this cancellation. Maps to API field Generador_NIF. Use for Spanish generators.
generadorOtroCodPais
string
ISO 3166-1 alpha-2 country code of the foreign generator. Maps to API field Generador_OtroCodPais. Use for non-Spanish generators.
generadorOtroIDType
int|string
Foreign ID type of the generator, from lista L7. Both the integer ID and the string code are accepted. Maps to API field Generador_OtroIDType.
generadorOtroID
string
Foreign identification number of the generator. Maps to API field Generador_OtroID.

Getters and Setters

MethodDescription
getIDEmisorFactura(): stringReturns the issuer NIF.
setIDEmisorFactura(string $v): voidSets the issuer NIF.
getNumSerieFactura(): stringReturns the invoice series/number.
setNumSerieFactura(string $v): voidSets the invoice series/number.
getFechaExpedicionFactura(): stringReturns the issue date.
setFechaExpedicionFactura(string $v): voidSets the issue date.
getRefExterna(): stringReturns the external reference.
setRefExterna(string $v): voidSets the external reference.
getSinRegistroPrevio(): int|stringReturns the no-prior-record flag (lista L4).
setSinRegistroPrevio(int|string $v): voidSets the no-prior-record flag (lista L4).
getRechazoPrevioA(): int|stringReturns the prior rejection flag (lista L4).
setRechazoPrevioA(int|string $v): voidSets the prior rejection flag (lista L4).
getGeneradoPor(): int|stringReturns the generator type (lista L16).
setGeneradoPor(int|string $v): voidSets the generator type (lista L16).
getGeneradorNombreRazon(): stringReturns the generator’s legal name.
setGeneradorNombreRazon(string $v): voidSets the generator’s legal name.
getGeneradorNIF(): stringReturns the generator’s NIF.
setGeneradorNIF(string $v): voidSets the generator’s NIF.
getGeneradorOtroCodPais(): stringReturns the generator’s country code.
setGeneradorOtroCodPais(string $v): voidSets the generator’s country code.
getGeneradorOtroIDType(): int|stringReturns the generator’s foreign ID type (lista L7).
setGeneradorOtroIDType(int|string $v): voidSets the generator’s foreign ID type (lista L7).
getGeneradorOtroID(): stringReturns the generator’s foreign ID number.
setGeneradorOtroID(string $v): voidSets the generator’s foreign ID number.

getArrayData()

getArrayData(): array returns an associative array containing only non-empty fields, ready to be submitted to the API. PHP property names differ from the API field names used in the payload:
PHP propertyAPI field key
IDEmisorFacturaIDEmisorFactura
numSerieFacturaNumSerieFactura
fechaExpedicionFacturaFechaExpedicionFactura
refExternaRefExterna
sinRegistroPrevioSinRegistroPrevio
rechazoPrevioARechazoPrevioA
generadoPorGeneradoPor
generadorNombreRazonGenerador_NombreRazon
generadorNIFGenerador_NIF
generadorOtroCodPaisGenerador_OtroCodPais
generadorOtroIDTypeGenerador_OtroIDType
generadorOtroIDGenerador_OtroID
$payload = $anulacion->getArrayData();
// Example output:
// [
//     'IDEmisorFactura'        => 'B12345678',
//     'NumSerieFactura'        => 'FACT-2024-001',
//     'FechaExpedicionFactura' => '2024-06-15',
// ]

empty()

RegistroAnulacion::empty(): RegistroAnulacion returns a RegistroAnulacion with all string fields set to '' and all integer/flag fields set to 0. Use it as a placeholder or for testing purposes.
$placeholder = RegistroAnulacion::empty();
A valid cancellation submission requires at minimum IDEmisorFactura, numSerieFactura, and fechaExpedicionFactura. These values must exactly match the corresponding fields on the original RegistroAlta or AEAT will reject the cancellation.

Build docs developers (and LLMs) love